Commit cb802a1
authored
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.File tree
6 files changed
+90
-34
lines changed6 files changed
+90
-34
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
| 106 | + | |
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | | - | |
| 140 | + | |
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
46 | | - | |
| 47 | + | |
47 | 48 | | |
| 49 | + | |
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
| 53 | + | |
51 | 54 | | |
52 | 55 | | |
53 | 56 | | |
| |||
69 | 72 | | |
70 | 73 | | |
71 | 74 | | |
| 75 | + | |
72 | 76 | | |
73 | 77 | | |
74 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
| |||
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
56 | 65 | | |
57 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
58 | 85 | | |
59 | 86 | | |
60 | | - | |
61 | | - | |
| 87 | + | |
62 | 88 | | |
| 89 | + | |
63 | 90 | | |
64 | 91 | | |
65 | 92 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
84 | 130 | | |
85 | | - | |
| 131 | + | |
| 132 | + | |
86 | 133 | | |
87 | 134 | | |
88 | | - | |
89 | | - | |
90 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
91 | 143 | | |
92 | 144 | | |
93 | | - | |
| 145 | + | |
94 | 146 | | |
95 | 147 | | |
96 | 148 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
0 commit comments