Skip to content

fix: improve browser launching on WSL#298

Merged
tomasz-tomczyk merged 1 commit intotomasz-tomczyk:mainfrom
omry:pr298
Apr 17, 2026
Merged

fix: improve browser launching on WSL#298
tomasz-tomczyk merged 1 commit intotomasz-tomczyk:mainfrom
omry:pr298

Conversation

@omry
Copy link
Copy Markdown
Contributor

@omry omry commented Apr 17, 2026

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.

Copilot AI review requested due to automatic review settings April 17, 2026 14:00
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 openBrowser into 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 thread main.go
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}})
}
Comment thread main.go
}

func runBrowserCommand(spec browserCommandSpec) error {
return exec.Command(spec.name, spec.args...).Run()
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is resolved in the latest push. rebase and review again.

Comment thread main.go
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.
@omry omry changed the title fix: improve WSL browser launching fix: improve browser launching on WSL Apr 17, 2026
@tomasz-tomczyk
Copy link
Copy Markdown
Owner

Thank you so much! 💛 💚 🩵

@tomasz-tomczyk tomasz-tomczyk merged commit 910da96 into tomasz-tomczyk:main Apr 17, 2026
8 checks passed
@omry omry deleted the pr298 branch April 18, 2026 06:16
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