Skip to content

feat(wsl-move): rewrite renderer stores for moved projects (D1b-7d) - #29827

Closed
nwparker wants to merge 3 commits into
nwparker/wsl-mover-d1b-7c-main-storesfrom
nwparker/wsl-mover-d1b-7d-renderer-stores
Closed

nwparker wants to merge 3 commits into
nwparker/wsl-mover-d1b-7c-main-storesfrom
nwparker/wsl-mover-d1b-7d-renderer-stores

Conversation

@nwparker

@nwparker nwparker commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​624 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​620
Prod 30 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​703 $\color{#cf222e}{\Huge{\mathbf{−}}}$​71 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​632

Stacked on #29652 (D1b-7c). For owner review; not to be merged by the agent. The stack: #29526 (6d-1) → #29550 (7a) → #29652 (7c) → this PR.

Shared paths this PR touches

  • Sidebar and catalog lists: the four places that prune repo-scoped UI after a repo list loads: the all-hosts validation, the runtime catalog fetch, the local catalog fetch, and UI re-hydration. Without a moved project each one returns exactly the value it returned before, same object included.
  • Startup: App.tsx starts the renderer rewrite once when it mounts. With no committed move, or with the internal WSL gate closed, that is one IPC call that returns an empty list. The moved-projects list fetch (from 7a) now starts before the local repo list instead of after it.
  • Editor storage modules: quick-open history, CSV/PDF view preferences and notebook interpreter storage each gain a copy function. Their normal read and write paths are unchanged, except that the save helpers now report whether the write succeeded.
  • Shared helpers (refactor, no behavior change): wslUncPathToLinux moves to src/shared/wsl-paths.ts. rewriteWorktreeIdPath is extracted into src/shared/worktree/id.ts, and main's rewriteOrcadMigrationWorktreeId now calls it.
  • No ratchet baseline changes.

ELI5

Some state is saved in the app window's own browser storage rather than in Orca's profile file: recent files for quick open, CSV column widths, PDF zoom, and which Python a notebook uses. When a WSL project moves to its WSL host, that state is still keyed by the old Windows path, so the moved project would come back with these settings forgotten. This PR copies them to the host's keys.

It also fixes a second problem. When the WSL host's project list hasn't loaded yet, the sidebar could throw away the moved project's filters, hook trust and "don't ask again about the setup script" choices. Nothing in the product writes a move yet, and everything is behind the internal WSL host gate, so nothing changes for anyone today.

What Changed

Before:

  • After a move, the WSL host's copy of the project:
    • had no quick-open history;
    • opened CSVs with default column widths and PDFs at default zoom;
    • asked again which Python a notebook should use.
  • If the WSL host's project list failed to load or was late, the next catalog refresh could:
    • remove the moved repo from the sidebar and agents filters;
    • drop its hook trust, so the trust prompt showed again;
    • drop its setup-script dismissal.

After:

  • Copied state: each of those entries gets a copy under the host's key: host route, Linux worktree id, Linux path. The original stays, so an older build after a downgrade still finds it.
  • Pruning: a moved repo's filters, trust and dismissals survive a refresh that doesn't list it.

Mechanism:

  • Registration: main registers three renderer-side stores in the ledgered rewrite stage from feat(wsl-mover): the ledgered desktop rewrite stage that finishes a committed move (D1b-7b) #29597: quick-open-history, file-view-preferences and notebook-environments.
  • The renderer's pass: after it starts, the window lists committed moves (wslMove:listPendingRendererRewrites). For each store it then:
    1. adds the host copies, through the store module so its in-memory cache stays in sync;
    2. writes an applied-marker in the same storage, only after the store's own write succeeded;
    3. records the store in the ledger (wslMove:recordStoreRewritten).
  • Main's side of recording: it accepts only the main window (other windows use other storage partitions), and asks Electron to flush that window's storage before writing the ledger entry.
  • Lazy storage flush: the browser writes this storage to disk lazily, and Electron's flush only schedules the write. So the list now includes every move from destination-committed onward, and each startup re-applies any store whose marker is missing. The marker sits in the same storage area as the data, so the two are lost together and the store simply runs again. Copies are added only when the host key is absent, so re-running never duplicates or overwrites anything.
  • Full stores: a store at its size limit makes room by dropping the moved project's now-unused local entries, never another project's.
  • Failed writes: a write the browser refuses throws, so that store gets neither a marker nor a ledger entry.
  • Scope:
    • Only local entries of the move's repos and folders, in its distro, are copied.
    • SSH, other runtime hosts, other distros and other projects are left alone.
    • Notebooks are keyed by bare file path, so they are also limited to the moved projects' directories (new scopeRootPaths, from the manifest). A notebook interpreter is carried only when it lives inside the distro; a Windows Python can't run on the host.
    • Native chats stay on this computer (decision C) and are not touched.
  • Prune guard:
    • withWslMovedRepoIds adds the moved repo ids from wslMovedProjects to the set each prune keeps.
    • withWslMovedSetupScriptDismissals keeps any dismissal of a moved repo, whichever host it names.
    • With no moved project, both return their input unchanged.

Store disposition (renderer)

Store Keyed by Disposition
orca.quick-open-history.v1 (item 42) route, worktree id, root Rewrite (this PR): host copy beside the local entry
orca.pdf.scale-preferences.v1, orca.csv.column-widths.v1 (item 72) worktree id, environment, path Rewrite (this PR): host copy
orca.notebookPythonEnvironments (item 43) notebook path Rewrite (this PR): host copy, moved directories only, interpreter inside the distro only
filterRepoIds, agentsFilterRepoIds, trustedOrcaHooks, setupScriptPromptDismissedRepoIds (renderer copies) repo id / repo-host identity Prune guard (this PR). Repo ids don't change in a move. The host-form setup dismissal was already added by 7c.
collapsedGroups, workspaceCleanup dismissals, manualRepoOrder, showDotfilesByWorktree, explorerDisplayRootByWorktree, visible-host lists, lastActiveWorktreeId worktree / host N/A here: saved UI that main rewrites (7c). The window's copy refreshes through the existing ui:stateChanged broadcast, and the UI writer only sends fields the window itself changed.
acknowledgedAgentsByPaneKey, activityClearedAtByPaneKey, manuallyUnreadTurnsByPaneKey pane key (tab:pane) N/A: tabs keep their ids across the move (7c), so the keys stay valid.
orca:structuredAgentLaunches:v1 (item 44) session id, host N/A: decision C, chats stay local.
Native chat draft journal, draft storage, legacy outbox (item 45) session id N/A: keyed by session id.
Worktree visit recency (item 32) worktree N/A: web client only; the desktop keeps it in the session.
Tabs, editor, browser and workspace session in the window's store worktree id N/A here: loaded from the session, which 7c rewrites and seeds before the window opens.
Live maps: expandedDirs, git status, huge-repo warnings (item 46) worktree id N/A: memory only, rebuilt on load.
Every other renderer storage module (item 62) global N/A: global preferences.
orca.wsl-move.renderer-rewrites.v1 (new) move id The mover's own applied-markers, listed in the disposition census.

Why

Copy instead of move: this matches 7c. An older build after a downgrade still reads the local keys, and the local rows are hidden rather than deleted.

Markers plus re-application, not trusting the flush: the renderer can't force its storage to disk, and Electron's flushStorageData() only schedules the write. If we re-applied at every startup with no marker, an entry the user deleted (or that dropped out of the recent-files limit) would come back. Writing the marker after the data in the same storage area means a lost flush loses both, and the store just runs again.

Copying through the store modules: quick open and notebooks keep in-memory caches that overwrite storage on their next save. Writing to storage behind their backs would be undone.

Guarding the prune with wslMovedProjects rather than delaying it: the prune is correct for every other repo. Moved repos are exactly the ones whose host row can be missing while the local row is hidden.

Linked Issue

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

Visual Proof

N/A: no visible change. Nothing writes a move yet, and the stores only add hidden storage entries.

Testing

  • I manually tested these changes locally

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

  • Key mapping (wsl-move-renderer-store-keys.test.ts):

    • moved worktree ids, both UNC spellings, workspace keys and folder workspaces;
    • other distros, unmoved repos, SSH and runtime entries, and host keys all return nothing, so a re-run can't chain;
    • CSV and PDF keys are built with the real buildFileViewPreferenceKey;
    • notebooks are limited to the moved directories and to interpreters inside the distro.
  • Renderer pass (wsl-move-renderer-store-rewrites.test.ts, real storage modules in happy-dom):

    • no move → storage byte-identical and nothing recorded;
    • a list failure never throws;
    • copies land and every store is recorded;
    • a reload doesn't re-apply a store whose marker exists, but still records it while pending;
    • a lost marker re-applies to an identical result;
    • a past-phase move is never recorded;
    • another move's scope leaves storage untouched;
    • concurrent calls join;
    • a failing store gets no marker or ledger entry and the next store continues;
    • a full store drops only the moved source;
    • a refused write is neither marked nor recorded.
  • Prune guard (wsl-moved-repo-ui-retention.test.ts, real store):

    • all-hosts refresh with the WSL environment missing;
    • the moved repo as the only repo;
    • local-only refresh;
    • UI re-hydration, including agentsFilterRepoIds;
    • each against a no-move control that prunes exactly as before;
    • identity is preserved when nothing is pruned.
  • Main:

    • listing covers phases before and after commit, with scopeRootPaths;
    • the flush runs before the ledger entry and not on a refusal;
    • only the main window can record;
    • the three renderer stores are registered;
    • scope roots.
  • Gate closed: both IPC channels answer empty or refuse (existing tests).

  • Checks:

    • pnpm tc, oxlint on touched paths, pnpm run check:code-quality:changed, and both ratchets pass;
    • about 3,260 neighbouring test files pass.
  • Adversarial review: a reviewer agent found no HIGH issues and four MEDIUM ones, all fixed here:

    • the flush is not a durability barrier (the comments now say so, and the design leans on re-application);
    • copies could push out other projects' entries;
    • a silently failed write could still be marked;
    • the guard did nothing when the moved repo was the only repo.

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

  • Main-store rewrites with a window already open: 7c finishes the main-side rewrite before the window loads at startup, but the hook that runs after a move commits still has no caller. Whoever wires it (the move UI) must make sure the open window doesn't save its old session over the rewrite. Persisted UI is safe: main's updateUI broadcasts to the window.
  • Notebook directories: a worktree that sits outside its repo's directory, and that the move carried no meta, lineage or session for, isn't in scopeRootPaths. Its notebook interpreter choice isn't copied, and the host asks again.
  • Moved repos' kept UI: a moved repo's filters and trust are kept for as long as its local row is retained.

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)

…heir UI through catalog prunes (D1b-7d)

Registers the renderer-side desktop rewrite stores quick-open-history, file-view-preferences and notebook-environments. The renderer copies each moved workspace's entry to its WSL host key, marks it applied in the same storage, and records the ledger entry; main requests a storage flush first and accepts only the main window. Committed moves are re-listed for re-application at every startup. Catalog prunes keep filters, hook trust and setup-script dismissals of moved repos.
…manifest exporter, where 7d moved it (D1b-7d)
@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