Repository navigation
feat(wsl-mover): fence moving projects from new terminals and hide them once the host owns them (D1b-5c) - #28668
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟠 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 winScope the live-session exception to the requested worktree.
When worktree A is fenced, a request can provide A with the live
sessionIdof 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 withworktreeIdbefore 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
📒 Files selected for processing: 3
src/main/ipc/pty/host-env/spawn-cwd-wsl-move.test.tssrc/main/persistence/moving-wsl-projects/wsl-move-scope-guard.test.tssrc/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.
…d hides them once the host owns them (D1b-5c)
…file paths, let a live pane reattach (D1b-5c)
ebda4f6 to
78ab42f
Compare
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.
src/main/persistence/moving-wsl-projects/wsl-move-scope-guard.ts).source-fencedup to beforedestination-committed), that project is read-only. Once the host owns it (destination-committedand later), its rows are also hidden.assertFolderWorkspacePtyPathUsabletoassertWorkspaceAcceptsNewPty. Both the desktop path and the runtime path (terminal.create, agent launches, setup scripts, orchestration workers) go through it.visibleRepos/visibleFolderWorkspaces), from the runtimerepo.listandfolderWorkspace.listcalls (CLI, mobile, paired clients), and fromworktrees:listAll.worktrees:listAlltherefore no longer runsgit worktree listagainst a path the host owns. The rows stay in the profile for a downgrade, the same way SSH moves work.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:
::workspace:suffix, a path containing::, and ids on another host.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.pnpm tc:nodeand 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
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.listcall; 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
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)