Skip to content

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

Merged
Jinwoo-H merged 38 commits into
mainfrom
fd/d2c-server-pane-writes
Oct 22, 2026
Merged

Jinwoo-H merged 38 commits into
mainfrom
fd/d2c-server-pane-writes

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​184 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​179
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​101 $\color{#cf222e}{\Huge{\mathbf{−}}}$​37 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​64

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:

  • dragging a terminal pane out into its own tab;
  • splitting a pane that hasn't started its terminal yet;
  • marking a workspace's default tabs as created.

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 after 90f19e61.

What Changed

This applies only to switch-on builds, and only to a workspace whose server advertises layout.intents.v1 and whose frames this desktop draws. Old servers, other workspaces and switch-off builds are unchanged.

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 (renderer components/terminal-pane, runtime and store, 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:

    • in 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;
    • in 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;
    • in terminal-pane-split-in-main.test.ts and terminal-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:

  • A refused split sent to the server only logs a warning; the user sees no message. The local switch-on split does the same today. No existing message fits, and new wording needs the owner's sign-off.
  • If the server's stream ends while a detach answer is pending, the desktop briefly shows a stray local tab under the server's id until the next snapshot replaces it.
  • Splits started by an issue command at startup still split locally on a server workspace.
  • A remaining race in the detach fix: if the server's frame draws the new tab before this desktop has learned the restarted shell's handle, the pane briefly keeps the old id. It corrects itself when the handle arrives, because the pane rebinds.

Agent skill upstream boundary

  • Not applicable.

Notes

  • Older peers: no new fields. A server without layout.intents.v1 gets exactly today's behaviour (tested).

…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
…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)
…s layout holds, with no window tree (layout-owner build, L197)
…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)
…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.
@Jinwoo-H
Jinwoo-H changed the base branch from fd/h5c1-server-layout-writes to main October 22, 2026 12:00
@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent 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: 2499cff8-f3e9-4bb2-a15e-9c71f48af256
📥 Commits

Reviewing files that changed from the base of the PR and between 4ac4eda and dc448ea.

📒 Files selected for processing: 3
  • src/renderer/src/components/terminal-pane/terminal-pane-detach-layout-owner.test.ts
  • src/renderer/src/runtime/server-layout-apply.test.ts
  • src/renderer/src/runtime/server-layout-apply.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.

📝 Walkthrough

Server-routed layout commands now include moves to new tabs and workspace default-tab marks. The inherited-CWD split path can submit a split to a paired server when the main handler declines it and a matching server route exists. Routed pane moves now derive the moved pane’s PTY binding from the server tab’s stored layout.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to dc448

The layout changes appear mergeable with owner awareness that the E2E checks still may not detect incorrect rendered layout or tab order.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 57.81% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 64 functions across 41 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 three main layout changes and the scope: paired desktops, server-owned layouts, and layout-owner builds.
Description check Passed The description is detailed and covers the required explanation, changes, rationale, testing, visual-proof exception, limitations, and compatibility impact. It is appropriate for an internal change wi…
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.
Full details: Description check

Explanation

The description is detailed and covers the required explanation, changes, rationale, testing, visual-proof exception, limitations, and compatibility impact. It is appropriate for an internal change without a linked issue.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • 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: 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
📥 Commits

Reviewing files that changed from the base of the PR and between 4dd97f0 and 4ac4eda.

📒 Files selected for processing: 42
  • .github/workflows/layout-owner-e2e.yml
  • src/main/runtime/paired-desktop-server-writes-layout-owner.test.ts
  • 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/layout-owner-pane-close.test.ts
  • src/renderer/src/components/terminal-pane/terminal-layout-title-persist.test.tsx
  • src/renderer/src/components/terminal-pane/terminal-pane-detach-layout-owner.test.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-detach-layout-owner.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-layout-owner-commands.test.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-layout-owner-commands.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-layout-owner-gestures.test.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-split-in-main.test.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-split-in-main.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-split-with-inherited-cwd.test.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-split-with-inherited-cwd.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-tab-detach-frame-drawn.test.ts
  • src/renderer/src/components/terminal-pane/use-terminal-pane-close-actions.ts
  • src/renderer/src/runtime/layout-apply-hold-release.ts
  • src/renderer/src/runtime/layout-apply-send.test.ts
  • src/renderer/src/runtime/layout-apply-send.ts
  • src/renderer/src/runtime/layout-frame-position.test.ts
  • src/renderer/src/runtime/layout-frame-position.ts
  • src/renderer/src/runtime/layout-frame-stream.ts
  • src/renderer/src/runtime/layout-owner-command.test.ts
  • src/renderer/src/runtime/server-layout-apply-routes.ts
  • src/renderer/src/runtime/server-layout-apply.test.ts
  • src/renderer/src/runtime/server-layout-apply.ts
  • src/renderer/src/runtime/server-layout-frame-ids.ts
  • src/renderer/src/runtime/server-layout-frames.ts
  • src/renderer/src/runtime/web-runtime-session-frame-drawn-writes.test.ts
  • src/renderer/src/runtime/web-runtime-session-tab-lifecycle.ts
  • src/renderer/src/runtime/web-runtime-session-undelivered-close.ts
  • src/renderer/src/runtime/web-runtime-terminal-actions.ts
  • src/renderer/src/runtime/web-session-tabs-sync/active-session-subscription.ts
  • src/renderer/src/runtime/web-session-tabs-sync/apply-snapshot.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-server-workspaces.ts
  • src/renderer/src/runtime/web-session-tabs-sync/initial-terminal-seeder.ts
  • tests/e2e/helpers/paired-desktop-server-layout.ts
  • tests/e2e/paired-desktop-server-layout-frames.spec.ts
  • tests/e2e/paired-desktop-server-layout-intents.spec.ts
  • tests/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.

Comment on lines +73 to +102
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)
}

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.

📐 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

Comment on lines +120 to +136
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])
})

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.

📐 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.

Suggested change
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

@Jinwoo-H
Jinwoo-H merged commit c941099 into main Oct 22, 2026
39 checks passed
Jinwoo-H added a commit that referenced this pull request Oct 22, 2026
…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.
Jinwoo-H added a commit that referenced this pull request Oct 22, 2026
… 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.
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