Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: allow configuring default browser #219885

Merged
merged 24 commits into from
Jul 7, 2024

Conversation

SimonSiefke
Copy link
Contributor

Helps with #96132.

This adds a new setting workbench.defaultBrowser for configuring which browser to open:

default-browser.mp4

The value for workbench.defaultBrowser is a string and can either be an application name like google-chrome or an absolute path like /usr/bin/google-chrome.

Copy link
Member

@bpasero bpasero left a comment

Choose a reason for hiding this comment

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

Nice approach 👏

@bpasero bpasero added this to the On Deck milestone Jul 4, 2024
@SimonSiefke
Copy link
Contributor Author

Thanks for the feedback! Changed the setting name to workbench.browser and the setting scope to application.

Also more variants are support now, for example:

  • chrome, google-chrome, /usr/bin/chrome
  • edge, microsoft-edge, /usr/bin/microsoft-edge
  • firefox, /usr/bin/firefox

In case of error, it now falls back to shell.openExternal.

@bpasero bpasero self-requested a review July 5, 2024 06:01
@bpasero
Copy link
Member

bpasero commented Jul 5, 2024

@SimonSiefke thanks, did some follow up cleanup, please check. I renamed the setting to workbench.externalBrowser.

Its sad we cannot use the latest open module which switched to ESM (yet).

I wonder if people in the future want more options, such as controlling arguments to the browser. In that case maybe the setting should already make room for other settings? Like workbench.externalBrowser.app?

@bpasero bpasero modified the milestones: On Deck, July 2024 Jul 5, 2024
@bpasero
Copy link
Member

bpasero commented Jul 5, 2024

Pushed some more changes to validate invalid inputs and missing paths, I think this is good to go as it is.

@gjsjohnmurray
Copy link
Contributor

I see you decided on application scope for the setting, #96132 (comment) gave a use case for workspace-specific settings. I think you considered allowing this for workspaces but only respecting it if the workspace has been trusted by the user. What was the reason for not doing that?

@bpasero
Copy link
Member

bpasero commented Jul 5, 2024

If we want to make this a workspace setting, the change will become larger: in nativeHostMainService we only have access to the application scoped settings, so the setting value would have to be passed down from the workbench window that has access to the workspace configuration.

I am fine making this a workspace supported setting if its untrusted.

@bpasero bpasero modified the milestones: July 2024, On Deck Jul 5, 2024
@SimonSiefke
Copy link
Contributor Author

I wonder if people in the future want more options, such as controlling arguments to the browser. In that case maybe the setting should already make room for other settings? Like workbench.externalBrowser.app?

I like that idea!

The workspace setting also sounds good to me! It seems it might be a larger change, so maybe it could be a separate pull request.

@bpasero
Copy link
Member

bpasero commented Jul 5, 2024

Ideally we do all the changes in one PR when we think its done. Maybe @gjsjohnmurray wants to join forces?

@SimonSiefke
Copy link
Contributor Author

Alright then, I can try to make the workspace setting changes. :)

Is there any standard way of handling multiple workspaces? E.g. when two workspaces are open (a and b) and the user clicks a link from the terminal, would it use the settings from a, b or the global application settings?

@bpasero
Copy link
Member

bpasero commented Jul 6, 2024

Alright then, I can try to make the workspace setting changes. :)

Is there any standard way of handling multiple workspaces? E.g. when two workspaces are open (a and b) and the user clicks a link from the terminal, would it use the settings from a, b or the global application settings?

The workspace settings are bound to the window you are in where you click from, so we do typically not support workspace settings in another folder, even if you are in that context.

I would suggest to read the setting here where we open links from a window:

const success = await this.nativeHostService.openExternal(href);

and send it over + provide a fallback for the other usages where we are not in a workspace context. in these cases I think its fine to do the config reading as we do today only supporting app scope.

@bpasero bpasero modified the milestones: On Deck, July 2024 Jul 7, 2024
@bpasero
Copy link
Member

bpasero commented Jul 7, 2024

I had some slack time and went ahead implementing what we discussed.

@bpasero
Copy link
Member

bpasero commented Jul 7, 2024

Waiting for #220273 for the dependencies.

@bpasero bpasero enabled auto-merge (squash) July 7, 2024 10:42
@SimonSiefke
Copy link
Contributor Author

Awesome, thanks! :)

@bpasero bpasero merged commit 477d233 into microsoft:main Jul 7, 2024
6 checks passed
aaronchucarroll pushed a commit to aaronchucarroll/vscode that referenced this pull request Jul 10, 2024
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Aug 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants