Repository navigation
A paired desktop's tab moves, splits, resizes, props and renames in a server workspace go to the server's layout (switch-on builds only) - #31714
Conversation
…positions per stream
…erver's stream; a restarted main starts its positions over
…-writes # Conflicts: # .github/workflows/layout-owner-e2e.yml # src/renderer/src/components/tab-group/tab-group-layout-owner-commands.test.ts # src/renderer/src/components/tab-group/tab-group-layout-owner-commands.ts # src/renderer/src/components/terminal-pane/pty-connection/exited-split-pane-close.test.ts # src/renderer/src/components/terminal-pane/terminal-pane-layout-owner-gestures.test.ts
…as the window-era close did
…ps and agent-launch tabs itself, with or without a window (layout-owner build)
…SH relay session; agent-launch tabs main writes keep the window's focus rule, prompt and outcome (layout-owner build)
…ow's ids, and the pane attaches to it (layout-owner build)
…cations see main's start of a new tab
…s layout holds, with no window tree (layout-owner build, L197)
…start's ledger row is L252
…t to, and a failed start keeps the tab's startup
…hy, which drops its hold and prompt; a rename through main answers the name it stored (layout-owner build)
… and a failed start's startup never runs twice
…, so no runtime module loads before its base class
…m what phones list at once, not at the window's next publish (layout-owner build)
…ain starts it (layout-owner build)
…artup back (layout-owner build)
…w asks over IPC, which labels itself a client (layout-owner build)
…es draw land in that server's main (layout-owner build) - Routes setTabProps, setChatPane and non-terminal renameTab to the server's main as layout.apply; closes, starts, sleeps and terminal names keep the RPCs that main now applies (session.tabs.close, terminal.close, terminal.split, session.tabs.createTerminal, terminal.rename). A window-style closeTabs is never routed: main takes it as already stopped and stops nothing. - A close the server refuses (a pinned tab) redraws the workspace from the server's frames, so the window's optimistic drop never outlives the answer; same for a refused pane close. - A frame-drawn workspace keeps none of the mirror's ledgers (L240): no tab-id mappings, close or focus intents; they stay only for servers without layout.intents.v1 until the Phase 2 cutoff. Its pane-geometry push is skipped (it goes as intents); pane renames still push. - e2e: paired-desktop-server-layout-writes covers close (layout, session.tabs, terminal stop), rename, split and new tab on a windowless switch-on serve.
…lay; a launch-agent clear stays off the server route
…keeping the lifecycle file under its line cap
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🔵 Low · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
a3874c5a-f809-483c-8a41-8deb9a398be2
📒 Files selected for processing: 37
.github/workflows/layout-owner-e2e.ymlsrc/main/runtime/paired-desktop-server-writes-layout-owner.test.tssrc/renderer/src/components/tab-group/tab-group-layout-owner-commands.test.tssrc/renderer/src/components/tab-group/tab-group-layout-owner-commands.tssrc/renderer/src/components/terminal-pane/layout-owner-pane-close.test.tssrc/renderer/src/components/terminal-pane/terminal-layout-title-persist.test.tsxsrc/renderer/src/components/terminal-pane/terminal-pane-detach-layout-owner.test.tssrc/renderer/src/components/terminal-pane/terminal-pane-layout-owner-commands.test.tssrc/renderer/src/components/terminal-pane/terminal-pane-layout-owner-commands.tssrc/renderer/src/components/terminal-pane/terminal-pane-layout-owner-gestures.test.tssrc/renderer/src/components/terminal-pane/terminal-pane-tab-detach-frame-drawn.test.tssrc/renderer/src/components/terminal-pane/use-terminal-pane-close-actions.tssrc/renderer/src/runtime/layout-apply-hold-release.tssrc/renderer/src/runtime/layout-apply-send.test.tssrc/renderer/src/runtime/layout-apply-send.tssrc/renderer/src/runtime/layout-frame-position.test.tssrc/renderer/src/runtime/layout-frame-position.tssrc/renderer/src/runtime/layout-frame-stream.tssrc/renderer/src/runtime/layout-owner-command.test.tssrc/renderer/src/runtime/server-layout-apply-routes.tssrc/renderer/src/runtime/server-layout-apply.test.tssrc/renderer/src/runtime/server-layout-apply.tssrc/renderer/src/runtime/server-layout-frame-ids.tssrc/renderer/src/runtime/server-layout-frames.tssrc/renderer/src/runtime/web-runtime-session-frame-drawn-writes.test.tssrc/renderer/src/runtime/web-runtime-session-tab-lifecycle.tssrc/renderer/src/runtime/web-runtime-session-undelivered-close.tssrc/renderer/src/runtime/web-runtime-terminal-actions.tssrc/renderer/src/runtime/web-session-tabs-sync/active-session-subscription.tssrc/renderer/src/runtime/web-session-tabs-sync/apply-snapshot.tssrc/renderer/src/runtime/web-session-tabs-sync/frame-drawn-server-workspaces.test.tssrc/renderer/src/runtime/web-session-tabs-sync/frame-drawn-server-workspaces.tssrc/renderer/src/runtime/web-session-tabs-sync/initial-terminal-seeder.tstests/e2e/helpers/paired-desktop-server-layout.tstests/e2e/paired-desktop-server-layout-frames.spec.tstests/e2e/paired-desktop-server-layout-intents.spec.tstests/e2e/paired-desktop-server-layout-writes.spec.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
| export async function desktopTree(page: Page, worktreeId: string): Promise<Tree> { | ||
| return page.evaluate((id) => { | ||
| const state = window.__store!.getState() | ||
| const tabs = state.unifiedTabsByWorktree[id] ?? [] | ||
| type Node = { type: 'leaf'; leafId: string } | { type: 'split'; first: Node; second: Node } | ||
| const leaves = (node: Node | null | undefined): string[] => | ||
| !node | ||
| ? [] | ||
| : node.type === 'leaf' | ||
| ? [node.leafId] | ||
| : [...leaves(node.first), ...leaves(node.second)] | ||
| return (state.groupsByWorktree[id] ?? []).map((group) => ({ | ||
| id: group.id, | ||
| tabs: group.tabOrder.map((tabId) => { | ||
| const tab = tabs.find((candidate) => candidate.id === tabId) | ||
| if (!tab) { | ||
| return { id: tabId, kind: 'missing', panes: [] } | ||
| } | ||
| return { | ||
| id: tab.id, | ||
| kind: tab.contentType, | ||
| panes: | ||
| tab.contentType === 'terminal' | ||
| ? leaves(state.terminalLayoutsByTabId[tab.entityId]?.root) | ||
| : [] | ||
| } | ||
| }) | ||
| })) | ||
| }, worktreeId) | ||
| } |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Check the desktop side of the parity assertion in the DOM, not in the store.
desktopTree reads groupsByWorktree, unifiedTabsByWorktree, and terminalLayoutsByTabId from window.__store. expectFrameDrawnTreeMatchesServer compares that store copy with the server layout. The intents spec and the writes spec use this comparison as their main assertion. Two failures can pass undetected:
- The frame sync writes the correct store state, but the tab strip renders the wrong tab order.
- The tab strip still renders a closed tab.
Add a DOM read of the tab order next to the store tree. For example, read the [data-testid="sortable-tab"] elements and their data-tab-id values for each group. Read the .pane[data-leaf-id] elements for pane order. Then require the DOM order to match the server tree as well.
The writes spec also performs the rename step through setTabCustomTitle on the store. It does not use the tab-rename UI, so that step does not test the user rename path.
As per coding guidelines: "Use window.__store for setup; assert user-visible behavior through the DOM (getByRole, toBeVisible, toHaveText). Writing state and reading it back cannot catch broken rendering. This applies to hidden CDP-driven renderers too."
Source: Coding guidelines
…ver sends an anchor the server does not hold (layout-owner build)
…the routing point, skipping desktop-only tabs (layout-owner build)
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:
e83d07e4-53ab-45f1-bdaf-00985d672764
📒 Files selected for processing: 10
src/renderer/src/components/tab-group/tab-group-layout-owner-commands.test.tssrc/renderer/src/components/tab-group/tab-group-layout-owner-commands.tssrc/renderer/src/components/terminal-pane/pty-connection-main-pane-restore-start.test.tssrc/renderer/src/runtime/layout-apply-send.tssrc/renderer/src/runtime/layout-frame-stream.tssrc/renderer/src/runtime/server-layout-apply.test.tssrc/renderer/src/runtime/server-layout-apply.tssrc/renderer/src/runtime/server-layout-frames.tssrc/renderer/src/runtime/web-runtime-session-tab-lifecycle.tssrc/renderer/src/runtime/web-session-user-tab-close-params.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
| const frameDrawn = isServerFrameDrawnWorkspace(environmentId, args.worktreeId) | ||
| const immediateHostTabId = toHostSessionTabId(args.tabId) | ||
| if (isClose) { | ||
| // The host's id for this tab; a frame-drawn close that never arrived is held under it for replay. | ||
| let closeHostTabId = immediateHostTabId | ||
| if (isClose && !frameDrawn) { |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Inspect whether frame-drawn classification requires a registered layout route.
rg -n -C 6 \
'isFrameDrawnServerWorkspace|isServerFrameDrawnWorkspace|layout\.intents\.v1|serverLayoutApplyRoute|redrawServerLayoutWorkspace' \
src/renderer/src/runtime/server-layout-apply-routes.ts \
src/renderer/src/runtime/server-layout-frames.ts \
src/renderer/src/runtime/web-session-tabs-sync/frame-drawn-server-workspaces.tsRepository: stablyai/orca
Length of output: 7455
🏁 Script executed:
set -e
printf '%s\n' '--- route registry ---'
nl -ba src/renderer/src/runtime/server-layout-apply-routes.ts | sed -n '1,180p'
printf '%s\n' '--- frame workspace state call sites ---'
rg -n -C 8 -F -- \
'setFrameDrawnServerWorkspaces' \
src/renderer/src/runtime/server-layout-frames.ts \
src/renderer/src/runtime/web-session-tabs-sync/frame-drawn-server-workspaces.ts
printf '%s\n' '--- route provider call sites ---'
rg -n -C 12 -F -- \
'provideServerLayoutApplyRoutes' \
src/renderer/src/runtime/server-layout-frames.ts \
src/renderer/src/runtime
printf '%s\n' '--- capability and frame lifecycle references ---'
rg -n -C 8 -e 'layout\.intents\.v1' -e 'showServerLayoutFrames' -e 'isFrameDrawnServerWorkspace' -e 'serverLayoutApplyRoute' \
src/renderer/src/runtime/server-layout-frames.ts \
src/renderer/src/runtime/web-session-tabs-sync/frame-drawn-server-workspaces.ts \
src/renderer/src/runtime/server-layout-apply-routes.tsRepository: stablyai/orca
Length of output: 31658
🏁 Script executed:
set -e
printf '%s\n' '--- installServerLayoutFrames lifecycle ---'
nl -ba src/renderer/src/runtime/server-layout-frames.ts | sed -n '55,235p'
printf '%s\n' '--- lifecycle close and redraw flow ---'
nl -ba src/renderer/src/runtime/web-runtime-session-tab-lifecycle.ts | sed -n '150,285p'Repository: stablyai/orca
Length of output: 15289
🏁 Script executed:
set -e
printf '%s\n' '--- installServerLayoutFrames teardown and callers ---'
nl -ba src/renderer/src/runtime/server-layout-frames.ts | sed -n '234,335p'
rg -n -C 12 -e 'serverFrames\.close|frames\.close|close\(false\)|close\(true\)|returnWorkspaces' \
src/renderer/src/runtime/server-layout-frames.ts \
src/renderer/src/runtime \
--glob '*.ts' --glob '*.tsx'Repository: stablyai/orca
Length of output: 17484
🏁 Script executed:
set -e
printf '%s\n' '--- lifecycle imports and post-RPC handling ---'
nl -ba src/renderer/src/runtime/web-runtime-session-tab-lifecycle.ts | sed -n '1,90p'
nl -ba src/renderer/src/runtime/web-runtime-session-tab-lifecycle.ts | sed -n '260,390p'
printf '%s\n' '--- route API usages in lifecycle ---'
rg -n -C 8 -e 'redrawServerLayoutWorkspace|serverLayoutApplyRoute|isServerFrameDrawnWorkspace' \
src/renderer/src/runtime/web-runtime-session-tab-lifecycle.tsRepository: stablyai/orca
Length of output: 13139
Retain recovery when the server layout route is unavailable.
During stream replacement, close(false) removes the old route but preserves the frame-drawn classification for the replacement stream. Before its first snapshot, redrawServerLayoutWorkspace has no route. A refused close can therefore skip mirror intent recording and fail to redraw the workspace. Use the mirror close-intent and recovery path when the redraw route is unavailable. Do not clear the inherited classification unconditionally.
…mark reach a server's own layout (dark, layout-owner build only; stacked on #31714) (#31869) * wip(h5c-1): server workspace layout intents go to the server's main; positions per stream * wip(h5c-1): e2e without a cast * fix(h5c-1): a routed move never moves here; routed callers read the server's stream; a restarted main starts its positions over * fix(h5c-1): layout-apply-send back under its line limit * test(h5c-1): a routed answer reaches the handler with the server's stream key * fix(terminal): a CLI or phone close through main keeps a pinned tab, as the window-era close did * feat(terminal): main applies phone closes, renames, pane titles, sleeps and agent-launch tabs itself, with or without a window (layout-owner build) * fix(terminal): a tab close through main also ends the tab's dormant SSH relay session; agent-launch tabs main writes keep the window's focus rule, prompt and outcome (layout-owner build) * feat(terminal): main starts a new tab's first terminal under the window's ids, and the pane attaches to it (layout-owner build) * test(terminal): tests that counted the window's create calls or publications see main's start of a new tab * fix(terminal): an account-switch restart binds only into a pane main's layout holds, with no window tree (layout-owner build, L197) * test(terminal): the new-tab start tests hold no type assertions; the start's ledger row is L252 * fix(terminal): a new tab's pane attaches to any terminal main binds it to, and a failed start keeps the tab's startup * test(terminal): a Claude account-switch restart's tests draw the pane main holds * fix(terminal): a launch pane main takes back still tells the window why, which drops its hold and prompt; a rename through main answers the name it stored (layout-owner build) * fix(terminal): a new tab another owner's terminal won attaches to it, and a failed start's startup never runs twice * fix(terminal): main's pane close reads its stop result as a type only, so no runtime module loads before its base class * fix(terminal): a phone's close through main drops the closed rows from what phones list at once, not at the window's next publish (layout-owner build) * chore(terminal): mark the phone-close row drop interim (ledger L260) * test(worktree-create): a new local tab's startup counts as run when main starts it (layout-owner build) * test(worktree-create): record main's starts without a type assertion * fix(terminal): a tab closed before main declines its start gets no startup back (layout-owner build) * fix(terminal): the window's new tab starts in main when its own window asks over IPC, which labels itself a client (layout-owner build) * feat(h5c-2): a paired desktop's writes to a server workspace its frames draw land in that server's main (layout-owner build) - Routes setTabProps, setChatPane and non-terminal renameTab to the server's main as layout.apply; closes, starts, sleeps and terminal names keep the RPCs that main now applies (session.tabs.close, terminal.close, terminal.split, session.tabs.createTerminal, terminal.rename). A window-style closeTabs is never routed: main takes it as already stopped and stops nothing. - A close the server refuses (a pinned tab) redraws the workspace from the server's frames, so the window's optimistic drop never outlives the answer; same for a refused pane close. - A frame-drawn workspace keeps none of the mirror's ledgers (L240): no tab-id mappings, close or focus intents; they stay only for servers without layout.intents.v1 until the Phase 2 cutoff. Its pane-geometry push is skipped (it goes as intents); pane renames still push. - e2e: paired-desktop-server-layout-writes covers close (layout, session.tabs, terminal stop), rename, split and new tab on a windowless switch-on serve. * fix(h5c-2): an undelivered close of a frame-drawn tab is held for replay; a launch-agent clear stays off the server route * refactor(h5c-2): the undelivered-close test moves to its own module, keeping the lifecycle file under its line cap * fix(layout): a paired desktop's pane detach, handle-less split and default-tabs mark on a server workspace go to the server's main (layout-owner build, L272/L276/L275) * fix(layout): a pane a paired server's main detached takes the terminal the server's frame drew, not the desktop's possibly stale one (layout-owner build, L272) * test(layout): the detach test resets the drawn layout after each case * test(layout): drop the in-test reset the afterEach now covers
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 already draws the server's workspaces from the server's own layout. But when you rearranged, renamed or closed tabs there, the desktop mostly changed its own copy, and the server's next update could put things back. Now each of those changes goes to the server's main process, which applies it to the one layout everyone draws from, so the change sticks, and phones and other desktops see it.
What Changed
Before (switch-on builds, a desktop paired to a server that advertises
layout.intents.v1):After:
layout.applyintents, under the server's ids, through one explicit allow-list (SERVER_ROUTED_LAYOUT_COMMANDSinserver-layout-apply.ts): moveTab, splitGroup, setGroupRatios, setPaneRatios, equalizePanes, movePane, setTabProps, setChatPane, and renameTab.layout-frame-position.ts).session.tabs.close,terminal.close,terminal.rename,terminal.split,session.tabs.createTerminal). The server's main now applies those to its own layout (D2 Main closes, renames, sleeps and starts new tabs' terminals itself, with or without a window (dark, layout-owner build only) #31571), and its close stops the terminals it ends.closeTabsto a server. Main reads that as "the window already stopped the terminals" and stops nothing, but a paired desktop can't stop a server's terminals itself.terminal.rename, which also names the server's terminal.setTabProps { clearLaunchAgent }, this desktop's guess that a launched agent exited, is never sent to the server, so it can't clear the server's relaunch record.apply-snapshot.ts). It also skips pane-geometry-only session pushes. Servers without the capability run all of it exactly as today; that part goes at the Phase 2 server cutoff (ledger L240).Known issues:
Known remaining old-path writes, tracked as ledger rows L269-L276 with owners:
Why
The server's main owns the layout, so the only way a desktop change sticks, and reaches phones and other desktops, is for that main to apply it. We considered sending everything through
layout.apply. But closes and starts need the server's terminal side, which its own close and start already do, and the window-style close would stop nothing on the server. So each write goes where the server applies it fully: placement and props throughlayout.apply, closes and starts through the existing RPCs. An explicit allow-list keeps this reviewable and keeps old servers on today's path.Linked Issue
Ledger: H5c-1 and H5c-2 (design H5c). L240 marked "goes at the Phase 2 server cutoff". Remaining writes: L269-L276.
Visual Proof
N/A: dark change, switch-on builds only. The e2e specs below drive the paired desktop against a real switch-on server.
Testing
Unit tests:
clearLaunchAgentkept off the route;The new behaviour tests fail on the old code.
Gates:
pnpm tc, the CI static-analysis gate, oxlint, and the e2e typecheck ratchet pass.src/renderer/src/runtime,components/terminal-pane,components/tab-group,src/main/runtime/rpcandsrc/main/runtime/session-tabs, at base b3f1607 vs head: 12,267 vs 12,294 tests, 0 failing at either.Server specs: switch-on, fresh build.
Note:
build:orcad's file-watcher preflight (a 5 s timer) timed out at load ~90 on the shared build machine. A retry at lower load passed; this PR doesn't touch orcad.Agent skill upstream boundary
Notes
layout.intents.v1never receiveslayout.applyfrom this path and keeps today's RPCs. Nothing new goes on the wire; the intents are existinglayout.applycommands.runtime:<env>workspaces drawn from a server's updates take these routes.ORCA_LAYOUT_OWNER_IS_MAIN, or behindisServerFrameDrawnWorkspace, which is false with the switch off. I checked the switch-off bundle at this head against the merge base, and every new code path in it is unreachable. A per-test switch-off comparison of the touched folders gave base 12,267 tests vs head 12,294, with no tests failing at head that pass at base. The one failure at base was the capability-advertisement test inworkspace-layout-paired-desktop.test.ts, and it passes at head.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)