Repository navigation
fix: fence browser recovery to attach inventory placements - #18910
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughThe attach handler captures runtime page placements before adoption. It passes the captured placements to page recovery. Recovery skips pages whose current placement differs from the attach-time placement. Tests cover pages created after inventory capture and pages whose placements were replaced before recovery. Merge Risk: ⚪ Minimal · up to Attach recovery now limits retirement to page placements observed when attachment began, preserving pages created or replaced during adoption. The targeted regressions cover both protected cases, with no remaining merge-blocking risk identified. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the problem, implementation, tradeoffs, testing, visual-proof rationale, and known limitations. However, it omits the required Linked Issue, Testing, Review, Agent skill upstream boundary, Notes, and Checklist sections. Resolution Add all required template sections. Include a valid issue reference after "Fixes #", complete the Testing section and checklist, state the AI disclosure status when applicable, complete Review, Agent skill upstream boundary, Notes, and the remaining Checklist items. ✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The fix fences browser recovery to the page placements captured at attach time, so a page created or replaced during adoption can no longer be mistaken for a missing guest and retired out from under a live tab.
- Placement snapshot at attach —
browser-client-host.tscapturespagePlacementsAtAttachfrom the page registry beforeregistry.attach()/emit readyand threads it into recovery. - Recovery fence —
recoverUnavailableRuntimeBrowserClientPagesgains an optionalpagePlacementsAtAttach; the filter now skips any page absent from the snapshot or whose placement changed since capture (viasameRuntimeBrowserPlacement). - Two deterministic regressions — a real-RPC test creating a page while adoption is held, and a unit test for a replacement placed after capture, both asserting no recovery commands and unchanged placement.
The fence is correctly conservative: the optional parameter leaves existing callers/tests unchanged, restored pages (whose sentinel placement is stable across capture) still reach recovery, and adopted pages remain doubly protected by adoptedPageIds. No wire or protocol change, and the snapshot is bounded by the existing registry cap. Focused test files pass locally (29 tests).
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
…stic Extract the placement check into isPlacedAsObservedAtAttach so the recovery filter stays a flat list of named predicates, and document that omitting pagePlacementsAtAttach recovers against unfenced live state. Replace the 30-microtask drain in the post-attach regression with the handler's own completion: attach only settles after recovery returns, so awaiting the dispatch orders the assertions instead of guessing at a microtask count. Verified by forcing the fence open: both regressions fail (the post-attach one in 60ms on a retired placement) and the other 27 still pass.
The barrier ran inline, so a waitFor timeout or the placement guard left the attach handler parked on a promise nothing awaited. Hoist it into settleAttach and call it from a finally as well; cleanup is guarded and the dispatch promise is already settled, so the second call is a no-op.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The follow-up commit hardens the regression test's determinism and names the recovery fence it exercises — no behavior change to the production path.
- Replaced the microtask drain with a real barrier — the real-RPC regression now waits on
cleanup()+await rig.dispatch, which only settles once the attach handler (and thus recovery) has returned, instead of guessing with 30 drained microtasks. - Extracted
isPlacedAsObservedAtAttach— the inline placement-match clause is now a named helper with a JSDoc explaining why readiness-before-recovery requires fencing pages created or replaced during adoption. Theobserved !== undefinedcheck is behavior-equivalent to the prior truthiness check, since a placement is always a non-null object.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The follow-up commit makes the regression test's settle barrier run even on early failure — no production code changes.
- Restored settle-on-failure for the regression test — the
cleanup()+await rig.dispatchbarrier is now asettleAttach()helper invoked in afinally, so the streaming attach handler still settles if an early step (e.g. thevi.waitForonresolveExecutionHostKey) fails, instead of hanging the test process. Calling it twice is safe because the handler'scleanup()is idempotent.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
…18910) * fix: fence browser recovery to attach inventory placements * refactor: name the attach-inventory fence and make its test deterministic Extract the placement check into isPlacedAsObservedAtAttach so the recovery filter stays a flat list of named predicates, and document that omitting pagePlacementsAtAttach recovers against unfenced live state. Replace the 30-microtask drain in the post-attach regression with the handler's own completion: attach only settles after recovery returns, so awaiting the dispatch orders the assertions instead of guessing at a microtask count. Verified by forcing the fence open: both regressions fail (the post-attach one in 60ms on a retired placement) and the other 27 still pass. * test: settle the attach handler even when the regression fails early The barrier ran inline, so a waitFor timeout or the placement guard left the attach handler parked on a promise nothing awaited. Hoist it into settleAttach and call it from a finally as well; cleanup is guarded and the dispatch promise is already settled, so the second call is a no-op.

