Repository navigation
Close, rename and equalize panes through main (dark, build switch off by default) - #29187
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.
…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
# 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
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: 🟡 Moderate · 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:
801f740a-7713-469f-8116-cea8f8e5678a
📒 Files selected for processing: 32
src/main/persistence/loading-store/pty-binding-persistence.tssrc/main/persistence/loading-store/store-domain-composition.tssrc/main/persistence/terminal-topology/layout-command-persistence.tssrc/main/persistence/terminal-topology/pane-close-remote-session.tssrc/main/persistence/terminal-topology/terminal-layout-apply.test.tssrc/main/persistence/terminal-topology/terminal-layout-pane-ops.test.tssrc/main/persistence/terminal-topology/terminal-pane-admission.tssrc/main/persistence/terminal-topology/terminal-topology-commit.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/workspace-layout-apply.test.tssrc/main/runtime/runtime-layout-apply.test.tssrc/main/runtime/runtime-layout-apply.tssrc/renderer/src/components/terminal-pane/layout-owner-pane-close.test.tssrc/renderer/src/components/terminal-pane/terminal-keyboard-action-dispatch.tssrc/renderer/src/components/terminal-pane/terminal-layout-gesture-persist.test.tsxsrc/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-split-through-layout-owner.test.tssrc/renderer/src/components/terminal-pane/terminal-pane-split-through-layout-owner.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/use-terminal-pane-close-actions.tssrc/renderer/src/components/terminal-pane/use-terminal-pane-context-actions.tssrc/renderer/src/components/terminal-pane/use-terminal-pane-context-menu.tssrc/renderer/src/components/terminal-pane/use-terminal-pane-layout-persistence.tssrc/renderer/src/lib/pane-manager/pane-split-ratio.tssrc/shared/rpc-contract/workspace-layout-params.tssrc/shared/workspace-layout/terminal-pane-tree.tssrc/shared/workspace-layout/workspace-layout-command-types.tssrc/shared/workspace-layout/workspace-layout-pane-commands.tssrc/shared/workspace-layout/workspace-layout-record-patch.test.tssrc/shared/workspace-layout/workspace-layout-record-patch.ts
💤 Files with no reviewable changes: 3
- src/renderer/src/components/terminal-pane/terminal-pane-split-through-layout-owner.test.ts
- src/main/persistence/loading-store/pty-binding-persistence.ts
- src/renderer/src/components/terminal-pane/terminal-pane-split-through-layout-owner.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
| function commitLayoutCommand( | ||
| hostIds: readonly ExecutionHostId[], | ||
| command: LayoutCommand, | ||
| context: TerminalTopologyCommitContext | ||
| ): DurableProfileStateMutation<LayoutApplyOutcome> { | ||
| const changes = hostIds.map((hostId) => ({ | ||
| hostId, | ||
| change: applyCommandToSession(hostId, context.getSession(hostId), command) | ||
| })) | ||
| const routed = changes[0]?.change.value | ||
| if (!routed) { | ||
| return { value: { ok: false, code: 'workspace_not_found' }, persist: false } | ||
| } | ||
| const writes = routed.ok | ||
| ? changes.filter(({ change }) => change.value.ok && change.session !== null) | ||
| : [] | ||
| if (writes.length === 0) { | ||
| return { value: routed, persist: false } | ||
| } | ||
| const restores = writes.map(({ hostId, change }) => | ||
| writeRestorable( | ||
| () => context.getSession(hostId), | ||
| (value) => context.markDirty(assignWorkspaceSessionPartition(context.state, hostId, value)), | ||
| keepFrozen(hostId, change.session!, context) | ||
| ) | ||
| ) | ||
| return { value: routed, rollback: () => restores.forEach((restore) => restore()) } | ||
| } | ||
|
|
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '255,300p' src/main/persistence/terminal-topology/terminal-topology-commit.ts
sed -n '55,85p' src/shared/workspace-layout/workspace-layout-pane-commands.ts
sed -n '135,177p' src/main/persistence/terminal-topology/terminal-layout-pane-ops.test.tsRepository: stablyai/orca
Length of output: 4386
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- changed diff ---'
git diff --unified=80 06ead8dad0329d53bb15cf3e564857680626733b 32e44e748d10c9aabf8815d881a234ab354d5fc2 -- src/main/persistence/terminal-topology/terminal-topology-commit.ts src/main/persistence/terminal-topology src/shared/workspace-layout src/main | sed -n '1,1200p'
printf '%s\n' '--- symbols and callers ---'
rg -n -F --glob '*.ts' -e 'applyLayout(' -e 'applyLayoutCommand(' -e 'applyCommandToSession' -e 'userPaneClose' -e 'closePane' src/main src/shared | sed -n '1,1000p'
printf '%s\n' '--- focused implementation ---'
sed -n '1,275p' src/main/persistence/terminal-topology/terminal-topology-commit.ts
sed -n '1,180p' src/main/persistence/terminal-topology/terminal-topology-store.ts 2>/dev/null || true
printf '%s\n' '--- repository close/routing docs and tests ---'
rg -n -i --glob '*.{ts,md,json}' -e 'last_pane' -e 'alreadyClosed' -e 'partition' -e 'layout\.apply' -e 'every partition' -e 'close.*pane' src docs README.md 2>/dev/null | sed -n '1,1000p'Repository: stablyai/orca
Length of output: 45648
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- commit module ---'
nl -ba src/main/persistence/terminal-topology/terminal-topology-commit.ts | sed -n '1,330p'
printf '%s\n' '--- layout persistence and RPC contract ---'
nl -ba src/main/persistence/terminal-topology/layout-command-persistence.ts
nl -ba src/shared/rpc-contract/workspace-layout-params.ts | sed -n '1,110p'
printf '%s\n' '--- all active layout command callers ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'applyLayoutCommand' -e 'layout.apply' -e 'contestedPartitionHosts' -e 'workspaceSessionPartitionHostFor' src tests | sed -n '1,800p'
printf '%s\n' '--- routing and close-related tests ---'
rg -n -i --glob '*.{ts,tsx}' -e 'hostIds' -e 'partitions holding' -e 'last_pane' -e 'alreadyClosed' -e 'close.*partition' -e 'layout.*apply' src/main src/renderer/src src/shared tests 2>/dev/null | sed -n '1,1200p'
printf '%s\n' '--- relevant changed hunks only ---'
git diff --unified=35 06ead8dad0329d53bb15cf3e564857680626733b 32e44e748d10c9aabf8815d881a234ab354d5fc2 -- src/main/persistence/terminal-topology/terminal-topology-commit.ts src/main/persistence/terminal-topology/layout-command-persistence.ts src/shared/workspace-layout/workspace-layout-pane-commands.ts src/main/ipc src/renderer/src | rg -n -B35 -A45 'commitLayoutCommand|applyLayoutCommand|contestedPartitionHosts|closePane|layout.apply|hostIds' | sed -n '1,1600p'Repository: stablyai/orca
Length of output: 42521
🏁 Script executed:
nl -ba src/main/persistence/terminal-topology/terminal-topology-commit.ts | sed -n '1,330p'
nl -ba src/main/persistence/terminal-topology/layout-command-persistence.ts
nl -ba src/shared/rpc-contract/workspace-layout-params.ts | sed -n '1,110p'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'applyLayoutCommand' -e 'layout.apply' -e 'contestedPartitionHosts' -e 'workspaceSessionPartitionHostFor' src tests | sed -n '1,800p'
rg -n -i --glob '*.{ts,tsx}' -e 'partitions holding' -e 'last_pane' -e 'alreadyClosed' -e 'close.*partition' -e 'layout.*apply' src/main src/renderer/src src/shared tests 2>/dev/null | sed -n '1,1200p'Repository: stablyai/orca
Length of output: 41967
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- runtime layout apply ---'
nl -ba src/main/runtime/runtime-layout-apply.ts | sed -n '1,180p'
printf '%s\n' '--- runtime workspace session controller ---'
nl -ba src/main/runtime/runtime-workspace-session-controller.ts | sed -n '1,180p'
printf '%s\n' '--- command adapter ---'
nl -ba src/main/persistence/terminal-topology/terminal-pane-admission.ts | sed -n '1,150p'
printf '%s\n' '--- close command and host routing definitions ---'
nl -ba src/shared/workspace-layout/workspace-layout-command-types.ts | sed -n '130,205p'
nl -ba src/main/runtime/orca-runtime.ts | sed -n '155,185p'
nl -ba src/main/runtime/terminal-surface-close.ts | sed -n '170,215p'
printf '%s\n' '--- focused tests for refusal/divergence ---'
nl -ba src/main/persistence/terminal-topology/terminal-layout-apply.test.ts | sed -n '50,155p'
nl -ba src/main/persistence/terminal-topology/terminal-layout-pane-ops.test.ts | sed -n '55,185p'
nl -ba src/main/runtime/orca-runtime-terminal-close-spill-partition.test.ts | sed -n '90,165p'Repository: stablyai/orca
Length of output: 36218
Apply close commands without the last-pane guard to secondary holders.
When getHostIdsForTab returns a routed partition with a split layout and another non-runtime partition with only the target pane, main adds userPaneClose: true for both partitions. The routed partition succeeds, but the secondary partition returns last_pane. commitLayoutCommand still returns the routed success and writes only the successful partition. The renderer then removes the pane locally while the secondary partition retains it.
Evaluate userPaneClose only for the routed partition. Secondary holders must also remove the target pane so the multi-partition close remains consistent.
Suggested fix
- const changes = hostIds.map((hostId) => ({
+ const changes = hostIds.map((hostId, index) => ({
hostId,
- change: applyCommandToSession(hostId, context.getSession(hostId), command)
+ change: applyCommandToSession(
+ hostId,
+ context.getSession(hostId),
+ index > 0 && command.type === 'closePane'
+ ? { ...command, userPaneClose: false }
+ : command
+ )
}))📝 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.
| function commitLayoutCommand( | |
| hostIds: readonly ExecutionHostId[], | |
| command: LayoutCommand, | |
| context: TerminalTopologyCommitContext | |
| ): DurableProfileStateMutation<LayoutApplyOutcome> { | |
| const changes = hostIds.map((hostId) => ({ | |
| hostId, | |
| change: applyCommandToSession(hostId, context.getSession(hostId), command) | |
| })) | |
| const routed = changes[0]?.change.value | |
| if (!routed) { | |
| return { value: { ok: false, code: 'workspace_not_found' }, persist: false } | |
| } | |
| const writes = routed.ok | |
| ? changes.filter(({ change }) => change.value.ok && change.session !== null) | |
| : [] | |
| if (writes.length === 0) { | |
| return { value: routed, persist: false } | |
| } | |
| const restores = writes.map(({ hostId, change }) => | |
| writeRestorable( | |
| () => context.getSession(hostId), | |
| (value) => context.markDirty(assignWorkspaceSessionPartition(context.state, hostId, value)), | |
| keepFrozen(hostId, change.session!, context) | |
| ) | |
| ) | |
| return { value: routed, rollback: () => restores.forEach((restore) => restore()) } | |
| } | |
| function commitLayoutCommand( | |
| hostIds: readonly ExecutionHostId[], | |
| command: LayoutCommand, | |
| context: TerminalTopologyCommitContext | |
| ): DurableProfileStateMutation<LayoutApplyOutcome> { | |
| const changes = hostIds.map((hostId, index) => ({ | |
| hostId, | |
| change: applyCommandToSession( | |
| hostId, | |
| context.getSession(hostId), | |
| index > 0 && command.type === 'closePane' | |
| ? { ...command, userPaneClose: false } | |
| : command | |
| ) | |
| })) | |
| const routed = changes[0]?.change.value | |
| if (!routed) { | |
| return { value: { ok: false, code: 'workspace_not_found' }, persist: false } | |
| } | |
| const writes = routed.ok | |
| ? changes.filter(({ change }) => change.value.ok && change.session !== null) | |
| : [] | |
| if (writes.length === 0) { | |
| return { value: routed, persist: false } | |
| } | |
| const restores = writes.map(({ hostId, change }) => | |
| writeRestorable( | |
| () => context.getSession(hostId), | |
| (value) => context.markDirty(assignWorkspaceSessionPartition(context.state, hostId, value)), | |
| keepFrozen(hostId, change.session!, context) | |
| ) | |
| ) | |
| return { value: routed, rollback: () => restores.forEach((restore) => restore()) } | |
| } |
| ): Promise<LayoutApplyReply> { | ||
| const hostIds = hostIdsForTab(command.workspace, command.tabId) | ||
| // Why: a paired server's workspaces keep today's mirrored layout until that server owns it. | ||
| if (!hostIds[0] || parseExecutionHostId(hostIds[0])?.kind === 'runtime') { | ||
| return { ok: false, code: 'host_not_owned' } | ||
| } | ||
| if (!store.applyLayoutCommand) { | ||
| throw new Error('layout_store_unavailable') | ||
| } | ||
| if (command.type !== 'closePane') { | ||
| return store.applyLayoutCommand(command, [hostIds[0]]) | ||
| } | ||
| const { workspace, tabId, leafId } = command | ||
| // A launch still starting in the pane the user closed stops, and says so (as the legacy close). | ||
| markAgentLaunchesClosedByUser(workspace, { kind: 'pane', tabId, leafId }) | ||
| // Why every holder: a legacy relay reattach can leave one tab in two partitions. | ||
| return store.applyLayoutCommand( | ||
| { ...command, userPaneClose: true }, | ||
| hostIds.filter((hostId) => parseExecutionHostId(hostId)?.kind !== 'runtime') | ||
| ) | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '1,75p' src/main/runtime/runtime-layout-apply.ts
rg -n 'markAgentLaunchesClosedByUser|last_pane' src/main/runtime src/renderer/src/components/terminal-pane/use-terminal-pane-close-actions.tsRepository: stablyai/orca
Length of output: 4186
🏁 Script executed:
set -e
printf '%s\n' '--- mark helper definition and usages ---'
rg -n -F --glob '*.ts' \
-e 'function markAgentLaunchesClosedByUser' \
-e 'const markAgentLaunchesClosedByUser' \
-e 'export function markAgentLaunchesClosedByUser' \
-e 'export const markAgentLaunchesClosedByUser' \
-e 'markAgentLaunchesClosedByUser(' \
src/main src/renderer
printf '%s\n' '--- helper owner block ---'
helper=$(rg -l -F --glob '*.ts' 'markAgentLaunchesClosedByUser' src/main | head -1)
printf 'helper=%s\n' "$helper"
if [ -n "$helper" ]; then
sed -n '1,320p' "$helper"
fi
printf '%s\n' '--- renderer close action ---'
sed -n '1,240p' src/renderer/src/components/terminal-pane/use-terminal-pane-close-actions.ts
printf '%s\n' '--- layout.apply references and close reply handling ---'
rg -n -F --glob '*.ts' \
-e 'layout.apply' \
-e 'last_pane' \
-e 'userPaneClose' \
-e 'applyLayoutCommand' \
src/main src/renderer
printf '%s\n' '--- runtime layout implementation candidates ---'
rg -n -F --glob '*.ts' \
-e 'applyLayoutCommand' \
-e 'userPaneClose' \
-e 'last_pane' \
src/main/runtime src/shared/workspace-layoutRepository: stablyai/orca
Length of output: 39194
🏁 Script executed:
set -e
printf '%s\n' '--- closedByUser consumers ---'
rg -n -F --glob '*.ts' \
-e '.closedByUser()' \
-e 'closedByUser()' \
-e 'closedByUser' \
src/main src/renderer | head -240
printf '%s\n' '--- pane command refusal implementation ---'
sed -n '1,230p' src/shared/workspace-layout/workspace-layout-pane-commands.ts
printf '%s\n' '--- persistence apply and commit result ---'
sed -n '1,190p' src/main/persistence/terminal-topology/layout-command-persistence.ts
sed -n '1,180p' src/main/persistence/terminal-topology/terminal-topology-commit.ts
printf '%s\n' '--- renderer command helper ---'
sed -n '1,180p' src/renderer/src/components/terminal-pane/terminal-pane-layout-owner-commands.ts
printf '%s\n' '--- relevant close/refusal tests ---'
sed -n '1,150p' src/renderer/src/components/terminal-pane/layout-owner-pane-close.test.ts
sed -n '1,130p' src/renderer/src/components/terminal-pane/terminal-pane-layout-owner-commands.test.tsRepository: stablyai/orca
Length of output: 29021
🏁 Script executed:
set -e
printf '%s\n' '--- launch consumers ---'
sed -n '92,125p' src/main/ipc/pty/ipc/spawn-agent-launch.ts
sed -n '38,62p' src/main/ipc/pty/ipc/spawn-agent-launch-end.ts
sed -n '248,280p' src/main/runtime/rpc/methods/agent-launch.ts
sed -n '126,190p' src/main/runtime/rpc/methods/agent-launch-surfaces.ts
printf '%s\n' '--- multi-host commit result ---'
rg -n -F -- 'function commitLayoutCommand' src/main/persistence/terminal-topology/terminal-topology-commit.ts
sed -n '300,390p' src/main/persistence/terminal-topology/terminal-topology-commit.tsRepository: stablyai/orca
Length of output: 6744
Mark the launch only after layout.apply succeeds.
applyWindowLayoutCommand marks the launch before store.applyLayoutCommand returns. A refusal can leave the target pane open, while launch consumers treat it as user-closed and stop or withdraw the launch.
Suggested fix
- markAgentLaunchesClosedByUser(workspace, { kind: 'pane', tabId, leafId })
// Why every holder: a legacy relay reattach can leave one tab in two partitions.
- return store.applyLayoutCommand(
+ const result = await store.applyLayoutCommand(
{ ...command, userPaneClose: true },
hostIds.filter((hostId) => parseExecutionHostId(hostId)?.kind !== 'runtime')
)
+ if (result.ok) {
+ markAgentLaunchesClosedByUser(workspace, { kind: 'pane', tabId, leafId })
+ }
+ return result📝 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.
| ): Promise<LayoutApplyReply> { | |
| const hostIds = hostIdsForTab(command.workspace, command.tabId) | |
| // Why: a paired server's workspaces keep today's mirrored layout until that server owns it. | |
| if (!hostIds[0] || parseExecutionHostId(hostIds[0])?.kind === 'runtime') { | |
| return { ok: false, code: 'host_not_owned' } | |
| } | |
| if (!store.applyLayoutCommand) { | |
| throw new Error('layout_store_unavailable') | |
| } | |
| if (command.type !== 'closePane') { | |
| return store.applyLayoutCommand(command, [hostIds[0]]) | |
| } | |
| const { workspace, tabId, leafId } = command | |
| // A launch still starting in the pane the user closed stops, and says so (as the legacy close). | |
| markAgentLaunchesClosedByUser(workspace, { kind: 'pane', tabId, leafId }) | |
| // Why every holder: a legacy relay reattach can leave one tab in two partitions. | |
| return store.applyLayoutCommand( | |
| { ...command, userPaneClose: true }, | |
| hostIds.filter((hostId) => parseExecutionHostId(hostId)?.kind !== 'runtime') | |
| ) | |
| } | |
| ): Promise<LayoutApplyReply> { | |
| const hostIds = hostIdsForTab(command.workspace, command.tabId) | |
| // Why: a paired server's workspaces keep today's mirrored layout until that server owns it. | |
| if (!hostIds[0] || parseExecutionHostId(hostIds[0])?.kind === 'runtime') { | |
| return { ok: false, code: 'host_not_owned' } | |
| } | |
| if (!store.applyLayoutCommand) { | |
| throw new Error('layout_store_unavailable') | |
| } | |
| if (command.type !== 'closePane') { | |
| return store.applyLayoutCommand(command, [hostIds[0]]) | |
| } | |
| const { workspace, tabId, leafId } = command | |
| // A launch still starting in the pane the user closed stops, and says so (as the legacy close). | |
| // Why every holder: a legacy relay reattach can leave one tab in two partitions. | |
| const result = await store.applyLayoutCommand( | |
| { ...command, userPaneClose: true }, | |
| hostIds.filter((hostId) => parseExecutionHostId(hostId)?.kind !== 'runtime') | |
| ) | |
| if (result.ok) { | |
| markAgentLaunchesClosedByUser(workspace, { kind: 'pane', tabId, leafId }) | |
| } | |
| return result | |
| } |
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 splitting a pane (#29185), three more pane actions now go through the background process first: closing a pane, renaming a pane, and making all panes the same size. Builds made the normal way are unchanged.
What Changed
Stacked on #29185. In a build made with
ORCA_LAYOUT_OWNER=main:Closing a pane. The window asks the background process to close the pane, waits for the answer, then removes the pane. The background process now applies the rules the existing pane close already follows:
These rules sit behind a field on the close command that only
layout.applysets. The window cannot send that field, and phone, headless and runtime-start-failure callers of the same command are unchanged.Renaming a pane. The new title, or a cleared one, is saved by the background process first; the window then shows it. Titles are trimmed, and blank titles are rejected.
Equal pane sizes. The background process equalizes first; the window then redraws. Equalized sizes are now saved the way the window saves them: an even split is stored with no ratio, and other ratios are rounded to 3 decimals. The only other users of that function are old-client translators that nothing calls today.
Writes. Only the records each command touches are written (Add the dark layout.apply channel and route pane splits through main (build switch, off by default) #29185). A command that changes nothing now writes nothing.
Structure.
layout.applygets its own small store section (LayoutCommandPersistence), and the routing moves intoruntime-layout-apply.ts. The window uses one helper,sendPaneCommandToLayoutOwner, for every pane command.Switch points added (3):
use-terminal-pane-close-actions.ts: pane close;use-terminal-pane-layout-persistence.ts: title set and clear;terminal-pane-layout-owner-commands.ts: equalize.All three check
ORCA_LAYOUT_OWNER_IS_MAINand are deleted when the old path goes.User-visible before and after: no change in any build that ships. In a
mainbuild, the three actions look the same and are now decided and saved by the background process.Why
The background process now makes these decisions, and the window shows the result: the same pattern as split.
Alternatives considered:
layout.apply, so nothing that runs today changes.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 4 panes, using the real menu and keyboard actions:layout.applywith anokreply.server-pane, and the close left 3 equal panes.Testing
I manually tested these changes locally (macOS, hidden dev app with the switch on; built bundles with it off)
Automated tests added/updated
Close compared with the existing close: run on every saved-session test profile, both current and old-format.
layout.applymust write what the existing pane close writes. Two exceptions are allowed:Where the existing close does nothing (last pane, or a pane it doesn't have),
layout.applywrites nothing.Close rules: the close applies in both a local and an SSH partition.
Restarted panes: a pane whose terminal restarted after the window asked still closes. Today the window removes the pane at once and saves its layout without it, even though the existing saved-state close refuses that case; main now closes it outright, so the user sees the same result.
Rename and equalize: both are saved exactly as the window saves them.
Write-only-what-changed check: extended with rename and the user pane close; no new round-trip gaps.
Routing: a close goes to every partition that is not a paired server, and the agent launch is marked. Other commands go to the main partition only. A paired server's tab is refused.
Window:
Switch off, built bundles: the registration and all window branches are compiled out. The window bundle contains no layout-owner code, and equalize compiles to the direct call.
Checks run:
pnpm tc, oxlint,check:code-quality:changed, the RPC catalog check, the layout-writer ratchets, and 1,204 test files.Review
A fresh review found 2 issues that matter only in the
mainbuild, both fixed:Plus 2 test and comment fixes. A delta review followed. Later decision: a user's close closes the pane even if its terminal restarted in the same instant, as today, so that refusal was removed.
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)