Skip to content

fix(wsl-mover): settle an interrupted move automatically, and hold the host's server update during a move - #34823

Merged
nwparker merged 4 commits into
mainfrom
nwparker/wsl-move-settle-and-orcad-hold
Oct 28, 2026
Merged

nwparker merged 4 commits into
mainfrom
nwparker/wsl-move-settle-and-orcad-hold

Conversation

@nwparker

@nwparker nwparker commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​313 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​309
Prod 21 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​245 $\color{#cf222e}{\Huge{\mathbf{−}}}$​97 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​148

ELI5

Two fixes for a WSL project move that gets interrupted, found in the audit behind #34813:

  1. If Orca is quit, crashes or updates at one specific moment of a move (after the copy is sent, before the WSL host confirms it), the projects stay read-only after restart. Orca's automatic mover kept retrying without ever fixing it; only starting the move again by hand did. Now the automatic mover checks with the host and either puts the earlier move back (the projects come back right away) or, when the host already has it, records that so the next start finishes it before any window opens.
  2. Updating the WSL host's server in the middle of a move cut the move off. Now, while a move is underway, the host keeps its running server, and the update waits until the move finishes.

What Changed

  • Interrupted commit, before:
    • A blobs-transferred record (copy sent; the commit may or may not have reached the host) can't be resolved at startup, which has no host to ask, so the projects stay fenced.
    • The automatic mover's step always previews first. The preview refuses an in-flight move (wsl_move_already_in_flight), and the orchestrator retries that as an uncounted transient forever, never reaching the start that would settle it.
  • Interrupted commit, after:
    • previewWslMove takes { settleInterrupted: true }, which only the automatic mover's wiring passes. It runs the same settle step a move start runs (settleInterruptedWslMove): it asks the host, then rolls back to zero, or rolls forward when the host committed.
    • An automatic forward settle records the commit (destination-committed) but doesn't run the desktop rewrite. That rewrite reloads the window past its unload veto, so it would mean an unprompted reload mid-session. The next start's rewrite pass finishes it before any window opens. Meanwhile the distro parks (finish-pending) instead of retrying, and the next start puts it back to pending. The user can finish it in-session: their Move (or the status line's Retry) finds the committed head and finishes it on the desktop immediately ('finish-now'), with the existing "finished an earlier move" result.
    • While settling, it claims the distro's move run, so it can never race a move the user starts. If one is already running, it answers wsl_move_already_running and leaves the record to that move.
    • The dialog's preview stays read-only.
    • The preview moved to wsl-move-driver-preview.ts; wsl-move-driver.ts re-exports it.
  • Host server update mid-move, before: deployAndLaunchWslOrcad had no move check. A Settings Update or Force, or a reconnect, could replace the destination's server under a running move. Recovery made that safe, but the move was lost.
  • Host server update mid-move, after:
    • isWslMoveUnderwayOnHost(userDataPath, distro) is true while this process runs a move of the distro that has journaled its own cutover. A run that only settles an earlier record never counts; otherwise an outdated server would be held and the settle would retry forever.
    • When it's true, admitWslOrcadUpdate keeps the running server for any version-changing plan, including Force. It reports a non-forceable deferred update with the new code orcad_update_wsl_move_running, which Settings shows as "Not done: a project is moving onto this server. Orca updates it once the move finishes."
    • The move's own first connect, before it journals, can still update an outdated server, as it did before.

Why

  • Settling. I considered three options:

    • always settling in the preview: that would make the dialog's preview write the journal behind the user's back;
    • having the orchestrator start on an in-flight refusal: that would start a whole move just to settle;
    • settling only in the automatic path, under the same run claim a move uses (chosen).

    It reuses the existing settle step, so the outcomes match a user-started move exactly.

  • The server hold mirrors how SSH hosts already skip auto-updates while a migration is unfinished. It keys on a journaled, running move, so a crash-left record (no run) never holds updates, and the move's pre-journal connect can still bring an old server up to date.

Linked Issue

N/A (internal).

Visual Proof

N/A: one new Settings status string in an internal, gated flow; the localization checks cover it.

Testing

  • wsl-move-driver-preview-settle.test.ts:
    • the read-only preview leaves the record;
    • the automatic preview resets a commit the host never made, lifts the fence and previews the move;
    • for a commit the host made, it records the commit without holding or reloading the window, and the next start's pass finishes it;
    • after an automatic settle records the commit, the user's Move finishes it with one desktop finish;
    • it defers to a move already running.
  • wsl-orcad-update-admission-move-hold.test.ts: connect, update and force all keep the running server with the waiting code while a move is underway, and the update deploys again once no move runs.
  • wsl-move-running-moves.test.ts: underway only between the run journaling its own cutover and the run's end, case-insensitive on the distro, never for a crash-left record, and never for a settle-only run over an earlier record.
  • The orchestrator wiring test pins that the automatic preview asks to settle.
  • pnpm tc, check:code-quality:changed, the localization checks, and the max-lines, test-runner, flaky-test and layout-writer checks pass. The mover, WSL orcad, move IPC and managed-server settings suites (89 files) pass. The full lint and test suites run in CI.

Review

Self-reviewed.

Agent skill upstream boundary

  • Not applicable.

Notes

nwparker added a commit that referenced this pull request Oct 28, 2026
…er holds its own host update

Review of #34823:
- A settle that finds the host committed ran the desktop rewrite, which reloads the window past
  its unload veto. From the automatic mover it now records the commit only (the projects stay
  fenced), and the next start's rewrite pass finishes it before any window opens. A move the user
  starts still finishes at once.
- The server hold counted any unfinished record of the distro, so an automatic settle of an old
  record with an outdated server was held, refused for an update, and retried the same way. The
  hold now counts only the cutover the running move journaled itself.
@nwparker
nwparker force-pushed the nwparker/wsl-move-settle-and-orcad-hold branch from 9aebaed to 123fd37 Compare October 28, 2026 07:18
nwparker added a commit that referenced this pull request Oct 28, 2026
…er holds its own host update

Review of #34823:
- A settle that finds the host committed ran the desktop rewrite, which reloads the window past
  its unload veto. From the automatic mover it now records the commit only (the projects stay
  fenced), and the next start's rewrite pass finishes it before any window opens. A move the user
  starts still finishes at once.
- The server hold counted any unfinished record of the distro, so an automatic settle of an old
  record with an outdated server was held, refused for an update, and retried the same way. The
  hold now counts only the cutover the running move journaled itself.
@nwparker
nwparker changed the base branch from nwparker/wsl-mover-land-2 to main October 28, 2026 07:18
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

The move driver now supports separate settlement behavior for user-requested and automatic previews. The orchestrator tracks host-committed moves that still need desktop completion as finish-pending. Active host moves are also detected during Orcad update admission, where updates can be deferred until the move finishes. Tests cover settlement, orchestrator triggers, move detection, and update admission.

Priority: Normal

Estimated code review effort:

Merge Risk: Moderate · up to c2c85

Version-changing WSL server updates are meant to be deferred while a project move is running, but one fallback path can still deploy a new server version during the move. Decide how that path should behave before merging, taking care not to block the move's own connection.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 17.65% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… 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 summarizes both primary changes: automatic settlement of interrupted WSL moves and deferral of host server updates during moves.
Description check Passed The description is mostly complete. It explains the user impact, implementation, rationale, testing, visual proof, scope, and review status. The linked issue is marked N/A for an internal change, and …
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.
Full details: Description check

Explanation

The description is mostly complete. It explains the user impact, implementation, rationale, testing, visual proof, scope, and review status. The linked issue is marked N/A for an internal change, and the omitted checklist does not prevent understanding or review.

Full details: Docstring Coverage

Explanation

Docstring coverage is 17.65% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 17 functions across 26 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

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.

…e host's server update during a move

An app update or crash between sending a move's copy and the host's commit leaves a
`blobs-transferred` record. Startup recovery has no host to ask, so the projects stay fenced, and
the automatic mover only previewed, which refuses an in-flight move, retrying forever. The
projects stayed read-only until the user started the move from the dialog. The automatic mover's
preview now settles that record first (through the host: back to zero, or forward when the host
committed), holding the distro's run while it does so it never races a move the user starts. The
dialog's preview stays read-only. The preview moves to its own module.

A Settings Update or Force, or any reconnect, could also redeploy the host's server in the middle
of a move, cutting it off (safe, but the move is lost). Once a running move has journaled, a
version-changing redeploy now keeps the running server and reports the update as waiting for the
move, mirroring the SSH path's skip while migrating. The move's own first connect, before it
journals, can still update an outdated server.
…er holds its own host update

Review of #34823:
- A settle that finds the host committed ran the desktop rewrite, which reloads the window past
  its unload veto. From the automatic mover it now records the commit only (the projects stay
  fenced), and the next start's rewrite pass finishes it before any window opens. A move the user
  starts still finishes at once.
- The server hold counted any unfinished record of the distro, so an automatic settle of an old
  record with an outdated server was held, refused for an update, and retried the same way. The
  hold now counts only the cutover the running move journaled itself.
… the automatic mover meanwhile

After an automatic settle records a commit for the next start, nothing could finish it in-session:
the user's Move refused as already in flight and the orchestrator retried for nothing.

- A settle that finds the head committed but not yet rewritten on this desktop finishes it now when
  the user asked (their Move, or the status line's Retry), returning the existing "finished an
  earlier move" answer; the automatic mover still leaves it for the next start.
- The automatic refusal carries detail `finish-pending`, which parks the distro (new reason
  `finish-pending`) instead of retrying; the next start, whose rewrite pass finishes the move before
  any window opens, puts it back to pending.
- The park rules move to wsl-move-orchestrator-park.ts.
Main's move status line (#34676) names every park reason; the finish-pending reason this PR adds
needs one: the earlier move is done on the host, and finishes here at restart or with Check again.
@nwparker
nwparker force-pushed the nwparker/wsl-move-settle-and-orcad-hold branch from aeaf130 to c2c85f1 Compare October 28, 2026 08:21

@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.

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0f90133f-33fb-449b-aafe-283759256335
Commits

Reviewing files that changed from the base of the PR and between 96cd21b and c2c85f1.

Files selected for processing: 27
  • src/main/ipc/wsl-move-orchestrator-wiring.test.ts
  • src/main/ipc/wsl-move-orchestrator-wiring.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-driver-plan.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-driver-preview-settle.test.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-driver-preview.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-driver.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-orchestrator-external-transitions.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-orchestrator-park.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-orchestrator-ports.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-orchestrator-step.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-orchestrator-store.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-orchestrator-transitions.test.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-orchestrator-transitions.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-running-moves.test.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-running-moves.ts
  • src/main/telemetry/wsl-move-orchestrator-telemetry.ts
  • src/main/wsl/wsl-orcad-deploy.ts
  • src/main/wsl/wsl-orcad-update-admission-move-hold.test.ts
  • src/main/wsl/wsl-orcad-update-admission.ts
  • src/renderer/src/components/settings/managed-server-copy.ts
  • src/renderer/src/components/wsl-move/wsl-move-orchestrator-copy.ts
  • src/renderer/src/components/wsl-move/wsl-move-orchestrator-status.test.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/shared/telemetry-wsl-move-event-schemas.ts
  • src/shared/wsl-host-types.ts
  • src/shared/wsl-move/wsl-move-driver-types.ts
  • src/shared/wsl-move/wsl-move-orchestrator-types.ts

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

failedBefore: failure !== null
})
if (plan.action !== 'skip' || plan.reason === 'current') {
const heldForMove = args.moveRunning === true && plan.action === 'update'

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.

Major · Stability & Availability · Heavy lift

Supported by static analysis

Script executed:

sed -n '1,140p' src/main/wsl/wsl-orcad-update-admission.ts
sed -n '1,120p' src/main/ssh/orcad-running-version-adoption.ts

Repository: stablyai/orca

Length of output: 8667


Script executed:

rg -n -F --glob '*.ts' -e 'moveRunning' -e 'admitWslOrcadUpdate' -e 'admitWslOrcadLaunch' -- src/main || test "$?" -eq 1
rg -n -F --glob '*.ts' -e 'ORCAD_UPDATE_WSL_MOVE_RUNNING_CODE' -- src/main || test "$?" -eq 1

Repository: stablyai/orca

Length of output: 2047


Script executed:

rg -n -F --glob '*.ts' -e 'isWslMoveUnderwayOnHost' -- src/main || test "$?" -eq 1
sed -n '165,200p' src/main/wsl/wsl-orcad-deploy.ts

Repository: stablyai/orca

Length of output: 2834


Apply the move hold when adoption returns null.

When moveRunning is true and the plan is update, the !adopted branch returns action: 'deploy' on the re-read record. It does not check heldForMove, which is applied only to the serve result. The deploy can then activate candidateVersion while the move runs. The PR's stated contract defers version-changing WSL server updates while a running move is in progress, so this path can violate that contract.

The correction needs a decision in the !adopted branch. A deferral that keeps the incumbent version does not apply when no server runs. Keep the move's own connection able to reach a server, or the move can stall. Limit any deferral to version-changing updates.

@nwparker
nwparker merged commit 21ad2d9 into main Oct 28, 2026
65 of 66 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