Repository navigation
fix(browser): server tabs no longer show twice after the desktop relaunches - #48032
Conversation
…unches A relaunch restores streamed pages without their server handle, so the first server snapshot could not match them and added a second tab for each one. Match a handle-less page by its saved server page id within the same server.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
ELI5
On a desktop paired to a server, each Server (streamed) browser tab you had open came back twice after you quit and reopened Orca. Now each one comes back once, in the same spot, and still streams.
What Changed
findBrowserWorkspaceForRemotePagelooks for the local tab that already shows each server page. Until now it matched only through the page's live server handle. For a page with no handle, it now also matches on the page's saved identity: the server it belongs to (browserRuntimeEnvironmentId) and its saved server page id (remoteBrowserPageId). The first server snapshot then adopts the restored tab and writes its handle, instead of adding a second tab. A live handle still wins whenever one exists.Why
Root cause: session restore re-adds saved streamed tabs but on purpose leaves out their server handle. Restore only seeds handles for This-device pages, so that a streamed page the server lost reopens its saved address instead of being adopted and deleted (#15448). The snapshot matching assumed every tab this desktop owns on a server has a handle. That holds for tabs created during the session, because creation stages a handle, but not for restored tabs. So on the first snapshot after a relaunch, nothing matched, and the server's rows became new tabs next to the restored ones.
Why this approach: it fixes the one lookup that decides which tab owns a server page, and leaves the restore rule alone. Restoring handles for streamed pages too would also stop the duplicates, but it would bring back the case #15448 avoided: a streamed page the server no longer has would close its row instead of reopening the saved address. With this change, a restored page that the server still has is adopted, and one it no longer lists stays unmatched and behaves exactly as before. The saved page id is only compared against rows from the same server, so a different server can never claim the tab.
Linked Issue
None. Found by the move-tab work in #47957, and listed there as a known issue that also happens on main for a plain new streamed tab.
Visual Proof
Hidden e2e desktop paired to a headless
orca serve. One This-device tab (alpha) and three streamed tabs (bravo, charlie, delta), then a desktop relaunch.Before (main): bravo, charlie and delta each show twice.
After: each tab once, in the original order, and the streamed page renders.
Testing
macOS, real paired runtime: a hidden e2e desktop paired to a headless
orca serve, using a scratch Playwright spec that is not committed. The desktop opens one This-device tab and three streamed tabs, then quits and relaunches on the same profile.Unit test
restored-server-browser-tab-adoption.test.tsruns the real save → restore → snapshot path:Each case fails with its guard removed. Linux and Windows: no platform-specific code. Covered by CI.
Performance
None, because the change adds one comparison of two fields per page that has no handle, inside a loop that already visits the worktree's browser pages. The loop runs per server browser row on each snapshot, and in the native chat browser-page button selector. No new listeners, timers, RPCs or stored state.
Risk
Level: Low
AI Disclosure
Review
Codex release gate on this head:
NO P0 OR P1.Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
SSH workspaces don't use server browser rows, so they're unaffected.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)