Skip to content

feat(wsl-mover): a moved pane reopens in its last folder on the WSL host (D1b-6b) - #28885

Merged
nwparker merged 2 commits into
mainfrom
nwparker/wsl-mover-d1b-6b-restore-hints
Oct 14, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/wsl-mover-d1b-6b-restore-hints

Conversation

@nwparker

@nwparker nwparker commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​667 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​665
Prod 18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​833 $\color{#cf222e}{\Huge{\mathbf{−}}}$​33 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​800

ELI5

When Orca moves a WSL project onto its WSL host, it pauses the project's terminals first and records which folder each pane was in. This PR carries those folders to the host. The first time a moved pane's terminal opens there, it starts back in that folder instead of the project root. Nothing sends the folders yet; the move flow that sends them comes later.

What Changed

This is step D1b-6b of the lossless WSL project mover. It rides on the blob channel from #28866.

  • Format (src/shared/orcad-migration-terminal-restore-hints.ts): a versioned JSON document {version: 1, hints: [{paneKey, cwd}]}.
    • Pane keys must parse as tabId:<uuid>.
    • Folders must be absolute POSIX paths, with no // or NUL.
    • At most 8192 hints, no duplicates, within the 4 MiB blob cap.
    • A desktop encoder (buildWslMoveRestoreHintsBlob) produces the blob for the move flow to send.
  • Validated before commit: a hints blob that passes its digest check but isn't a valid document fails the catalog commit. The move then aborts while the desktop still owns everything, so nothing is lost.
  • Installed after commit: on the server, the hints go into a small fsync'd file (<profile>/orcad-migration-blobs/installed/terminal-restore-hints.json) rather than into profile state, so neither persisted state nor the wire format changes. Each hint carries its worktree and migration, and expires after 30 days. The installed-migration record means a commit retry never brings back a hint that was already used. The received blob is then deleted.
  • Installs are retried: a pending install runs again at store load and whenever the catalog state is queried as committed.
  • Applied once, at terminal creation (orca-runtime-create-terminal.ts). The pane is claimed first, then the hint is read.
    • Default folder: if the caller asked for no folder, the workspace isn't SSH, the worktree matches, and the folder exists and can be entered, the pane opens there. Otherwise today's default applies.
    • Explicit folder: a create that asks for a specific folder still uses up the hint, because that create was the restore.
    • Removed only when the spawn commits: a failed or retried create keeps the hint.
  • Dropped with its project: when a repo or folder workspace is removed from the host, its panes' hints go too. The reverse mover will also need to drop hints when it exports a worktree back; that's noted in the tracker.
  • Advertised: the server now advertises orcad.migration-blob.terminal-restore-hints.v1.

Why

The owner decided on "pause and restore" for terminals. Restoring a shell at the project root instead of where the user was is a silent loss. The folder lives only in the paused terminal's daemon checkpoint on the desktop, so it has to travel with the move. It's captured after the terminals pause, while the manifest is signed earlier, so it travels as a blob rather than in the manifest. That also keeps SSH manifests byte-identical.

Linked Issue

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

Visual Proof

N/A: no UI change, and nothing sends hints yet.

Testing

  • I manually tested these changes locally

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

  • Format: a bad pane key, a relative folder and an oversize document are refused; the encoder round-trips.

  • Install, using a real store:

    • an install succeeds, and a retry after a failed install succeeds;
    • a retry is idempotent;
    • a malformed blob is refused before commit, and a damaged installed file is handled;
    • the received blob is deleted after install;
    • hints are dropped when their repo or folder workspace is removed.
  • Terminal creation:

    • a hint is used once;
    • a failed create keeps it and the retry uses it;
    • an explicit folder uses it up;
    • a missing or unenterable folder falls back to the default;
    • a hint for another worktree is ignored;
    • the claim happens before the read.
  • Checks: the capability is advertised, the SSH manifest golden digest is unchanged, and pnpm tc:node, both oxlint configs and the changed-code quality gate pass. The only failing unit test, orca-runtime-agent-session-operation.test.ts, fails the same way on main.

  • Adversarial review: found two MEDIUM issues (a hint used up before the spawn succeeded; a stale hint reaching a later reopen) and three LOW ones (failed installs never retried, a pause before the pane claim, unenterable folders accepted). 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

  • Gate: everything stays behind the internal WSL host gate, and SSH workspaces never use hints.
  • Compatibility: an older server doesn't advertise the hints capability, so the desktop refuses to send hints to it rather than dropping them.

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: 9dd8a979-6766-4ee2-a98a-2449ee0f5bfe
📥 Commits

Reviewing files that changed from the base of the PR and between 232f604 and 02f2834.

📒 Files selected for processing: 23
  • src/main/persistence-orcad-migration-terminal-restore-hints.test.ts
  • src/main/persistence/loading-store/project-collection-operations.ts
  • src/main/persistence/loading-store/repo-lifecycle-operations.ts
  • src/main/persistence/loading-store/store-domain-composition.ts
  • src/main/persistence/loading-store/store-runtime-state.ts
  • src/main/persistence/loading-store/store.ts
  • src/main/persistence/migrating-orcad-catalog/orcad-catalog-import.ts
  • src/main/persistence/migrating-orcad-catalog/orcad-migration-blob-install-persistence.ts
  • src/main/persistence/migrating-orcad-catalog/orcad-migration-blob-installers.ts
  • src/main/persistence/migrating-orcad-catalog/orcad-migration-blob-staging.ts
  • src/main/persistence/migrating-orcad-catalog/orcad-terminal-restore-hint-store.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-restore-hints-blob.test.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-restore-hints-blob.ts
  • src/main/runtime/migrated-pane-restore-cwd.ts
  • src/main/runtime/orca-runtime-create-terminal.ts
  • src/main/runtime/orca-runtime-migrated-pane-restore-cwd.test.ts
  • src/main/runtime/orca-runtime-report-pty-spawn-commit.ts
  • src/main/runtime/orcad-migration-catalog-import.ts
  • src/main/runtime/runtime-store-contract.ts
  • src/shared/orcad-migration-blob-transfer.test.ts
  • src/shared/orcad-migration-blob-transfer.ts
  • src/shared/orcad-migration-terminal-restore-hints.test.ts
  • src/shared/orcad-migration-terminal-restore-hints.ts

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

📝 Walkthrough

The change adds terminal restore hints to Orcad migration blob transfer and persistence. The store validates, persists, and scopes hints to worktrees. Terminal creation can use a matching hint as its cwd and consumes it after spawn commit. Workspace and repo removal clear associated hints. Tests cover format validation, blob installation, retry behavior, cwd restoration, and cleanup.

Estimated code review effort

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 02f28

No merge-blocking issue was identified in the reviewed hint-transfer, installation, terminal-creation, or cleanup paths. Normal checks remain appropriate before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 37.25% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 51 functions across 23 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 primary user-facing change: moved WSL panes reopen in their previous folder on the WSL host.
Description check Passed The description covers the required sections, explains the user impact and implementation, documents testing and compatibility considerations, and marks visual proof as not applicable. The maintainer-…
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.

@nwparker
nwparker merged commit 0b1a600 into main Oct 14, 2026
46 checks passed
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