Skip to content

feat(wsl-mover): rewrite the desktop's routing and seed the host's session after a move (D1b-7c) - #29652

Closed
nwparker wants to merge 2 commits into
nwparker/wsl-mover-d1b-7a-moved-project-chatsfrom
nwparker/wsl-mover-d1b-7c-main-stores
Closed

nwparker wants to merge 2 commits into
nwparker/wsl-mover-d1b-7a-moved-project-chatsfrom
nwparker/wsl-mover-d1b-7c-main-stores

Conversation

@nwparker

@nwparker nwparker commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1027 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1025
Prod 20 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​899 $\color{#cf222e}{\Huge{\mathbf{−}}}$​31 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​868

Stacked for owner review. Not to be merged by the agent. The stack: #29526 (6d-1, base main) → #29550 (7a) → this PR. It touches shared user paths, listed below.

Shared paths this PR touches

  • Session persistence (startup): the gated desktop rewrite pass now finishes before runtime services and the first window load. It's bounded at 5 s, and there's no wait at all with the WSL gate off.
  • Renderer session hydration: a moved workspace's non-chat local rows are dropped before the local and host partitions merge, so a moved tab exists once, on the host. The chat tabs stay, per decision C and feat(wsl-mover): a moved project's existing chats stay listed and resumable on this computer (D1b-7a) #29550. The moved-workspace check now lives in a shared tab filter.
  • findCrossHostPaneTabIds: skips the retained local copy of a moved workspace.
  • Persisted ui and session globals: rewritten only for moved projects, through copy rather than move (see below).
  • Layout-writer baseline: config/main-layout-writer-baseline.txt gets +2 for two one-time, ledgered session writes in wsl-move-main-rewrite-stores.ts. One sets the local focus; the other seeds the WSL host's partition. No layout command can set focus or seed a runtime host's partition (runtime-layout-apply refuses runtime hosts), and the agent reports the coordinator approved the bump. Please confirm.

ELI5

After a WSL project's move commits, this computer's own saved state still points at the old Windows path: the last opened worktree, per-worktree settings, sidebar host filters, and saved tabs. This PR rewrites that state to point at the WSL host's copy. It also prefills the host's saved session so the first screen after a move shows every tab. Nothing writes a move yet, and everything is behind the internal WSL host gate, so nothing changes for anyone today.

What Changed

This is step D1b-7c of the lossless WSL project mover. It registers three main-side stores in the ledgered rewrite stage from #29597:

  • ui-routing (moved repos and folders only):
    • lastActiveWorktreeId, the keys of showDotfilesByWorktree and explorerDisplayRootByWorktree: Linux worktree ids. Folder roots are mapped in place.
    • Cleanup dismissals, setup-prompt dismissals, lineage collapsed groups, and manualRepoOrder: WSL-host forms are added beside the local ones, which are kept.
    • The WSL host is added after local in the visible-host lists and in workspaceHostOrder.
    • workspaceHostScope and automationHostFilter hold a single value, so they are left alone. A legacy local scope gets the host through visibleWorkspaceHostIds, which takes precedence.
  • session-globals: if the local focus is on a moved workspace, focus moves to the Linux id on the WSL host.
  • host-session-seed: fills the WSL host's saved session from the move manifest, but only for moved workspaces the host doesn't already have. Chat tabs (they stay local) and PTY bindings are excluded. The seeded workspace ids are recorded on the move record as seededHostWorkspaceIds (optional, grow-only), so a retry never brings back tabs the user has since closed.
  • Flush: each store's flush awaits the profile store's flushPendingOrThrowAsync().
  • Re-runs: each store writes only when something differs, so a second run writes nothing.

Why

Copy instead of move: an older build after a downgrade still finds its preferences.

Prefilling the host's session: first paint reads workspaceSessionsByHostId, not remoteLayoutSnapshots, which has no renderer reader.

One copy of each tab: the retained local rows stay on disk for downgrade, so the window drops them before merging, and a tab never resolves to the fenced local copy. Tabs keep their ids because restore hints and scrollback refs depend on them.

Finishing before the window loads: the window's whole-session save would otherwise undo the rewrite.

Linked Issue

N/A (maintainer; tracked in the WSL-via-orcad implementation tracker, step D1b-7).

Visual Proof

N/A: no visible UI change, and nothing writes a move yet.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • Per-store rewrites, run against the mixed Windows/WSL fixture profile:

    • moved rows change; unmoved and other-host rows don't;
    • copy-not-move semantics;
    • \\wsl$ and lowercase-distro spellings;
    • folder workspaces, including a folder-type activeWorkspaceKey;
    • legacy dismissal keys and dismissals with no host;
    • a group that held only chat tabs is dropped.
  • Host seed: excludes chat tabs and PTY ids, never overwrites the host, and is never re-seeded after the user closes tabs (covered by a flush-timeout, close, re-run test).

  • Hydration: both partitions holding tab-1 end with only the host's copy. The local chat tab stays, and findCrossHostPaneTabIds reports nothing for it.

  • Startup ordering: tested.

  • Real-store driver test: a committed journal runs all three stores in order and stays destination-committed, since the registry isn't complete until 7f. A re-run after a lost ledger entry is covered.

  • Checks: pnpm tc:node, pnpm tc:web, both ratchets, both oxlint configs, and the changed-code quality gate against feat(wsl-mover): a moved project's existing chats stay listed and resumable on this computer (D1b-7a) #29550 pass. 4001 test files pass.

  • Adversarial review: it found two MEDIUM issues (a startup race with the window; duplicate tab ids across partitions) and three LOW ones (folder explorer root, copy vs move, re-seeding closed tabs), plus test gaps. All are fixed here.

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

The rewrite hook after a move commits has no caller yet. A comment there says it must run with no window open, or alongside the renderer stores in 7d. 7d also covers the renderer pruning a host-form dismissal before the host's repo list loads.

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)

