Repository navigation
feat(layout): move panes and save divider sizes through main behind ORCA_LAYOUT_OWNER - #29192
Conversation
… through main behind ORCA_LAYOUT_OWNER A build made with ORCA_LAYOUT_OWNER=main registers layout.apply: main applies the window's layout command to the stored partition through the shared applyLayoutCommand, minting new ids. A user split then waits for main's answer and mounts the pane id main minted. Every other build substitutes 'window', so neither branch is compiled in.
A load-then-save rewrite also normalizes records the command never touched. The command's effect is now the diff between the save before and after it, written onto the stored partition record by record. A split whose main reply says a paired server holds the tab splits as today.
…d partitions reload to the command's result
…CA_LAYOUT_OWNER In a layout-owner build the window's pane close, title change and equalize go through layout.apply and the window shows main's answer. A window pane close keeps the legacy close's rules: the tab's last pane is refused, a pane restarted since main read the close is left alone, every partition holding the tab closes it, and the tab's remote session id follows the remaining pane. The rules sit behind a command field only layout.apply sets.
…ORCA_LAYOUT_OWNER Claude-Session: 10569c9a-a0a1-4fc9-8469-0edfb7aed125
Claude-Session: 10569c9a-a0a1-4fc9-8469-0edfb7aed125
…e drops main cannot take Claude-Session: 10569c9a-a0a1-4fc9-8469-0edfb7aed125
…oday Claude-Session: 10569c9a-a0a1-4fc9-8469-0edfb7aed125
…de-up profile state Claude-Session: 10569c9a-a0a1-4fc9-8469-0edfb7aed125
…row names a paired server The split switch point asked which host to route to with a helper that falls back to the focused server, so a focused server could claim a workspace whose row names no owner. Use the same owner test the tab mirror uses.
…yout/c1b-pane-ops # Conflicts: # src/renderer/src/components/terminal-pane/terminal-pane-split-through-layout-owner.test.ts # src/renderer/src/components/terminal-pane/terminal-pane-split-through-layout-owner.ts
…/c1b2-pane-gestures
# Conflicts: # src/main/persistence/loading-store/pty-binding-persistence.ts # src/main/persistence/terminal-topology/terminal-layout-apply.test.ts # src/main/persistence/terminal-topology/terminal-pane-admission.ts # src/main/runtime/orca-runtime.ts # src/main/runtime/rpc/methods/workspace-layout-apply.test.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/shared/rpc-contract/workspace-layout-params.ts # src/shared/workspace-layout/workspace-layout-record-patch.test.ts # src/shared/workspace-layout/workspace-layout-record-patch.ts
… layout-owner files
…1b2-pane-gestures
…ures # Conflicts: # src/main/persistence/terminal-topology/terminal-layout-pane-ops.test.ts # src/main/runtime/rpc/methods/workspace-layout-apply.test.ts # src/renderer/src/components/terminal-pane/terminal-pane-layout-owner-commands.ts # src/shared/rpc-contract/workspace-layout-params.ts
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🔵 Low · up to
|
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
93c80738-c3a7-4f3a-aca7-6e38dcca7146
📒 Files selected for processing: 15
src/main/persistence/terminal-topology/terminal-layout-pane-ops.test.tssrc/main/runtime/rpc/methods/workspace-layout-apply.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-layout-owner-gestures.tssrc/renderer/src/components/terminal-pane/terminal-pane-manager-options.tssrc/renderer/src/lib/pane-manager/pane-divider-drag.tssrc/renderer/src/lib/pane-manager/pane-divider.test.tssrc/renderer/src/lib/pane-manager/pane-drag-reorder.tssrc/renderer/src/lib/pane-manager/pane-drop-no-op.test.tssrc/renderer/src/lib/pane-manager/pane-manager-drag-wiring.tssrc/renderer/src/lib/pane-manager/pane-manager-types.tssrc/renderer/src/lib/pane-manager/pane-tree-ops.tssrc/shared/rpc-contract/workspace-layout-params.tssrc/shared/workspace-layout/workspace-layout-record-patch.test.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.
| return sendPaneCommandToLayoutOwner( | ||
| worktreeId, | ||
| { type: 'movePane', tabId, leafId, targetLeafId, side: zone }, | ||
| { apply: move, asToday: move } | ||
| ) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
rg -n 'sendPaneCommandToLayoutOwner|movePane|refused' src/renderer/src/components/terminal-pane/terminal-pane-layout-owner-gestures.ts src/renderer/src/components/terminal-pane/terminal-pane-layout-owner-commands.ts src/main/runtime/rpc/methods/workspace-layout-apply.tsRepository: stablyai/orca
Length of output: 1845
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- gestures ---'
nl -ba src/renderer/src/components/terminal-pane/terminal-pane-layout-owner-gestures.ts
printf '%s\n' '--- command sender ---'
nl -ba src/renderer/src/components/terminal-pane/terminal-pane-layout-owner-commands.ts
printf '%s\n' '--- references and likely consumers ---'
rg -n -F --glob '*.{ts,tsx}' -e 'takePaneDrop' -e 'sendPaneCommandToLayoutOwner' -e "type: 'movePane'" -e 'movePane' src/renderer/src src/main/src src/main 2>/dev/null || true
printf '%s\n' '--- movePane files ---'
rg --files | rg 'layout|pane|workspace' | head -200Repository: stablyai/orca
Length of output: 41749
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- drag entrypoint ---'
nl -ba src/renderer/src/lib/pane-manager/pane-drag-reorder.ts | sed -n '100,155p'
printf '%s\n' '--- layout apply symbols ---'
rg -n -F --glob '*.{ts,tsx}' -e "'layout.apply'" -e 'layout.apply' -e 'LayoutApplyReply' -e 'LayoutRefusalCode' -e 'movePane' src/main src/shared src/renderer/src/runtime src/renderer/src/components/terminal-pane | head -240
printf '%s\n' '--- main layout apply test ---'
nl -ba src/main/runtime/rpc/methods/workspace-layout-apply.test.ts | sed -n '1,220p'
printf '%s\n' '--- command contract ---'
rg -n -F --glob '*.{ts,tsx}' -e 'export type LayoutApplyReply' -e 'type LayoutApplyReply' -e 'LayoutCommandResult' -e 'host_not_owned' -e 'layout.apply' src/shared src/main | head -240Repository: stablyai/orca
Length of output: 32204
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- move command implementation ---'
nl -ba src/shared/workspace-layout/workspace-layout-pane-commands.ts | sed -n '1,180p'
printf '%s\n' '--- command result and refusal types ---'
nl -ba src/shared/workspace-layout/workspace-layout-command-types.ts | sed -n '130,205p'
printf '%s\n' '--- runtime routing ---'
nl -ba src/main/runtime/runtime-layout-apply.ts
nl -ba src/main/runtime/orca-runtime.ts | sed -n '155,190p'
printf '%s\n' '--- layout owner gesture tests ---'
nl -ba src/renderer/src/components/terminal-pane/terminal-pane-layout-owner-gestures.test.tsRepository: stablyai/orca
Length of output: 17126
Handle refused and failed pane moves before enabling this path.
For a valid, non-no-op drop, takePaneDrop returns true before main replies. The local move callback runs only on success or host_not_owned. Other refusals and RPC failures leave the pane visibly unmoved. Add an explicit failure/refusal recovery or resynchronization path. Do not call move after a refusal unless main confirms that the command was applied.
This is a user-visible functional issue, not a trivial nitpick.
| onDividerRatiosCommitted: () => { | ||
| // Why the store: the gesture's own persist has just written the window's tree there. | ||
| const root = useAppStore.getState().terminalLayoutsByTabId[tabId]?.root | ||
| if (root && pane.shouldPersistLayout()) { | ||
| const keep = (): void => {} | ||
| sendPaneCommandToLayoutOwner( | ||
| worktreeId, | ||
| { type: 'setPaneRatios', tabId, root }, | ||
| { apply: keep, asToday: keep } | ||
| ) | ||
| } | ||
| } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
rg -n 'setPaneRatios|movePane|sendPaneCommandToLayoutOwner' src/main src/renderer/src/components/terminal-pane/terminal-pane-layout-owner-commands.ts | head -110Repository: stablyai/orca
Length of output: 2098
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- candidate files ---'
rg --files src/main src/renderer/src/components/terminal-pane | rg 'layout|pane|command'
printf '%s\n' '--- exact references ---'
rg -n -F --glob '*.{ts,tsx}' -e 'sendPaneCommandToLayoutOwner' -e 'setPaneRatios' -e 'movePane' -e 'pane_structure_changed' src/main src/renderer | head -240
printf '%s\n' '--- sender implementation ---'
sed -n '1,180p' src/renderer/src/components/terminal-pane/terminal-pane-layout-owner-commands.tsRepository: stablyai/orca
Length of output: 41438
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- layout.apply references and owning files ---'
rg -n -F --glob '*.ts' -e "kind: 'local'" -e "'layout.apply'" -e 'workspace-layout-apply' -e 'applyWorkspaceLayout' -e 'pane_structure_changed' src/main src/shared src/renderer | head -220
printf '%s\n' '--- RPC method test ---'
sed -n '1,300p' src/main/runtime/rpc/methods/workspace-layout-apply.test.ts
printf '%s\n' '--- topology operation test ---'
sed -n '1,290p' src/main/persistence/terminal-topology/terminal-layout-pane-ops.test.tsRepository: stablyai/orca
Length of output: 39845
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- exact applyLayoutCommand declarations and calls ---'
rg -n -F --glob '*.ts' -- 'applyLayoutCommand' src/main src/shared src/renderer
printf '%s\n' '--- layout RPC registration ---'
rg -n -F --glob '*.ts' -- 'layout.apply' src/main/runtime/rpc
printf '%s\n' '--- command operation implementation ---'
sed -n '1,280p' src/shared/workspace-layout/workspace-layout-pane-commands.ts
sed -n '1,260p' src/main/persistence/terminal-topology/terminal-pane-admission.tsRepository: stablyai/orca
Length of output: 23927
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- OrcaRuntimeService and runtime dispatch ---'
sed -n '130,205p' src/main/runtime/orca-runtime.ts
sed -n '1,100p' src/main/runtime/runtime-layout-apply.ts
printf '%s\n' '--- layout persistence contract and implementation references ---'
sed -n '1,240p' src/main/persistence/terminal-topology/layout-command-persistence.ts
rg -n -F --glob '*.ts' -e 'layoutCommand' -e 'applyCommandToSession' -e 'applyLayoutCommand(' src/main/persistence/terminal-topology src/main | head -180
printf '%s\n' '--- store layout apply implementation candidates ---'
rg -n -F --glob '*.ts' -e 'class' -e 'implements' src/main/persistence/terminal-topology | rg 'Store|Topology|Session|Layout' | head -120Repository: stablyai/orca
Length of output: 15040
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- terminal topology commit ---'
sed -n '220,315p' src/main/persistence/terminal-topology/terminal-topology-commit.ts
printf '%s\n' '--- runDurableMutation declarations and implementation ---'
rg -n -F --glob '*.ts' -e 'runDurableMutation' -e 'DurableMutation' src/main/persistence src/main | head -180
printf '%s\n' '--- store runtime state and mutation queue context ---'
sed -n '1,260p' src/main/persistence/loading-store/store-runtime-state.ts
printf '%s\n' '--- concurrency-related layout tests ---'
rg -n -i --glob '*.ts' -e 'concurr' -e 'parallel' -e 'pending' -e 'queue' src/main/persistence/terminal-topology src/main/persistence/loading-store | head -180Repository: stablyai/orca
Length of output: 41350
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- durable mutation implementation ---'
sed -n '1,145p' src/main/persistence/loading-store/primary-state-writes.ts
printf '%s\n' '--- layout commit wrapper ---'
sed -n '1,95p' src/main/persistence/terminal-topology/terminal-topology-commit.ts
printf '%s\n' '--- relevant mutation ordering tests ---'
sed -n '280,345p' src/main/persistence/loading-store/profile-state-worker-coordination.spec.ts
sed -n '140,220p' src/main/persistence/loading-store/terminal-close-async-durability.test.tsRepository: stablyai/orca
Length of output: 14392
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- mutation queue implementation ---'
sed -n '195,240p' src/main/persistence/loading-store/primary-state-writes.ts
printf '%s\n' '--- applyLayout definition and call ---'
rg -n -F --glob '*.ts' -e 'function applyLayout' -e 'applyLayout(' src/main/persistence/terminal-topology/terminal-topology-commit.ts
sed -n '315,390p' src/main/persistence/terminal-topology/terminal-topology-commit.tsRepository: stablyai/orca
Length of output: 1795
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- complete gesture implementation ---'
sed -n '1,130p' src/renderer/src/components/terminal-pane/terminal-pane-layout-owner-gestures.ts
printf '%s\n' '--- gesture tests covering callbacks and ratio commit ---'
sed -n '1,150p' src/renderer/src/components/terminal-pane/terminal-pane-layout-owner-gestures.test.ts
printf '%s\n' '--- applyLayout implementation ---'
sed -n '100,155p' src/main/persistence/terminal-topology/terminal-topology-commit.tsRepository: stablyai/orca
Length of output: 6745
Retry divider ratios after a pending pane move.
Main serializes the commands. The move persists first, then the stale pre-move root can make setPaneRatios return pane_structure_changed. The divider handler ignores that refusal, so the divider size is not persisted. Re-read the current root and retry once after this refusal.
Suggested fix
- const keep = (): void => {}
- sendPaneCommandToLayoutOwner(
- worktreeId,
- { type: 'setPaneRatios', tabId, root },
- { apply: keep, asToday: keep }
- )
+ const keep = (): void => {}
+ const saveRatios = (retry: boolean): void => {
+ const currentRoot = useAppStore.getState().terminalLayoutsByTabId[tabId]?.root
+ if (!currentRoot || !pane.shouldPersistLayout()) return
+ sendPaneCommandToLayoutOwner(
+ worktreeId,
+ { type: 'setPaneRatios', tabId, root: currentRoot },
+ {
+ apply: keep,
+ asToday: keep,
+ refused: (code) => {
+ if (retry && code === 'pane_structure_changed') {
+ saveRatios(false)
+ }
+ }
+ }
+ )
+ }
+ saveRatios(true)📝 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.
| onDividerRatiosCommitted: () => { | |
| // Why the store: the gesture's own persist has just written the window's tree there. | |
| const root = useAppStore.getState().terminalLayoutsByTabId[tabId]?.root | |
| if (root && pane.shouldPersistLayout()) { | |
| const keep = (): void => {} | |
| sendPaneCommandToLayoutOwner( | |
| worktreeId, | |
| { type: 'setPaneRatios', tabId, root }, | |
| { apply: keep, asToday: keep } | |
| ) | |
| } | |
| } | |
| onDividerRatiosCommitted: () => { | |
| // Why the store: the gesture's own persist has just written the window's tree there. | |
| const root = useAppStore.getState().terminalLayoutsByTabId[tabId]?.root | |
| if (root && pane.shouldPersistLayout()) { | |
| const keep = (): void => {} | |
| const saveRatios = (retry: boolean): void => { | |
| const currentRoot = useAppStore.getState().terminalLayoutsByTabId[tabId]?.root | |
| if (!currentRoot || !pane.shouldPersistLayout()) return | |
| sendPaneCommandToLayoutOwner( | |
| worktreeId, | |
| { type: 'setPaneRatios', tabId, root: currentRoot }, | |
| { | |
| apply: keep, | |
| asToday: keep, | |
| refused: (code) => { | |
| if (retry && code === 'pane_structure_changed') { | |
| saveRatios(false) | |
| } | |
| } | |
| } | |
| ) | |
| } | |
| saveRatios(true) | |
| } | |
| } |
ELI5
This continues moving the job of deciding the tab and pane layout from the app window to the background process, in a build nobody ships yet. After split (#29185) and close, rename and equalize (#29187), the two drag gestures inside a tab now go through the background process too: dragging a pane to a new spot, and dragging the divider between panes. Builds made the normal way are unchanged.
What Changed
Stacked on #29187. In a build made with
ORCA_LAYOUT_OWNER=main:terminal-pane-manager-options.tsadds both hooks whenORCA_LAYOUT_OWNER_IS_MAIN. It is deleted when the old path goes.User-visible before and after: no change in any build that ships. In a
mainbuild, both gestures look the same and are now saved by the background process.Why
The background process now decides the layout and the window shows the result: the same pattern as split, close, rename and equalize.
Alternatives considered:
Moving a pane out to a new tab and closing a tab are tab actions; they come with the later tab work.
Linked Issue
Internal layout refactor, phase C1 (no public issue).
Visual Proof
N/A for every shipped build: no behaviour change. For the
mainbuild, I checked it in a hidden dev app on a tab with 3 panes:layout.applywith anokreply.Testing
I manually tested these changes locally (macOS, hidden dev app with the switch on; built bundles with it off)
Automated tests added/updated
Pane manager: a taken drop moves only when its callback runs, and does nothing if a pane closed meanwhile; a drop that changes nothing is never offered; the ratio hook fires when a drag ends, not on a cancelled drag.
Window gestures: a drop waits for the answer; a drop the background process cannot take moves at once; divider sizes are skipped during a restore.
Same tree on both sides: on a nested, resized split, the window's move draws exactly the tree the background process saves.
Background process: move and size commands are saved exactly as the window saves them; the write-only-what-changed check is extended with both, with no new round-trip gaps.
Request checks: the side must be one of the four drop sides; sizes must be a valid pane tree.
Switch off, built bundles: the window bundle has no layout-owner gesture code.
Checks run:
pnpm tc, oxlint,check:code-quality:changed, the RPC catalog check, the layout-writer ratchets, and 1,293 test files.Review
A fresh review found no bugs (MERGE AS IS) and asked for more tests, now added:
A delta review of those tests: MERGE AS IS.
Two follow-ups for before the switch is turned on:
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)