Skip to content

A browser tab opened in a server workspace drawn from the server's layout stays open (switch-on builds only) - #31898

Merged
Jinwoo-H merged 10 commits into
mainfrom
fd/l282-frame-drawn-browser-create
Oct 22, 2026
Merged

Jinwoo-H merged 10 commits into
mainfrom
fd/l282-frame-drawn-browser-create

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

With the layout-owner build switch on (off in every shipped build), a desktop paired to an Orca server draws that server's workspaces from the server's layout updates ("frames"). In such a workspace, opening a new browser tab failed: a tab hosted on this desktop disappeared after 8 seconds, and a tab hosted on the server disappeared about half a second later, both with "The paired runtime could not create a managed browser tab." Now both open and stay.

Builds on L273-core (#31853, merged: this desktop's client-hosted browser tabs kept in a server's frames).

What Changed

Everything below happens only with ORCA_LAYOUT_OWNER=main, in a workspace a paired server's frames draw.

  • L282, a tab hosted on this desktop. The desktop draws the tab at once as "staged" and waits for proof the server created it. That proof used to come from the session mirror, which skips frame-drawn workspaces, so after 8 s the create gave up and closed the page.

    • Now the frame-drawn branch of the snapshot apply adopts just the page's handle when the server's snapshot lists the page with this desktop's placement (frame-drawn-desktop-browser-handles.ts). Tabs, groups and pages stay the frames'; L273 keeps the tab itself drawn.
    • The snapshot is the completion signal because it is the only message carrying the page's full placement (host generations); the create reply carries only the page id.
  • L284, a tab hosted on the server. A server-hosted page enters the server's layout, so about 180 ms after the click the frames draw the server's own tab for it and drop the staged one. The create read the missing staged tab as the user closing it, closed the server page, and failed.

    • Now the frame build records "the frames took this staged tab over" when it drops a staged tab while drawing a tab for the same page (workspace-layout-frame-browser-handover.ts, one call in buildLayoutFrameStorePatch). The create reads "staged gone + handed over" as done, and clears the record when it settles. The build looks at dropped pages only when a staged create's page is among those drawn, so closing a tab with many pages costs no extra pass.
    • A user close before the frames draw the page still cancels as before (the existing cancel test is unchanged). A close at the same moment as the server's draw reads as a handover, so the tab stays on the server, which matches what the server holds.
  • L291, the server's reply named the wrong id (since Browser, chat and simulator tabs main-first: the window asks main for each change and draws only main's update (dark, layout-owner build only) #31516). A switch-on host replied to browser.tabCreate with the workspace id instead of the page id: its window opens the tab through main and draws the page only when main's frame lands, so the reply fell back to the workspace id. The client then saw a page id it never asked for, missed the handover, and closed the server's page. The reply now names the page id the create asked for, then the new record's own page (browser-request-ipc-bridge.ts). Switch-off is unchanged: the page is already in the store there, with the same id.

  • A server-hosted create whose tab is not selected. A frame-drawn server tab gets a page handle only when its pane mounts, so a background create used to wait 8 s and close the server's page. The handover now counts as the create landing, also when it arrives during the wait.

Why

The frames own every tab in these workspaces, so the old "the mirror adopts my staged rows" completion path no longer exists there. Each fix gives the create the one signal frames-era workspaces still have, without a second wait path and without writing tab structure outside the frames.

Linked Issue

Internal (terminal-layout final design; ledger L282, L284, L291).

Visual Proof

N/A: dark path behind a build switch that is off in shipped builds. Covered by the e2e spec below.

Testing

  • Fail-first unit tests:

    • L282: frame-drawn-server-workspaces.test.ts, "adopts a staged client-hosted page this desktop created once the server's snapshot lists it (L282)".
    • L284: web-runtime-session-browser-create-staging.test.ts, describe "a server-hosted create the server's frames take over (L284)": the take-over completes and closes nothing; a close before the frames draw the page still cancels; a record left by an earlier create is not reused; a close of the drawn tab after the handover is left to the server tab's own close. Three of the four fail without the fix (the early-close case guards today's behaviour). workspace-layout-frame-browser-handover.test.ts covers the frame-side record.
    • Unselected tab: "completes when the drawn tab has no handle yet, its pane not mounted" and web-runtime-browser-materialization-wait.test.ts (a handover mid-wait) fail without the fix.
    • L291: browser-request-ipc-bridge.owner.test.ts, "answers with the new tab's page before main's frame draws it (layout-owner build)", fails without the fix.
  • E2e (gate 14): paired-client-hosted-browser.spec.ts, run switch-on: both tests pass at head 32d55d3 and both fail at base main 2c93754 with "could not create a managed browser tab" (at the first create, the client-hosted one).

  • In-app trace (hidden window): the server's frames draw its own tab for a server-hosted page about 50 ms after the create, with the page id the client asked for; the create completes into that tab and closes nothing.

  • Server specs (switch-on builds): tab-composition, layout-frames and focused-terminal-create pass at head 32d55d3 and at base 2c93754 (layout-intents is not on main).

  • Switch-on comparison (src/renderer/src runtime, store, lib, hooks/ipc-events; run-vitest with the pinned Bun 1.4.3), head 32d55d3 against base main 2c93754: base 14,872 tests, head 14,885; no test passing at base fails at head; ABSENT 0; files that ran no tests 0 (16 failing at each side, all the same).

  • Static gate: every pr.yml static step passes.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Review