@nwparker
nwparker force-pushed the nwparker/wsl-mover-d1b-7a-moved-project-chats branch from d9a6f2f to 1a052ad Compare October 16, 2026 12:18
@nwparker
nwparker force-pushed the nwparker/wsl-mover-d1b-7c-main-stores branch from 4c4b533 to 5a9576a Compare October 16, 2026 12:18
@nwparker

Copy link
Copy Markdown
Contributor Author

CI note: the only failure on this head (5a9576a) is the real WSL terminal lane's terminal-inline-images test ("All three protocol images must appear in the rendered screenshot"). That flake also hits unrelated PRs, and #29633 is fixing it. This PR doesn't touch terminal rendering, and the rest of that lane passed (20 tests). I'm not retrying until #29633 lands.

@nwparker
nwparker force-pushed the nwparker/wsl-mover-d1b-7a-moved-project-chats branch from 1a052ad to 5d9dcb2 Compare October 16, 2026 12:41
@nwparker
nwparker force-pushed the nwparker/wsl-mover-d1b-7c-main-stores branch from 5a9576a to bcc1373 Compare October 16, 2026 12:41
@nwparker

Copy link
Copy Markdown
Contributor Author

Update: the stack was rebased onto main 78f2e9b, which includes the inline-images fix #29633 (d3cafe2) and the alt-screen test fix #29661. This PR's head is now bcc1373, so the real WSL terminal lane should run against the fixed test. Results will follow once CI finishes.

@nwparker

Copy link
Copy Markdown
Contributor Author

CI result on bcc1373, which includes #29633: the real WSL terminal lane still fails terminal-inline-images ("All three protocol images must appear in the rendered screenshot") on the headful repeat pass, so #29633 didn't fully fix it. The rest of that lane passed (20 tests). The other failure here is orcad-serve-parity.integration.test.ts on Windows ARM, which fails across unrelated PRs. This PR touches neither area. I'm not retrying.

@nwparker
nwparker force-pushed the nwparker/wsl-mover-d1b-7a-moved-project-chats branch from 5d9dcb2 to fa92dab Compare October 20, 2026 21:06
@nwparker
nwparker force-pushed the nwparker/wsl-mover-d1b-7c-main-stores branch from bcc1373 to 8d312b4 Compare October 20, 2026 21:06
@nwparker
nwparker force-pushed the nwparker/wsl-mover-d1b-7a-moved-project-chats branch from fa92dab to 76f3e02 Compare October 20, 2026 23:16
@nwparker
nwparker force-pushed the nwparker/wsl-mover-d1b-7c-main-stores branch 2 times, most recently from 574e5f0 to dd04a70 Compare October 21, 2026 00:45
@nwparker
nwparker force-pushed the nwparker/wsl-mover-d1b-7a-moved-project-chats branch from 76f3e02 to c035565 Compare October 21, 2026 00:46
…ssion after a move (D1b-7c)

Registers the main-side desktop rewrite stores ui-routing, session-globals and host-session-seed. Adds a +2 main layout-writer baseline line for wsl-move-main-rewrite-stores.ts: these are one-shot, ledgered move rewrites, and no LayoutCommand can set focus or seed a runtime host's partition.
… one copy of each moved tab, and copy instead of move (D1b-7c)
@nwparker
nwparker force-pushed the nwparker/wsl-mover-d1b-7a-moved-project-chats branch from c035565 to ed9c23a Compare October 21, 2026 05:16
@nwparker
nwparker force-pushed the nwparker/wsl-mover-d1b-7c-main-stores branch from dd04a70 to 0a93bdd Compare October 21, 2026 05:17
@nwparker

Copy link
Copy Markdown
Contributor Author

Contained in the dark landing PR #34059 (its head commit is an ancestor of the landing branch). Closing in favour of it; branch kept.

@nwparker nwparker closed this Oct 26, 2026
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