Repository navigation
fix(wsl): account sync and usage previews never boot a stopped WSL distro (E9) - #35387
Conversation
…stro (E9) Four account paths touched WSL distros in the background: - Every launch mirrored ~/.codex/config.toml into each WSL Codex account home over UNC. - Inactive Codex usage previews read a WSL home that nobody had checked. - The startup Claude publish and inactive Claude previews trusted an unsettled running list. Any of these booted a stopped distro, or one still stopping. The mirror now skips WSL homes not seen running after any stop; launch preparation syncs them before use. The other three use the settled running gate.
|
Warning Review limit reachedYou'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 16 minutes. View limit details
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. Comment |
[Medium impact] The PR appears safe to merge, with one non-blocking preview race still open from the previous review. Findings
SummaryThe PR keeps background account work from starting stopped WSL distros.
Reviews (2) · Last reviewed commit: "fix(wsl): the Codex mirror trusts only a..." · Reviewed by Greptile |
| } | ||
| } | ||
| const home = account.resolveHome() | ||
| const home = await account.resolveHome() |
There was a problem hiding this comment.
Preview outlives account changes
resolveHome() now waits for the WSL check, but the loop does not recheck whether the account is still inactive afterward. If the user selects or removes that account while the check waits, the loop still starts a preview against its old home. The check after fetchCodexRateLimits() discards the result, but cannot prevent the extra reads and usage request.
Recheck the account and fetchGeneration after this new await, before marking it as fetching.
WSL's own idle stop is reported by nothing, so an old list must not vouch for a distro. Drop the inert user-act clause: select and sign-in do not run as WSL user acts.
Flag-off: Not WSL-host-specific. On main these paths run on any Windows desktop with WSL Codex or Claude managed accounts (bridge users included), so this fixes them flag-off too.
User-risk: Low. At launch, a stopped distro's Codex account home is not re-mirrored from
~/.codex/config.toml. Launch preparation already syncs that home before every Codex launch, which is a user act. An inactive Codex or Claude account whose distro is stopped shows "usage unavailable" until it runs, the same as a stopped distro showed before when the list caught it.ELI5
Orca must never start a WSL distro you stopped unless you ask (rule E9). Four background account tasks could start it anyway: copying Codex settings at every app launch, previewing usage for accounts you aren't using, and publishing Claude accounts at startup. Now each one checks the distro is really running first, and skips it if not.
What Changed
codex-config-mirror.ts). Before: every launch read~/.codex/config.tomlover\\wsl.localhostfor every WSL Codex managed account, which booted every such distro. Select and sign-in did the same for all distros. After: a WSL home is synced only when the lastwsl --list --runningboth named the distro and was probed after any stop settled (wasWslDistroLastSeenRunningSettled). That list must also be at most 60 s old (maxAgeMs: WSL_UNC_RUNNING_LEASE_MS), because WSL's own idle stop is reported by nothing. Otherwise the sync is skipped, and Codex launch preparation syncs that home before use. Select and sign-in take the same check; neither runs as a WSL user act, so neither passes it by being a click.auth.jsonover UNC and ranwsl --exec codex app-server; the switcher expand and the phone'saccounts.subscribeorrefreshUsagetriggered it. After: the newrate-limits/inactive-codex-home.ts(inactiveCodexHomeUnlessStopped) skips a WSL home unless the settled gateblockedWslDistroForPathpasses.resolveHomemay now be async; the type allows both.claude-managed-account-usage.ts) and the startup Claude publish (ClaudeWslProfileRouter.runningDistros). Before: both used the unsettledfilterPathsToRunningWslDistrosAsyncorlistRunningWslDistrosAsync. A list taken while a distro is still stopping names it, and the home probe, UNC reads and guest setup that followed booted it again. After: the settled gate, per distro.Why
CodexAccountServiceconstructor and inselect, which are synchronous. A cached "seen running after the settle" verdict keeps them synchronous and never probes. Launch preparation covers the skipped sync, so the skip loses nothing users rely on.Linked Issue
Internal WSL tracker, E9 audit (/tmp/fanout/wsl-exec-audit.md, rows A1–A4).
Visual Proof
N/A: no UI change.
Testing
New tests. Each one fails with its fix reverted (I checked, except the extracted helper; see the last bullet):
codex-config-mirror-wsl-stopped.test.ts: a WSL account home is not touched at startup when the distro hasn't been seen running. It is synced when the distro was seen running. The check asks for a list no older than the 60 s lease.wsl-last-seen-running-age.test.ts: a running list 59 s old vouches for the distro, but one 61 s old does not. Callers that pass no bound keep today's answer. This test and the lease case fail without the change.claude-profile-wsl-router.test.ts: startup publish skips a distro the list still names while the settled gate says it stopped.claude-profile-usage.test.ts: an inactive WSL account that a running list still names while it stops is not read.inactive-codex-home.test.ts: a stopped or stopping distro's home is skipped; running and host homes are previewed; untrusted homes stay skipped. This module is new, so its tests can't run against the old code; they pin the check's behaviour.Updated:
service-wsl-accounts.test.tsmarks its distro as running so the mirror still syncs.Suites: codex-accounts, rate-limits, claude-accounts, codex, claude and provider-account-services pass (550 files).
Load rule:
pnpm tc,typecheck:ci, oxlint, the anti-slop lint, oxfmt,check:code-quality:changed, and the ast-grep gates.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
Notes
accounts.*calls now no longer boot distros.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)