Independent review APPROVE WITH NITS; nits fixed (restored-handle clause dropped as unreachable, the frame build's side effect named, a comment corrected). A second review on L273-core found the unselected-tab timeout (fixed above). Delta reviews of that fix and of the L291 reply found no bugs. W6 (L273 owner) approved the frame-build hunk, and its later early return (01d25c2).

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

  • Remote and wire: no RPC or stream change; the desktop only reads what servers already send.
  • Switch-off: unchanged. Frame-drawn workspaces exist only with the switch on, and local workspaces never hold staged browser handles.
  • Known follow-up, L285: a frame rebuild of the workspace before the server publishes the page (during client-host preparation) still drops a staged server-hosted tab with no handover, and the create reads that as a cancel. Holding staged server-hosted tabs through L273's keep-tab mechanism until a drawn tab carries the page would close it.

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)
  • 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)

…drawn workspace survive the server's frames (switch-on)

A tab the server's layout never lists (a client-hosted browser tab today; any kind recorded the
same way) used to vanish on the server's next frame rebuild. This desktop now records such tabs by
server and workspace, in its localStorage only (never a session field nor sent), and the server's
frame builds keep them as drawn, inside the server's own groups:
- A held tab drawn in a group the server lacks moves to the nearest server group; it shows there
  only if the user was on it, and the user's group follows it. The group tree stays the server's.
- The record forgets an id once the server's frame lists it, on close, and on worktree removal,
  and prunes ids the restored session no longer has before the first frame after a reload.
- A held tab's drag moves it here only (no session.tabs.move); it offers no new split, and a
  server tab sharing its group counts only the server's tabs for split no-ops.
- Client-hosted staging records its tab (both ids) in layout-owner builds; restage takes the
  worktree from its caller instead of scanning the store.
…tch off; clearer names

- With the switch off the record is never read, kept or written (a single gate in the record).
- The frame-drawn check is isDesktopCreatedTabInFrameDrawnServerWorkspace in
  frame-drawn-desktop-created-tabs.ts: "held" stays the frame hold's word.
- The held-tab placement drops its unread activeGroupId; the group follow derives it.
…e-drawn server workspace completes once the server's snapshot lists it, instead of undoing itself after 8 s (switch-on)
…e-drawn server workspace completes when the server's frames take it over, instead of reading as the user's close (switch-on)
…he frame build's handover note (review nits)
…reate though its pane, unmounted, has no handle yet (layout-owner build only)
…te with the new page's id, not its workspace's, before main's frame draws it
…en a staged create's page is drawn, so a large close stays one pass
…frame-drawn-browser-create

# Conflicts:
#	src/renderer/src/components/tab-group/tab-group-layout-owner-commands.ts
#	src/renderer/src/runtime/server-layout-frames-held-tabs.test.ts
@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

The changes add persistent tracking for desktop-created server tabs and integrate held-tab rules into layout-frame reconciliation. Split operations use server-tab counts and exclude eligible desktop-created tabs. Browser creation now recognizes when frames take over a staged page, and snapshot synchronization can adopt matching client-hosted handles. Tab-creation replies also select a page ID from the request or workspace state.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 01d25

Focus may fail to follow a retained tab when its former group is removed. This localized navigation issue can be fixed or accepted as a bounded follow-up before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 59.32% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 59 functions across 38 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the primary behavior change: browser tabs created in server-layout workspaces remain open. The switch-on scope is also stated.
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.
Description check Passed The description follows the required structure and provides a clear user impact, implementation details, rationale, testing evidence, visual-proof justification, review notes, scope notes, and complet…
Full details: Description check

Explanation

The description follows the required structure and provides a clear user impact, implementation details, rationale, testing evidence, visual-proof justification, review notes, scope notes, and completed checklist items. The Linked Issue section does not contain an actual issue reference or Fixes # entry, but the description is otherwise complete and identifies the related internal ledger items and stacked pull requests.

✨ Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
⚔️ Resolve merge conflicts: 💡
  • Resolve merge conflict in branch fd/l282-frame-drawn-browser-create
  • 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

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ 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: bbceba17-ffe9-485e-b086-5ac35b9105b9
📥 Commits

Reviewing files that changed from the base of the PR and between 2c93754 and 01d25c2.