ELI5
Orca can show web pages inside the app, and a paired device can be the thing that actually holds those pages open. When the part of Orca that keeps track of them restarted, it took a moment to re-check its list of open pages. If you opened a brand-new tab during that brief moment, the restarted bookkeeping did not know about that tab, assumed it had gone missing, and tried to build a replacement on top of the tab that was already sitting there. The desktop refused the contradictory instruction, and instead of losing just that one tab, every browser tab on that device went dead until you reconnected.
Now Orca writes down exactly which pages existed at the instant it began re-checking, and it only re-checks those. A tab you open while it is still catching up is left alone, because it is new and healthy and does not need rescuing. Opening a tab right after a restart no longer takes down the rest of your browser tabs.
What changed
After a paired runtime restarts, opening a new browser tab can shut down the entire client browser host. Attach publishes readiness and waits for existing-page adoption; recovery then scans the current page registry using the older attach inventory. It treats the newly created page as missing, retires its placement without closing the live guest, and sends another create at a higher generation. The desktop rejects that command with
browser_host_page_replacement_requires_retirement, leaving all its browser tabs unavailable.Capture page placements before publishing attach readiness and constrain recovery to those exact placements. Pages created or replaced during adoption retain their authority. The existing recovery path still handles pages that the captured inventory actually describes.
Validation: a real RPC regression creates a page while adoption is held; it fails before the fix because its placement is retired, then passes afterward. A second regression protects a replacement generation. All 51 focused adoption/recovery/negotiation tests pass, as do the 96 tests in the matching browser-network gate command.
pnpm tc:nodeand targeted lint pass. The previously failing macOS paired cookie-survival journey passes three consecutive Electron runs, verifying the rendered post-restart page, surviving route cookie, and isolated default-session cookie jar. Double-restart, quit-survival, and ghost-close neighbors are still under investigation.Reliability gate:
browser-network-tunnel.bounded-fail-closed-route. Invariant: stale attach inventory must not retire a newer live page placement. Oracle: unchanged placement and active page, zero recovery commands for the new page, and rendered cookie survival after a real runtime restart. Diagnostics: the generation-replacement error and Playwright traces identify the original failure; both deterministic regressions preserve the race. The added snapshot is bounded by the existing 256-page registry cap and occurs once per attach; no polling, subprocess, or new protocol field is added. The host sends fewer erroneous recovery commands through the existing negotiated protocol, with no new behavior required of older clients. macOS paired/native execution is rendered-covered; Linux, Windows, SSH, WSL, folder workspaces, and mobile rendered coverage remain gaps. The logic compares page placements independently of execution-host paths and retains the existing folder/remote resolver.Tradeoffs
Genuine negatives, not "none":
pagePlacementsAtAttachis optional, so recovery runs unfenced if a future caller omits it. Only the attach handler calls it today and the parameter is documented, but this is a latent way to reintroduce the bug.Mapof page id to placement is built on every attach, bounded by the existing 256-page registry cap, and released when the handler returns. No polling, no subprocess, no new protocol field.Visual proof
Not applicable, and not valuable here. The change has no rendered surface of its own; it suppresses an erroneous recovery command during attach. The only visible symptom is the absence of a failure — browser tabs staying alive after a restart — which a screenshot cannot distinguish from a broken build. The meaningful evidence is the paired cookie-survival Electron journey noted above plus the two deterministic regressions. Local Electron launches are paused for this task, so no app was launched.
Application behavior change: left open for user review; do not merge automatically.