Problem
Agent Flow's visualizer fails to display real-time agent events when running
in standalone mode (pnpm run dev). Events are transmitted from the relay
server to the browser via Server-Sent Events (SSE), but are never visualized
on the canvas or processed by the simulation engine.
Symptoms
- Browser console shows:
[SSE] Connected to relay ✓
- Browser console shows:
[SSE] Received message: agent-event ✓
- Browser displays:
WAITING FOR AGENT SESSION (no agents rendered)
- Events are buffered in sessionEventsRef but never delivered to simulation
Root Causes
-
Unreliable PostMessage Pattern: Original code in use-vscode-bridge.ts
attempts to route SSE messages through window.postMessage(), which doesn't
reliably trigger message handlers in same-origin contexts. The VSCodeBridge's
message handler is designed for cross-origin postMessage (VS Code extension ↔
webview), not self-messaging.
-
Missing Session Auto-Selection: When SSE events arrive before a session
is selected (selectedSessionIdRef.current === null), they are routed to
"background activity" instead of pendingEventsRef, preventing the simulation
engine from ever receiving them.
Expected Behavior
- SSE events should be processed directly in the hook
- Session should auto-select on first event
- Canvas should display agent and update in real-time
- Timeline should populate with events
Steps to Reproduce
- Start relay:
pnpm run dev
- Run Claude Code session:
claude code "list files"
- Observe: Browser shows "WAITING FOR AGENT SESSION" instead of visualization
Impact
Standalone mode is completely non-functional without this fix.
For detailed technical analysis, see the related pull request and
FEAT_SSE_EVENT_PROCESSING.md documentation.
Problem
Agent Flow's visualizer fails to display real-time agent events when running
in standalone mode (
pnpm run dev). Events are transmitted from the relayserver to the browser via Server-Sent Events (SSE), but are never visualized
on the canvas or processed by the simulation engine.
Symptoms
[SSE] Connected to relay✓[SSE] Received message: agent-event✓WAITING FOR AGENT SESSION(no agents rendered)Root Causes
Unreliable PostMessage Pattern: Original code in
use-vscode-bridge.tsattempts to route SSE messages through
window.postMessage(), which doesn'treliably trigger message handlers in same-origin contexts. The VSCodeBridge's
message handler is designed for cross-origin postMessage (VS Code extension ↔
webview), not self-messaging.
Missing Session Auto-Selection: When SSE events arrive before a session
is selected (
selectedSessionIdRef.current === null), they are routed to"background activity" instead of
pendingEventsRef, preventing the simulationengine from ever receiving them.
Expected Behavior
Steps to Reproduce
pnpm run devclaude code "list files"Impact
Standalone mode is completely non-functional without this fix.
For detailed technical analysis, see the related pull request and
FEAT_SSE_EVENT_PROCESSING.md documentation.