Skip to content

fix(chat): reconnect silently stalled live streams - #8272

Merged
Sg312 merged 1 commit into
stagingfrom
fix/staging-tool-group-stream
Sep 24, 2026
Merged

Sg312 merged 1 commit into
stagingfrom
fix/staging-tool-group-stream

Conversation

@Sg312

@Sg312 Sg312 commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

When a browser SSE connection remains open but stops delivering data, chat can stay frozen on its last tool activity until refresh even while the backend continues. Bound live reads to 45 seconds without incoming chunks, then use the existing cursor-based recovery path to catch up. Heartbeat comments reset the deadline; recovery cancels only the transport reader and never resends or aborts the backend turn.

The reported staging trace confirms continued execution and successful replay on refresh. Browser socket telemetry was unavailable, so this fixes the reproduced silent-connection failure without claiming every possible display stall has the same cause.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other

Testing

  • 152 tests pass across the SSE reader, mounted chat hook, stream context, and event dispatch suites.
  • The silent-read regression fails before the change. Mounted hook regressions recover both initial and tail connections after a finished tool, preserving the cursor and message with one send and no backend abort.
  • Keepalive comments sustain a long tool operation; timeout cancellation does not wait for a hung underlying source.
  • App typecheck, Biome, API validation audit, and git diff checks pass.
  • Browser verification skipped at the user's request. Wait for completed code review and CI before staging merge.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Sep 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Sep 24, 2026 9:00pm UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

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.

No issues found across 4 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge based on the reviewed stream and recovery paths.

Summary

The PR adds a 45-second per-read idle deadline to workspace chat SSE connections. A silent connection is cancelled so the existing cursor-based recovery can replay missed events and reconnect, while keepalive comments sustain healthy long-running streams.

  • Adds reader tests for silent cancellation and keepalive activity.
  • Adds mounted-hook tests for recovery from silent initial and tail connections without resending the message.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Live chat SSE read] --> B{Chunk within 45 seconds?}
  B -->|Yes| C[Process data or keepalive]
  C --> A
  B -->|No| D[Cancel transport reader]
  D --> E[Fetch events after saved cursor]
  E --> F{Turn terminal?}
  F -->|Yes| G[Replay and finalize]
  F -->|No| H[Replay and attach new tail]
  H --> A
Loading

Reviews (1) · Last reviewed commit: "fix(chat): reconnect silently stalled li..."

@Sg312
Sg312 merged commit 5ab33dd into staging Sep 24, 2026
34 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/staging-tool-group-stream branch September 24, 2026 21:43

This branch was previously deployed

1 inactive deployment
Preview — cff12d5d Deployed Sep 24, 2026 by vercel[bot]
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