You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make browser detection more robust on Linux (#2257)
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.
0 commit comments