Repository navigation
fix(wsl): keep the desktop pairing across host restarts - #29042
Conversation
|
Problem. When the Orca server inside a WSL distro restarted, the desktop threw away its saved pairing and enrolled as a brand-new client from the server's fresh startup pairing offer. To the host that was a different caller, so a worker the desktop had already started there became unreachable ("dispatch not found") even though the host still had it. User-facing change. Restarting the WSL server, or the desktop, no longer cuts the desktop off from work it started on that host. The desktop reconnects with the pairing it saved and the host key it pinned, and only picks up the server's new bridge address. A desktop whose pairing was revoked on the host is still refused, and removing and re-adding the host still creates a new pairing that cannot claim the old work. Review. One full Final head Verified.
Deferred.
For Brennan's review
|
|
Windows QA for head 5f9723e (Windows high spec, real signed-in Claude Code 2.1.302 inside a throwaway WSL2 distro, Codex driving the UI over CDP) Note: steps 4-7 below ran on the #29106 head (7f2c19b), which contains this PR. This PR's own head was used only for the comparison at the end.
Comparison with this PR alone (5f9723e): after a desktop restart that moved the local connection port, this PR alone cleared the selected workspace and dropped the editor and Claude tabs. On the #29106 head the same kind of restart kept the selection and all tabs. Side notes: after the pairing was rejected, the host row said "Failed to start — Could not restart the Orca server in OrcaQaB3 after 7 attempts" although the server was running; the real reason (pairing rejected) only shows in the log. Also, after re-pairing, the desktop accepted a message to the old dispatch without an error, though the host correctly never received it. Real Claude worker in the distro, started from the desktop coordinator: After the simulated revoke, reconnect fails: This PR alone after a desktop restart: no workspace selected and the tabs are gone: Final head 31240e4 = QA'd head 5f9723e plus a main merge; CI green on it |
…stable-client-identity # Conflicts: # src/main/wsl/wsl-orcad-connection.ts # src/main/wsl/wsl-orcad-pairing-identity.ts
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
…stable-client-identity
…onnection under its line limit
Its CI ran before #30863 added the check. Formatting pushed wsl-orcad-connection.ts past its line limit, so its port-fallback listen moves next to the stdio bridge it wraps.
… rollback and recovery orcad's startup offer names a pending device, which it re-mints once a client has paired with it. Update, rollback and recovery re-paired the desktop from that offer, so the desktop became a new device to its host after each one. They now keep the enrolled grant, as WSL does since #29042.
… rollback and recovery orcad's startup offer names a pending device, which it re-mints once a client has paired with it. Update, rollback and recovery re-paired the desktop from that offer, so the desktop became a new device to its host after each one. They now keep the enrolled grant, as WSL does since #29042.
… rollback and recovery orcad's startup offer names a pending device, which it re-mints once a client has paired with it. Update, rollback and recovery re-paired the desktop from that offer, so the desktop became a new device to its host after each one. They now keep the enrolled grant, as WSL does since #29042.
… rollback and recovery (#31684) * fix(ssh): keep the enrolled pairing across a managed server's update, rollback and recovery orcad's startup offer names a pending device, which it re-mints once a client has paired with it. Update, rollback and recovery re-paired the desktop from that offer, so the desktop became a new device to its host after each one. They now keep the enrolled grant, as WSL does since #29042. * fix(orcad): count WSL incumbent terminals with the enrolled pairing, and warn on a changed host key The WSL incumbent's terminal count authenticated with the startup offer, which marked that pending device used, so every orcad start enrolled another device. It now uses this desktop's enrolled pairing. After an SSH update, rollback or recovery, a server that names a host key other than the pinned one is reported with a warning instead of a plain success. * fix(ssh): keep a pairing the terminal count repaired; leave the host-key warning to a follow-up The census can repair a refused pairing before the update re-pairs, so the enrolled grant is re-read from the store rather than taken from the copy read first. The host-key warning goes back out: only the CLI would show it, and surfacing it in the desktop lifecycle UI is a separate change. * refactor: keep two touched files under the line limit after rebasing onto main refreshPairing reads the enrolled offer in one statement, and the WSL connection error classes move into their own file.



ELI5
Restarting a WSL host made the desktop forget who it was to that host. A federated worker could then report “dispatch_not_found” even though its saved dispatch still existed, because the host correctly refused access from the desktop's new identity. The desktop now keeps the same pairing across host restarts, so restart recovery can reach the existing worker.
What Changed
The host's device registry and encryption key already survive restart. Startup publishes a pairing offer for a new client, but WSL was replacing its existing, authenticated credential with that new offer. WSL now follows the existing managed SSH behavior: keep the saved client credential and pinned host key, and update only the bridge address. An existing bridge also verifies that saved credential when reconnecting, and a registered host with missing or unreadable saved credentials refuses reconnect rather than silently enrolling again. Revoked credentials and another host's key remain refused; explicit re-pairing establishes a different caller.
Neil's C5/C7 files touched:
src/main/wsl/wsl-orcad-connection.ts,src/main/wsl/wsl-orcad-connection.test.ts,src/main/wsl/wsl-host-connector.ts,src/main/wsl/wsl-host-connection-record.ts,src/main/wsl/wsl-orcad-pairing-identity.ts, andsrc/shared/runtime-environment-wsl-host-store.ts. The shared tunnel pairing encoder accepts an optional existing pairing; existing SSH callers retain their behavior.Why
Ownership belongs to a paired client, not a server process. Reusing the saved pairing fixes federation ownership, native-chat caller ownership, and delegated phone parentage together, without adding another identity store or weakening federation's ownership check. Notification replay already uses event IDs and epochs, and client capabilities are negotiated on each connection.
The common pattern retains enrollment across daemon restarts. Intended difference: Windows still reaches the host through the existing WSL stdio bridge; changing transport is unnecessary for stable enrollment. Existing gates remain in place, and no wire format changes are required for older hosts.
Linked Issue
Live Windows QA finding F1 in QA-PR11-REPORT.md: restarting the guest server changed the caller and prevented federated-worker recovery.
Visual Proof
N/A. Connection identity and restart recovery change; no UI elements change.
Testing
One real authenticated RPC contract covers retaining the caller across host and desktop connection-manager restarts, refusing a revoked pairing, and changing the caller after explicit re-pairing. The bridge lifecycle test now expects startup offers to leave the enrolled identity intact. CI runs the checks; local lint, typecheck, tests, and builds are prohibited on this shared Mac for this lane.
CI passed on
5f9723e0a78b89b7f2d33f955689751050d7df26: PR workflow and aggregate gate, including static analysis/typecheck, all five unit shards, relay integration, and both packaging jobs. Completed logs confirm all 3 managed-tunnel restart tests and all 14 WSL connection tests passed. WSL2 systemd off/on also passed.Windows QA handed to the coordinator: use a disposable imported distro and isolated profiles, launch a federated worker, record the pairing device ID and caller fingerprint without logging the token, restart only the recorded guest server PID mid-dispatch, then reconnect and verify the same dispatch is found and recovers without a duplicate worker. Recreate the desktop connection and repeat; explicit revoke must fail closed, and explicit re-pair must create a different caller without granting access to the old caller's dispatch.
Review
The saved host key and credential are still verified. Federation's exact fingerprint comparison is unchanged. No mover internals or new persisted fields are involved.
Agent skill upstream boundary
Notes
WSL-specific connection selection stays in WSL code. Managed SSH behavior, Linux execution ownership, folder workspaces, and mixed-version protocol compatibility are preserved. Attachments already orphaned by a discarded pre-fix credential are not reassigned to another caller. Live Windows mid-dispatch recovery is pending coordinator QA; the RPC contract is transport-independent and does not prove that live workflow.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)