Skip to content

fix(claude): retain managed WSL selection across distro casing - #31992

Merged
nwparker merged 2 commits into
mainfrom
nwparker/claude-wsl-selection-casing
Oct 23, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/claude-wsl-selection-casing

Conversation

@nwparker

@nwparker nwparker commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

On Windows, Ubuntu and ubuntu are the same WSL distro: wsl -d ubuntu and \\wsl.localhost\ubuntu\... both work. Orca saved the chosen Claude account under the exact spelling from the Settings dropdown (Ubuntu), then looked it up using the spelling in the project path. A project added as \\wsl.localhost\ubuntu\... found nothing. Its Claude terminals quietly used the WSL system-default login, and switching accounts appeared to do nothing there.

What changes for you: a Claude account you pick for a WSL distro now applies to every project in that distro, whatever casing its path uses. Nothing is migrated or renamed; saved settings keep their original spelling.

Fixes #23960 (reported by @Minsubs, whose suggested fix is case-insensitive distro comparison).

What changed

  • getClaudeWslSelectionKey now folds case. The account lookup, the duplicate-account check, the WSL router's "does this distro have accounts" check, and selection pruning all compare distros case-insensitively.
  • Lookup order: a saved key with the exact same spelling wins, so every lookup that works today returns the same answer. If there is no exact key, the lookup falls back to a case-insensitive match. When two differently-cased keys name different accounts and neither matches exactly, the result is "no managed account" (we don't pick one at random).
  • Switching accounts writes the choice to every existing casing variant of that distro's key, so mixed keys converge after one switch. Key spelling is kept for older clients.
  • Selecting a WSL account from a differently-cased target (for example ubuntu for an account recorded as Ubuntu) is allowed. Another distro (Debian, Ubuntu-24.04) is still refused.
  • Guest profile ownership marker: the WSL distro comparison ignores case, so the same profile folder reached as ubuntu is not refused as "another target". The marker file's bytes are never rewritten.

Verification

  • Real Windows host (awin, Windows + WSL Ubuntu-24.04, PR head 482ccaca):
    • wsl.exe -d Ubuntu-24.04, -d ubuntu-24.04 and -d UBUNTU-24.04 all print WSL_DISTRO_NAME=Ubuntu-24.04, and \\wsl.localhost\ubuntu-24.04\etc\hostname and \\wsl$\UBUNTU-24.04\etc\hostname both exist. Windows treats the name as case-insensitive.
    • A throwaway script, bundled with esbuild, ran the real parseWslUncPath and runtime-selection.ts with the saved selection { "Ubuntu-24.04": "acct-A" }. On main, the paths \\wsl.localhost\ubuntu-24.04\..., \\wsl$\UBUNTU-24.04\... and \\WSL.LOCALHOST\ubuntu-24.04\... returned account=null, and prune cleared { "ubuntu-24.04": "acct-A" }. On this PR, all four spellings return acct-A and prune keeps the entry. orca-qa stays null. Conflicting {Ubuntu-24.04: A, ubuntu-24.04: B} resolves exact-first (A, B), and UBUNTU-24.04 gets null. Switching from UBUNTU-24.04 gives {"Ubuntu-24.04":"C","ubuntu-24.04":"C"}. On main it added a third key.
    • The guest helper (claude-profile-wsl-entry.ts, bundled on Windows) ran inside the real WSL distro on Linux Node 24 against a scratch home. With the PR, ubuntu-24.04 and UBUNTU-24.04 exit 0, and the profile.json marker stays byte-identical ("distro":"Ubuntu-24.04"). orca-qa and a marker owned by another account still exit 2 (belongs to another account or target). With main's claude-profile-paths.ts, the lower and upper spellings exit 2.
    • pnpm test on Windows for the changed claude-accounts tests plus src/main/rate-limits/: the PR and main show the same 12 Windows-only failures (in codex-fetcher, rate-limit service and opencode-go tests, plus one copy-link sign-in test). That set includes none of this PR's new tests, so nothing new fails.
  • Old code fails the new tests: I swapped the pre-PR runtime-selection.ts, claude-profile-paths.ts and claude-account-selection.ts back in, and 7 tests failed: lookup, alias update, pruning, the marker alias, account-service select/clear, router publish/launch, and the built standalone guest helper running as a subprocess. With the PR code they pass.
  • pnpm test src/main/claude-accounts/ src/main/rate-limits/: 86 files and 1063 tests pass (3 skipped, as before). oxlint and oxfmt pass on the changed files.

Risks / tradeoffs

  • Mixed keys that disagree: if settings already hold Ubuntu: A and ubuntu: B, each spelling keeps its own account, exactly as today. A third spelling (UBUNTU) gets no managed account. One explicit switch reconciles all of them.
  • Status bar and Settings are unchanged: the renderer's "which account is active" readout still uses exact keys. It shows the right answer for the Settings dropdown's spelling. A status-bar group built from a differently-cased target could still say "System default" while launches use the managed account. That display was already wrong before this PR.
  • Not physically exercised end-to-end: no Claude launch inside a real WSL guest with live credentials. The selection code and the guest profile helper were run on the real Windows/WSL host (above), but not the full Orca launch path.
  • Out of scope: Codex selection keys have the same mismatch, but they also feed persisted pane lanes, so they need a separate change that handles compatibility. Nothing here changes a wire method or the settings schema, and this PR does not touch WSL sign-in capture or restart eligibility.

Related

  • No external contributor PRs found for this issue.

Visual proof: n/a, this is main-process account routing with no UI change.

@coderabbitai

coderabbitai Bot commented Oct 22, 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: fd3c83f1-bf5c-416a-9a87-bed9c8a13126
📥 Commits

Reviewing files that changed from the base of the PR and between a3c4ecf and 482ccac.

📒 Files selected for processing: 2
  • src/main/claude-accounts/runtime-selection.test.ts
  • src/main/claude-accounts/runtime-selection.ts

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

📝 Walkthrough

WSL distro selection keys now match case-insensitively during lookup, updates, and pruning. Account target validation uses those keys when checking a requested distro. Profile ownership-marker comparisons trim whitespace and ignore casing for WSL distro values, while new markers retain the original ownership record. Tests cover aliases, conflicting selections, unrelated targets, and profile preparation.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 482cc

The WSL casing compatibility change is mergeable with normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 15.38% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 7 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: preserving managed Claude WSL selections across distro-name casing differences.
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 follows the template well. It has a clear ELI5, a What changed section, a Why-style explanation of the bug and the fix, a linked issue (Fixes #23960), a detailed Testing section with r…
Full details: Description check

Explanation

The description follows the template well. It has a clear ELI5, a What changed section, a Why-style explanation of the bug and the fix, a linked issue (Fixes #23960), a detailed Testing section with real Windows/WSL verification, risks and tradeoffs, and a note that visual proof is N/A with a reason. Gaps: the Visual Proof section says 'n/a' without the exact 'N/A' wording the template asks for, the Testing checkboxes are not ticked, the AI Disclosure section is blank, the Review and Agent skill upstream boundary sections are missing, and the Checklist is absent. The Why section does not explicitly compare against the alternatives beyond the mention of Codex and the case-insensitive suggestion. These gaps are non-critical, so the description is mostly complete.

✨ 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.

A saved key that matches the launch distro exactly now resolves as before,
so existing mixed-alias selections do not regress to System default.

Co-Authored-By: Claude <noreply@anthropic.com>
@nwparker
nwparker merged commit 77f1523 into main Oct 23, 2026
39 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.

[Bug]: Managed WSL Claude account is ignored when the project path uses different distro casing (\\wsl.localhost\ubuntu vs Ubuntu)

1 participant