fix: improve browser launching on WSL#298
Merged
tomasz-tomczyk merged 1 commit intotomasz-tomczyk:mainfrom Apr 17, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Improves automatic browser launching on Linux/WSL by adding a fallback chain of launch commands and factoring the selection logic into testable units.
Changes:
- Refactors
openBrowserinto a command-spec selection + execution pipeline with fallback behavior. - Adds WSL detection logic and prefers WSL/Windows-aware launchers before
xdg-open. - Introduces unit tests covering WSL detection, command spec ordering, and fallback execution.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| main.go | Adds WSL detection and a launcher fallback chain via browserCommandSpecs/tryOpenBrowser. |
| browser_test.go | Adds tests validating WSL detection and launcher selection/fallback behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+2556
to
+2564
| if hasCommand("powershell.exe") { | ||
| specs = append(specs, browserCommandSpec{ | ||
| name: "powershell.exe", | ||
| args: []string{"-NoProfile", "-NonInteractive", "-Command", "Start-Process", url}, | ||
| }) | ||
| } | ||
| if hasCommand("cmd.exe") { | ||
| specs = append(specs, browserCommandSpec{name: "cmd.exe", args: []string{"/c", "start", "", url}}) | ||
| } |
| } | ||
|
|
||
| func runBrowserCommand(spec browserCommandSpec) error { | ||
| return exec.Command(spec.name, spec.args...).Run() |
Contributor
Author
There was a problem hiding this comment.
This is resolved in the latest push. rebase and review again.
Detect WSL explicitly and try WSL-aware browser launchers before falling back to the standard Linux opener. This adds a launcher sequence of `wslview`, `powershell.exe`, `cmd.exe`, and finally `xdg-open`, and keeps trying later options when an earlier launcher fails. It also quotes URLs for the Windows launcher commands so common query strings containing characters like `&` are treated as literals instead of shell operators.
Owner
|
Thank you so much! 💛 💚 🩵 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Detect WSL explicitly and try WSL-aware browser launchers before
falling back to the standard Linux opener.
This adds a launcher sequence of
wslview,powershell.exe,cmd.exe,and finally
xdg-open, and keeps trying later options when an earlierlauncher fails.
It also quotes URLs for the Windows launcher commands so common query
strings containing characters like
&are treated as literals instead ofshell operators.