Skip to content

fix(wsl): account sync and usage previews never boot a stopped WSL distro (E9) - #35387

Merged
nwparker merged 2 commits into
mainfrom
nwparker/wsl-e9-accounts
Oct 28, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/wsl-e9-accounts

Conversation

@nwparker

@nwparker nwparker commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​221 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​218
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​53 $\color{#cf222e}{\Huge{\mathbf{−}}}$​17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​36

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 at launch (codex-config-mirror.ts). Before: every launch read ~/.codex/config.toml over \\wsl.localhost for 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 last wsl --list --running both 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.
  • Inactive Codex usage previews. Before: the inactive-account resolver returned WSL homes unchecked, then read auth.json over UNC and ran wsl --exec codex app-server; the switcher expand and the phone's accounts.subscribe or refreshUsage triggered it. After: the new rate-limits/inactive-codex-home.ts (inactiveCodexHomeUnlessStopped) skips a WSL home unless the settled gate blockedWslDistroForPath passes. resolveHome may now be async; the type allows both.
  • Inactive Claude previews (claude-managed-account-usage.ts) and the startup Claude publish (ClaudeWslProfileRouter.runningDistros). Before: both used the unsettled filterPathsToRunningWslDistrosAsync or listRunningWslDistrosAsync. 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

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.ts marks 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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

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)

…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.
@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 16 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: 62e9f4c3-b075-4098-8a34-6222efc9c2be
Commits

Reviewing files that changed from the base of the PR and between c66d873 and dcfd520.

Files selected for processing: 14
  • src/main/claude-accounts/claude-profile-wsl-router.test.ts
  • src/main/claude-accounts/claude-profile-wsl-router.ts
  • src/main/codex-accounts/codex-config-mirror-wsl-stopped.test.ts
  • src/main/codex-accounts/codex-config-mirror.ts
  • src/main/codex-accounts/service-wsl-accounts.test.ts
  • src/main/provider-account-services.ts
  • src/main/rate-limits/claude-managed-account-usage.ts
  • src/main/rate-limits/claude-profile-usage.test.ts
  • src/main/rate-limits/inactive-codex-home.test.ts
  • src/main/rate-limits/inactive-codex-home.ts
  • src/main/rate-limits/service/service-inactive-accounts.ts
  • src/main/rate-limits/service/service-types.ts
  • src/main/wsl-background-distro-gate.ts
  • src/main/wsl-last-seen-running-age.test.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.

@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with one non-blocking preview race still open from the previous review.

Findings

  1. P2 Preview outlives account changes ▶

Summary

The PR keeps background account work from starting stopped WSL distros.

  • Codex config mirroring checks WSL state before syncing account homes.
  • Inactive Codex previews check WSL state before reading an account home.
  • Inactive Claude previews check WSL state before preparing account usage.
  • Claude startup publishing filters out WSL distros the settled check blocks.

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()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.
@nwparker
nwparker merged commit e5b5ae2 into main Oct 28, 2026
52 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