Repository navigation
A browser tab opened in a server workspace drawn from the server's layout stays open (switch-on builds only) - #31898
Conversation
…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
… then the new record's own page (L291)
…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
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🔵 Low · up to
|
There was a problem hiding this comment.
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
📒 Files selected for processing: 38
src/renderer/src/components/tab-bar/tab-move-to-pane-column.tssrc/renderer/src/components/tab-bar/web-runtime-tab-move-mirror.tssrc/renderer/src/components/tab-group/tab-group-layout-owner-commands.tssrc/renderer/src/components/tab-group/tab-group-panel-split-target.tssrc/renderer/src/hooks/ipc-events/browser-request-ipc-bridge.owner.test.tssrc/renderer/src/hooks/ipc-events/browser-request-ipc-bridge.tssrc/renderer/src/lib/desktop-created-server-tabs-switch-off.test.tssrc/renderer/src/lib/desktop-created-server-tabs.test.tssrc/renderer/src/lib/desktop-created-server-tabs.tssrc/renderer/src/lib/frame-drawn-desktop-created-tabs.tssrc/renderer/src/lib/staged-browser-frame-handover.tssrc/renderer/src/runtime/held-tab-group-follow.tssrc/renderer/src/runtime/layout-frame-stream.tssrc/renderer/src/runtime/server-layout-frames-held-tabs.test.tssrc/renderer/src/runtime/server-layout-frames.tssrc/renderer/src/runtime/web-runtime-browser-creation-context.tssrc/renderer/src/runtime/web-runtime-browser-creation.tssrc/renderer/src/runtime/web-runtime-browser-materialization-wait.test.tssrc/renderer/src/runtime/web-runtime-browser-materialization-wait.tssrc/renderer/src/runtime/web-runtime-browser-tab-staging-hosting-intent.test.tssrc/renderer/src/runtime/web-runtime-browser-tab-staging.tssrc/renderer/src/runtime/web-runtime-session-browser-create-staging.test.tssrc/renderer/src/runtime/web-session-tabs-sync/frame-drawn-desktop-browser-handles.tssrc/renderer/src/runtime/web-session-tabs-sync/frame-drawn-server-workspaces.test.tssrc/renderer/src/runtime/web-session-tabs-sync/frame-drawn-workspace-status-patch.tssrc/renderer/src/runtime/workspace-layout-frame-apply-check.test-fixture.tssrc/renderer/src/runtime/workspace-layout-frame-apply-observer.tssrc/renderer/src/runtime/workspace-layout-frame-operations.test.tssrc/renderer/src/runtime/workspace-layout-frame-sync.tssrc/renderer/src/store/slices/browser/browser-close-actions.tssrc/renderer/src/store/slices/tabs/tabs-close-actions.tssrc/renderer/src/store/slices/worktrees/teardown/removed-worktree-renderer-teardown.tssrc/renderer/src/store/workspace-layout-frame-browser-handover.test.tssrc/renderer/src/store/workspace-layout-frame-browser-handover.tssrc/renderer/src/store/workspace-layout-frame-held-tab-groups.tssrc/renderer/src/store/workspace-layout-frame-held-tabs.tssrc/renderer/src/store/workspace-layout-frame-store-patch.test.tssrc/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)) { |
There was a problem hiding this comment.
🎯 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.
| 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)))) { |
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.
frame-drawn-desktop-browser-handles.ts). Tabs, groups and pages stay the frames'; L273 keeps the tab itself drawn.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.
workspace-layout-frame-browser-handover.ts, one call inbuildLayoutFrameStorePatch). 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.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.tabCreatewith 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:
frame-drawn-server-workspaces.test.ts, "adopts a staged client-hosted page this desktop created once the server's snapshot lists it (L282)".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.tscovers the frame-side record.web-runtime-browser-materialization-wait.test.ts(a handover mid-wait) fail without the fix.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
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)