Skip to content

feat(wsl): serve saved WSL work behind a closed hosts gate (gate states, kill switch 1/2) - #34683

Merged
nwparker merged 3 commits into
mainfrom
nwparker/wsl-kill-switch-gate-states
Oct 28, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/wsl-kill-switch-gate-states

Conversation

@nwparker

@nwparker nwparker commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​402 $\color{#cf222e}{\Huge{\mathbf{−}}}$​31 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​371
Prod 20 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​182 $\color{#cf222e}{\Huge{\mathbf{−}}}$​38 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​144

Based on main at 1eaaf85e9fd (after #34059 merged). #34694 stacks on this PR.

ELI5

Today, if the internal WSL hosts switch is turned off, every WSL host and every project already moved onto one disappears, and those projects just break. This gives the switch a middle position. When it's off but you already have WSL hosts or moved projects, Orca keeps serving them (serve-only), while nothing new can be added or moved. With nothing saved, "off" behaves exactly as before.

What Changed

Gate states (src/shared/wsl-host-internal-gate.ts, src/main/wsl/wsl-host-gate.ts):

  • open: ORCA_INTERNAL_WSL_HOSTS=1, unchanged.
  • serve-only: the gate is closed, but this profile has a saved WSL host (a record in the WSL host deployment store) or any entry in the WSL move journal, committed or not. Recovery can then still reset an in-flight move whose host record is already gone.
  • closed: neither exists. This is today's closed gate.
  • configureWslHostsGateFromDisk (new wsl-host-gate-startup.ts) reads those two facts once, early in src/main/index.ts, before any gate check. The result is fixed for the run, since nothing can create a host or a move while the gate isn't open. Unreadable state counts as absent, which means closed.

New helper and call sites: wslHostsServing() (open or serve-only).

  • Use it:
    • isGatedOffWslHost, so runtime environments are listed, connected, removed and tunneled, and the session scanner sees saved hosts;
    • the WSL host service (wsl-host-handlers.ts): holders, reconnect and automation wake;
    • the early distro wake;
    • the committed-move desktop rewrite passes (startup, after a move, retry, renderer rewrites);
    • retention;
    • interrupted-move recovery;
    • "Use on this computer again" (wsl-move-use-locally, wslMove:useProjectHereAgain).
  • Also serving: the unfinished-move list (wslMove:listUnfinished).
  • Still need the open gate: move preview, start and cancel, the move orchestrator and move planning. wslHosts:add is refused (kind: 'disabled') unless the gate is open, here in this PR, so it's safe on its own. The renderer hiding comes in the next PR.
  • Shared readers: main notes serve-only in the shared gate module (noteWslHostsServeOnly), so readWslHostDeploymentsForRegistry fails closed on an unreadable store in serve-only, as it does with the gate open.
  • Telemetry: wsl_usage_snapshot gains an optional wsl_hosts_gate_state (open / serve-only / closed). It's optional, so older payloads still validate.

Preload: it can't read the disk, so every window on the shared preload (the main window, the dashboard popout and the Space window) gets --orca-wsl-hosts-serve-only in its additionalArguments when the state is serve-only, from one helper, wslHostsWindowArguments(). getWslHostsApi then exposes the API, still only on Windows or under the e2e fake. Outside serve-only the popout and Space windows get no additionalArguments key, as before.

Flag-off: with no saved WSL host and no committed move, the state is closed, and every gated path returns exactly what it does today.

  • The only new work is the startup read of two files.
  • The deployment store is read only if it exists.
  • The move journal directory is listed only if it exists. When it exists, it can sweep its own orphaned temporaries, but that directory exists only for profiles that once moved a project.

Why

The design (wsl-kill-switch.md, section 3) chose "block new moves, keep serving moved projects" over auto-undo (it would end live orcad sessions) and over read-only (it breaks running agents for no safety gain). Saved WSL work, rather than a new setting, decides the promotion: a user who never used WSL hosts can't reach any of this.

Linked Issue

N/A (WSL hosts kill switch, PR1 of the design).

Visual Proof

N/A: the screens are unchanged. Serve-only shows the saved host where an open gate would. The e2e saves wsl-hosts-serve-only-settings.png.

Testing

  • wsl-host-internal-gate.test.ts: state resolution and the argv flag.

  • wsl-host-gate.test.ts:

    • flag-off closed, exactly as before;
    • serve-only for a saved host or a committed move, while the gate itself stays closed;
    • unreadable state means closed;
    • an open gate reads nothing;
    • closed before startup configures it.
  • wsl-host-gate-startup.test.ts (real files): a profile that never had WSL work stays closed and creates nothing; a saved host promotes; a committed move promotes; an uncommitted move does not.

  • wsl-hosts-api.test.ts: the stamped argv exposes the API, still Windows or fake only.

  • dashboard-popout-window.test.ts and the new workspace-space-window.test.ts: both windows carry the argument in serve-only. The popout carries none otherwise. wsl-host-gate.test.ts checks that the helper stamps only in serve-only.

  • e2e wsl-host-fake-transport.spec.ts, split the gate-closed case in two. Both pass locally, hidden (ORCA_BACKGROUND_LAUNCH=1).

    • Closed with nothing saved: no WSL surface, nothing created.
    • Closed with a saved host (serve-only): the API is present, the host is listed and connects through the fake, it's shown in Settings → Servers, and it stays on disk.
    • A moved repo is not exercised in e2e; the committed-move promotion is covered by the unit tests.
  • The 50 existing suites that import the touched modules pass (455 tests). pnpm tc, typecheck:ci, oxlint, the anti-slop lint, ast-grep-gates.mjs, check:code-quality:changed and check:process-host-imports pass.

  • I manually tested these changes locally

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

AI Disclosure

Review

This widens what a closed gate reaches (risk: medium). Please review alongside the next PR, which closes add-host in serve-only.

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

  • Desktop only. Nothing changes on the wire, and orcad and SSH hosts don't see it. Every check still keys on orcadDeployment.kind === 'wsl'.
  • Telemetry: wsl_hosts_gate_open still reports the internal gate itself, and wsl_hosts_gate_state adds the promoted state.

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)

The WSL hosts gate gains three states. A closed gate with a saved WSL host or a
committed move becomes serve-only: saved hosts stay listed and reachable,
committed rewrites, retention, interrupted-move recovery and the way back keep
running, and the preload API is exposed through a stamped window argument.
Adding hosts and starting moves still need the open gate. With nothing saved
the gate stays closed exactly as before.
…s too

They load the same preload, so without the argument they hid saved WSL hosts'
status and Connect in serve-only. One helper now supplies the argument for every
window on the shared preload.
- Refuse wslHosts:add unless the internal gate is open here, so this PR is safe
  on its own.
- Promote on any move journal entry, so recovery can reset an in-flight move
  whose host record is gone.
- List unfinished moves in serve-only.
- An unreadable WSL deployment store fails closed in serve-only too, through a
  shared serving flag main sets at startup.
- Report the gate state in wsl_usage_snapshot as an optional field.
@nwparker
nwparker force-pushed the nwparker/wsl-kill-switch-gate-states branch from d5c4907 to b4b8acf Compare October 28, 2026 07:20
@nwparker
nwparker changed the base branch from nwparker/wsl-mover-land-2 to main October 28, 2026 07:20
@coderabbitai

coderabbitai Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 6 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

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: 236baedf-d827-4dfc-afb7-f473539ac936
Commits

Reviewing files that changed from the base of the PR and between b287531 and b4b8acf.

Files selected for processing: 31
  • src/main/index.ts
  • src/main/ipc/wsl-host-handlers-user-actions.test.ts
  • src/main/ipc/wsl-host-handlers.ts
  • src/main/ipc/wsl-move-handlers.test.ts
  • src/main/ipc/wsl-move-handlers.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-desktop-rewrite.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-reset.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-retention.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-rewrite-retry.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-startup-rewrite.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-use-locally.ts
  • src/main/telemetry/wsl-usage-reporter.ts
  • src/main/telemetry/wsl-usage-snapshot.test.ts
  • src/main/telemetry/wsl-usage-snapshot.ts
  • src/main/window/createMainWindow.ts
  • src/main/window/dashboard-popout-window.test.ts
  • src/main/window/dashboard-popout-window.ts
  • src/main/window/workspace-space-window.test.ts
  • src/main/window/workspace-space-window.ts
  • src/main/wsl/wsl-host-gate-startup.test.ts
  • src/main/wsl/wsl-host-gate-startup.ts
  • src/main/wsl/wsl-host-gate.test.ts
  • src/main/wsl/wsl-host-gate.ts
  • src/preload/api/wsl-hosts-api.test.ts
  • src/preload/api/wsl-hosts-api.ts
  • src/shared/runtime-environment-store-file.ts
  • src/shared/telemetry-wsl-usage-event-schemas.ts
  • src/shared/wsl-host-deployment-store.test.ts
  • src/shared/wsl-host-internal-gate.test.ts
  • src/shared/wsl-host-internal-gate.ts
  • tests/e2e/wsl-host-fake-transport.spec.ts
  • 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 ad8d35e into main Oct 28, 2026
2 checks passed
nwparker added a commit that referenced this pull request Nov 2, 2026
…only Settings (#37394)

wsl-host-paired-phone asserted the pre-#36771 'isn't running' copy; it now
asserts the stable remote_runtime_unavailable code and '<distro> is stopped'.

wsl-move-dialog's gate-closed case seeds a saved host, which since #34683 puts
the app in serve-only: the WSL hosts section still lists the host. Assert
instead that Add is hidden and the host row's menu has no move entry.

Co-authored-by: Claude <noreply@anthropic.com>
nwparker added a commit that referenced this pull request Nov 6, 2026
…ery keeps

Since #34683 a move journal promotes the WSL hosts gate to serve-only, so startup
recovery now runs and undoes a move interrupted before blobs-transferred. The
spec restarted at source-fenced and expected the fence to survive; assert the
undo there, fence from blobs-transferred, and expect the committed refusal to
name the host (#34880). Route fence and recovery sources to the spec.

Co-Authored-By: Claude <noreply@anthropic.com>
nwparker added a commit that referenced this pull request Nov 6, 2026
…ery keeps (#39200)

Since #34683 a move journal promotes the WSL hosts gate to serve-only, so startup
recovery now runs and undoes a move interrupted before blobs-transferred. The
spec restarted at source-fenced and expected the fence to survive; assert the
undo there, fence from blobs-transferred, and expect the committed refusal to
name the host (#34880). Route fence and recovery sources to the spec.

Co-authored-by: Claude <noreply@anthropic.com>
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