Skip to content

fix(browser): server tabs no longer show twice after the desktop relaunches - #48032

Merged
AmoabaKelvin merged 2 commits into
mainfrom
fix/browser-server-tabs-duplicate-after-relaunch
Nov 24, 2026
Merged

AmoabaKelvin merged 2 commits into
mainfrom
fix/browser-server-tabs-duplicate-after-relaunch

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

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.

Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​129 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​129
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​6 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​5

What Changed

  • Before: after a desktop relaunch, the paired worktree's strip showed every streamed tab this desktop had created twice: the restored tab, plus a copy built from the server's tab list. Both pointed at the same server page. This-device tabs were fine.
  • After: each streamed tab appears once, keeps its tab id and position, and streams as before. This-device tabs and local tabs are unchanged.
  • Mechanism: when the server's tab list arrives, findBrowserWorkspaceForRemotePage looks 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.

before-main-after-relaunch.png

After: each tab once, in the original order, and the streamed page renders.

after-fix-after-relaunch.png

Testing

  • 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

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.

  • On main, the strip went from 4 browser tabs to 7: each streamed tab twice, with the server-id copies inserted before the restored ones.
  • With the fix, the strip has the same 4 tab ids in the same order, from the first read after relaunch onward. Each streamed tab renders its page when focused. The server still has exactly 3 pages, and alpha is still This-device.
  • I also re-ran feat(browser): move a tab between this computer and a paired server from the ⋯ menu #47957's scratch move spec. It moves tabs both ways, then relaunches with Server (streamed) set. The relaunched strip has no duplicates, and the moved page still comes back hosted here.

Unit test restored-server-browser-tab-adoption.test.ts runs the real save → restore → snapshot path:

  • a restored streamed tab is adopted by its server row, with one tab and its own ids;
  • a row with the same page id from a different server does not claim it.

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

  • Who can trigger it: nobody new. The match runs only when a server's own tab list is applied, and only against pages already saved as belonging to that same server. No new RPC, no wire change, no new saved field.
  • Older servers and phones see no change. An older desktop is unaffected. The phone doesn't restore desktop tabs.
  • Unchanged, and separate from this fix: if a restored streamed tab's pane opens before the first server snapshot arrives, it can still create a fresh server page. That did not happen in any relaunch run here.
  • Back out: plain revert.

AI Disclosure

Review

Codex release gate on this head: NO P0 OR P1.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

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

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…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.
@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

When a page has no remote handle, findBrowserWorkspaceForRemotePage matches it using its saved environment ID and remote page ID. When a handle exists, matching uses the handle’s IDs. New tests cover restored-tab adoption for snapshots from the same and different environments.

Merge Risk: Minimal · up to 699fa

This change stops streamed browser tabs from duplicating after the desktop relaunches by matching restored tabs to server rows using their saved IDs. It affects only restored streamed tabs, and the tests cover both the matching and non-matching cases. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title follows conventional commit form and names the primary change: server (streamed) browser tabs no longer appear twice after the desktop relaunches. The changeset matches this: it adds saved-i…
Description check Passed The description follows the template well. It has ELI5, What Changed (before/after and mechanism), Why (root cause and alternative rejected), Visual Proof (before/after images), Testing with checked i…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title follows conventional commit form and names the primary change: server (streamed) browser tabs no longer appear twice after the desktop relaunches. The changeset matches this: it adds saved-identity matching in findBrowserWorkspaceForRemotePage for handle-less restored pages, plus tests for restored tab adoption.

Full details: Description check

Explanation

The description follows the template well. It has ELI5, What Changed (before/after and mechanism), Why (root cause and alternative rejected), Visual Proof (before/after images), Testing with checked items, Performance with a reason, Risk with level and back-out plan, AI Disclosure left empty, Review, Agent skill boundary, Notes, and a completed checklist. The Linked Issue section says 'None' and does not use the 'Fixes #' form, which the template asks for from outside contributors. The author is likely a maintainer, so this gap is non-critical. The AI Disclosure section is empty, which is acceptable for internal contributors per the template comment.

Resolution

Optional: state the linked issue explicitly if one exists, or confirm the author is a maintainer exempt from the issue requirement. Consider filling in AI Disclosure if an AI model was used.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6b98916d-099d-44d7-b88e-934d4d63acc5
Commits

Reviewing files that changed from the base of the PR and between f124b4b and 699fafa.

Files selected for processing: 2

  • src/renderer/src/runtime/web-session-tabs-sync/tab-projection/mirrored-browser-tabs.ts
  • src/renderer/src/runtime/web-session-tabs-sync/tab-projection/restored-server-browser-tab-adoption.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@AmoabaKelvin
AmoabaKelvin merged commit da483ae into main Nov 24, 2026
54 checks passed
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