📒 Files selected for processing: 38
  • src/renderer/src/components/tab-bar/tab-move-to-pane-column.ts
  • src/renderer/src/components/tab-bar/web-runtime-tab-move-mirror.ts
  • src/renderer/src/components/tab-group/tab-group-layout-owner-commands.ts
  • src/renderer/src/components/tab-group/tab-group-panel-split-target.ts
  • src/renderer/src/hooks/ipc-events/browser-request-ipc-bridge.owner.test.ts
  • src/renderer/src/hooks/ipc-events/browser-request-ipc-bridge.ts
  • src/renderer/src/lib/desktop-created-server-tabs-switch-off.test.ts
  • src/renderer/src/lib/desktop-created-server-tabs.test.ts
  • src/renderer/src/lib/desktop-created-server-tabs.ts
  • src/renderer/src/lib/frame-drawn-desktop-created-tabs.ts
  • src/renderer/src/lib/staged-browser-frame-handover.ts
  • src/renderer/src/runtime/held-tab-group-follow.ts
  • src/renderer/src/runtime/layout-frame-stream.ts
  • src/renderer/src/runtime/server-layout-frames-held-tabs.test.ts
  • src/renderer/src/runtime/server-layout-frames.ts
  • src/renderer/src/runtime/web-runtime-browser-creation-context.ts
  • src/renderer/src/runtime/web-runtime-browser-creation.ts
  • src/renderer/src/runtime/web-runtime-browser-materialization-wait.test.ts
  • src/renderer/src/runtime/web-runtime-browser-materialization-wait.ts
  • src/renderer/src/runtime/web-runtime-browser-tab-staging-hosting-intent.test.ts
  • src/renderer/src/runtime/web-runtime-browser-tab-staging.ts
  • src/renderer/src/runtime/web-runtime-session-browser-create-staging.test.ts
  • src/renderer/src/runtime/web-session-tabs-sync/frame-drawn-desktop-browser-handles.ts
  • src/renderer/src/runtime/web-session-tabs-sync/frame-drawn-server-workspaces.test.ts
  • src/renderer/src/runtime/web-session-tabs-sync/frame-drawn-workspace-status-patch.ts
  • src/renderer/src/runtime/workspace-layout-frame-apply-check.test-fixture.ts
  • src/renderer/src/runtime/workspace-layout-frame-apply-observer.ts
  • src/renderer/src/runtime/workspace-layout-frame-operations.test.ts
  • src/renderer/src/runtime/workspace-layout-frame-sync.ts
  • src/renderer/src/store/slices/browser/browser-close-actions.ts
  • src/renderer/src/store/slices/tabs/tabs-close-actions.ts
  • src/renderer/src/store/slices/worktrees/teardown/removed-worktree-renderer-teardown.ts
  • src/renderer/src/store/workspace-layout-frame-browser-handover.test.ts
  • src/renderer/src/store/workspace-layout-frame-browser-handover.ts
  • src/renderer/src/store/workspace-layout-frame-held-tab-groups.ts
  • src/renderer/src/store/workspace-layout-frame-held-tabs.ts
  • src/renderer/src/store/workspace-layout-frame-store-patch.test.ts
  • src/renderer/src/store/workspace-layout-frame-store-patch.ts

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

const tabId = (before.groupsByWorktree[worktreeId] ?? []).find(
(group) => group.id === userGroupId
)?.activeTabId
if (!tabId || !held.keepsInMainGroups?.(worktreeId, tabId)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Resolve the entity ID before the keepsInMainGroups check.

heldTabsInMainGroups is called with keepsInMain(key, tab.id) || keepsInMain(key, tab.entityId). This check passes only the tab-bar ID. The registry can record a tab by its entity ID alone (see isDesktopCreatedServerTab). In that case the placement moves the tab into a main group, but this check returns []. The user then stays on a group that no longer exists, and focus does not follow the tab.

Look up the tab in before.unifiedTabsByWorktree and test both IDs.

🐛 Proposed fix
--- "a/src/renderer/src/runtime/held-tab-group-follow.ts"
+++ "b/src/renderer/src/runtime/held-tab-group-follow.ts"
@@ -25,9 +25,13 @@
     const tabId = (before.groupsByWorktree[worktreeId] ?? []).find(
       (group) => group.id === userGroupId
     )?.activeTabId
-    if (!tabId || !held.keepsInMainGroups?.(worktreeId, tabId)) {
+    const entityId = (before.unifiedTabsByWorktree[worktreeId] ?? []).find(
+      (tab) => tab.id === tabId
+    )?.entityId
+    const keeps = (id: string): boolean => held.keepsInMainGroups?.(worktreeId, id) === true
+    if (!tabId || !(keeps(tabId) || (entityId !== undefined && keeps(entityId)))) {
       return []
     }
     const groupId = after.unifiedTabsByWorktree[worktreeId]?.find(
       (tab) => tab.id === tabId
     )?.groupId
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (!tabId || !held.keepsInMainGroups?.(worktreeId, tabId)) {
const entityId = (before.unifiedTabsByWorktree[worktreeId] ?? []).find(
(tab) => tab.id === tabId
)?.entityId
const keeps = (id: string): boolean => held.keepsInMainGroups?.(worktreeId, id) === true
if (!tabId || !(keeps(tabId) || (entityId !== undefined && keeps(entityId)))) {

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