Skip to content

fix(layout): close the dark layout path's gaps, and refuse to package it - #29207

Merged
Jinwoo-H merged 29 commits into
mainfrom
layout/c1c-dark-followups
Oct 16, 2026
Merged

Jinwoo-H merged 29 commits into
mainfrom
layout/c1c-dark-followups

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​215 $\color{#cf222e}{\Huge{\mathbf{−}}}$​16 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​199
Prod 11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​192 $\color{#cf222e}{\Huge{\mathbf{−}}}$​44 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​148

ELI5

This fills the gaps an independent review found in the new, unshipped way of laying out terminal panes (#29185, #29187, #29192). In that build, the window asks the background process before it splits, closes, moves or resizes a pane. This PR covers the cases where that request can't finish normally: the background process doesn't have the pane yet, the call fails, or the window loses the pane while it waits. In all of them the window now ends up in a sensible state. It also makes sure that build can never be packaged as a release. Builds made the normal way are unchanged.

What Changed

Stacked on #29192. Everything below applies only to a build made with ORCA_LAYOUT_OWNER=main, except the release guard.

  • A split pane the window could not show. The background process saves the new pane and returns its id. If the source pane or the pane manager went away during that wait, the window can't show the new pane. Before, the saved pane was still in the saved layout and came back on the next start. Now the window asks the background process to close it again.
  • Main's copy is behind, or the call failed. The window still saves its own layout in this phase, so the background process's copy can lag behind it. Before, a refusal that only means "I don't have that workspace, tab or pane" (or a call that threw) only logged a warning, and the user's split, close, rename, equalize or move did nothing. Now each of these does what it does today. The rule lives in one place, sendPaneCommandToLayoutOwner. A close the background process refuses as its last pane, while the window still has other panes, also closes as today. A handler that throws no longer triggers the fallback as well.
  • Divider sizes during a move. The background process has the moved tree before the window does, so divider sizes sent in that gap were refused. Now they wait until every move in flight has finished in the window, then they are sent.
  • Server bundle. The orcad bundle now gets the ORCA_LAYOUT_OWNER value when the switch is on. Before, a switched-on server always ran with the switch off.
  • Release guard. Packaging (electron-builder beforePack) and the orcad template build now fail if ORCA_LAYOUT_OWNER=main is set. Packaging also fails if out/main holds a marker file, which a switched-on main build leaves behind (config/layout-owner-build.cjs).
  • Tidy-up in workspace-layout-record-patch.ts. The two ! assertions are gone, and the unclear "Why 2:" comment is replaced with a plain one.

Why

  • Close the extra pane again, rather than proposing ids. The window could mint the new pane's id itself, so it could withdraw it even after a failed call. But the request schema deliberately accepts no new ids from the window, because the background process mints every id. A thrown call already rolls the write back (runDurableMutation), so the only pane that can be stranded is one the window received but could not mount, and the window knows that pane's id.
  • Fall back in one place. Each caller had its own partial rule (only split, and only for some refusals). One rule in the sender covers split, close, rename, equalize and move the same way.
  • Accepted: divider sizes sent while a split, close or equalize is in flight can still be refused. The window's own save still writes those sizes in this phase, and the case goes away once the background process is the only writer.

Linked Issue

Internal layout refactor, phase C1 follow-up (no public issue).

Visual Proof

N/A. No shipped build changes behaviour. With the switch off, the built bundles match #29192's except for the record-patch tidy-up, which only the switched-on path reaches (see Testing).

Testing

  • I manually tested these changes locally

  • Automated tests added/updated

  • A split whose source pane or manager is gone when the answer arrives closes the minted pane in main. A split that mounts sends nothing more.

  • For split, close, rename, equalize and move: the window acts as today when main lacks the workspace, tab or pane, and when the call throws. A throwing handler does not run the fallback.

  • A close refused as the last pane closes the tab when the window has one pane, closes the pane as today when it has more, and does nothing when the tab is not mounted.

  • Divider sizes are held until two moves in flight have both settled, including one whose local move threw.

  • The release guard refuses the switch and a marked out/main. The beforePack test runs with the switch on.

  • Switch off, built bundles (build:electron-vite and the three orcad entry bundles, at feat(layout): move panes and save divider sizes through main behind ORCA_LAYOUT_OWNER #29192's head and this head, build commit normalized): the renderer (1,374 files) and preload are byte-identical. out/main/index.js and orcad-server.js differ only in the two record-patch lines (queue.shift() ?? record, and the loop in insertionIndex). That code runs only from layout.apply, which is registered only with the switch on. orcad-launcher.js differs only in the server's sha256 that it embeds. With the switch on, the orcad server bundle has no unresolved ORCA_LAYOUT_OWNER read left.

Checks run: the static-analysis job's steps locally (oxlint, anti-slop, code-quality gates, ratchets, RPC catalog, pnpm tc), plus the terminal-pane, record-patch, layout.apply and packaging-config tests.

… 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
…wups

# Conflicts:
#	src/renderer/src/components/terminal-pane/layout-owner-pane-close.test.ts
#	src/renderer/src/components/terminal-pane/terminal-pane-layout-owner-commands.test.ts
#	src/renderer/src/components/terminal-pane/terminal-pane-layout-owner-commands.ts
#	src/renderer/src/components/terminal-pane/terminal-pane-layout-owner-gestures.test.ts
#	src/renderer/src/components/terminal-pane/terminal-pane-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
@Jinwoo-H
Jinwoo-H changed the base branch from layout/c1b2-pane-gestures to main October 16, 2026 02:41
@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e9e71d15-bed4-4e5b-8343-1e81cde8f5a5
📥 Commits

Reviewing files that changed from the base of the PR and between 7306273 and d9bbef2.

📒 Files selected for processing: 18
  • config/electron-builder.config.cjs
  • config/layout-owner-build.cjs
  • config/scripts/build-orcad-template.mjs
  • config/scripts/electron-builder-config.test.mjs
  • config/scripts/headless-detector-compiler-cache.test.mjs
  • config/scripts/layout-owner-build.test.mjs
  • config/scripts/orcad-entry-build.mjs
  • electron.vite.config.ts
  • src/renderer/src/components/terminal-pane/layout-owner-last-pane-refusal.ts
  • src/renderer/src/components/terminal-pane/layout-owner-pane-close.test.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-layout-owner-commands.test.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-layout-owner-commands.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-layout-owner-gestures.test.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-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/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; 5 remain after this review.

📝 Walkthrough

The build configuration adds layout-owner metadata, emits a marker for main-owner builds, and checks for those builds during packaging and template generation. Renderer pane commands use local fallbacks for selected refusals and rejected calls. Pane-close refusals, owner-assigned splits, and divider-ratio updates have updated handling. Workspace layout record patching changes queue fallback and insertion-position lookup.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to d9bbe

This change closes gaps in a layout path that is not yet shipped and adds guards that stop it from being packaged. Default builds are unaffected. No merge-blocking risk is evident.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description covers the user impact, implementation, rationale, testing, visual proof, and checklist context. It does not provide the required linked issue under “Linked Issue”; it only states that… Add the actual issue link or issue reference required by the repository template, such as a pre-existing internal issue connected to this follow-up. Complete the remaining checklist items or explain why they do not apply.
Docstring Coverage Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 20 functions across 18 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly summarizes the main changes: fixing gaps in the dark layout path and preventing packaging of that build.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description covers the user impact, implementation, rationale, testing, visual proof, and checklist context. It does not provide the required linked issue under “Linked Issue”; it only states that the work is an internal follow-up.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • 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.

@Jinwoo-H
Jinwoo-H merged commit 9b99928 into main Oct 16, 2026
46 of 49 checks passed
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