Repository navigation
fix(mobile): replay a page's streams only after its connection verdict - #39419
Merged
Merged
Conversation
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 14 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
A reconnect or a cutover after a drop re-sent every stream the page held before the page's verdict for the new connection, bypassing the bridge's hold. The client now asks the stream's owner before re-sending; the bridge holds the re-send until the verdict opens. An unsent stream's cancel no longer sends an unsubscribe.
…e for the verdict hold
AmoabaKelvin
force-pushed
the
replay-streams-after-verdict
branch
from
November 7, 2026 09:58
02815a8 to
8282484
Compare
11 tasks done
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.
ELI5
When the phone loses its connection to the desktop and gets it back, a page that was open has to wait until the phone has checked that the desktop and the page still understand each other. New requests from the page already waited for that check. The page's live feeds (terminal output, chat, status) did not: the phone re-opened them by itself the moment the connection came back, before the check. Now those wait for the check too, and they come back right after it, before anything else the page asked for in the meantime.
What Changed
holdReplay(resend) => boolean. Both places that re-send without being asked call it: the stream registry's re-auth replay and the logical client's cutover. The bridge passes it for page streams. While the page's verdict is closed, or anything else is waiting, the verdict hold stores theresendunder the page's stream id. When the verdict opens, it runs the stored re-sends first and then the page's parked frames. A page that walls or closes first never sends them.rpc-client-stream-request.tsand the cutover error tological-client-cutover-error.ts, which is still re-exported from its old path.Why
The verdict belongs to each page document: it checks the cached page build's own window, and two documents can share one client. So the client can't decide on its own whether a page may talk. It has to ask the stream's owner, and the bridge already holds that answer. The re-send machinery stays in the client (latest terminal viewport, screencast bookkeeping, routing reset), so the bridge only decides when.
Ruled out:
end. Older cached pages don't do that, so their streams would die.Linked Issue
No issue. Follow-up from #39174 (W7), item 103 in the mobile speed program's follow-ups sweep.
Numbers
Method: a local probe test, not committed. It runs a real
DirectRpcClientover a mock socket, wrapped in the real logical client, with a real bridge host. The page holds 3 open terminal streams. Counts are exact; one run per arm because the scenario is deterministic. Base is this branch's merge-basef5f45784e28with this change reverted in the four owning files, and head is this branch.Round trips: unchanged. The re-sends move behind the
status.getthe page already makes, so a resumed stream's first frame waits about one status round trip longer after a reconnect than before. That wait is the point of the change.Bundle (
pnpm build:mobile-web, verify OK): 191 assets and 110 chunks on both, 12,840,253 total bytes and 9,724,145 of 9,961,472 budget bytes on both (+0).Visual Proof
N/A. Nothing on screen changes. A page keeps showing "connecting" through the reconnect, as it already does after #39174. The only difference is when the phone sends stream frames, which the Numbers table counts.
Testing
New tests, each failing with its side of the change reverted:
Updated
bridge-execution-host.test.tsto expect the hold on a page stream's subscribe options.Ran
npx vitest run src/transport src/mobile-web-shell src/test-support/rpc-recording src/session src/browser src/home src/notifications --maxWorkers=2. Everything passed except four tests that timed out under machine load (load average about 70) and pass when run alone. The RPC recording goldens are unchanged, because the harnesses model no verdict.Checks: mobile typecheck,
pnpm check:changedandpnpm build:mobile-webpass.Not run: no simulator run. The change is in transport timing, which the probe above counts exactly.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Risk
The riskiest part is a held stream that never resumes. Re-sends are stored only while the verdict is closed or something else is waiting. The bridge re-checks on every committed change of the verdict, so they run as soon as it opens. If the verdict never opens (status unreadable, or an incompatible desktop), the page's streams stay quiet, as its requests already do. That is fail-closed. A stored re-send that has gone stale does nothing: the stream was cancelled, the connection moved on, or the client closed.
What it doesn't cover: a live cutover, where the old session is still connected, never closes the verdict, so streams re-attach right away as before. That's a separate gap: the host status gates don't re-judge on a cutover between two connected sessions. The bridge's request hold has the same gap.
Mixed versions: the wire is unchanged, so old and new desktops behave the same. Old cached pages need no change, because they still rely on the native side to resume their streams. A plain revert undoes it.
Ships with the next store release (native shell JS).
Level: Medium
AI Disclosure
Review
Two review rounds, Codex and Claude. Round 1 found that
bridge-execution-host.test.tsexpected the exact subscribe options; fixed. Round 2 was clean from both. A design challenge before building (two rounds) added the no-unsubscribe-for-unsent-streams rule. It also made held re-sends count as waiting, so a page frame admitted between the verdict opening and the flush can't overtake them.Rejected:
resendHeld. That needs a socket write to fail with no close event while the verdict is publishing. No reachable case was found.Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)