Repository navigation
refactor(wsl-hosts): add flow in wsl-host-registration; liveness split into state, evidence and monitor - #29506
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to
|
484a1b1 to
4eb5bf8
Compare
…eview; pin main's release on a failed connect
…t liveness into state, evidence and monitor
4eb5bf8 to
bab0c15
Compare
ELI5
Two WSL-host files had grown to do too many things. One mostly handled day-to-day hosts but also held the whole "add a new WSL host" procedure. The other was called a "model" but held timers, wake-up handling and evidence gathering. This PR moves code into files named for what they do. The code itself doesn't change. WSL hosts stay behind an internal switch that is off, so no user can see any of this.
What Changed
Nothing a user can see. Under the hood:
wsl-host-service.tsinto the newwsl-host-registration.tsasregisterWslHost. That procedure is: refuse, admit, check for an orcad this desktop already reaches, connect, save, and undo the connection if the save fails. The service keeps everything else and still makes sure two adds for the same distro share one in-flight attempt. The service file drops from 351 to 289 lines.wsl-orcad-liveness-model.tsis split three ways.-stateholds the dependencies, the per-distro record, creating it and disarming it.-evidenceholds exit classification, the running-list check and evidence gathering.-monitorholds timers, the power-resume wake, the holder re-ensure and the held watch. The function bodies are identical: I compared the old file's lines against the three new files' lines and they match as a set.Why
Smaller files with concrete names are easier to review. They also keep the active WSL work from colliding in one large file. I chose plain moves over redesigning the supervisor so that the change stays mechanical and easy to check.
Linked Issue
N/A (maintainer cleanup; internal plan items 10 and 11)
Visual Proof
N/A: no visual or interaction change. Code moves only.
Testing
The first commit only adds tests, and they pass against the old code:
The same tests pass after the move.
tsc(node project), vitest for all ofsrc/main/wsland the WSL IPC tests (433 passed), andpnpm run check:code-quality:changed(0 findings).E2E: I started the WSL fake-transport spec and the SSH-on-managed-orcad specs by hand. This PR also triggers the real-WSL-distro lane through its path filter.
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
Notes
SSH: untouched. Windows/WSL: the gate stays closed, and the WSL commands and their order are unchanged. Wire and on-disk formats: no change.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Risk rating (final): LOW
main(rebased 2026-10-20) after upstream changed the add flow:wsl-host-first-connect.ts, and a failed connect now releases the connection and the distro holder.The add flow was re-extracted from
main's current code. Those upstream changes are in it unchanged; the registration module reads the turned-off count through a getter that the service provides.main's new release-on-failed-connect behaviour, and verified againstmain's unmodified service before the move.main's new importerwsl-host-connector.tsnow imports from-evidence. The function bodies still match the old module line for line.WSL2 distros (systemd off and on)on real WSL andreal WSL terminal.