Skip to content

feat(layout): move, reorder and split tab groups through main behind the layout-owner build switch - #29313

Merged
Jinwoo-H merged 34 commits into
mainfrom
layout/c2-tab-groups
Oct 16, 2026
Merged

Jinwoo-H merged 34 commits into
mainfrom
layout/c2-tab-groups

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​597 $\color{#cf222e}{\Huge{\mathbf{−}}}$​166 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​431
Prod 19 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​522 $\color{#cf222e}{\Huge{\mathbf{−}}}$​101 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​421

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 main once #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:

  • Gestures covered: dragging a tab within its group, into another group, or to a group's edge (a new split), plus the tab menu's Move Tab to Split. Each one now asks the background process first, through layout.apply (moveTab or splitGroup).
  • Waiting for the answer: the drag ends at once. The tab lands when the background process answers, which is milliseconds.
    • If the background process's layout update already drew the move, the window only selects the tab.
    • Otherwise the window makes the same move itself, using the group id the background process created.
  • Moving a group's only tab beside another group: the background process moves the whole group and keeps its id. The window does the same.
  • Group divider sizes: drawn while dragging, as today. When the drag ends, the window sends the sizes (setGroupRatios), and they go to the workspace's own saved partition.
  • Closing an empty group: sends nothing. The background process never holds an empty group.
  • Paired-server workspaces keep today's path.
  • When the background process lacks the tab, the group or the workspace, the window acts as today. This happens because the window still saves its own copy in this phase.

Saved-data fix for layout.apply (switch on only):

  • Before: some old saved sessions hold a second record of a terminal tab. Loading folds that record into the real tab and leaves it on disk. Closing or moving the real tab then let the next load bring the old record back, or give it the real tab's terminal (pinned in Add the dark layout.apply channel and route pane splits through main (build switch, off by default) #29185's tests as FOLDED_LEGACY_ROW_GAPS).
  • Now: a command that changes such a record's claim writes the record as the load reads it. Every other record still stays exactly as stored.

Refactor: the window's layout.apply sender moved from components/terminal-pane/ to runtime/layout-owner-command.ts, because tab groups use it too. Its behaviour is unchanged, apart from also acting as today on group_not_found.

Why

  • The window makes main's move itself rather than always waiting for the layout update. The background process's layout update is held back while the window owes it a save. During a drag that is common, because hovering a tab changes the selection, and the window saves selection. So the window cannot rely on the update arriving first.
  • Main's group id is passed into the window's existing drop (one switch point in dropUnifiedTab), not minted by the window. That way both sides agree on group ids in every case.
  • Old duplicate records are fixed by their claim, not by normalizing the whole workspace. Normalizing everything would rewrite records no command touched, which Add the dark layout.apply channel and route pane splits through main (build switch, off by default) #29185 set out to avoid.

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.apply replies 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.

Gesture Sent Reply Window after
Drag tab into the other group moveTab index 0 ok tab first in target group, that group focused
Drag tab to reorder in its group moveTab index 0 ok order [Terminal 4, Terminal 3]
Drag tab to a group's bottom edge splitGroup down ok, new group 7a6e3cd2… new group has that exact id, focused
Drag a group's only tab beside another group splitGroup right ok, group 841f55c7… kept same group id moved, tree matches main's
Tab menu, Move Tab to Split, Down splitGroup down ok, new group cb66ce8f… new group has that id
Drag the group divider setGroupRatios ratio 0.336 ok ratio kept

After 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

  • I manually tested these changes locally (macOS, hidden dev app with the switch on, as above)
  • Automated tests added/updated

Automated tests:

  • Record patch: every saved-session fixture now round-trips every command, including tab moves, group splits and group sizes. There are no known gaps left; FOLDED_LEGACY_ROW_GAPS is removed.
  • Which records a command writes: limited to the command's own, plus old duplicate records written in their loaded form.
  • Old duplicate records: new cases for closing the real tab, moving the duplicate, renaming (writes nothing extra), and an SSH-only shared session.
  • Window:
    • Tab moves when main's update has or has not drawn them already.
    • Main's group id on a split.
    • A lone group moved whole, and a lone group main moved while the window holds more tabs in it.
    • Skipped drops, reorder index, refusal and fallback.
    • Divider sizes.
  • layout.apply: params and routing.

Layout oracle, with the switch on (ORCA_LAYOUT_OWNER=main, built from this branch merged with current main): workspace-layout-oracle.spec.ts passed 21/21.

Switch off, built bundles (build:electron-vite at base 0d7361f and this branch, chunk hashes and build commit normalized, short minified names normalized):

  • Preload: identical.
  • Renderer: 1,289 chunks.
    • 327 chunks differ only in minified export names.
    • The rest differ by:
      • the new window module (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.
      • the switch constant false, now exported to chunks that compile out their checks. It is imported but never read.
    • dropUnifiedTab compiles to the old createBrowserUuid(); newGroupId does not appear anywhere in the store chunk.
  • Main: differs in the record patch and folded-record code, the new layout.apply params and the routing for group sizes. All of these run only from layout.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

  • Opus review: MERGE AFTER FIXES, four should-fix items:
    • folded-record check missed SSH-only shared sessions;
    • the test's allow-list was too broad;
    • drag clean-up waited for the reply;
    • the lone-group case trusted main's tab count.
  • All four are fixed in 7dc2538.
  • Opus delta review: fixes correct. One no-op line was removed in d67766d. The second-drag race is accepted above.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

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

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

… 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.
…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
…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
…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).
@Jinwoo-H
Jinwoo-H changed the base branch from layout/c1c-dark-followups to main October 16, 2026 03:28
@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough
📝 Walkthrough

The pull request adds RPC commands for tab movement, group splitting, and group-ratio updates, with runtime routing for workspace-level commands. The renderer delegates tab and pane layout operations through a shared layout-owner command sender and reconciles owner-applied tab changes locally. The record-patching path also adopts loaded forms of touched folded legacy rows and updates related layout and active-tab state.

Priority: ➖ Normal

Estimated code review effort:

Merge Risk: 🟡 Moderate · up to 215f8

Resizing a divider while the window has an outdated group layout can lose a newer group placement. Prevent that write before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 34 functions across 28 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description check Passed The description is complete and explains the user impact, implementation, rationale, linked work, visual proof, testing, review findings, scope, and compatibility considerations. The Linked Issue temp…
Linked Issues check Passed The description references the related work through #29207, #29187, #29192, and the layout single-owner plan. This provides traceability for the stated objective.
Out of Scope Changes check Passed The production and test changes support the stated layout-owner objective. The routing refactor and folded-record persistence changes are directly related supporting changes, and no unrelated scope is…
Title check Passed The title clearly and concisely describes routing tab movement, reordering, and group splitting through main behind the layout-owner build switch.
Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 34 functions across 28 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ 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: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8d99caf7-0229-4531-b05e-35098ed84844
📥 Commits

Reviewing files that changed from the base of the PR and between 9b99928 and 215f8fd.

📒 Files selected for processing: 29
  • config/renderer-layout-writer-baseline.txt
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/workspace-layout-apply.test.ts
  • src/main/runtime/runtime-layout-apply.test.ts
  • src/main/runtime/runtime-layout-apply.ts
  • src/renderer/src/components/tab-bar/tab-move-to-pane-column.ts
  • src/renderer/src/components/tab-group/TabGroupSplitNodeTree.tsx
  • src/renderer/src/components/tab-group/tab-drag-drop-commit.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-gesture-persist.test.tsx
  • 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-layout-owner-gestures.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/use-terminal-pane-close-actions.ts
  • src/renderer/src/components/terminal-pane/use-terminal-pane-layout-persistence.ts
  • src/renderer/src/runtime/layout-owner-command.test.ts
  • src/renderer/src/runtime/layout-owner-command.ts
  • src/renderer/src/store/slices/tabs/tabs-drop-actions.ts
  • src/renderer/src/store/slices/tabs/tabs-slice-contract.ts
  • src/shared/rpc-contract/workspace-layout-params.ts
  • src/shared/workspace-layout/legacy-terminal-row-claims.ts
  • src/shared/workspace-layout/workspace-layout-folded-rows.ts
  • src/shared/workspace-layout/workspace-layout-record-patch.test.ts
  • src/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.

Comment on lines +160 to +178
/** 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 }
)
}
}

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.

🗄️ 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 -160

Repository: 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/src

Repository: 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()
   }
 }

@Jinwoo-H
Jinwoo-H merged commit 991e2dd into main Oct 16, 2026
45 checks passed
Jinwoo-H added a commit that referenced this pull request Oct 16, 2026
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.
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