The best way to control Claude Code, Codex and more from any computer or phone
fix(contracts): Open in VS Code keeps a plus in the SSH username (#34578)
Julius Marminge committed
Nov 11, 2026 at 14:22 UTC
3a2564319236bf0a315edb8ca1e94bf52389ab0b
2 files changed
+34
-1
apps/web/src/remoteOpen.test.ts
+24
@@ -186,6 +186,30 @@ describe("buildRemoteOpenUrl", () => {
186
).toBe("vscode://vscode-remote/ssh-remote+sol/C%3A/Users/theo");
187
});
188
189
+ it("keeps a plus in the SSH username through Remote-SSH's authority parsing", () => {
190
+ const url = buildRemoteOpenUrl({
191
+ editor: "vscode",
192
+ host: "ssh.example.com",
193
+ username: "vm+demo",
194
+ absolutePath: "/workspace/project",
195
+ });
196
+ // VS Code decodes the authority, then Remote-SSH (0.129) takes `authority.split("+")[1]` and
197
+ // reads it as hex-encoded JSON `{ hostName, user }` or as `user@host`.
198
+ const authority = decodeURIComponent(new URL(url ?? "").pathname.split("/")[1] ?? "");
199
+ const destination = authority.split("+")[1] ?? "";
200
+ const hexBytes = /^(?:[0-9a-f]{2})+$/i.test(destination)
201
+ ? destination.match(/../g)?.map((byte) => Number.parseInt(byte, 16))
202
+ : undefined;
203
+ const resolved =
204
+ hexBytes === undefined
205
+ ? destination.match(/^(?:(?<user>.*)@)?(?<hostName>.+?)$/)?.groups
206
+ : JSON.parse(new TextDecoder().decode(new Uint8Array(hexBytes)));
207
+ expect({ user: resolved?.user, hostName: resolved?.hostName }).toEqual({
208
+ user: "vm+demo",
209
+ hostName: "ssh.example.com",
210
+ });
211
+ });
212
+
213
it("drops the Windows drive letter for Zed", () => {
214
expect(
215
buildRemoteOpenUrl({ editor: "zed", host: "sol", absolutePath: "C:\\Users\\theo" }),
packages/contracts/src/editor.ts
+10
-1
@@ -227,7 +227,16 @@ export const buildRemoteOpenUrl = (input: {
227
return `${scheme}://ssh/${zedDestination}${encodedZedPath}`;
228
}
229
const encodedPath = rootedPath.split("/").map(encodeURIComponent).join("/");
230
- const destination = input.username === undefined ? input.host : `${input.username}@${input.host}`;
230
+ const plainDestination =
231
+ input.username === undefined ? input.host : `${input.username}@${input.host}`;
232
+ // Remote-SSH splits the decoded authority on "+", so a destination containing one must use its
233
+ // hex-encoded JSON form instead.
234
+ const destination = plainDestination.includes("+")
235
+ ? Array.from(
236
+ new TextEncoder().encode(JSON.stringify({ hostName: input.host, user: input.username })),
237
+ (byte) => byte.toString(16).padStart(2, "0"),
238
+ ).join("")
239
+ : plainDestination;
240
// VS Code opens a bare vscode-remote path as a folder; a trailing position makes it open the file.
241
return `${scheme}://vscode-remote/ssh-remote+${encodeURIComponent(destination)}${encodedPath}${input.isFile ? ":1:1" : ""}`;
242
};