Repository navigation
Main drops the layout of workspaces the catalog no longer validates (dark, layout-owner build only) - #30177
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
ELI5
When a workspace's worktree is gone (deleted outside Orca) or its project is no longer registered, the window already throws away that workspace's saved tabs when it loads. In the build where the main process owns the layout, main kept those tabs, so a stale workspace could come back through main's layout updates. Now main throws them away by the same rule the window uses. Shipped builds are unchanged.
What Changed
Before (layout-owner build only): the window dropped tabs of an invalid workspace when it loaded the saved session, but main's stored layout still held them. Once window saves stop carrying layout, nothing would ever remove them from main.
After (layout-owner build only): main removes the stored layout of a workspace the catalog no longer validates, at two points:
Mechanism:
src/shared/worktree/degraded-repo-worktree-validity.ts). The window's four load paths import it from there; main calls the same function. There is one copy of the rule.removeWorkspaceSessionStateForWorktree, which writes the partition and notifies the layout stream, so the window receives aremovedframe for each dropped workspace.The window's own load filter stays in place.
Why
Main is becoming the single owner of layout. A rule that exists only in the window stops working once window saves no longer carry layout, so main has to apply it itself. Sharing the one function, rather than writing a main-side copy, keeps the two from drifting. Running the purge on main's own listings (instead of waiting for the window to report what it dropped) needs no new message between window and main, and main already knows whether each scan was complete.
Alternatives considered: a new layout command to remove a workspace (larger, and a wire change older peers would drop); matching the window's hidden-worktree handling exactly (it would close a worktree's tabs as soon as it was hidden mid-session).
Linked Issue
Internal layout-owner work (prep for the step that stops window saves from carrying layout).
Visual Proof
N/A: the change is compiled out of shipped builds, and in the layout-owner build it only removes tabs of workspaces that no longer exist.
Testing
New
src/main/persistence-invalid-workspace-layout-purge.test.ts(switch on):removedfor it; a scan that cannot prove deletion, a stale listing, and a project id two hosts register all keep everything.Failing first, before the change: without the module the test file cannot load; with the module but before wiring it into load, the "key naming no registered project" case fails. The deregistered-project case already passes before this change because of the existing load sweep.
Gates:
pnpm tcpass;pnpm run check:code-quality:changedpass; layout-writer ratchet pass (main 212, renderer 651); focus-read ratchet pass (1082); anti-slop lint pass; vitest (--maxWorkers=4) 122 files, 1070 passed, 1 skipped across the new test, the deregistered-residue test, the window hydration tests,src/main/ipc/worktrees,src/main/persistence/loading-store,src/main/persistence/restoring-sessions, the layout stream, tabs and terminal store tests.Switch-off bundle (unminified, base af056df vs head): main bundle identical except the commit stamp; preload identical; renderer identical except one source-region comment in one chunk that names the moved file's new path. Chunk hashes differ only because of that comment.
Layout-owner build, save-divergence detector, same specs on base and head (golden-quit-relaunch-session, worktree-lifecycle, golden-worktree-create-switch, local-worktree-visibility-runtime-active, worktree-delete-shortcut, folder-setup): base 9 passed, 0 reports; head 9 passed, 0 reports. Positive control (cli-file-open-position) 1 report on both builds, so the detector was live.
Platforms: macOS. SSH: covered by the unit cases above (disconnected SSH project kept; SSH listings in main are never complete scans).
Review
Layout-writer baseline: this adds one main writer (
invalid-workspace-layout-purge.ts, 1 call ofremoveWorkspaceSessionStateForWorktree). Removing invalid workspaces in main needs a session write; the alternative was a new layout command.Flip capability list: none. No new layout command or field.
Agent skill upstream boundary
Notes
Security: none. Cross-platform: keys are compared as stored, no path handling added. SSH: loss of contact never drops a layout. Mobile: unchanged. Backwards compatibility: no wire change. Performance: one pass over a partition's workspace keys per listing, only in the layout-owner build.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)