Skip to content

fix: live-stream continuity across SSE reconnects - #5

Open
XKILLER2006Y wants to merge 1 commit into
mainfrom
fix/live-stream-catchup
Open

fix: live-stream continuity across SSE reconnects#5
XKILLER2006Y wants to merge 1 commit into
mainfrom
fix/live-stream-catchup

Conversation

@XKILLER2006Y

Copy link
Copy Markdown
Owner

Problem

SSE does not replay events that streamed while the connection was down (mobile OS idle kill during long thinking gap, LAN blip, backgrounding). Tokens arriving during the gap were lost forever — answers appeared 'cut'. The existing resync only recovered busy→idle transitions, not answer content.

Fix

  • \sessions.ts: new \catchUpSessionMessages()\ — re-fetch current session's messages/parts on reconnect and merge with on-screen state, preserving \ emp-\ optimistic placeholders (same pattern as \loadOlderMessages).
  • \events.ts: fire the catch-up once per re-established stream alongside the busy-session resync.

Verification

  • \ sc --noEmit\ clean locally.
  • Build via CI (this PR).

SSE resumes from 'now' after a reconnect — it never replays events that
streamed while the connection was down (mobile OS idle kill during a long
thinking gap, LAN blip, app backgrounding). The old resync only recovered
busy->idle transitions, so tokens that arrived during the gap were lost
forever and the answer appeared 'cut'.

- sessions.ts: add catchUpSessionMessages() — re-fetch the current
  session's messages/parts and merge with on-screen state, preserving
  temp- optimistic placeholders (established loadOlderMessages merge
  pattern).
- events.ts: fire the catch-up once per re-established stream, alongside
  the existing busy-session resync.
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.

2 participants