Repository navigation
feat(layout): move, reorder and split tab groups through main behind the layout-owner build switch - #29313
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
…ed or failed splits and moves, ratios during a move, release guard - A pane main saved but the window could not mount (source pane or manager gone during the await) is closed again in main, so it does not come back on restart. - A split main refuses because its copy lacks the workspace, tab or pane, or a failed call, splits as today; a refused or failed move moves as today. - Divider ratios committed while a move is in flight wait for the window's move, then go to main. - The orcad bundle gets the ORCA_LAYOUT_OWNER define when the switch is on. - Packaging and the orcad template refuse ORCA_LAYOUT_OWNER=main and any output a dark build marked. - workspace-layout-record-patch.ts: no non-null assertions; plain comment for the map depth.
…throws, not just for splits - sendPaneCommandToLayoutOwner runs asToday for workspace/tab/pane_not_found and a thrown call, so close, rename and equalize fall back like split and move; a handler that throws no longer runs the fallback too. - A close main refuses as its last pane, while this window still has others, closes as today. - A move whose local step throws still releases held divider ratios. - Drop the orcad output marker: nothing read it; the template build refuses the switch itself.
# 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
…1c-dark-followups
…e checkout fixture
…ut.apply command touches its claim A legacy terminal row the load folds into a tab-bar tab stays stored as is. Closing the tab it repeats, or giving it a tab-bar entry by moving it, let the next load resolve the claim the other way: the row came back or took the other tab's terminal. Such a command now writes the row as the load had it; every other record still stays as stored.
…t.apply Group sizes have no tab, so they go to the workspace's routed partition.
…rminal pane folder Tab groups send through it too; it now also acts as today when main lacks the group.
…s, through main behind ORCA_LAYOUT_OWNER A tab drop and Move Tab to Split wait for main's answer and then show main's placement, with main's new group id; group divider sizes are drawn while dragging and saved by main when the drag ends. Closing an empty group needs no command: main never holds an empty group.
- Read a folded row's terminals with the loader's own claim rule, so rows sharing only an SSH session are covered too, and drop the row's remote session entry with it. - The record-patch test allows a folded row only in its loaded form. - A tab drag ends at once; main's answer shows the move after. - A lone group main moved whole is placed so only when this window's group is lone too.
A row's remote session entry is carried through load and save unchanged, so adopting it from the load changed nothing (the earlier commit's message overstated it).
📝 Walkthrough
Merge Risk: 🟡 Moderate · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
8d99caf7-0229-4531-b05e-35098ed84844
📒 Files selected for processing: 29
config/renderer-layout-writer-baseline.txtsrc/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/tab-bar/tab-move-to-pane-column.tssrc/renderer/src/components/tab-group/TabGroupSplitNodeTree.tsxsrc/renderer/src/components/tab-group/tab-drag-drop-commit.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-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-layout-owner-gestures.test.tssrc/renderer/src/components/terminal-pane/terminal-pane-layout-owner-gestures.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-layout-persistence.tssrc/renderer/src/runtime/layout-owner-command.test.tssrc/renderer/src/runtime/layout-owner-command.tssrc/renderer/src/store/slices/tabs/tabs-drop-actions.tssrc/renderer/src/store/slices/tabs/tabs-slice-contract.tssrc/shared/rpc-contract/workspace-layout-params.tssrc/shared/workspace-layout/legacy-terminal-row-claims.tssrc/shared/workspace-layout/workspace-layout-folded-rows.tssrc/shared/workspace-layout/workspace-layout-record-patch.test.tssrc/shared/workspace-layout/workspace-layout-record-patch.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
| /** Sets a group divider's ratio here, as today, then has main save the workspace's group sizes. */ | ||
| export function setGroupRatioThroughLayoutOwner( | ||
| worktreeId: string, | ||
| nodePath: string, | ||
| ratio: number | ||
| ): void { | ||
| const state = useAppStore.getState() | ||
| state.setTabGroupSplitRatio(worktreeId, nodePath, ratio) | ||
| const groupLayout = useAppStore.getState().layoutByWorktree[worktreeId] | ||
| if (groupLayout && groupLayout !== state.layoutByWorktree[worktreeId]) { | ||
| // Why keep on every answer: the window's own save still writes these sizes in this phase. | ||
| const keep = (): void => {} | ||
| sendLayoutCommandToOwner( | ||
| worktreeId, | ||
| { type: 'setGroupRatios', groupLayout }, | ||
| { apply: keep, asToday: keep } | ||
| ) | ||
| } | ||
| } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- handler ---'
nl -ba src/renderer/src/components/tab-group/tab-group-layout-owner-commands.ts | sed -n '145,190p'
printf '%s\n' '--- owner command transport ---'
nl -ba src/renderer/src/runtime/layout-owner-command.ts | sed -n '1,85p'
printf '%s\n' '--- session subscriber relevant symbols ---'
rg -n -F --glob '*.ts' -e 'buildWorkspaceSessionPatch' -e 'patchWorkspaceSessionByHost' -e 'debounce' -e 'layout.apply' -e 'synchronize' src/renderer/src | head -200
printf '%s\n' '--- session subscriber ---'
nl -ba src/renderer/src/lib/session-write-subscriber.ts | sed -n '130,230p'
printf '%s\n' '--- renderer patch construction ---'
nl -ba src/renderer/src/lib/workspace-session-patch.ts | sed -n '160,205p'
printf '%s\n' '--- unified tab layout persistence ---'
nl -ba src/renderer/src/lib/workspace-session-unified-tabs.ts | sed -n '80,115p'
printf '%s\n' '--- host persistence ---'
nl -ba src/renderer/src/lib/workspace-session-host-persistence.ts | sed -n '215,265p'
printf '%s\n' '--- main patch merge ---'
nl -ba src/main/persistence/loading-store/session-snapshot-operations.ts | sed -n '80,125p'
printf '%s\n' '--- layout command refusal ---'
nl -ba src/shared/workspace-layout/workspace-layout-group-commands.ts | sed -n '100,140p'Repository: stablyai/orca
Length of output: 42459
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- full owner command module ---'
nl -ba src/renderer/src/components/tab-group/tab-group-layout-owner-commands.ts | sed -n '1,190p'
printf '%s\n' '--- ratio handler usages ---'
rg -n -F --glob '*.ts' -e 'setGroupRatioThroughLayoutOwner' -e 'setTabGroupSplitRatio' src/renderer/src src/shared | head -120
printf '%s\n' '--- split ratio action definition ---'
rg -n -F --glob '*.ts' 'setTabGroupSplitRatio:' src/renderer/src
printf '%s\n' '--- session persistence setup ---'
nl -ba src/renderer/src/app-shell/use-app-session-persistence.ts | sed -n '1,120p'
printf '%s\n' '--- subscriber setup and public return ---'
nl -ba src/renderer/src/lib/session-write-subscriber.ts | sed -n '1,135p'
printf '%s\n' '--- owner write activity symbols ---'
rg -n -F --glob '*.ts' -e 'reportWindowSessionWriteActivity' -e 'windowSessionWrite' -e 'owesWrite' src/renderer/src src/main | head -160Repository: stablyai/orca
Length of output: 26076
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- owner-command module imports ---'
rg -n -F --glob '*.ts' -e 'tab-group-layout-owner-commands' -e 'setGroupRatioThroughLayoutOwner' src/renderer/src src/shared || test "$?" -eq 1
printf '%s\n' '--- split layout production ratio path ---'
rg -n -F --glob '*.tsx' -e 'setTabGroupSplitRatio' -e 'onRatio' -e 'ratio' src/renderer/src/components/tab-group | head -160
printf '%s\n' '--- split layout source ---'
nl -ba src/renderer/src/components/tab-group/TabGroupSplitLayout.tsx | sed -n '1,240p'
printf '%s\n' '--- ratio action ---'
nl -ba src/renderer/src/store/slices/tabs/tabs-split-ratio-actions.ts | sed -n '1,100p'
printf '%s\n' '--- write activity ---'
nl -ba src/renderer/src/lib/window-session-write-activity.ts | sed -n '1,100p'
printf '%s\n' '--- frame synchronization ---'
nl -ba src/renderer/src/runtime/workspace-layout-frame-sync.ts | sed -n '1,240p'Repository: stablyai/orca
Length of output: 22261
🏁 Script executed:
nl -ba src/renderer/src/components/tab-group/TabGroupSplitNodeTree.tsx | sed -n '1,30p'
nl -ba src/renderer/src/components/tab-group/TabGroupSplitNodeTree.tsx | sed -n '165,260p'
rg -n -F --glob '*.{ts,tsx}' -e 'setGroupRatioThroughLayoutOwner' -e 'tab-group-layout-owner-commands' src/renderer/srcRepository: stablyai/orca
Length of output: 7554
Apply the ratio locally only after main accepts the layout.
The main-owner resize path calls this handler from TabGroupSplitNodeTree. The handler currently changes layoutByWorktree before sending setGroupRatios. If the renderer group tree is stale, main can return group_set_changed, while the independent debounced session writer persists the stale full tabGroupLayouts entry. This can replace a newer group placement.
Compute the candidate layout without publishing it. Apply the local ratio only from the accepted-result or fallback callbacks. Leave the renderer layout unchanged for other refusals.
Suggested fix
-import { moveGroupLeafBeside } from '../../../../shared/workspace-layout/tab-group-layout-tree'
+import {
+ moveGroupLeafBeside,
+ updateSplitRatio
+} from '../../../../shared/workspace-layout/tab-group-layout-tree'
...
): void {
const state = useAppStore.getState()
- state.setTabGroupSplitRatio(worktreeId, nodePath, ratio)
- const groupLayout = useAppStore.getState().layoutByWorktree[worktreeId]
- if (groupLayout && groupLayout !== state.layoutByWorktree[worktreeId]) {
- // Why keep on every answer: the window's own save still writes these sizes in this phase.
- const keep = (): void => {}
- sendLayoutCommandToOwner(
- worktreeId,
- { type: 'setGroupRatios', groupLayout },
- { apply: keep, asToday: keep }
- )
+ const currentLayout = state.layoutByWorktree[worktreeId]
+ if (!currentLayout) {
+ return
+ }
+ let targetNode = currentLayout
+ for (const segment of nodePath.length > 0 ? nodePath.split('.') : []) {
+ targetNode =
+ targetNode.type === 'split' && (segment === 'first' || segment === 'second')
+ ? targetNode[segment]
+ : undefined
+ }
+ if (!targetNode || targetNode.type !== 'split' || (targetNode.ratio ?? 0.5) === ratio) {
+ return
+ }
+ const groupLayout = updateSplitRatio(
+ currentLayout,
+ nodePath.length > 0 ? nodePath.split('.') : [],
+ ratio
+ )
+ const applyLocally = (): void => {
+ useAppStore.getState().setTabGroupSplitRatio(worktreeId, nodePath, ratio)
+ }
+ const sent = sendLayoutCommandToOwner(
+ worktreeId,
+ { type: 'setGroupRatios', groupLayout },
+ { apply: applyLocally, asToday: applyLocally }
+ )
+ if (!sent) {
+ applyLocally()
}
}Main moved the layout.apply sender to runtime/layout-owner-command.ts: the tab-bar rename and props commands join its WindowLayoutCommand, and the params reuse main's OnTab.
ELI5
In a test-only build (switch
ORCA_LAYOUT_OWNER=main), moving tabs between and within tab groups now goes through the background process first. The background process decides where the tab lands and names any new group; the window then shows that answer. Normal builds are unchanged.Stacked on #29207 (pane operations through the background process). Retarget to
mainonce #29187, #29192 and #29207 land.What Changed
Normal builds: nothing. Every new path sits behind the build switch, which is off in every shipped build.
Test builds with the switch on, for a local or SSH workspace:
layout.apply(moveTaborsplitGroup).setGroupRatios), and they go to the workspace's own saved partition.Saved-data fix for
layout.apply(switch on only):FOLDED_LEGACY_ROW_GAPS).Refactor: the window's
layout.applysender moved fromcomponents/terminal-pane/toruntime/layout-owner-command.ts, because tab groups use it too. Its behaviour is unchanged, apart from also acting as today ongroup_not_found.Why
dropUnifiedTab), not minted by the window. That way both sides agree on group ids in every case.Known gaps, dark only:
Linked Issue
Part of the layout single-owner plan (phase C2). Tab close and dragging a pane out to a new tab follow in a stacked PR.
Visual Proof
N/A for shipped builds: no behaviour change with the switch off.
Switch on: a hidden test app (background launch, driven with mouse events over the debugging protocol). I instrumented
layout.applyreplies in a local copy only, not in this PR. Each gesture below was checked against the background process's reply and the window's state afterwards.moveTabindex 0moveTabindex 0[Terminal 4, Terminal 3]splitGroup down7a6e3cd2…splitGroup right841f55c7…keptsplitGroup downcb66ce8f…setGroupRatiosratio 0.336After a restart on the same profile, all four groups came back with the same ids and tree. The background process's saved session matched the window's groups and tree.
Testing
Automated tests:
FOLDED_LEGACY_ROW_GAPSis removed.layout.apply: params and routing.Layout oracle, with the switch on (
ORCA_LAYOUT_OWNER=main, built from this branch merged with currentmain):workspace-layout-oracle.spec.tspassed 21/21.Switch off, built bundles (
build:electron-viteat base 0d7361f and this branch, chunk hashes and build commit normalized, short minified names normalized):tab-group-layout-owner-commands, plus the moved sender). It is present but has no caller, because every switch point compiles to the old code.moveGroupLeafBeside, now exported from the store chunk.false, now exported to chunks that compile out their checks. It is imported but never read.dropUnifiedTabcompiles to the oldcreateBrowserUuid();newGroupIddoes not appear anywhere in the store chunk.layout.applyparams and the routing for group sizes. All of these run only fromlayout.apply, which is registered only with the switch on.Checks run locally: the static-analysis steps (oxlint, low-evidence patterns, code-quality plugins, type-aware baseline, changed-code gate, React Doctor, selector fan-out, reliability gates, dead classes, max-lines, ts-nocheck, runtime-electron, focus-read and layout-writer ratchets, node pin),
pnpm tc, and the vitest suites for workspace-layout, terminal-topology,layout.apply, tab-group, tab-bar, terminal-pane and the tabs store.Layout-writer ratchet: +1 renderer write, the lone-group placement in the dark-only window module. It goes with phase F, when the window draws from main's layout alone.
Review
Agent skill upstream boundary
Notes
SSH workspaces take the same path as local ones. Paired-server workspaces keep today's path. Folder workspaces are covered by the oracle's folder scenario. Mobile, the CLI and the web client never compile the switch on.
Temporary code (removed when main becomes the only layout writer, phase F unless noted): the four drag-drop switch points, Move Tab to Split, group divider sizes, the window adopting main's new group id, the window's lone-group move (one added line in the layout-writer baseline), the drag ending before main answers, and treating a missing group as "main lacks the target". The folded-row adoption goes with the touched-records-only write.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)