Skip to content

Commit 478850f

Browse files
fix(desktop): let wsl editor deep links through the external URL allowlist
The desktop main process only passed `vscode-remote/ssh-remote+` links to the OS, so the renderer's `wsl+<distro>` links were dropped and the editor never opened. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 32000b9 commit 478850f

2 files changed

Lines changed: 37 additions & 4 deletions

File tree

‎apps/desktop/src/electron/ElectronShell.test.ts‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,37 @@ describe("ElectronShell", () => {
8888
}).pipe(Effect.provide(ElectronShell.layer)),
8989
);
9090

91+
it.effect("opens WSL editor URLs", () =>
92+
Effect.gen(function* () {
93+
openExternalMock.mockResolvedValue(undefined);
94+
95+
const electronShell = yield* ElectronShell.ElectronShell;
96+
const result = yield* electronShell.openExternal(
97+
"vscode://vscode-remote/wsl+Debian/home/user/project",
98+
);
99+
100+
assert.equal(result, true);
101+
assert.deepEqual(openExternalMock.mock.calls, [
102+
["vscode://vscode-remote/wsl+Debian/home/user/project"],
103+
]);
104+
}).pipe(Effect.provide(ElectronShell.layer)),
105+
);
106+
107+
it.effect("does not open remote editor URLs without a host", () =>
108+
Effect.gen(function* () {
109+
openExternalMock.mockResolvedValue(undefined);
110+
111+
const electronShell = yield* ElectronShell.ElectronShell;
112+
const results = yield* Effect.all([
113+
electronShell.openExternal("vscode://vscode-remote/wsl+"),
114+
electronShell.openExternal("vscode://vscode-remote/ssh-remote+"),
115+
]);
116+
117+
assert.deepEqual(results, [false, false]);
118+
assert.equal(openExternalMock.mock.calls.length, 0);
119+
}).pipe(Effect.provide(ElectronShell.layer)),
120+
);
121+
91122
it.effect("opens Zed's ssh deep link", () =>
92123
Effect.gen(function* () {
93124
openExternalMock.mockResolvedValue(undefined);

‎apps/desktop/src/electron/ElectronShell.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@ import * as Option from "effect/Option";
1212
import * as Electron from "electron";
1313

1414
// Remote open-in-editor deep links (`vscode://vscode-remote/ssh-remote+…`,
15-
// `zed://ssh/<host>/<path>`) must reach the OS handler; every other non-web
16-
// scheme stays blocked.
15+
// `vscode://vscode-remote/wsl+<distro>/…`, `zed://ssh/<host>/<path>`) must
16+
// reach the OS handler; every other non-web scheme stays blocked.
1717
const SAFE_WEB_PROTOCOLS = new Set(["http:", "https:"]);
1818
const REMOTE_EDITOR_PROTOCOLS = new Set(
1919
REMOTE_CAPABLE_EDITOR_IDS.flatMap((id) => {
2020
const scheme = remoteSchemeForEditor(id);
2121
return scheme === undefined ? [] : [`${scheme}:`];
2222
}),
2323
);
24+
const VSCODE_REMOTE_AUTHORITY_PREFIXES = ["/ssh-remote+", "/wsl+"];
2425

2526
// Zed's host sits in the first path segment, so it needs its own userinfo ban.
2627
const ZED_SSH_PATHNAME = /^\/[^/@:]+\/.*$/;
@@ -32,8 +33,9 @@ const isRemoteEditorUrl = (url: URL) =>
3233
(url.protocol === "zed:"
3334
? url.host === "ssh" && ZED_SSH_PATHNAME.test(url.pathname)
3435
: url.host === "vscode-remote" &&
35-
url.pathname.startsWith("/ssh-remote+") &&
36-
url.pathname.length > "/ssh-remote+".length);
36+
VSCODE_REMOTE_AUTHORITY_PREFIXES.some(
37+
(prefix) => url.pathname.startsWith(prefix) && url.pathname.length > prefix.length,
38+
));
3739

3840
export function parseSafeExternalUrl(rawUrl: unknown): Option.Option<string> {
3941
if (typeof rawUrl !== "string") {

0 commit comments

Comments
 (0)