Repository navigation
Main records when a workspace's default tabs were applied (dark, layout-owner build only) - #30176
Conversation
…indow (dark, layout-owner build only)
📝 Walkthrough
Priority: ⬇️ Low 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:
a2cfdebc-6f99-40d3-b47e-7529e155efdf
📒 Files selected for processing: 9
src/main/persistence/terminal-topology/terminal-layout-default-tabs-applied.test.tssrc/main/runtime/runtime-layout-apply.tssrc/renderer/src/lib/worktree-default-terminal-tabs-layout-owner.test.tssrc/renderer/src/lib/worktree-default-terminal-tabs.tssrc/renderer/src/runtime/layout-apply-send.tssrc/shared/rpc-contract/workspace-layout-params.tssrc/shared/workspace-layout/workspace-layout-command-types.tssrc/shared/workspace-layout/workspace-layout-commands.tstests/e2e/default-tabs-mark-crash-relaunch.spec.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.
…vers (dark, layout-owner build only)
…h (dark, layout-owner build only)
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 · Await the durable setDefaultTabsApplied RPC. · layout-apply-send.ts:245-251
src/renderer/src/runtime/layout-apply-send.ts:245-251
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick winAwait the durable
setDefaultTabsAppliedRPC.
recordLayoutApplystartsipcRenderer.invoke('runtime:call', ...)and returns immediately. Main persists the mark only inside the asynchronouslayout.applyhandler. If the window closes before that handler accepts or completes the request, the bounded quit path can destroy the renderer and callapp.quit()before the mark is durable. The final store flush cannot persist a request that main has not accepted, so relaunch can reapply the default tabs.Return the durable promise from
recordLayoutApplyand await it throughapplyDefaultTerminalTabsand its initial-seeding caller before allowing this flow to exit. The synchronous caller chain must be updated together.
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
df440e39-2501-4fe7-9703-5e4fb50659f3
📒 Files selected for processing: 1
tests/e2e/default-tabs-mark-crash-relaunch.spec.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.
ELI5
When a new workspace opens its default tabs (the tabs a project's
orca.yamllists), Orca writes down "this workspace already got its default tabs" so it never adds them again. In the layout-owner test build, the main process is becoming the one place that saves the layout, but this note only reached it two ways: inside the window's next save, or when one of those tabs first started its terminal. Now the window tells main directly, the moment it writes the note. Shipped builds are unchanged.What Changed
setDefaultTabsAppliedonlayout.apply. Main setsrecords.defaultTabsAppliedByWorkspace[workspace], which is already saved to disk asdefaultTerminalTabsAppliedByWorktreeId. A repeat changes nothing. It never creates a workspace, so a workspace with no tabs yet is marked without making an empty layout for it.applyDefaultTerminalTabssends that command when it marks the workspace in the window: right away when there are zero templates, otherwise after it has created the default tabs, so main's write queue stores the mark only behind their rows (a crash in between never leaves a mark without its tabs). It is sent as a record: whatever main answers, the window's own copy stays as it is. The send sits at two points (the zero-template return and after the loop) on purpose: dropping that early return so one send serves both would change the shipped window code, since the return stays in builds with the switch off.Before (layout-owner build): if the app quit hard after the window marked the workspace but before its 150 ms save and before any default tab started a terminal, the note was lost. After: main has it on disk as soon as the command lands.
What a user sees today is the same in both cases: main already saved the default tabs themselves, and a workspace with tabs is never given default tabs again. The two cases this covers matter once main stops taking these notes from window saves (the next step of this work): a workspace whose
orca.yamlhad zero default tabs, and a crash between the window's note and the first terminal start.Why
Main already sets the same note when a terminal start binds (
pty-binding-session-update.ts), and keeps old notes through window saves (runtime-authored-workspace-session-fields.ts). Neither covers zero templates or a crash before the first start. A record-only command is how the window already reports changes it made itself (chat pane, sleep records), so this reusesrecordLayoutApplyinstead of adding a new channel. No existing command fit: they all act on a tab, pane, group or browser tab, and this note belongs to no tab.Linked Issue
N/A (internal layout-owner work).
Visual Proof
N/A: no UI change, and shipped builds are unchanged.
Testing
Unit tests (written first; 4 of 6 failed before the change):
terminal-layout-default-tabs-applied.test.ts(real store on disk): the note survives a reopen for a git worktree and for a folder workspace, creates no tab rows, groups or tab list; a repeat changes nothing.worktree-default-terminal-tabs-layout-owner.test.ts: zero templates sends the command; with templates it is sent after every tab create and title; an already marked workspace sends nothing; switch off sends nothing.Relaunch specs (new,
tests/e2e/default-tabs-mark-crash-relaunch.spec.ts, layout-owner build only): main drops the window's saves and holds every terminal start, the window applies default tabs (zero, or two titled tabs), main is killed with SIGKILL, and the relaunched window is offered two default tabs again.Gates:
pnpm tcpass;check:code-quality:changedpass (0 new findings, 9 files);check:layout-writer-ratchetsOK (211 main, 651 renderer);check:focus-read-ratchetOK (1082);audit:anti-sloppass;verify:rpc-params-catalogpass; oxlint on changed files pass; vitest on touched areas (src/renderer/src/lib,src/renderer/src/runtime,src/shared/workspace-layout,src/main/persistence/terminal-topology) 1032 files, 9903 passed, 4 expected fail, 1 skipped; earlier alsosrc/shared/rpc-contract, the layout.apply RPC test and the divergence detector, all passing.Save-divergence detector, switch on, same spec on base and head: 0 reports on each.
Unminified switch-off bundle, merge base vs head:
index.js: thesetDefaultTabsAppliedhandler in the shared layout command code. Onlylayout.applycan name it, and that method is registered only in layout-owner builds.ssh-session-teardownchunk: the command's wire schema inLayoutApplyParams, which also onlylayout.applyreads.Flip capability list: new
layout.applycommand typesetDefaultTabsApplied({ type, workspace }). An older main rejects it as invalid params; the window ignores the answer and keeps saving its own note, as today.Known gap, older than this PR: a workspace that has only this note and no tabs keeps the note under its old id when the workspace is renamed.
renameWorkspacereturns early when main holds no layout for the old id (workspace-layout-owner-transitions.ts:47-49), so its records are not re-keyed.AI Disclosure
Review
Agent skill upstream boundary
Notes
SSH: the command goes to the workspace's routed partition, so an SSH workspace's note lands with its other records. Folder workspaces are covered by the store test. A paired server's workspace is skipped by the existing owner check in
sendLayoutApply. Mobile and the web client never send it.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)