Skip to content

fix: properly open link on macos#11

Merged
skynet2 merged 2 commits into
masterfrom
fix-browser
Oct 10, 2025
Merged

fix: properly open link on macos#11
skynet2 merged 2 commits into
masterfrom
fix-browser

Conversation

@skynet2

@skynet2 skynet2 commented Oct 10, 2025

Copy link
Copy Markdown
Member

Closes #10

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @skynet2, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves an issue where links were not opening correctly, particularly on macOS, by implementing a robust cross-platform solution. It introduces a new utility function that intelligently selects the correct command to open a URL based on the operating system, thereby enhancing the application's compatibility and user experience across Windows, macOS, and Linux environments.

Highlights

  • Cross-Platform URL Opening: Introduced a new utility function, OpenBrowser, to handle opening URLs using the appropriate system command for Windows, macOS, and Linux.
  • Refactored Link Handling: The pkg/instance/instance.go file was updated to utilize the new OpenBrowser utility, replacing the previous Windows-specific rundll32 command.
  • macOS and Linux Support: Explicit support for opening links on macOS (using open) and Linux (using xdg-open) has been added, resolving previous platform-specific issues.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov

codecov Bot commented Oct 10, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 23.58%. Comparing base (c5d6dbc) to head (61acdb1).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
pkg/utils/browser.go 0.00% 10 Missing ⚠️
pkg/instance/instance.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #11      +/-   ##
==========================================
- Coverage   24.09%   23.58%   -0.52%     
==========================================
  Files           9       10       +1     
  Lines         415      424       +9     
==========================================
  Hits          100      100              
- Misses        314      323       +9     
  Partials        1        1              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the logic for opening a browser URL into a new utility function, utils.OpenBrowser, which correctly handles different operating systems including macOS, Linux, and Windows. This is a positive change that improves modularity and fixes the issue with opening links on macOS. My review includes suggestions to enhance error handling by wrapping errors with more context, which will improve debuggability.

Comment thread pkg/instance/instance.go
if err = utils.OpenBrowser(targetUrl); err != nil {
i.ShowAlert()
return errors.Wrap(err, "failed to open url")
return err

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The error returned from utils.OpenBrowser is now returned directly. The previous implementation wrapped the error with "failed to open url", which provides valuable context for debugging. It would be best to restore this error wrapping to maintain clear error messages.

Suggested change
return err
return errors.Wrap(err, "failed to open url")

Comment thread pkg/utils/browser.go
Comment on lines +10 to +21
func OpenBrowser(url string) error {
switch runtime.GOOS {
case "windows":
return exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
case "darwin":
return exec.Command("open", url).Start()
case "linux":
return exec.Command("xdg-open", url).Start()
default:
return errors.Newf("unsupported platform: %s", runtime.GOOS)
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This is a great utility function. To make it more robust and provide better diagnostics, consider wrapping the errors from cmd.Start() with context about the operating system. This will make the function more self-contained and easier to debug if it's used elsewhere.

Suggested change
func OpenBrowser(url string) error {
switch runtime.GOOS {
case "windows":
return exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
case "darwin":
return exec.Command("open", url).Start()
case "linux":
return exec.Command("xdg-open", url).Start()
default:
return errors.Newf("unsupported platform: %s", runtime.GOOS)
}
}
func OpenBrowser(url string) error {
var cmd *exec.Cmd
switch runtime.GOOS {
case "windows":
cmd = exec.Command("rundll32", "url.dll,FileProtocolHandler", url)
case "darwin":
cmd = exec.Command("open", url)
case "linux":
cmd = exec.Command("xdg-open", url)
default:
return errors.Newf("unsupported platform: %s", runtime.GOOS)
}
if err := cmd.Start(); err != nil {
return errors.Wrapf(err, "failed to open browser on %s", runtime.GOOS)
}
return nil
}

@skynet2 skynet2 merged commit 4212b56 into master Oct 10, 2025
2 of 4 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.

Open browser on MacOS

1 participant