Repository navigation
Add the dark layout.apply channel and route pane splits through main (build switch, off by default) - #29185
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
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🔵 Low · up to
|
…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.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 Minor · Use the local fallback only for refused replies. · terminal-pane-split-through-layout-owner.ts:20-42
src/renderer/src/components/terminal-pane/terminal-pane-split-through-layout-owner.ts:20-42
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winUse the local fallback only for refused replies.
When
reply.okisfalse,LayoutApplyOutcomestates that the command changed nothing. Callmount(undefined)for every refusal, not onlyhost_not_owned.Do not call
mount(undefined)when a successful reply has noleafId. The boundsplitPaneimplementation always returns aleafIdon success, and a successful reply indicates that the command was applied. Retrying that case could duplicate the split.Do not retry after an RPC rejection. The command state is unknown. The current rejection branch only logs the error, so surface it through the user-visible error mechanism.
Suggested fix
} else { console.warn('[layout-owner] split refused:', reply.ok ? 'no_leaf' : reply.code) + if (!reply.ok) { + mount(undefined) + } }
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
522b4ea2-9079-4734-9c28-e8582a9d3740
📒 Files selected for processing: 2
src/renderer/src/components/terminal-pane/terminal-pane-split-through-layout-owner.test.tssrc/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; 6 remain after this review.
|
On the outside-diff note about terminal-pane-split-through-layout-owner.ts:20-42 (fall back on every refusal, never retry after a rejection): this code only runs with the layout-owner switch on. #29207, stacked on this PR, makes the fallback cover every refusal and every pane command. A rejected call is safe to fall back on there: main's write is rolled back when the call fails, so the local split can't duplicate one main already applied. |
ELI5
We are moving the job of deciding the layout of tabs and panes from the app window to the app's background process, one action at a time, in a build that nobody ships yet. This PR adds the channel the window uses to ask the background process for a layout change, and moves the first action onto it: splitting a terminal pane. Builds made the normal way are unchanged.
What Changed
A build switch.
ORCA_LAYOUT_OWNERis fixed when the app is built. It iswindowin every normal build andmainonly when the build asks for it. It is read in exactly one file,src/shared/layout-owner-switch.ts. Every place that behaves differently checksORCA_LAYOUT_OWNER_IS_MAIN, so a search for that name finds them all. In a normal build both branches are removed when the app is built, which I checked in the built main and window bundles.The
layout.applyrequest (main process). The background process looks up which saved partition holds the tab: local, an SSH host, or a folder workspace. It applies the shared layout command to that partition and saves it to disk before replying. The background process creates every new id; the request schema does not accept one from the window. Workspaces that belong to a paired remote Orca server are refused withhost_not_owned, because those layouts stay on the existing mirror path until that server owns them. The request is registered only in amainbuild, and it is not advertised to phones or remote clients.Only the changed records are written. Loading a partition and saving it again also tidies up records the command never touched, such as old legacy rows, sort orders, key order and pane incarnations. To avoid that, the command's own effect is worked out by comparing the save before the command with the save after it. Only those records are written onto the stored partition (
workspace-layout-record-patch.ts).Splitting a pane. In a
mainbuild, a split from the keyboard or the context menu waits for the background process to reply, then shows the new pane using the id it created. In a normal build the split works exactly as before.Switch points added (2):
src/main/runtime/rpc/methods/index.ts: registerlayout.apply.terminal-pane-split-with-inherited-cwd.ts: route a user split through the background process.Both are deleted when the old path goes.
User-visible before and after: no change in any build that ships. In a
mainbuild, a split looks the same, and the pane is now decided and saved by the background process.Why
The plan is to build the background-process path dark and switch over in one step, instead of running two layout owners side by side in released builds.
Linked Issue
Internal layout refactor, phase C1 (no public issue).
Visual Proof
N/A for every shipped build: no behaviour change. For the
mainbuild, the split was checked in a hidden dev app:layout.apply. The reply contained a new pane id created by the background process, the window showed that pane, and its terminal started.layout.applyreturnsmethod_not_foundand splits work as before.Testing
Automated tests:
layout.applyis absent in a normal build, never advertised or open to phones, and drops any id the window sends.layout.applyaccepts only splits today; this must be fixed before it accepts close or move.layout.apply.Checks run:
pnpm tc, oxlint,check:code-quality:changed, the RPC catalog check, the layout-writer ratchets, and the touched suites (591 files earlier, plus re-runs after each fix).Review
Fresh review, then a fix round, then a delta review. The fixes:
Agent skill upstream boundary
Notes
layout.applywrites them there.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)