Skip to content

Main records when a workspace's default tabs were applied (dark, layout-owner build only) - #30176

Merged
Jinwoo-H merged 3 commits into
mainfrom
e2-6/p6-default-tabs-applied-record
Oct 18, 2026
Merged

Jinwoo-H merged 3 commits into
mainfrom
e2-6/p6-default-tabs-applied-record

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​369 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​369
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​39 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​38

ELI5

When a new workspace opens its default tabs (the tabs a project's orca.yaml lists), 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

  • New layout command setDefaultTabsApplied on layout.apply. Main sets records.defaultTabsAppliedByWorkspace[workspace], which is already saved to disk as defaultTerminalTabsAppliedByWorktreeId. 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.
  • In layout-owner builds only, applyDefaultTerminalTabs sends 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.
  • Main routes the command to the workspace's own partition (local, or the SSH host's), as it already does for editor-file renames.

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.yaml had 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 reuses recordLayoutApply instead 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

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

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.

  • Base (switch on): both fail, on the strict check "the relaunch remembers the default tabs were applied". The later checks (no tab added in test 1, exactly one tab per title in test 2) would pass on base too: main had already saved the default tabs, and a workspace with tabs is never re-seeded. They stay in as a guard for the next step.
  • Head (switch on): both pass.

Gates: pnpm tc pass; check:code-quality:changed pass (0 new findings, 9 files); check:layout-writer-ratchets OK (211 main, 651 renderer); check:focus-read-ratchet OK (1082); audit:anti-slop pass; verify:rpc-params-catalog pass; 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 also src/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:

  • Renderer: identical apart from chunk hashes (the send sits behind the build switch and is removed).
  • Main index.js: the setDefaultTabsApplied handler in the shared layout command code. Only layout.apply can name it, and that method is registered only in layout-owner builds.
  • Main ssh-session-teardown chunk: the command's wire schema in LayoutApplyParams, which also only layout.apply reads.
  • Commit stamp and chunk hashes otherwise.

Flip capability list: new layout.apply command type setDefaultTabsApplied ({ 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. renameWorkspace returns 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

  • 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: 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

  • 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)

@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

The change adds a workspace-scoped setDefaultTabsApplied command to the layout command types and RPC contract. The layout command handler records the mark even when the workspace does not exist and leaves an existing mark unchanged. In layout-owner builds, the renderer sends the command after applying default tabs, including when no templates exist. Persistence and end-to-end tests cover repeated application, empty and populated template sets, and crash-and-relaunch behavior.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 5a242

A quick exit can race the marker write and cause default tabs to be applied again after relaunch. The timing window is narrow and the impact localized; awaiting durable completion would close it.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 23.08% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 9 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
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.
Title check Passed The title clearly and concisely describes the main change: recording when a workspace's default tabs were applied in the layout-owner build.
Description check Passed The description is comprehensive and follows the template. It explains the user impact, implementation, rationale, linked-issue exception, testing, compatibility considerations, and checklist status.
  • 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: a2cfdebc-6f99-40d3-b47e-7529e155efdf
📥 Commits

Reviewing files that changed from the base of the PR and between 6c45958 and 0f76471.

📒 Files selected for processing: 9
  • src/main/persistence/terminal-topology/terminal-layout-default-tabs-applied.test.ts
  • src/main/runtime/runtime-layout-apply.ts
  • src/renderer/src/lib/worktree-default-terminal-tabs-layout-owner.test.ts
  • src/renderer/src/lib/worktree-default-terminal-tabs.ts
  • src/renderer/src/runtime/layout-apply-send.ts
  • src/shared/rpc-contract/workspace-layout-params.ts
  • src/shared/workspace-layout/workspace-layout-command-types.ts
  • src/shared/workspace-layout/workspace-layout-commands.ts
  • 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; 4 remain after this review.

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟡 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 win

Await the durable setDefaultTabsApplied RPC.

recordLayoutApply starts ipcRenderer.invoke('runtime:call', ...) and returns immediately. Main persists the mark only inside the asynchronous layout.apply handler. If the window closes before that handler accepts or completes the request, the bounded quit path can destroy the renderer and call app.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 recordLayoutApply and await it through applyDefaultTerminalTabs and 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
📥 Commits

Reviewing files that changed from the base of the PR and between 9d64f49 and 5a242b3.

📒 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.

@Jinwoo-H
Jinwoo-H merged commit 31f7665 into main Oct 18, 2026
54 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