Repository navigation
🧭 refactor: Give the Resumable Stream a Core Run and Subscription - #17117
Merged
Merged
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Merged
5 tasks done
berry-13
added this pull request to stack #17153
October 15, 2026 13:49
berry-13
force-pushed
the
refactor/chat-resumable-run
branch
from
October 15, 2026 15:03
98dfa53 to
c08b0b5
Compare
berry-13
force-pushed
the
refactor/chat-resumable-run
branch
2 times, most recently
from
October 15, 2026 15:20
300234c to
0c991f8
Compare
berry-13
force-pushed
the
refactor/chat-resumable-run
branch
from
October 15, 2026 15:22
0c991f8 to
c48c975
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Summary
useResumableSSEkeeps everything it knows about the attached generation in seventeen refs (the live connection, the reconnect ladder, the submission it serves, the optimistic stream ids, the frame retries waiting on a placeholder, the edit-prefix state, the epoch and run-end flags) and rebuilds the attachment's own fences, reattach timers, foreground recovery and stream route inline in a 2,600-line callback. None of that is React, and as long as it lives there no other host can run a resumable stream.This adds two core classes in
packages/chat/src/core/resumable/.ResumableRunowns the pane's run state and takes its clock and frames through an injected scheduler.ResumableSubscriptionis one attachment: it holds the submission as the stream revises it, the fences every late callback checks (isCurrent), the delayed and immediate re-attach, the foreground re-attach and its status check (through an injected status read and page visibility), the stream route and the connection's event routing. The hook now creates one run per pane and one subscription per attach, and the frame, failure and reconcile handlers it still holds read the subscription instead of closure variables; they move into core in the next links.StreamStatusResponseand the protocol headers move into core with it, re-exported where the client already imported them. No behavior changes. Stacked on #17112.Type of change
Testing
Tested environments/configuration:
Not applicable: the lifecycle is moved, not changed; the existing hook specs exercise every path through the new classes.
Automated tests:
packages/chat/src/core/__tests__/subscription.spec.ts: fences, stream route, event routing, delayed re-attach that a newer attachment supersedes, foreground re-attach for a closed connection and for an open one the status proves terminal, one foreground listener per pane, and the run's prefix and timer state, all against a fake scheduler, visibility and status read.npx jest src/coreinpackages/chat(146 pass), and inclientthe hooks/SSE and hooks/Chat specs plus data-provider/SSE (1148 pass, including the 6,000-lineuseResumableSSE.spec.tsandtransport.spec.tsxunchanged).npx tsc --noEmitinpackages/chatandclient, eslint, prettier and sort-imports on the changed files: clean.Screenshots / recordings
No user-facing change.
Risk / compatibility
Timers, animation frames and the clock now go through the run's scheduler, which defaults to the browser globals and reads them at call time, so fake timers in tests behave as before.
Checklist