Repository navigation
A paired desktop keeps the tabs it created in a server workspace drawn from the server's layout (switch-on builds only) - #31853
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.
…wn workspace survives its frames (switch-on) The server never has this desktop's emulator tab, so its frame rebuilds dropped it. The simulator open now records the tab as created here when a server's frames draw the workspace, and opens it in the server group it would have split beside, since that workspace has no group of this desktop's own. L290 (the host runs and streams the simulator, #6701) removes the note.
…and can fail; the side-open test starts from another group Co-Authored-By: Claude <[email protected]>
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🔵 Low · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments: 1
src/renderer/src/runtime/server-layout-frames.ts: 1
154-160: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winLimit the published-tab cleanup to workspaces the frame changed.
Every translated frame loops over all
translator.keys(). For each key, the code builds the full[tab.id, tab.entityId]list beforeforgetPublishedServerTabscan return early. Most workspaces have no record, so this is wasted work on every frame. The cost grows with workspace count times tab count.Skip keys that have no record before building the id list. You can also restrict the loop to the workspaces named in the frame.
♻️ Proposed direction
- for (const key of translator.keys()) { - forgetPublishedServerTabs( - key, - (translator.serverLayout(key)?.tabs ?? []).flatMap((tab) => [tab.id, tab.entityId]) - ) - } + for (const key of translator.keys()) { + if (!hasDesktopCreatedServerTabs(key)) { + continue + } + forgetPublishedServerTabs( + key, + (translator.serverLayout(key)?.tabs ?? []).flatMap((tab) => [tab.id, tab.entityId]) + ) + }Add
hasDesktopCreatedServerTabs(workspace)todesktop-created-server-tabs.ts. It returnsentriesOf(workspace).length > 0.
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
c60912a2-1281-4abb-ac23-72a947ddd3d8
📒 Files selected for processing: 27
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/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/ensure-simulator-tab.tssrc/renderer/src/lib/frame-drawn-desktop-created-tabs.tssrc/renderer/src/lib/simulator-tab-layout-owner.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-tab-staging-hosting-intent.test.tssrc/renderer/src/runtime/web-runtime-browser-tab-staging.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-held-tab-groups.tssrc/renderer/src/store/workspace-layout-frame-held-tabs.tssrc/renderer/src/store/workspace-layout-frame-store-patch.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
| const tabId = useAppStore | ||
| .getState() | ||
| .unifiedTabsByWorktree[args.worktreeId]?.find( | ||
| (tab) => tab.contentType === 'browser' && tab.entityId === workspace.id | ||
| )?.id | ||
| const staged = { | ||
| workspaceId: workspace.id, | ||
| pageId, | ||
| clientHosted: args.clientHosted === true, | ||
| ...(tabId ? { tabId } : {}) | ||
| } | ||
| noteClientHosting(args.environmentId, args.worktreeId, staged) | ||
| return staged |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '35,110p' src/renderer/src/runtime/web-runtime-browser-tab-staging.ts
rg -n 'stageWebRuntimeBrowserTab|noteClientHosting|restageWebRuntimeBrowserTabHostingIntent' src/renderer/src/runtime src/renderer/src/store --glob '!**/*.test.ts'Repository: stablyai/orca
Length of output: 4457
🏁 Script executed:
set -o pipefail
sed -n '1,235p' src/renderer/src/runtime/web-runtime-browser-tab-staging.ts
printf '\n--- creation context ---\n'
sed -n '1,255p' src/renderer/src/runtime/web-runtime-browser-creation-context.ts
printf '\n--- staged/tabId/frame references ---\n'
rg -n -F --glob '*.ts' -e 'staged.tabId' -e '.tabId' -e 'isFrameDrawn' -e 'frameDrawn' -e 'clientHosted' -e 'noteClientHosting' src/renderer/src/runtime src/renderer/src/store src/renderer/src --glob '!**/*.test.ts' | head -n 300Repository: stablyai/orca
Length of output: 41503
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- exact symbol locations ---'
rg -n -F --glob '*.ts' -e 'createBrowserTab' -e 'noteDesktopCreatedServerTab' -e 'forgetDesktopCreatedServerTab' -e 'desktopCreatedServerTab' -e 'frameDrawnPreviousTabIds' -e 'isFrameDrawnServerWorkspace' src/renderer/src src/shared
printf '%s\n' '--- snapshot application ---'
sed -n '1,240p' src/renderer/src/runtime/web-session-tabs-sync/apply-snapshot.ts
printf '%s\n' '--- frame-created tab handling candidates ---'
rg -l -F --glob '*.ts' -e 'frameDrawnPreviousTabIds' -e 'createdServer' -e 'DesktopCreatedServer' src/renderer/src/runtime/web-session-tabs-sync src/renderer/src/lib src/renderer/src/store | while read -r f; do echo "### $f"; sed -n '1,280p' "$f"; doneRepository: stablyai/orca
Length of output: 42441
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- createBrowserTab declarations ---'
rg -n -F --glob '*.ts' -e 'createBrowserTab:' -e 'createBrowserTab (' -e 'createBrowserTab(' src/renderer/src/store src/renderer/src/runtime | head -n 120
printf '%s\n' '--- likely tab slice files ---'
rg -l -F --glob '*.ts' 'createBrowserTab' src/renderer/src/store | head -n 80
printf '%s\n' '--- desktop hold implementation ---'
sed -n '1,220p' src/renderer/src/lib/frame-drawn-desktop-created-tabs.ts
sed -n '1,220p' src/renderer/src/lib/desktop-created-server-tabs.ts
printf '%s\n' '--- frame-drawn layout path ---'
rg -n -F --glob '*.ts' -e 'buildFrameDrawnWorkspaceStatusPatch' -e 'DESKTOP_CREATED_SERVER_TAB_HOLDS' -e 'isTabHeld' -e 'withDrawnBrowserPages' src/renderer/src/runtime src/renderer/src/store src/renderer/src/lib | head -n 200Repository: stablyai/orca
Length of output: 29442
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- held-tab filtering ---'
sed -n '130,215p' src/renderer/src/store/workspace-layout-frame-held-tabs.ts
printf '%s\n' '--- frame-drawn patch ---'
sed -n '1,260p' src/renderer/src/runtime/web-session-tabs-sync/frame-drawn-workspace-status-patch.ts
printf '%s\n' '--- create action definitions ---'
rg -n -F --glob '*.ts' -e 'function createBrowserTab' -e 'const createBrowserTab' -e 'createBrowserTab:' src/renderer/src/store src/renderer/src/lib | grep -v '\.test\.ts' | head -n 100
printf '%s\n' '--- browser tab action files ---'
sed -n '1,280p' src/renderer/src/store/slices/browser/browser-tab-actions.ts
sed -n '1,260p' src/renderer/src/store/slices/browser/create-browser-slice.tsRepository: stablyai/orca
Length of output: 22699
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- layout-owner browser open helper ---'
sed -n '1,300p' src/renderer/src/store/slices/browser/browser-tab-open-through-layout-owner.ts
printf '%s\n' '--- all staging tabId references and note calls ---'
rg -n -F --glob '*.ts' -e 'staged.tabId' -e 'tabId: staged' -e 'noteClientHosting(' -e 'StagedWebRuntimeBrowserTab' src/renderer/src/runtime src/renderer/src/store src/renderer/src/lib --glob '!**/*.test.ts'Repository: stablyai/orca
Length of output: 7167
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- content-tab layout-owner open ---'
sed -n '1,340p' src/renderer/src/runtime/layout-owner-content-tab-open.ts
printf '%s\n' '--- serverTabCount consumers and related layout logic ---'
rg -n -F --glob '*.ts' -e 'serverTabCount(' -e 'serverTabCount' -e 'isDesktopCreatedServerTab(' src/renderer/src/runtime src/renderer/src/store src/renderer/src/lib --glob '!**/*.test.ts'
printf '%s\n' '--- relevant tests ---'
rg -n -F --glob '*.test.ts' -e 'serverTabCount' -e 'tab count' -e 'client-hosted' -e 'split' src/renderer/src/runtime/server-layout-frames-held-tabs.test.ts src/renderer/src/store/workspace-layout-frame-store-patch.test.ts src/renderer/src/runtime/web-runtime-session-browser-create-split-placement.test.ts 2>/dev/null | head -n 160Repository: stablyai/orca
Length of output: 5827
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- published-record cleanup callers ---'
rg -n -F --glob '*.ts' -e 'forgetPublishedServerTabs' -e 'serverTabCount' -e 'isDesktopCreatedTabInFrameDrawnServerWorkspace' -e 'isDesktopCreatedServerTab' src --glob '!**/*.test.ts'
printf '%s\n' '--- held-tab setup and split tests ---'
sed -n '190,235p' src/renderer/src/runtime/server-layout-frames-held-tabs.test.ts
sed -n '360,455p' src/renderer/src/runtime/server-layout-frames-held-tabs.test.ts
printf '%s\n' '--- publication cleanup implementation context ---'
rg -n -F --glob '*.ts' -e 'publishedTabIds' -e 'forgetPublished' src/renderer/src/runtime src/renderer/src/store | head -n 120Repository: stablyai/orca
Length of output: 10574
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- tab-bar ID consumers ---'
sed -n '1,125p' src/renderer/src/components/tab-group/tab-group-layout-owner-commands.ts
sed -n '125,215p' src/renderer/src/components/tab-group/tab-group-panel-split-target.ts
sed -n '1,75p' src/renderer/src/components/tab-bar/tab-move-to-pane-column.ts
sed -n '1,65p' src/renderer/src/components/tab-bar/web-runtime-tab-move-mirror.ts
printf '%s\n' '--- frame publication cleanup ---'
sed -n '130,175p' src/renderer/src/runtime/server-layout-frames.tsRepository: stablyai/orca
Length of output: 13301
Record the unified tab ID after layout-owner drawing.
When ORCA_LAYOUT_OWNER_IS_MAIN routes creation through openContentTabThroughLayoutOwner, stageWebRuntimeBrowserTab can run before the frame creates the unified tab. The staged record then contains workspaceId but no tabId, and no later path updates it.
The workspace ID keeps the tab during frame reconciliation, but tab-bar-ID checks do not resolve the entity ID. isDesktopCreatedTabInFrameDrawnServerWorkspace and serverTabCount can therefore treat the client-hosted tab as a server tab. A move can be mirrored to the server, and a split can be offered or applied, although the tab must remain local.
Update the desktop-created record when the layout-owner callback provides the drawn unified tab ID. Keep the existing workspace/entity ID record for frame retention.
…age census It is keyed by a paired server's environment; a local or WSL project never has one, so a move has nothing to carry.
…core-created-here-holds # Conflicts: # src/renderer/src/components/tab-group/tab-group-layout-owner-commands.ts
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 Minor · Scope held-tab retention and publication cleanup by… · server-layout-frames.ts:151-159
src/renderer/src/runtime/server-layout-frames.ts:151-159
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winScope held-tab retention and publication cleanup by
environmentId.A tab recorded for environment A can be retained in environment B's frame because the shared hold object filters only by
worktreeId. When environment A publishes a tab, the unscoped cleanup can also remove the matching record for environment B. This can show A's tab in B's workspace or make B's recorded tab disappear from B's frame.Pass the current
environmentIdto both hold evaluation and publication cleanup. This is the single correction for this cross-server scope defect.Suggested fix
diff --git a/src/renderer/src/lib/desktop-created-server-tabs.ts b/src/renderer/src/lib/desktop-created-server-tabs.ts @@ -const entriesOf = (workspace: string): Entry[] => - [...recordMap().values()].filter((entry) => entry.worktreeId === workspace) +const entriesOf = (workspace: string, environmentId?: string): Entry[] => + [...recordMap().values()].filter( + (entry) => + entry.worktreeId === workspace && + (environmentId === undefined || entry.environmentId === environmentId) + ) @@ -export function forgetPublishedServerTabs(workspace: string, ids: Iterable<string>): void { - const entries = entriesOf(workspace) +export function forgetPublishedServerTabs( + workspace: string, + ids: Iterable<string>, + environmentId?: string +): void { + const entries = entriesOf(workspace, environmentId) @@ -const isCreated = (workspace: string, id: string): boolean => - entriesOf(workspace).some((entry) => entry.ids.has(id)) +const isCreated = (workspace: string, id: string, environmentId?: string): boolean => + entriesOf(workspace, environmentId).some((entry) => entry.ids.has(id)) + +export function desktopCreatedServerTabHolds(environmentId: string): HeldDrawnTabs { + const isHeld = (workspace: string, id: string): boolean => + isCreated(workspace, id, environmentId) + return { + isTabHeld: isHeld, + isGroupLayoutHeld: () => false, + keepsInMainGroups: isHeld + } +} diff --git a/src/renderer/src/runtime/server-layout-frames.ts b/src/renderer/src/runtime/server-layout-frames.ts @@ - DESKTOP_CREATED_SERVER_TAB_HOLDS, + desktopCreatedServerTabHolds, @@ - heldTabs: DESKTOP_CREATED_SERVER_TAB_HOLDS, + heldTabs: desktopCreatedServerTabHolds(environmentId), @@ forgetPublishedServerTabs( key, - (translator.serverLayout(key)?.tabs ?? []).flatMap((tab) => [tab.id, tab.entityId]) + (translator.serverLayout(key)?.tabs ?? []).flatMap((tab) => [tab.id, tab.entityId]), + environmentId )
ℹ️ 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:
d04d30c9-73c9-4ba6-bd3e-35651bb014af
📒 Files selected for processing: 2
src/renderer/src/components/tab-group/tab-group-layout-owner-commands.tssrc/shared/wsl-move/wsl-move-storage-dispositions.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.
ELI5
This only affects test builds where the main process owns the layout (the "layout-owner" switch, still off for users). In those builds, a desktop paired to an Orca server draws the server's workspaces from the server's own layout. A tab that only this desktop knows about, such as a browser page this desktop hosts or a simulator running on this desktop, is not in the server's layout, so the server's next layout update wiped it from the screen. Now the desktop remembers which tabs it created there and keeps them, placed inside the server's own groups.
What Changed
Before (switch-on builds, a paired desktop drawing a server workspace from the server's layout updates):
After:
lib/desktop-created-server-tabs.ts). It is kept per server and per workspace.session.tabs.movenames it.Why
The server's layout is the one every client draws from, so the desktop must not invent groups of its own. It must not drop tabs that genuinely live only on this desktop either. Keeping a small desktop-local record and folding those tabs into the server's groups satisfies both.
Alternatives considered:
The record's writes go through the frame hold's existing layout writes, so the layout-writer ratchet does not grow.
Linked Issue
Ledger L273-core (L274). W3's L282, L284 and L270 stack on this.
Visual Proof
N/A: dark change, switch-on builds only. Covered by unit tests against the real layout-update build, and by the server specs below.
Testing
Unit tests (
server-layout-frames-held-tabs.test.tsand others), with a client-hosted browser tab as the created-here tab:The drag, split and reload/prune tests fail without their fixes.
Gates:
pnpm tc, the layout-writer ratchet (no baseline change), oxlint,check:code-quality:changedand the CI static-analysis gate pass.src/renderer/src/runtime,store,lib,components/tab-barandcomponents/tab-group(15,492 vs 15,512 tests), plus the remaining importer folderscomponents/terminal-pane,hooks/ipc-events,components/right-sidebarandbrowser-pane/host-guest(8,790 tests). No test that passes at base fails at head, switch-on or switch-off. Switch-on has 25 failures, identical at base and head.Server specs: switch-on, fresh build.
paired-client-hosted-browser fails at both with "The paired runtime could not create a managed browser tab". That is the L282/L284 create path, which W3's PR, stacked on this one, fixes.
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)