Skip to content

Comments

Release 2.7.2#2267

Merged
mjcheetham merged 10 commits intoreleasefrom
main
Feb 11, 2026
Merged

Release 2.7.2#2267
mjcheetham merged 10 commits intoreleasefrom
main

Conversation

mjcheetham and others added 10 commits February 3, 2026 13:47
Let's not crash the process if we are unable to launch PowerShell to
determine the Windows session ID.

Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Given that the ISessionManager has the ability to determine if a web
browser is available (via `IsWebBrowserAvailable`), it's only natural
that this is the component that should also be responsible for
actually launching the browser.

We remove the `BrowserUtils` class and transpose its only method
(`OpenDefaultBrowser`) to the session manager component. This means we
can keep the Linux-specific behaviour in a scoped component.

Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
…2261)

Given that the ISessionManager has the ability to determine if a web
browser is available (via `IsWebBrowserAvailable`), it's only natural
that this is the component that should also be responsible for actually
launching the browser.

We remove the `BrowserUtils` class and transpose its only method
(`OpenDefaultBrowser`) to the session manager component. This means we
can keep the Linux-specific behaviour in a scoped component.
Let's not crash the process if we are unable to launch PowerShell to
determine the Windows session ID.
Since we have special handling on Linux (eg WSL support), we try to use
our own logic for launching the user's default web browser for
interactive authentication.

In the event we fail to start the browser, we fall back to using MSAL's
logic, with a preference of Edge (Chromium-based) - largely because this
is the only way to hook ourselves back into MSAL's default handling.

Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
In non-WSL environments we make our checks for a browser more
robust by checking for a 'shell execute' handler (like xdg-open).
Previously we just relied on a desktop session ($DISPLAY or
$WAYLAND_DISPLAY), which isn't accurate since in `OpenBrowser`
we require a shell execute handler. The check and implementation
are now aligned!

We refactor the method to avoid nesting `if`s and use early returns to
make things a little clearer.

Helped-by: Marc Becker <becm@gmx.de>
Co-authored-by: Kyle Rader <kyrader@microsoft.com>
Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
In a Visual Studio Code remote session, we may be able to launch a
browser without the `DISPLAY` environment variable set. This is because
VSCode sets the `BROWSER` environment variable in remote sessions, such
that it can forward requests to start a browser to the client machine.

However! There are several types of remote session in VSCode, and the
way they handle automatic port forwarding differs slightly. Since a very
common case in GCM for launching the user browser is the ability to
connect back to GCM via localhost:<port>, we only consider a subset of
remote sessions to be able to launch a browser:

* Remote SSH     [YES]
* Dev Containers [YES]
* Remote Tunnel  [NO]

Sadly, for whatever reason, the remote connection over Microsoft Dev
Tunnels does NOT automatically surface a forwarded port to localhost on
the client. The forwarded port is only available via the devtunnels.ms
URLs.

Detecting the different types of remote session is tricky as it's not
always as explicit as we'd like.

All types: VSCODE_IPC_HOOK_CLI is set.

Dev Containers : REMOTE_CONTAINERS is set.
Remote SSH     : SSH_CONNECTION is set.
Remote Tunnel  : absense of REMOTE_CONTAINERS and SSH_CONNECTION.

Note, when starting a tunnel server from a regular SSH connection the
SSH_CONNECTION variable gets inherited by the tunnel connections
themselves! This means we need to also check for the absence of SSH_TTY
because the tunnel server unsets this. SSH_TTY is set only in regular
SSH sessions.

Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Since we have special handling on Linux (eg WSL support), we try to use
our own logic for launching the user's default web browser for
interactive authentication.

In the event we fail to start the browser, we fall back to using MSAL's
logic, with a preference of Edge (Chromium-based) - largely because this
is the only way to hook ourselves back into MSAL's default handling.
In non-WSL environments we make our checks for a browser more robust by
checking for a 'shell execute' handler (like xdg-open).

Previously we just relied on a desktop session (`DISPLAY` or
`WAYLAND_DISPLAY`), which isn't accurate since in `OpenBrowser` we
require a shell execute handler. The check and implementation are now
aligned!

In a Visual Studio Code remote session, we may be able to launch a
browser without the `DISPLAY` environment variable set. This is because
VSCode sets the `BROWSER` environment variable in remote sessions, such
that it can forward requests to start a browser to the client machine.

However! There are several types of remote session in VSCode, and the
way they handle automatic port forwarding differs slightly. Since a very
common case in GCM for launching the user browser is the ability to
connect back to GCM via `localhost:<port>`, we only consider a subset of
remote sessions to be able to launch a browser:

* Remote SSH     ✅ 
<img width="186" height="48" alt="image"
src="https://github.com/user-attachments/assets/49778759-52a8-42b0-87f1-f08d6ed54677"
/>

* Dev Containers ✅ 
<img width="140" height="54" alt="image"
src="https://github.com/user-attachments/assets/36fb5c43-23a9-473e-83db-f4841335253a"
/>

* Remote Tunnel  ❌ 
<img width="148" height="51" alt="image"
src="https://github.com/user-attachments/assets/a682b49a-1056-4f2b-95e2-a759c70046c5"
/>
    
Sadly, for whatever reason, the remote connection over Microsoft Dev
Tunnels does NOT automatically surface a forwarded port to localhost on
the client. The forwarded port is only available via the devtunnels.ms
URLs.

Dev Tunnels|SSH
-|-
<img width="731" height="130" alt="image"
src="https://github.com/user-attachments/assets/d8c33c92-6fa7-4bb0-a914-7bd57cea9a10"
/>|<img width="647" height="92" alt="image"
src="https://github.com/user-attachments/assets/92dc6ac7-c94b-4c30-a640-d38b1e3e1dd6"
/>

Detecting the different types of remote session is tricky as it's not
always as explicit as we'd like.
    
All types: `VSCODE_IPC_HOOK_CLI` is set.

Dev Containers : `REMOTE_CONTAINERS` is set.
Remote SSH     : `SSH_CONNECTION` is set.
Remote Tunnel  : absense of `REMOTE_CONTAINERS` and `SSH_CONNECTION`.
    
Note, when starting a tunnel server from a regular SSH connection the
`SSH_CONNECTION` variable gets inherited by the tunnel connections
themselves! This means we need to also check for the absence of
`SSH_TTY` because the tunnel server unsets this. `SSH_TTY` is set only
in regular SSH sessions.
@mjcheetham mjcheetham requested review from a team as code owners February 11, 2026 14:15
@mjcheetham mjcheetham requested a review from dscho February 11, 2026 14:15
@mjcheetham mjcheetham enabled auto-merge February 11, 2026 14:16
@mjcheetham mjcheetham disabled auto-merge February 11, 2026 14:17
@mjcheetham
Copy link
Contributor Author

Install from source (Ubuntu) failure is a known issue. That version of Ubuntu is using a broken dotnet version with a bug that changed overload resolution for string::Split.

@mjcheetham mjcheetham merged commit 072a76d into release Feb 11, 2026
22 of 23 checks passed
@bigbob78C

This comment was marked as spam.

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