1+ import { MAC_PERMISSION_SETTINGS_URLS } from "../permissions/MacPermission.ts" ;
12import {
23 REMOTE_CAPABLE_EDITOR_IDS ,
34 remoteSchemeForEditor ,
@@ -10,22 +11,9 @@ import * as Option from "effect/Option";
1011
1112import * as Electron from "electron" ;
1213
13- /**
14- * Deep links to individual System Settings panes. These are app-fixed, not
15- * renderer-supplied, so they skip `parseSafeExternalUrl` — which exists to keep
16- * arbitrary link schemes from reaching the OS handler — and open through their
17- * own path below. The pane rather than the URL crosses the IPC boundary, so a
18- * renderer can only ask for one of these known destinations.
19- *
20- * Full Disk Access uses the post-Ventura `PrivacySecurity.extension` anchor.
21- */
22- const SYSTEM_SETTINGS_URLS : Record < SystemSettingsPane , string > = {
23- "full-disk-access" :
24- "x-apple.systempreferences:com.apple.settings.PrivacySecurity.extension?Privacy_AllFiles" ,
25- } ;
26-
27- // Remote open-in-editor deep links (`vscode://vscode-remote/ssh-remote+…`)
28- // must reach the OS handler; every other non-web scheme stays blocked.
14+ // 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.
2917const SAFE_WEB_PROTOCOLS = new Set ( [ "http:" , "https:" ] ) ;
3018const REMOTE_EDITOR_PROTOCOLS = new Set (
3119 REMOTE_CAPABLE_EDITOR_IDS . flatMap ( ( id ) => {
@@ -34,13 +22,18 @@ const REMOTE_EDITOR_PROTOCOLS = new Set(
3422 } ) ,
3523) ;
3624
25+ // Zed's host sits in the first path segment, so it needs its own userinfo ban.
26+ const ZED_SSH_PATHNAME = / ^ \/ [ ^ / @ : ] + \/ .* $ / ;
27+
3728const isRemoteEditorUrl = ( url : URL ) =>
3829 REMOTE_EDITOR_PROTOCOLS . has ( url . protocol ) &&
3930 url . username . length === 0 &&
4031 url . password . length === 0 &&
41- url . host === "vscode-remote" &&
42- url . pathname . startsWith ( "/ssh-remote+" ) &&
43- url . pathname . length > "/ssh-remote+" . length ;
32+ ( url . protocol === "zed:"
33+ ? url . host === "ssh" && ZED_SSH_PATHNAME . test ( url . pathname )
34+ : url . host === "vscode-remote" &&
35+ url . pathname . startsWith ( "/ssh-remote+" ) &&
36+ url . pathname . length > "/ssh-remote+" . length ) ;
4437
4538export function parseSafeExternalUrl ( rawUrl : unknown ) : Option . Option < string > {
4639 if ( typeof rawUrl !== "string" ) {
@@ -82,7 +75,7 @@ export const make = ElectronShell.of({
8275 } ) ,
8376 openSystemSettings : ( pane ) =>
8477 Effect . promise ( ( ) =>
85- Electron . shell . openExternal ( SYSTEM_SETTINGS_URLS [ pane ] ) . then (
78+ Electron . shell . openExternal ( MAC_PERMISSION_SETTINGS_URLS [ pane ] ) . then (
8679 ( ) => true ,
8780 ( ) => false ,
8881 ) ,
0 commit comments