Skip to content

refactor(layout): build today's store slices from layout frames (inert) - #29181

Merged
Jinwoo-H merged 7 commits into
mainfrom
e2a-frame-slices
Oct 15, 2026
Merged

Jinwoo-H merged 7 commits into
mainfrom
e2a-frame-slices

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​359 $\color{#cf222e}{\Huge{\mathbf{−}}}$​73 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​286
Prod 12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​832 $\color{#cf222e}{\Huge{\mathbf{−}}}$​357 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​475

ELI5

Today the window rebuilds its tabs at startup by reading the saved session file. Later in this refactor, the main process will tell the window what tabs exist, and the window will draw from that message instead. This PR adds the piece that turns main's message into the exact data the window's tab bars, terminals, editors and browser tabs already read. Nothing uses it yet; a test proves it gives the same result as today's startup.

What Changed

  • New, unused: buildLayoutFrameSlices (src/renderer/src/store/workspace-layout-frame-slices.ts). Input: each workspace's layout as main publishes it, the content facts kept beside the layout (titles, scrollback, page state), and this window's own selection. Output: today's store data for tabs, groups, terminal rows and panes, open files, browser tabs, and each workspace's selected tab. The window's global selection (active workspace and tab) stays the window's own; remote-server workspaces stay on today's mirror path.
  • How it works: it reads the published layout back into the shared layout model, writes today's records with the same shared code main saves with, then runs the window's own startup-restore builders on them. A terminal tab's title is the live title of the pane this window focuses, when main reports one.
  • Inert extractions (same inputs, same order, same result): the pure parts of editor restore, browser restore, and the per-workspace active terminal restore now live in their own functions, and the store actions call them.
  • Published layout gains optional fields the window needs to rebuild the same records: a terminal's launch inputs (start folder, shell, agent), a browser tab's label and creation time, and which host owns an editor file. The layout stream has no production subscriber yet.
  • Test: startup-window-frame-parity.test.ts. For every stored profile (local git worktree, folder workspace, floating terminal, SSH host, remote server, every legacy shape, plus editor files owned by an SSH host and by a server, and tab groups with no selected tab in a terminal workspace and an editor-only one), the slices built from main's published layout must equal the slices today's startup restores, field by field, apart from a short listed set. What the user sees must differ only as the existing Loader parity test already lists. The parity difference tables moved unchanged into a shared fixture.

No user-visible change.

Why

The plan's switch step (setting the window's tabs from main's messages) needs this conversion, and it must not change what users see. Building it first, unused, with an equivalence test, separates "is the conversion right" from "is the switch safe". Reusing the shared save code and the window's own restore builders, instead of writing a new converter, means no second copy of the restore rules. Writing a direct converter was the alternative; it would have duplicated the restore's sorting, de-duplication and file-id rules.

Differences the test found and lists:

  • A legacy tab-bar entry with no host recorded gets the host named; readers already treat a missing host as the workspace's.
  • A session from before the tab bar gets a root group whose id comes from the workspace key instead of a random one; group ids are never shown.
  • Each workspace from main's layout gets a saved (possibly empty) terminal row list, as today's window always saves one, so a tab group with no selected tab gets its first tab in every workspace, as today's startup does.
  • Main's published layout did not carry terminal launch inputs, browser tab labels and creation times, or editor file owners; it does now.

Not produced from main's layout (they stay main's records and today's restore until the switch moves them): sleeping agent records, closed-tab records, default-tab marks, and which terminal a tab reattaches at startup.

Linked Issue

N/A (internal refactor step)

Visual Proof

N/A: nothing calls the new code; no UI or behaviour change.

Testing

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

pnpm tc, oxlint, pnpm run check:code-quality:changed; vitest over src/renderer/src/store, src/renderer/src/app-shell, src/shared/workspace-layout, src/renderer/src/runtime, src/renderer/src/lib and the layout stream test. Checked the test is not vacuous by removing the new published fields: three cases fail.

AI Disclosure

Review

Fresh review and a delta review after fixes: approve.

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

Security, platforms, SSH, mobile, compatibility, performance: no runtime path changes. The new published fields are optional additions; this applier only ever reads the window's own main process.

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)

Adds the phase E2a frame applier: published layout frames plus content
facts plus the window's view become today's tab, terminal, editor and
browser slices, through the shared Serializer and the window's own
restore builders. Nothing calls it yet. Publishes the fields the window
needs to rebuild those records (terminal launch inputs, browser tab
label and creation time, editor file owner) and extracts the pure parts
of editor, browser and terminal restore. An equivalence test compares
the result with today's startup restore for every stored profile.
@coderabbitai

coderabbitai Bot commented Oct 15, 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: ec7505ef-b9f6-47c8-94bf-079adf86db0d
📥 Commits

Reviewing files that changed from the base of the PR and between bcd7eaf and 960549a.

📒 Files selected for processing: 1
  • config/main-layout-writer-baseline.txt
🚧 Files skipped from review as they are similar to previous changes: 1
  • config/main-layout-writer-baseline.txt

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

📝 Walkthrough

The changes expand published workspace data and add conversion into the stored layout model. Browser, editor, and terminal session restoration now uses dedicated projection helpers. A new builder derives state slices from published layouts, content facts, and a desktop view. Startup parity tests compare restored state with frame-derived state across layout fixtures and check recorded view differences.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 96054

No issue requiring a change before merge is established by the selected baseline update.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 59.09% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 22 functions across 13 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main change: building store slices from layout frames. The “inert” qualifier accurately states that the new path is unused.
Description check Passed The description is detailed and follows the required structure. It explains the change, rationale, testing, lack of visual impact, compatibility considerations, and scope. The unchecked full command c…
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: Docstring Coverage

Explanation

Docstring coverage is 59.09% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 22 functions across 13 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
  • 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 13b79a2 into main Oct 15, 2026
38 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