Skip to content

Conversation

@ibetitsmike
Copy link
Contributor

Problem

In mux server mode (browser UI), after idle time or sleep/wake, the chat UI can stop reflecting live stream state:

  • You can hit Send and the input clears
  • The message (and subsequent assistant stream) does not appear in the transcript
  • No "connection lost / reconnecting / degraded" banner shows
  • A full page refresh reloads history and reveals the conversation did happen

Root Cause

The transcript is not updated optimistically on send; it updates only via the streaming subscription workspace.onChat. Any failure where the async iterator stalls without ending/throwing produces exactly this UX: the RPC send succeeds, but the UI never receives the type:"message" / stream events that drive the transcript.

Solution

1. connectionEpoch tracking

APIProvider increments a connectionEpoch on each new connection. WorkspaceStore restarts all subscriptions when the epoch changes, preventing stale iterators from the old connection.

2. Subscription watchdog

Monitors all chat subscriptions and auto-restarts them if:

  • No caught-up received within 15s (buffering stall)
  • Active stream has no events for 30s (stream stall)

3. UI feedback

New SubscriptionStatusIndicator shows "Reconnecting chat stream…" when a subscription is being restarted, so users know recovery is in progress.

4. Diagnostics

Added logging for WS close events (code/reason) and ping failures to help debug future connection issues.

Testing

  • make static-check passes
  • Manual testing: after sleep/wake, subscriptions should auto-recover without refresh

Generated with mux • Model: anthropic:claude-opus-4-5 • Thinking: high

Problem: In mux server mode (browser UI), after idle time or sleep/wake,
the chat UI can stop reflecting live stream state—you send a message,
input clears, but nothing appears in the transcript. No connection
warning shows, and refreshing the page reveals the conversation happened.

Root cause: The transcript updates only via the workspace.onChat streaming
subscription. If that async iterator silently stalls (common after
sleep/wake or network changes), the RPC send succeeds but the UI never
receives the events that drive the transcript.

Solution:

1. **connectionEpoch tracking**: APIProvider increments an epoch on each
   new connection. WorkspaceStore restarts all subscriptions when the
   epoch changes, preventing stale iterators from the old connection.

2. **Subscription watchdog**: Monitors all chat subscriptions and
   auto-restarts them if:
   - No caught-up received within 15s (buffering stall)
   - Active stream has no events for 30s (stream stall)

3. **UI feedback**: New SubscriptionStatusIndicator shows "Reconnecting
   chat stream..." when a subscription is being restarted, so users know
   recovery is in progress.

4. **Diagnostics**: Added logging for WS close events (code/reason) and
   ping failures to help debug future connection issues.

5. **Storybook**: Added Chromatic story for the reconnecting banner.

---
_Generated with `mux` • Model: `anthropic:claude-opus-4-5` • Thinking: `high`_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant