Repository navigation
Create terminal tabs through main behind the layout-owner build switch (off by default) - #29311
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
Main writes each window-created terminal tab under the window's ids before any later command names its pane, and decides a workspace's first terminal on activation. Main refuses a tab id another tab holds; the same create again changes nothing.
… activation fallback only in the shown workspace
…records leave its owner unclear
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🔵 Low · 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:
08d422f2-e02e-450e-bc4a-ab3ae6e80bb9
📒 Files selected for processing: 13
src/main/persistence/terminal-topology/terminal-layout-create.test.tssrc/main/persistence/terminal-topology/terminal-pane-admission.tssrc/main/runtime/rpc/methods/workspace-layout-apply.test.tssrc/renderer/src/components/use-terminal-watcher-effects.tssrc/renderer/src/hooks/ipc-events/terminal-presentation-frame-drawn-tab.test.tssrc/renderer/src/hooks/ipc-events/terminal-presentation-ipc-bridge.tssrc/renderer/src/lib/window-session-write-activity.tssrc/renderer/src/store/slices/store-create-tab-layout-owner.test.tssrc/renderer/src/store/terminals/terminal-tab-create-through-layout-owner.test.tssrc/renderer/src/store/terminals/terminal-tab-create-through-layout-owner.tssrc/renderer/src/store/terminals/terminal-tab-creation.tssrc/shared/rpc-contract/workspace-layout-params.tssrc/shared/workspace-layout/workspace-layout-command-types.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
| if (reply.ok) { | ||
| // No tab id: main's copy already shows a tab here, which its frames bring. | ||
| if (reply.result.tabId === tabId && !holdsTerminalTab(getState(), tabId)) { | ||
| create({ tabId, leafId }) | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '75,155p' src/renderer/src/store/terminals/terminal-tab-create-through-layout-owner.ts
sed -n '235,275p' src/renderer/src/components/use-terminal-watcher-effects.ts
sed -n '170,305p' src/renderer/src/store/terminals/terminal-tab-creation.tsRepository: stablyai/orca
Length of output: 10739
🏁 Script executed:
rg -n -F --glob '*.ts' -e 'function createTab' -e 'const createTab' -e 'shouldActivate' -e 'ownsGlobalSelection' -e 'holdLayoutFramesForWindowCommand' -e 'layout.apply' src/renderer/src/store src/renderer/src/components
sed -n '1,220p' src/renderer/src/store/terminals/terminal-tab-creation.ts
sed -n '1,180p' src/renderer/src/components/use-terminal-watcher-effects.tsRepository: stablyai/orca
Length of output: 28492
🏁 Script executed:
sed -n '1,80p' src/renderer/src/store/global-selection-owner.ts
sed -n '205,275p' src/renderer/src/store/terminals/terminal-tab-creation.ts
sed -n '1,125p' src/renderer/src/store/terminals/terminal-tab-create-through-layout-owner.ts
rg -n -F --glob '*.ts' -e 'holdLayoutFramesForWindowCommand' -e 'pendingActivationSpawn' src/renderer/src/lib src/renderer/src/store src/renderer/src/componentsRepository: stablyai/orca
Length of output: 26108
Do not activate a late main-owned tab.
A successful reply must still draw main’s tab so the window receives the tab that main created. However, createTab activates by default and updates the workspace’s remembered selection even when that workspace is inactive. If the user opens another tab or leaves the workspace while the RPC is pending, the reply can select the activation tab when the user returns.
Set activation only when the workspace is still active and empty. Keep drawing the tab in all successful-reply cases.
Suggested fix
- create: (ids?: { tabId: string; leafId: string }) => void
+ create: (ids?: { tabId: string; leafId: string; activate?: boolean }) => void
...
if (reply.result.tabId === tabId && !holdsTerminalTab(getState(), tabId)) {
- create({ tabId, leafId })
+ const state = getState()
+ create({
+ tabId,
+ leafId,
+ activate:
+ state.activeWorktreeId === worktreeId &&
+ !state.tabsByWorktree[worktreeId]?.length
+ })
}Pass ids.activate through the watcher’s createTab options.
Main split the layout.apply command type into runtime/layout-apply-send.ts: the tab-bar rename and props commands join it there.
ELI5
The plan is for the app's background process to own every workspace's tabs and panes, with the window only drawing them. This step covers making a new terminal tab, and it only applies in a special internal build. Normal builds do not include it.
What Changed
layout.apply, which normal builds do not register.ORCA_LAYOUT_OWNER=main:createTerminalTabcommand carrying the ids it just drew. The background process writes the tab before any later command from the window can name its pane.Why
Linked Issue
Internal refactor plan (phase C3), no issue.
Visual Proof
N/A. Normal builds are unchanged. In the internal build the tab bar looks the same; the difference is in what the background process has saved, which the checks below verify.
Testing
Hidden app (background launch), internal build, before and after this change. Right after each create, in the same JavaScript turn, a probe asked the background process about the new pane.
tab_not_foundorpane_not_found.Workspace layout check, internal build: 21/21 pass. The headless variant: 9 pass and 9 skipped (that variant's server was not built).
Unit tests:
Bundle diff: off build vs base, unminified, compared line by line across chunks (results above).
SSH, hidden app against a Docker SSH host, this build vs the base: new tab, agent tab, create then split, and quit/relaunch all match across the window, the server and the saved file. There were no duplicates, refusals or layout warnings. Every SSH host now runs its own managed server (a host it can't serve fails to connect; there is no relay fallback). So SSH tabs are created on that server and kept under its entry, and this change never runs for them. It skips them like any paired-server workspace. The unit test for SSH-only saved data covers a case current builds no longer produce.
macOS only.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Two independent reviews. The first: merge after fixes. All of its findings were fixed except the group fallback, which is described above. The second, on the fixes: merge as is. Its one cheap finding was also applied.
Agent skill upstream boundary
Notes
Stacked on #29207. Paired-server workspaces keep their mirrored layout, and the web client is not affected (the switch is not set there).
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)