Skip to content

Make agent URLs configurable and update quickstart docs#1148

Open
zeroasterisk wants to merge 1 commit intomainfrom
fix/onboarding-friction
Open

Make agent URLs configurable and update quickstart docs#1148
zeroasterisk wants to merge 1 commit intomainfrom
fix/onboarding-friction

Conversation

@zeroasterisk
Copy link
Copy Markdown
Collaborator

This PR addresses onboarding friction by making agent URLs configurable via env vars and updating the quickstart documentation.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the quickstart documentation to use specific demo commands and introduces environment variable support for configuring agent URLs in the Lit client samples. The review feedback suggests using distinct ports in the documentation examples to avoid confusion and adding optional chaining when accessing environment variables in TypeScript to improve robustness and adhere to style guidelines.

Comment on lines +213 to +214
export VITE_RESTAURANT_AGENT_URL="http://localhost:8000"
export VITE_CONTACTS_AGENT_URL="http://localhost:8000"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The example shows both agents using the same port (8000). Since these are typically separate processes, it is clearer to show them on different ports to avoid potential port conflicts for users trying to run both demos simultaneously.

Suggested change
export VITE_RESTAURANT_AGENT_URL="http://localhost:8000"
export VITE_CONTACTS_AGENT_URL="http://localhost:8000"
export VITE_RESTAURANT_AGENT_URL="http://localhost:8000"
export VITE_CONTACTS_AGENT_URL="http://localhost:8001"

"Just a moment...",
],
serverUrl: "http://localhost:10003",
serverUrl: (import.meta as any).env.VITE_CONTACTS_AGENT_URL || "http://localhost:10003",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Accessing (import.meta as any).env without optional chaining can cause a runtime error if env is undefined (e.g., in certain test environments or non-Vite builds). Adding optional chaining makes the code more robust. Additionally, while any is used here to bypass missing type definitions for import.meta.env, it is generally discouraged in TypeScript per standard style guides.

Suggested change
serverUrl: (import.meta as any).env.VITE_CONTACTS_AGENT_URL || "http://localhost:10003",
serverUrl: (import.meta as any).env?.VITE_CONTACTS_AGENT_URL || "http://localhost:10003",
References
  1. The TypeScript style guide generally discourages the use of the any type to maintain type safety and prevent runtime errors. (link)

"Almost there...",
],
serverUrl: "http://localhost:10002",
serverUrl: (import.meta as any).env.VITE_RESTAURANT_AGENT_URL || "http://localhost:10002",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using (import.meta as any).env without optional chaining can cause a runtime error if env is undefined. Adding optional chaining makes the code more resilient. Also, avoiding any is preferred for better type safety.

Suggested change
serverUrl: (import.meta as any).env.VITE_RESTAURANT_AGENT_URL || "http://localhost:10002",
serverUrl: (import.meta as any).env?.VITE_RESTAURANT_AGENT_URL || "http://localhost:10002",
References
  1. The TypeScript style guide generally discourages the use of the any type to maintain type safety and prevent runtime errors. (link)

@zeroasterisk zeroasterisk force-pushed the fix/onboarding-friction branch from 74559bc to 1244dc1 Compare April 12, 2026 00:23
@zeroasterisk zeroasterisk requested a review from dmandar April 12, 2026 00:32
@zeroasterisk zeroasterisk added type: documentation Improvements or additions to documentation component: samples Relevant to the agent or client samples labels Apr 12, 2026
@zeroasterisk zeroasterisk requested review from ava-cassiopeia, ditman and paullewis and removed request for ava-cassiopeia, ditman and paullewis April 12, 2026 00:37
Copy link
Copy Markdown
Collaborator

@ditman ditman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small change, please try not to use as any, instead, define the type that you expect for ImportMeta!

"Just a moment...",
],
serverUrl: "http://localhost:10003",
serverUrl: (import.meta as any).env?.VITE_CONTACTS_AGENT_URL || "http://localhost:10003",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The contacts sample is gone from the shell app, this is not needed anymore!

"Almost there...",
],
serverUrl: "http://localhost:10002",
serverUrl: (import.meta as any).env?.VITE_RESTAURANT_AGENT_URL || "http://localhost:10002",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, don't do as any here. Maybe define an ImportMeta and ImportMetaEnv types (as described here).

Also, when have you found yourself needing this? I normally start the demos with npm run demo:blah and that has all the batteries included!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: samples Relevant to the agent or client samples type: documentation Improvements or additions to documentation

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

3 participants