Skip to content

Commit a2917c8

Browse files
committed
updated readmes
1 parent 62b2b71 commit a2917c8

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,18 @@ You can run the following examples:
3636
- `show_line_selector` presents the user a multiple-choice question using a widget.
3737
- Route-planning replies attach entity sources for the stations in the suggested path as annotations.
3838

39-
### Client tool calls that mutate UI state
39+
### Client tool calls that mutate or fetch UI state
4040

4141
- **Metro Map**:
42-
- Client tool `add_station` (sent after the server adds a stop) updates the metro map canvas; handled via `onClientTool` in [ChatKitPanel.tsx](examples/metro-map/frontend/src/components/ChatKitPanel.tsx).
42+
- Client tool `get_selected_stations` pulls the currently selected nodes from the canvas so the agent can use client-side state in its response ([ChatKitPanel.tsx](examples/metro-map/frontend/src/components/ChatKitPanel.tsx), [metro_map_agent.py](examples/metro-map/backend/app/agents/metro_map_agent.py)).
4343

4444
### Fire-and-forget client effects
4545

4646
- **Cat Lounge**:
4747
- Client effects `update_cat_status` and `cat_say` are invoked by server tools to sync UI state and surface speech bubbles; handled via `onEffect` in [ChatKitPanel.tsx](examples/cat-lounge/frontend/src/components/ChatKitPanel.tsx).
4848
- **Metro Map**:
4949
- Client effect `location_select_mode` is streamed within the server action handler ([server.py](examples/metro-map/backend/app/server.py)) after a line is chosen and updates the metro map canvas ([ChatKitPanel.tsx](examples/metro-map/frontend/src/components/ChatKitPanel.tsx)).
50+
- Client effect `add_station` is streamed by the agent after map updates to immediately sync the canvas and focus the newly created stop ([metro_map_agent.py](examples/metro-map/backend/app/agents/metro_map_agent.py), [ChatKitPanel.tsx](examples/metro-map/frontend/src/components/ChatKitPanel.tsx)).
5051

5152
### Page-aware model responses
5253

@@ -60,7 +61,12 @@ You can run the following examples:
6061
- Retrieval tools stream `ProgressUpdateEvent` messages while searching tags, authors, keywords, exact text, or loading the current page so the UI surfaces “Searching…”/“Loading…” states ([news_agent.py](examples/news-guide/backend/app/agents/news_agent.py)).
6162
- The event finder emits progress as it scans dates, days of week, or keywords to keep users informed during longer lookups ([event_finder_agent.py](examples/news-guide/backend/app/agents/event_finder_agent.py)).
6263
- **Metro Map**:
63-
- The metro agent emits a quick sync update when it loads the line data via `get_map` ([metro_map_agent.py](examples/metro-map/backend/app/agents/metro_map_agent.py)).
64+
- The metro agent emits a progress update while retrieving map information in `get_map`; it also emits a progress update while waiting for a client tool call to complete in `get_selected_stations` ([metro_map_agent.py](examples/metro-map/backend/app/agents/metro_map_agent.py)).
65+
66+
### Response lifecycle UI state
67+
68+
- **Metro Map**:
69+
- The client locks map interaction at response start and unlocks when the stream ends so canvas state doesn’t drift during agent updates by adding `onResponseStart` and `onResponseEnd` handlers ([ChatKitPanel.tsx](examples/metro-map/frontend/src/components/ChatKitPanel.tsx)).
6470

6571
### Widgets without actions
6672

examples/metro-map/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ Chat-driven GUI updates for a metro map using a React Flow canvas that lets the
1313
- "Add a new station named Aurora" (line picker widget will appear)
1414
- "Plan a route from Titan Border to Lyra Verge."
1515
- "Tell me about @Cinderia station." (@-mention stations; need to type @ manually, copy paste won't work)
16+
- "Tell me about the stations I've selected." (lasso some stations on the canvas first)
1617

1718
## Features
1819

1920
- Map sync + lookup tools: `get_map`, `list_lines`, `list_stations`, `get_line_route`, `get_station` keep the agent grounded in the latest network data.
21+
- Selection-aware replies: the agent calls the `get_selected_stations` client tool to pull the user’s current canvas selection before continuing a response, handled in `onClientTool` ([ChatKitPanel.tsx](frontend/src/components/ChatKitPanel.tsx), [metro_map_agent.py](backend/app/agents/metro_map_agent.py)).
2022
- Plan-a-route responses attach entity sources for each station in the recommended path so ChatKit can keep the canvas focused on the stops being discussed.
2123
- Station creation flow: `show_line_selector` streams a clickable `line.select` widget, the server stashes `<LINE_SELECTED>`, and `add_station` triggers a widget update and a client tool call to refresh the canvas and focus the new stop.
2224
- Location placement helper: after a line is chosen, a `location_select_mode` client effect flips the UI into placement mode so users pick start/end of line for insertion.

examples/metro-map/backend/app/agents/metro_map_agent.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ async def get_selected_stations(
274274
ctx: RunContextWrapper[MetroAgentContext],
275275
) -> SelectedStationsResult:
276276
logger.info("[TOOL CALL] get_selected_stations")
277+
# This progress update will persist while waiting for the client tool output to be send back to the server.
277278
await ctx.context.stream(ProgressUpdateEvent(text="Fetching selected stations from the map..."))
278279
ctx.context.client_tool_call = ClientToolCall(
279280
name="get_selected_stations",

0 commit comments

Comments
 (0)