Skip to content

feat(wsl-mover): fence moving projects from new terminals and hide them once the host owns them (D1b-5c) - #28668

Merged
nwparker merged 3 commits into
mainfrom
nwparker/wsl-mover-d1b-5c-fence
Oct 14, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/wsl-mover-d1b-5c-fence

Conversation

@nwparker

@nwparker nwparker commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​353 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​351
Prod 15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​242 $\color{#cf222e}{\Huge{\mathbf{−}}}$​29 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​213

ELI5

While Orca moves a WSL project onto its WSL host, nothing should open a new terminal in that project, or the move could leave a process behind. Once the host owns the project, the old local copy should disappear from lists, because the host now lists it. This PR adds both behaviors. Both are driven by the move journal from D1b-5a. Nothing writes a journal yet, so today nothing changes for anyone.

What Changed

This is step D1b-5c of the lossless WSL project mover.

  • One fence, held in memory (src/main/persistence/moving-wsl-projects/wsl-move-scope-guard.ts).
    • Loading: it loads at startup, before any handler registers, and reloads on every journal write. Terminal spawns and list calls never read the disk for it. It compares profile folder paths after resolving them, case-insensitively on Windows, so a respelled path still matches.
    • What it blocks: while a move is taking a project (phases source-fenced up to before destination-committed), that project is read-only. Once the host owns it (destination-committed and later), its rows are also hidden.
    • If the journal can't be read: every project at a WSL path becomes read-only, and nothing is hidden.
  • New terminals are refused for a fenced or owned project. The existing spawn preflight dependency was generalized from assertFolderWorkspacePtyPathUsable to assertWorkspaceAcceptsNewPty. Both the desktop path and the runtime path (terminal.create, agent launches, setup scripts, orchestration workers) go through it.
    • Reattach still works: a window reload mid-move can reattach a pane whose session the daemon still runs.
    • Still refused: a fresh spawn, a cold restore, and any spawn when the daemon census goes unanswered.
  • Owned rows are hidden from the desktop repo and folder lists (visibleRepos / visibleFolderWorkspaces), from the runtime repo.list and folderWorkspace.list calls (CLI, mobile, paired clients), and from worktrees:listAll. worktrees:listAll therefore no longer runs git worktree list against a path the host owns. The rows stay in the profile for a downgrade, the same way SSH moves work.
  • Journal reads for the fence use a new non-copying scan, scanWslMoveCutovers, instead of deep-cloning every manifest.

Refusing repo and worktree edits through every handler is a separate follow-up (D1b-5c-2). Freezing session saves comes with the pause step in D1b-5d, because it must start after Sleep has written its records.

Why

The owner decided that a move pauses terminals and restores them on the host. That only works if no new terminal can start in a moving project. A spawn already past the check when the fence lands is still covered by the move itself: the terminal gate runs again under the fence, and the exit proof from D1b-5b refuses any live terminal in scope.

The fence is held in memory because spawns and list calls are hot paths, and only this process writes the journal.

Hiding owned rows reuses the visible-row filters SSH moves already use, so there is one rule for both.

Linked Issue

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

Visual Proof

N/A: there's no UI change, and nothing writes a move journal yet. The new e2e covers the behavior end to end.

Testing

  • I manually tested these changes locally

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

  • Unit tests:

    • Guard (16): every fence phase, an unreadable journal, a respelled profile path, and removing a finished move. Workspace id forms: a ::workspace: suffix, a path containing ::, and ids on another host.
    • Spawn check (5): a refused fresh spawn, a live reattach, a cold restore, and an unanswered daemon census.
  • New e2e (tests/e2e/wsl-move-fence.spec.ts, run locally on macOS). It writes a real journal into the test profile and relaunches the app.

    • While fenced, the moving folder and git repo refuse new terminals but stay listed.
    • Once owned, they also drop out of the folder, repo and worktree lists.
    • An untouched folder spawns normally throughout.
  • pnpm tc:node and oxlint are clean.

  • An adversarial review found five MEDIUM/LOW issues, all fixed here: list leaks, path spelling, a spawn already in flight, reattach on reload, and the store-less path.

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

Everything stays behind the internal WSL host gate, and no journal exists without a move.

There is no SSH behavior change. Rows hidden after an SSH conversion still leak into the runtime repo.list call; that's a separate fix, tracked as a follow-up.

The orcad server process never loads this fence. That's correct: it is the move's destination, never its source.

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 14, 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: 7bb00d06-9f68-4208-ac92-f33ca86869a7
📥 Commits

Reviewing files that changed from the base of the PR and between ebda4f6 and 78ab42f.

📒 Files selected for processing: 1
  • src/main/startup/main-process-ready-foundation.ts

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

📝 Walkthrough

The change loads and refreshes WSL move fences from the cutover journal. PTY admission checks use the fence and live-daemon session census. Repository, folder-workspace, worktree, and retained-source listings filter projects in the hidden scope. Unit and end-to-end tests cover the fence states, PTY admission, and listing behavior.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 78ab4

WSL move fences are loaded and refreshed before consumers use them, and WSL-hidden repositories remain filtered from repo.list after SSH conversion. No actionable merge-blocking risk remains beyond normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 36 functions across 20 files. 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: WSL move fencing for new terminals and hiding projects after host ownership.
Description check Passed The description is complete and matches the repository template. It explains the user impact, implementation, rationale, linked tracking item, visual proof, testing, platform considerations, follow-up…
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.
  • 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.

Caution

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

⚠️ Outside diff range comments (1)

🟠 Major · Scope the live-session exception to the requested worktree. · spawn-cwd.ts:23-41

src/main/ipc/pty/host-env/spawn-cwd.ts:23-41
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Scope the live-session exception to the requested worktree.

When worktree A is fenced, a request can provide A with the live sessionId of worktree B. The global census accepts B, and the attach contract can reuse that session. The PTY can then be recorded under A. Compare the session owner with worktreeId before allowing the reattach exception.

Suggested fix
 import { parseWorkspaceKey } from '../../../../shared/workspace-scope'
+import { parsePtySessionId } from '../../../../shared/pty-session-id-format'
@@
-    return assertReattachesLiveSession(sessionId).then(() =>
+    return assertReattachesLiveSession(worktreeId, sessionId).then(() =>
       assertFolderWorkspacePtyPathUsable(store, worktreeId)
     )
@@
-async function assertReattachesLiveSession(sessionId: string | undefined): Promise<void> {
+async function assertReattachesLiveSession(
+  worktreeId: string | undefined,
+  sessionId: string | undefined
+): Promise<void> {
   // An unanswered census is never proof the session lives, so it refuses.
   const live = sessionId ? await listLiveDaemonPtyIds() : null
-  if (!sessionId || !live?.includes(sessionId)) {
+  const sessionWorktreeId = sessionId ? parsePtySessionId(sessionId).worktreeId : null
+  if (!worktreeId || !sessionId || sessionWorktreeId !== worktreeId || !live?.includes(sessionId)) {
     throw new WslMoveProjectFencedError()
   }
 }

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 20a45b52-0ba2-4255-b4da-bde899794159
📥 Commits

Reviewing files that changed from the base of the PR and between 9f8a5a0 and ebda4f6.

📒 Files selected for processing: 3
  • src/main/ipc/pty/host-env/spawn-cwd-wsl-move.test.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-scope-guard.test.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-scope-guard.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.

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