Repository navigation
fix(editors): open remote projects in Zed #11022
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| import { | ||
| REMOTE_CAPABLE_EDITOR_IDS, | ||
| remoteLinkStyleForEditor, | ||
| remoteSchemeForEditor, | ||
| type EditorRemoteLinkStyle, | ||
| type SystemSettingsPane, | ||
| } from "@t3tools/contracts"; | ||
| import * as Context from "effect/Context"; | ||
|
|
@@ -24,23 +26,38 @@ const SYSTEM_SETTINGS_URLS: Record<SystemSettingsPane, string> = { | |
| "x-apple.systempreferences:com.apple.settings.PrivacySecurity.extension?Privacy_AllFiles", | ||
| }; | ||
|
|
||
| // Remote open-in-editor deep links (`vscode://vscode-remote/ssh-remote+…`) | ||
| // must reach the OS handler; every other non-web scheme stays blocked. | ||
| // Remote open-in-editor deep links (`vscode://vscode-remote/ssh-remote+…` and | ||
| // `zed://ssh/<host>/<path>`) must reach the OS handler; every other non-web | ||
| // scheme stays blocked. Each scheme only unlocks its own editor's link shape, | ||
| // so a Zed link cannot ride in on a VS Code scheme or the reverse. | ||
| const SAFE_WEB_PROTOCOLS = new Set(["http:", "https:"]); | ||
| const REMOTE_EDITOR_PROTOCOLS = new Set( | ||
| const REMOTE_EDITOR_PROTOCOLS = new Map<string, EditorRemoteLinkStyle>( | ||
| REMOTE_CAPABLE_EDITOR_IDS.flatMap((id) => { | ||
| const scheme = remoteSchemeForEditor(id); | ||
| return scheme === undefined ? [] : [`${scheme}:`]; | ||
| const style = remoteLinkStyleForEditor(id); | ||
| return scheme === undefined || style === undefined | ||
| ? [] | ||
| : [[`${scheme}:`, style] as [string, EditorRemoteLinkStyle]]; | ||
| }), | ||
| ); | ||
|
|
||
| const isRemoteEditorUrl = (url: URL) => | ||
| REMOTE_EDITOR_PROTOCOLS.has(url.protocol) && | ||
| url.username.length === 0 && | ||
| url.password.length === 0 && | ||
| url.host === "vscode-remote" && | ||
| url.pathname.startsWith("/ssh-remote+") && | ||
| url.pathname.length > "/ssh-remote+".length; | ||
| // `zed://ssh/<host>/<path>`: a host segment plus a non-empty path. | ||
| const ZED_SSH_PATHNAME = /^\/[^/]+\/.+$/; | ||
|
|
||
| const isRemoteEditorUrl = (url: URL) => { | ||
| const style = REMOTE_EDITOR_PROTOCOLS.get(url.protocol); | ||
| if (style === undefined || url.username.length > 0 || url.password.length > 0) { | ||
| return false; | ||
| } | ||
| if (style === "zed-ssh") { | ||
| return url.host === "ssh" && ZED_SSH_PATHNAME.test(url.pathname); | ||
| } | ||
| return ( | ||
| url.host === "vscode-remote" && | ||
| url.pathname.startsWith("/ssh-remote+") && | ||
| url.pathname.length > "/ssh-remote+".length | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Require a remote host and path for VS Code URLs. The current checks accept Require 🤖 Prompt for AI Agents
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note Written by vs code remote url validation is pre-existing and out of scope for this pr, which only adds the zed scheme. happy to follow up separately.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The VS Code URL validation finding remains applicable as a separate hardening task. Would you like me to open a follow-up GitHub issue for it? You are interacting with an AI system. |
||
| ); | ||
| }; | ||
|
|
||
| export function parseSafeExternalUrl(rawUrl: unknown): Option.Option<string> { | ||
| if (typeof rawUrl !== "string") { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 High
electron/ElectronShell.ts:45isRemoteEditorUrlrejectszed://ssh/<host>/whenabsolutePathis/, so the desktop bridge returnsfalseand Zed cannot open remote projects rooted at the filesystem root.ZED_SSH_PATHNAMErequires at least one character after the host’s slash; allow that segment to be empty for the root path.🤖 Copy this AI Prompt to have your agent fix this: