Skip to content

Commit 423ba36

Browse files
fix(web): don't offer VS Code for remote links on iOS and Android browsers
A browser on iOS/iPadOS or Android cannot open a vscode://vscode-remote link, yet the Open in picker offered VS Code there as the fallback editor. The fallback now comes from remoteFallbackEditors(), which uses the existing clientMetadata OS classification (including iPadOS's Macintosh user agent) and returns no editor on those devices. The menu then shows one disabled line saying to open from a computer instead of "No installed editors found" and the SSH key hint. Desktop browsers and the desktop app's editor probe are unchanged. Fixes #27544 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent a9fcdbc commit 423ba36

4 files changed

Lines changed: 38 additions & 5 deletions

File tree

‎apps/web/src/components/chat/OpenInPicker.browser.test.tsx‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,25 @@ describe("remote editor links", () => {
200200
expect(state.openUrl).toHaveBeenCalledWith(expect.stringContaining("ssh-remote+sol"));
201201
expect(state.run).not.toHaveBeenCalled();
202202
});
203+
204+
it("explains why a phone or tablet browser has no editor to open", async () => {
205+
await using fixture = await setup();
206+
const { renderPicker, byLabel, primaryButton, menuItems, click, pressOpenFavorite } = fixture;
207+
state.remote = { mode: "remote-links", host: { kind: "ssh-alias", host: "sol" } };
208+
state.clientEditors = [];
209+
await renderPicker();
210+
211+
expect(primaryButton().disabled).toBe(true);
212+
expect((await pressOpenFavorite()).defaultPrevented).toBe(false);
213+
await click(byLabel("Choose editor"));
214+
await vi.waitFor(() =>
215+
expect(menuItems().map((item) => item.textContent)).toEqual([
216+
"Open from a computer to edit on Test host",
217+
]),
218+
);
219+
expect(menuItems()[0]!.getAttribute("aria-disabled")).toBe("true");
220+
expect(state.openUrl).not.toHaveBeenCalled();
221+
});
203222
});
204223

205224
describe("open in editor announcement", () => {

‎apps/web/src/components/chat/OpenInPicker.tsx‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,18 @@ export const OpenInPicker = memo(function OpenInPicker({
286286
const primaryOption = options.find(({ value }) => value === preferredEditor) ?? null;
287287
const primaryLabel = isPanel ? `Open in ${primaryOption?.label ?? "editor"}` : "Open";
288288

289+
const unavailableReason =
290+
remote.mode === "remote-unavailable"
291+
? `No SSH route to ${environmentLabel}`
292+
: remote.mode === "remote-links" && options.length === 0
293+
? `Open from a computer to edit on ${environmentLabel}`
294+
: null;
295+
289296
const editorItems = (
290297
<>
291-
{remote.mode === "remote-unavailable" ? (
298+
{unavailableReason !== null ? (
292299
<MenuItem density={presentation === "menu" ? "touch" : "default"} disabled>
293-
No SSH route to {environmentLabel}
300+
{unavailableReason}
294301
</MenuItem>
295302
) : (
296303
<>

‎apps/web/src/connection/clientMetadata.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type {
55
DesktopBridge,
66
} from "@t3tools/contracts";
77

8-
interface BrowserIdentity {
8+
export interface BrowserIdentity {
99
readonly userAgent: string;
1010
readonly platform: string;
1111
readonly maxTouchPoints: number;
@@ -32,7 +32,7 @@ function isIpadosDesktopUserAgent(identity: BrowserIdentity): boolean {
3232
);
3333
}
3434

35-
function browserClientOs(identity: BrowserIdentity): ClientOs {
35+
export function browserClientOs(identity: BrowserIdentity): ClientOs {
3636
const userAgent = identity.userAgent;
3737
if (userAgent.trim() === "") return "unknown";
3838
if (/iphone|ipad|ipod/i.test(userAgent) || isIpadosDesktopUserAgent(identity)) return "iOS";

‎apps/web/src/remoteOpen.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import * as Schema from "effect/Schema";
1010
import { Atom } from "effect/reactivity";
1111
import { useAtomValue } from "@effect/atom-react";
1212

13+
import { browserClientOs, type BrowserIdentity } from "~/connection/clientMetadata";
1314
import { isDesktopLocalConnectionTarget } from "~/connection/desktopLocal";
1415
import { isLoopbackHostname } from "~/environments/primary/target";
1516
import { useLocalStorage } from "~/hooks/useLocalStorage";
@@ -146,6 +147,12 @@ export function useRemoteOpenState(environmentId: EnvironmentId | null): RemoteO
146147

147148
const REMOTE_FALLBACK_EDITORS: ReadonlyArray<EditorId> = ["vscode"];
148149

150+
// Phone and tablet browsers have no desktop editor to receive a vscode:// remote link.
151+
export function remoteFallbackEditors(identity: BrowserIdentity): ReadonlyArray<EditorId> {
152+
const os = browserClientOs(identity);
153+
return os === "iOS" || os === "Android" ? [] : REMOTE_FALLBACK_EDITORS;
154+
}
155+
149156
// Probed once per page: installed editors rarely change, and the probe spawns processes.
150157
const remoteCapableEditorsAtom = Atom.make((get): ReadonlyArray<EditorId> => {
151158
const probe = window.desktopBridge?.probeRemoteEditors;
@@ -156,7 +163,7 @@ const remoteCapableEditorsAtom = Atom.make((get): ReadonlyArray<EditorId> => {
156163
},
157164
() => undefined,
158165
);
159-
return REMOTE_FALLBACK_EDITORS;
166+
return remoteFallbackEditors(navigator);
160167
}).pipe(Atom.keepAlive, Atom.withLabel("remote-capable-editors"));
161168

162169
export function useRemoteCapableEditors(): ReadonlyArray<EditorId> {

0 commit comments

Comments
 (0)