Repository navigation
A paired desktop's pane drag-out, handle-less split and default-tabs mark reach a server's own layout (dark, layout-owner build only; stacked on #31714) - #31869
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
…fault-tabs mark on a server workspace go to the server's main (layout-owner build, L272/L276/L275)
…l the server's frame drew, not the desktop's possibly stale one (layout-owner build, L272)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🔵 Low · up to
|
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ 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:
9e3dd011-199a-4537-b3af-c4b502488418
📒 Files selected for processing: 42
.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-detach-layout-owner.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-split-in-main.test.tssrc/renderer/src/components/terminal-pane/terminal-pane-split-in-main.tssrc/renderer/src/components/terminal-pane/terminal-pane-split-with-inherited-cwd.test.tssrc/renderer/src/components/terminal-pane/terminal-pane-split-with-inherited-cwd.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; 5 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
Compare against the rendered tab strip, not only the store.
desktopTree builds the desktop tree from window.__store (groupsByWorktree, unifiedTabsByWorktree, terminalLayoutsByTabId). expectFrameDrawnTreeMatchesServer and every spec that uses it therefore prove only that the store matches the server. They do not prove that the window renders the result. The rendering can break, for example by showing a stale order in the sortable tab strip, while these tests still pass.
Add a DOM check of tab order for each group. For example, read [data-testid="sortable-tab"] data-tab-id values in each group container, and compare that list with tabs.map((tab) => tab.id). Use the DOM result in the match as well as the store tree.
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."
Source: Coding guidelines
| await test.step('a tab drag reorders the server’s own layout', async () => { | ||
| await dragTab(desktop.page, third, first) | ||
| await expect | ||
| .poll( | ||
| async () => | ||
| tabOrders( | ||
| await expectFrameDrawnTreeMatchesServer( | ||
| host, | ||
| desktop, | ||
| worktreeId, | ||
| 'The drag never reached the server’s layout' | ||
| ) | ||
| )[0]?.filter((id) => tabs.includes(id)), | ||
| { timeout: 90_000 } | ||
| ) | ||
| .toEqual([third, first, second]) | ||
| }) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Assert the reordered tab strip in the DOM after the drag.
This step performs a real pointer drag. The step then checks the result only through expectFrameDrawnTreeMatchesServer, and that helper reads window.__store. Add a DOM assertion on the rendered order of [data-testid="sortable-tab"] data-tab-id values, so the test catches a frame that updates the store but does not redraw the strip.
Proposed addition
.toEqual([third, first, second])
+ await expect
+ .poll(async () =>
+ (
+ await desktop.page
+ .locator(SORTABLE_TAB)
+ .evaluateAll((nodes) => nodes.map((node) => node.getAttribute('data-tab-id')))
+ ).filter((id): id is string => id !== null && tabs.includes(id))
+ )
+ .toEqual([third, first, second])
})As per coding guidelines: "assert user-visible behavior through the DOM ... This applies to hidden CDP-driven renderers too."
📝 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.
| await test.step('a tab drag reorders the server’s own layout', async () => { | |
| await dragTab(desktop.page, third, first) | |
| await expect | |
| .poll( | |
| async () => | |
| tabOrders( | |
| await expectFrameDrawnTreeMatchesServer( | |
| host, | |
| desktop, | |
| worktreeId, | |
| 'The drag never reached the server’s layout' | |
| ) | |
| )[0]?.filter((id) => tabs.includes(id)), | |
| { timeout: 90_000 } | |
| ) | |
| .toEqual([third, first, second]) | |
| }) | |
| await test.step('a tab drag reorders the server’s own layout', async () => { | |
| await dragTab(desktop.page, third, first) | |
| await expect | |
| .poll( | |
| async () => | |
| tabOrders( | |
| await expectFrameDrawnTreeMatchesServer( | |
| host, | |
| desktop, | |
| worktreeId, | |
| 'The drag never reached the server’s layout' | |
| ) | |
| )[0]?.filter((id) => tabs.includes(id)), | |
| { timeout: 90_000 } | |
| ) | |
| .toEqual([third, first, second]) | |
| await expect | |
| .poll(async () => | |
| ( | |
| await desktop.page | |
| .locator(SORTABLE_TAB) | |
| .evaluateAll((nodes) => nodes.map((node) => node.getAttribute('data-tab-id'))) | |
| ).filter((id): id is string => id !== null && tabs.includes(id)) | |
| ) | |
| .toEqual([third, first, second]) | |
| }) |
Source: Coding guidelines
…ayout-frames to keep it under the line cap Main's #31869 grew server-layout-frames past 300 lines once merged with H5d; the two helpers move unchanged.
… server workspace from the server's layout (switch-on builds only) (#32088) * 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 * Editor tabs main-first: the window sends each editor action to main and draws editor tabs only from main's frames (dark, layout-owner build only) With ORCA_LAYOUT_OWNER_IS_MAIN on, editor open (preview replace, open to the side), reopen at its position, close, close-all, promote, the resolved conflict placeholder, a restored-editor move and a disk rename are layout commands the window sends before it draws anything. Window content (open file records, drafts, buffers, the autosave gate) is written at once for an open, and rekeyed in the same store update as the frame for a move or rename. Main publishes each non-edit tab's view, keeps views in memory across applies and partition changes, stamps the tab's time, folds same-file duplicates, and republishes a windowless host's session.tabs after its own file open. The switch-off path is unchanged. * 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 * test(d3a-2): the buffer view index follows a rename main answers * 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) * feat(h5d): hand desktop-only editor tabs to a layout-intents server before its frames draw the workspace A paired desktop dropped an editor tab it opened in a server workspace (with its open file and unsaved draft) on the server's next records frame once that workspace became frame-drawn, and editor opens made after gating hit the same loss. - openEditorTab is now on SERVER_ROUTED_LAYOUT_COMMANDS: the proposed tab id and group are kept, the file id becomes the server's own, and the record loses the desktop's runtimeEnvironmentId. - Before a workspace gates, server-layout-frames hands its desktop-only editor tabs to the server's main (sendToServerMain), recomputes them on each answer, and gates only when all answered ok or tab_exists. Any other refusal or a failed call keeps it on the mirror for that connection; the next one retries. No timer, no hold store. * fix(h5d): only an applied open counts as handed over; tab_exists keeps the tab on the mirror * 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(h5d): a tab closed while its hand-over was in flight is closed on the server before the workspace gates * fix(h5d): an editor tab closed in a workspace a server's frames draw closes on that server by session.tabs.close; a tab kept on the mirror closes here only * fix(h5d): a handed-over tab closed here before the gate is closed on the server first; a server-opened tab's close in a frame-drawn workspace is covered * chore(h5d): a closed stream also closes the hand-over its hand-back started * refactor(h5d): move the frame stream's routing inputs out of server-layout-frames to keep it under the line cap Main's #31869 grew server-layout-frames past 300 lines once merged with H5d; the two helpers move unchanged.
ELI5
On the dark layout-owner build, a desktop paired to a newer Orca server draws the server's workspaces from the server's own layout. Three edits made on such a workspace never reached the server, so the server's layout undid them:
This PR sends each of them to the server, using the route #31714 adds for every other layout change.
Stacked on #31714 (
fd/h5c1-server-layout-writes). Review only the commits after90f19e61.What Changed
This applies only to switch-on builds, and only to a workspace whose server advertises
layout.intents.v1and whose frames this desktop draws. Old servers, other workspaces and switch-off builds are unchanged.movePaneToNewTabis on 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's list of commands routed to the server. It goes with the server's tab id and no desktop terminal id, since the server's main uses its own binding. The moved pane takes the terminal the server's frame drew for it, which arrives before the answer, and only falls back to the desktop's id if the frame drew none. This keeps a stale id from overwriting a shell the server restarted.terminal.splitto the server, addressed by pane (the server's tab id and the leaf id), with the new pane's id. The server's main writes the split and starts the terminal, then its frames draw it. This reuses the send path that splits already use on the desktop's own main.setDefaultTabsAppliedis routed too.worktree-initial-terminal-seeding.ts:136), and before its owner is known 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 has no route for it.workspace-layout-default-tabs.ts:19). No path does that today.Why
Main owning the layout is the plan of record. #31714 already routes a paired desktop's layout writes to the server's main. These three were missing from its list, and adding them reuses that route instead of building a second one.
Linked Issue
N/A (internal layout-owner track).
Visual Proof
N/A. The build is dark and unshipped, and switch-off is unchanged.
Testing
ci-static-gate: all steps pass at the head.
Unit suites, head vs 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's head
90f19e61(renderercomponents/terminal-pane,runtimeandstore, with the switch on and off; per-test diff): no test that passes at base fails at head, and no new failures. In a later re-run, a few timing tests failed under machine load (load average about 66). They pass when run alone and differ from run to run.Server specs: switch-on, fresh build at each commit: headless-serve-focused-terminal-create, paired-mobile-desktop-tab-composition, paired-desktop-server-layout-frames and live-background-terminal-mount-authority all pass at head d1e614d and at base 90f19e6.
New tests, each checked to fail with its fix reverted:
server-layout-apply.test.ts, a dragged-out pane and the default-tabs mark go to the server's main, and the existing old-server test now also covers both commands;terminal-pane-detach-layout-owner.test.ts, the desktop's terminal id is kept, and a pane takes the terminal the server's frame drew rather than a stale one;terminal-pane-split-in-main.test.tsandterminal-pane-split-with-inherited-cwd.test.ts, a handle-less split goes to the server whose frames draw it, and other workspaces keep today's path.I manually tested these changes locally (hidden-window e2e)
Automated tests added/updated
Review
Reviewed by Opus: nothing blocking. Fixed: the pane binding after a routed detach now follows the server's frame. Known, not changed:
Agent skill upstream boundary
Notes
layout.intents.v1gets exactly today's behaviour (tested).