Skip to content

fix(wsl): route global CLI fallbacks to user-pinned terminalWindowsWslDistro - #9734

Merged
nwparker merged 1 commit into
stablyai:mainfrom
TingdeLiu:fix/wsl-default-distro-gh-fallback
Jul 24, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
TingdeLiu:fix/wsl-default-distro-gh-fallback

Conversation

@TingdeLiu

@TingdeLiu TingdeLiu commented Jul 21, 2026 •

Copy link
Copy Markdown

fix(wsl): route global CLI fallbacks to user-pinned terminalWindowsWslDistro

Summary

On Windows with WSL-only installs of gh/glab, global CLI commands now honor the user's pinned WSL distro instead of failing against an arbitrary default distro.

ELI5

If your GitHub/GitLab tools live inside one Linux setup on Windows, the app used to guess the wrong one and fail. Now it uses the Linux distro you actually picked in settings.

Root cause & fix

Global CLI calls carry no repository cwd, so when the host executable is missing the fallback resolved to the first distro from wsl --list via getDefaultWslDistro() — wrong when the user's tools/credentials live in a different distro. The fix adds a module-level defaultWslDistroOverride with an exported setDefaultWslDistroOverride setter in src/main/git/runner.ts; resolveDefaultWslCli now prefers override ?? getDefaultWslDistro(). src/main/index.ts applies the override from terminalWindowsWslDistro both at startup and on settings change.

Evidence

Validated & rebased onto latest main during a bug-bash triage on 2026-07-23. Rebase clean (base 8a23618310, head fbdce08bc2).

  • Test: src/main/git/runner-wsl-gh-fallback.test.ts (new override-vs-default-distro case).
  • On branch: 1 file passed, 22 tests passed.
  • Revert fix files to origin/main (keeping the test): 22 tests failed — proving the fix is load-bearing:
npx vitest run --config config/vitest.config.ts src/main/git/runner-wsl-gh-fallback.test.ts

On branch:        Test Files 1 passed | Tests 22 passed
Fix reverted:     Tests 22 failed
  → TypeError: setDefaultWslDistroOverride is not a function
  • Lint clean: npx oxlint src/main/git/runner.ts src/main/index.ts → exit 0.

Trade-offs

None — pure fix.

Regression risk

Effectively zero. The override defaults to null, so resolveDefaultWslCli falls back to getDefaultWslDistro() exactly as before when no distro is pinned; only the WSL-fallback branch changes, and non-Windows paths are gated by process.platform. The index.ts wiring is a straightforward read of an existing terminalWindowsWslDistro setting and cannot be unit-tested directly (Electron whenReady), but was inspected.

Credit to @TingdeLiu for the original fix. Validated, rebased, and (where applicable) hardened via automated bug-bash review; original fix design preserved.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds OpenSpec documentation and configuration for pinning global GitHub and GitLab CLI fallback execution to the configured WSL distribution. Implements an override in the Git runner, initializes and updates it from terminalWindowsWslDistro, and adds tests covering both overridden and default distro resolution.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title is concise and accurately describes the main change: routing global CLI WSL fallbacks to the pinned distro setting.
Description check ✅ Passed The description is detailed and covers the change, rationale, testing, and risk, though it omits some template sections like screenshots and security audit.

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.

@nwparker
nwparker force-pushed the fix/wsl-default-distro-gh-fallback branch from fbdce08 to 2e6009a Compare July 23, 2026 11:49
@nwparker
nwparker merged commit 1ace87c into stablyai:main Jul 24, 2026
@nwparker

Copy link
Copy Markdown
Contributor

Thanks so much for this, @TingdeLiu — route global CLI fallbacks to user-pinned terminalWindowsWslDistro. Verified (fail-on-main/pass-on-branch), rebased on latest main, reviewed, and merged. Really appreciate it! 🙏

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.

3 participants