Skip to content

perf(wsl-host): start booting only the focused WSL host early at launch (E9, replaces #33141) - #33924

Merged
nwparker merged 3 commits into
mainfrom
nwparker/wsl-host-early-wake-focused
Oct 26, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/wsl-host-early-wake-focused

Conversation

@nwparker

@nwparker nwparker commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

After a reboot, the WSL distro you were working in is switched off, and switching it on takes a few seconds. Orca now remembers which WSL host you last had focused and starts switching that one distro on at the very beginning of the next launch, while the rest of the app loads. Other distros you had tabs in are never touched.

What Changed

This replaces #33141, which started booting every distro the last run had open work on. Its early-boot mechanism (wsl-host-early-wake.ts, run from src/main/index.ts) is kept unchanged. What changes is what gets remembered:

  • Each focus entry from fix(wsl-host): boot only the focused WSL host, and keep a stopped one down (E9 A) #33838 (the user switching to a workspace on a WSL host, including the launch restore) records just that host's distro.
  • A focus entry on a workspace that isn't on WSL (sent as focusHost({ environmentId: null })) clears it. So does turning WSL hosts off, or a host that can't run.
  • The list is authoritative, because the early wake runs before settings load:
    • turning WSL hosts off deletes it synchronously (and empties it if the delete fails);
    • removing a host drops it;
    • a missing or unreadable list wakes nothing.
  • Next launch, if that distro is still a registered WSL host, wsl.exe -d <distro> --exec true starts it booting in the background. The focus entry that follows does the real connect.

Why

Linked Issue

WSL re-write, gate E9. Based on main (#33838 merged). Supersedes #33141 and #33111.

Visual Proof

N/A: no UI.

Testing

  • wsl-host-service.test.ts: open work alone isn't remembered; a focus entry remembers its host; a null focus and turning WSL hosts off clear it; removing the host forgets it, even if the distro is re-added.
  • wsl-host-early-wake.test.ts: turning WSL hosts off deletes the file and the next launch wakes nothing; a removed host is forgotten even while its record is still on disk.
  • wsl-host-ipc-bridge-focus.test.ts: the bridge sends a null focus entry when the user leaves WSL and the host again on return.
  • wsl-host-early-wake.test.ts (from perf(wsl-host): start booting the distros the last run had open work on as the app launches #33141): only remembered, still-registered hosts are woken.
  • pnpm tc:node, pnpm tc:web, the touched tests, and pnpm run check:code-quality:changed. The machine was too loaded for a full local pnpm lint, so CI runs it.

Review

Self-reviewed. The early-wake mechanism itself was reviewed in #33141.

Agent skill upstream boundary

  • Not applicable.

Notes

  • Flag-off: the early wake runs only on Windows with the internal gate open. Turning the Experimental switch off deletes the list synchronously, so the next launch wakes nothing. With the gate closed, nothing is read or spawned.
  • There is no pendingStop field on host records yet. Once E11 adds it, the wake should skip those records too; until then the registered-host filter covers removed records.

Gated like the rest of the WSL host code (internal gate, Windows only).

@nwparker
nwparker force-pushed the nwparker/wsl-host-early-wake-focused branch from 9bb7590 to 3cfcfdf Compare October 26, 2026 19:16
nwparker added a commit that referenced this pull request Oct 26, 2026
…, forgotten on Remove

Review of #33924: the early wake runs before settings load, so it can't read the WSL
hosts setting. Turning WSL hosts off now deletes the list synchronously (emptying it
if the delete fails; a missing or unreadable list wakes nothing), and removing a host
drops it from the list. There is no pendingStop field on host records yet (E11); the
existing registered-host filter covers removed records until then.

Co-Authored-By: Claude <[email protected]>
@nwparker
nwparker force-pushed the nwparker/wsl-host-early-wake-focused branch from 3cfcfdf to 0f1c930 Compare October 26, 2026 20:12
@nwparker
nwparker changed the base branch from nwparker/wsl-host-visible-work-policy to main October 26, 2026 20:12
@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent 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: cf2b0422-a052-4f1e-9724-71731c85a359
Commits

Reviewing files that changed from the base of the PR and between 0f1c930 and 63ff2d4.

Files selected for processing: 2
  • src/main/wsl/wsl-host-service.test.ts
  • src/main/wsl/wsl-host-service.ts

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

Walkthrough

The focus API now accepts a nullable environment ID, and the renderer sends null when no WSL host is focused. The service records runnable focused hosts in a persisted wake list and clears entries when focus is cleared, support is disabled, or a host is removed. On Windows, after preflight and when the WSL host gate is open, startup attempts to wake remembered hosts that remain deployed. Tests cover focus updates, wake-list handling, and startup selection.

Priority: Low

Merge Risk: Low · up to 63ff2

Stale remembered WSL hosts may still be started on a later launch; this persistence failure should be fixed before merge.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 9 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 and concisely describes the main change: early boot now starts only the focused WSL host and identifies the related policy context.
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.
Description check Passed The description is detailed and covers the change, rationale, testing, visual proof, review notes, and platform constraints. It omits the repository checklist and does not provide an explicit issue li…
Full details: Description check

Explanation

The description is detailed and covers the change, rationale, testing, visual proof, review notes, and platform constraints. It omits the repository checklist and does not provide an explicit issue link or Fixes #... reference, but the main required information is present.

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.

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: 33777556-f9af-4d14-91a4-aa4573cc6da0
Commits

Reviewing files that changed from the base of the PR and between 33a86f3 and 0f1c930.

Files selected for processing: 9
  • src/main/index.ts
  • src/main/ipc/wsl-host-handlers.ts
  • src/main/wsl/wsl-host-early-wake.test.ts
  • src/main/wsl/wsl-host-early-wake.ts
  • src/main/wsl/wsl-host-service.test.ts
  • src/main/wsl/wsl-host-service.ts
  • src/preload/api/wsl-hosts-api.ts
  • src/renderer/src/hooks/ipc-events/wsl-host-ipc-bridge-focus.test.ts
  • src/renderer/src/hooks/ipc-events/wsl-host-ipc-bridge.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.

Comment on lines +50 to +52
} catch (error) {
console.warn('[wsl-hosts] Could not save the distros to wake at next launch:', error)
}

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.

Minor · Data Integrity & Integration · Quick win

Remove the stale wake list when saving a replacement fails.

If a valid wake list contains Ubuntu and a later focus update cannot write its replacement, this catch leaves Ubuntu in the file. On the next launch, wakeRememberedWslHosts can still boot Ubuntu, even after focus moved off WSL. Attempt to delete the old file when the replacement write fails, and report a failure if the old file cannot be removed.

nwparker and others added 3 commits October 26, 2026 14:04
…on as the app launches

The WSL host connect can only start once the store has loaded, about 1.5-2 s into
startup on a slow PC, and its first command then waits for the distro to boot.
The service now remembers which distros had open work, and the next launch starts
booting just those right after taking the single-instance lock.
…ces #33141's list)

open work on, which conflicts with E9 (a launch boots only the focused host). Each
focus entry now records just that host's distro for the next launch's early boot,
and focusing a workspace off WSL (reported as a null focus entry), turning WSL hosts
off, or a host that can't run clears it.

Co-Authored-By: Claude <[email protected]>
…, forgotten on Remove

Review of #33924: the early wake runs before settings load, so it can't read the WSL
hosts setting. Turning WSL hosts off now deletes the list synchronously (emptying it
if the delete fails; a missing or unreadable list wakes nothing), and removing a host
drops it from the list. There is no pendingStop field on host records yet (E11); the
existing registered-host filter covers removed records until then.

Co-Authored-By: Claude <[email protected]>
@nwparker
nwparker force-pushed the nwparker/wsl-host-early-wake-focused branch from 0f1c930 to 63ff2d4 Compare October 26, 2026 21:11
@nwparker
nwparker merged commit 2e67ba5 into main Oct 26, 2026
45 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