#19223: fix: add WSL2 Windows browser detection for Linux platform
size: S
trusted-contributor
Cluster:
Windows Compatibility Fixes
Fixes #19185
## What changed
- Added WSL2 detection to check for "Microsoft" or "WSL2" in /proc/version
- When running on WSL2, checks for Windows browsers mounted at /mnt/c/ (Brave, Chrome, Edge, Chromium)
- Both detectDefaultChromiumExecutableLinux() and findChromeExecutableLinux() now check for WSL2 Windows browsers first
## AI-assisted contribution
- This fix was generated by an AI agent (OpenClaw cron: gh-issues-fix)
- Testing depth: validated with pnpm build && pnpm lint
- The fix addresses the root cause by detecting Windows browsers when running under WSL2
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR adds WSL2 detection to the Linux browser executable resolution, allowing the app to find Windows browsers mounted at `/mnt/c/` when running under WSL2. Two new helper functions (`isWsl2()` and `detectWsl2WindowsBrowser()`) are introduced and called from both `detectDefaultChromiumExecutableLinux()` and `findChromeExecutableLinux()`.
- **Logic concern**: In `detectDefaultChromiumExecutableLinux`, the WSL2 check runs before `xdg-settings`/`xdg-mime`, meaning it will override the user's explicitly configured default browser on WSL2 systems. The WSL2 check would be better placed as a fallback after the standard detection fails.
- **Style**: `isWsl2()` spawns `cat` to read `/proc/version` when `fs.readFileSync` (already imported) would be simpler and more efficient.
- **Missing tests**: No tests were added for the new WSL2 detection logic, despite the existing test file (`chrome.default-browser.test.ts`) already having the mocking infrastructure in place.
<h3>Confidence Score: 3/5</h3>
- Functionally works for the target WSL2 use case but has a behavioral issue where it overrides user's default browser preference on WSL2
- The core WSL2 detection and path resolution logic is correct and handles edge cases (non-Linux platforms, missing /proc/version). However, the placement of the WSL2 check in detectDefaultChromiumExecutableLinux bypasses the user's configured default browser, which is a meaningful behavioral issue. No tests were added for the new code paths.
- Pay close attention to `src/browser/chrome.executables.ts` — the WSL2 detection placement in `detectDefaultChromiumExecutableLinux` overrides user's default browser preference
<sub>Last reviewed commit: 9ca2990</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#19495: fix: handle Chrome process re-parenting on Windows
by andenwick · 2026-02-17
75.1%
#14944: fix(browser): prefer openclaw profile in headless/noSandbox environ...
by BenediktSchackenberg · 2026-02-12
72.8%
#23142: fix(test): Windows CI — use path.join for XDG path assertions in qm...
by ihsanmokhlisse · 2026-02-22
71.3%
#8614: fix(browser): detect early chromium exit to prevent startup hang
by Wren-OC · 2026-02-04
71.3%
#9020: fix(browser): skip port ownership and WS reachability checks for re...
by yepack · 2026-02-04
70.7%
#17760: fix(browser): rewrite 0.0.0.0 and [::] wildcard addresses in CDP We...
by joeharouni · 2026-02-16
70.5%
#13568: Fix browser (OpenClaw-managed) launch fail by binding remote debugg...
by singlag · 2026-02-10
70.3%
#8303: fix(browser): enable downloads via CDP Browser.setDownloadBehavior
by gavinbmoore · 2026-02-03
70.3%
#8124: fix(browser): add path validation for file upload and download
by yubrew · 2026-02-03
70.2%
#18143: fix(windows): wrap shell builtins with cmd.exe /c for proper execution
by brandonwise · 2026-02-16
70.0%