@devries-cameron20 / t3code Mirror · read-only / commits / 6c3c31d5e5
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 23:15 UTC

fix(web): preserve usernames in remote editor links (#18092)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Jake Leventhal committed Oct 20, 2026 at 01:05 UTC 6c3c31d5e5d8cf42a2785e6eef10eb3b5fdf84b1
9 files changed +198 -47
apps/desktop/src/electron/ElectronShell.test.ts
+6 -6
@@ -78,12 +78,12 @@ describe("ElectronShell", () => {
78
79 const electronShell = yield* ElectronShell.ElectronShell;
80 const result = yield* electronShell.openExternal(
81 - "vscode://vscode-remote/ssh-remote+example.com/home/user/project",
81 + "vscode://vscode-remote/ssh-remote+user%40example.com/home/user/project",
82 );
83
84 assert.equal(result, true);
85 assert.deepEqual(openExternalMock.mock.calls, [
86 - ["vscode://vscode-remote/ssh-remote+example.com/home/user/project"],
86 + ["vscode://vscode-remote/ssh-remote+user%40example.com/home/user/project"],
87 ]);
88 }).pipe(Effect.provide(ElectronShell.layer)),
89 );
@@ -94,13 +94,13 @@ describe("ElectronShell", () => {
94
95 const electronShell = yield* ElectronShell.ElectronShell;
96 const results = yield* Effect.all([
97 - electronShell.openExternal("zed://ssh/example.com/home/user/project"),
97 + electronShell.openExternal("zed://ssh/user@example.com/home/user/project"),
98 electronShell.openExternal("zed://ssh/example.com/"),
99 ]);
100
101 assert.deepEqual(results, [true, true]);
102 assert.deepEqual(openExternalMock.mock.calls, [
103 - ["zed://ssh/example.com/home/user/project"],
103 + ["zed://ssh/user@example.com/home/user/project"],
104 ["zed://ssh/example.com/"],
105 ]);
106 }).pipe(Effect.provide(ElectronShell.layer)),
@@ -111,7 +111,7 @@ describe("ElectronShell", () => {
111 openExternalMock.mockResolvedValue(undefined);
112
113 const url =
114 - "jetbrains://gateway/ssh/environment?h=example.com&launchIde=true&ideHint=IU&projectHint=%2Fhome%2Fuser%2Fproject";
114 + "jetbrains://gateway/ssh/environment?h=example.com&launchIde=true&ideHint=IU&projectHint=%2Fhome%2Fuser%2Fproject&u=user";
115 const electronShell = yield* ElectronShell.ElectronShell;
116 const result = yield* electronShell.openExternal(url);
117
@@ -150,7 +150,7 @@ describe("ElectronShell", () => {
150 electronShell.openExternal(
151 "vscode://:secret@vscode-remote/ssh-remote+example.com/home/user/project",
152 ),
153 - electronShell.openExternal("zed://ssh/user@example.com/home/user/project"),
153 + electronShell.openExternal("zed://ssh/user:secret@example.com/home/user/project"),
154 electronShell.openExternal("jetbrains://user@gateway/ssh/environment?h=example.com"),
155 ]);
156
apps/desktop/src/electron/ElectronShell.ts
+2 -2
@@ -22,8 +22,8 @@ const REMOTE_EDITOR_PROTOCOLS = new Set(
22 }),
23 );
24
25 -// Zed's host sits in the first path segment, so it needs its own userinfo ban.
26 -const ZED_SSH_PATHNAME = /^\/[^/@:]+\/.*$/;
25 +// Zed embeds [user@]host in the path; reject passwords and ports there.
26 +const ZED_SSH_PATHNAME = /^\/(?:[^/@:]+@)?[^/@:]+\/.*$/;
27
28 const isRemoteEditorUrl = (url: URL) =>
29 REMOTE_EDITOR_PROTOCOLS.has(url.protocol) &&
apps/server/src/environment/RemoteOpenTargets.test.ts
+55 -9
@@ -1,3 +1,6 @@
1 +// @effect-diagnostics nodeBuiltinImport:off -- replace the native OS lookup and sync its ESM bindings.
2 +import * as NodeModule from "node:module";
3 +import type * as NodeOS from "node:os";
4 import { it } from "@effect/vitest";
5 import * as HostProcess from "@t3tools/shared/HostProcess";
6 import * as NetService from "@t3tools/shared/Net";
@@ -7,10 +10,17 @@ import * as Sink from "effect/Sink";
10 import * as Stream from "effect/Stream";
11 import * as ChildProcess from "effect/process/ChildProcess";
12 import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
10 -import { describe, expect } from "vite-plus/test";
13 +import { afterEach, describe, expect, vi } from "vite-plus/test";
14
15 import * as RemoteOpenTargets from "./RemoteOpenTargets.ts";
16
17 +const mutableOs = NodeModule.createRequire(import.meta.url)("node:os") as typeof NodeOS;
18 +
19 +afterEach(() => {
20 + vi.restoreAllMocks();
21 + NodeModule.syncBuiltinESMExports();
22 +});
23 +
24 const encoder = new TextEncoder();
25
26 const TAILSCALE_STATUS_JSON = JSON.stringify({
@@ -59,8 +69,11 @@ const resolveTargets = (input: {
69 readonly sshd: { readonly ipv4: boolean; readonly ipv6: boolean };
70 readonly tailscale: { readonly status: CommandResult; readonly prefs: CommandResult };
71 readonly hostname: string;
62 -}) =>
63 - Effect.flatMap(RemoteOpenTargets.RemoteOpenTargets, (service) => service.resolveTargets()).pipe(
72 + readonly username?: string | null;
73 +}) => {
74 + const resolve = Effect.flatMap(RemoteOpenTargets.RemoteOpenTargets, (service) =>
75 + service.resolveTargets(),
76 + ).pipe(
77 Effect.provideService(HostProcess.Hostname, input.hostname),
78 Effect.provide(
79 RemoteOpenTargets.layer.pipe(
@@ -69,6 +82,11 @@ const resolveTargets = (input: {
82 ),
83 );
84
85 + return input.username === undefined
86 + ? resolve
87 + : resolve.pipe(Effect.provideService(HostProcess.Username, input.username));
88 +};
89 +
90 const prefsJson = (prefs: { readonly RunSSH: boolean; readonly WantRunning: boolean }) => ({
91 exitCode: 0,
92 stdout: JSON.stringify(
@@ -90,6 +108,7 @@ describe("RemoteOpenTargets", () => {
108 sshd: { ipv4: false, ipv6: false },
109 tailscale: TAILSCALE_UP,
110 hostname: "bb-1",
111 + username: "t3-user",
112 });
113 expect(targets).toEqual([]);
114 }),
@@ -101,8 +120,11 @@ describe("RemoteOpenTargets", () => {
120 sshd: { ipv4: false, ipv6: false },
121 tailscale: TAILSCALE_SSH,
122 hostname: "bb-1",
123 + username: "t3-user",
124 });
105 - expect(targets).toEqual([{ kind: "tailscale", host: "bb-1.tail1234.ts.net" }]);
125 + expect(targets).toEqual([
126 + { kind: "tailscale", host: "bb-1.tail1234.ts.net", username: "t3-user" },
127 + ]);
128 }),
129 );
130
@@ -112,6 +134,7 @@ describe("RemoteOpenTargets", () => {
134 sshd: { ipv4: false, ipv6: false },
135 tailscale: { status: STATUS_UP, prefs: prefsJson({ RunSSH: true, WantRunning: false }) },
136 hostname: "bb-1",
137 + username: null,
138 });
139 expect(targets).toEqual([]);
140 }),
@@ -123,10 +146,11 @@ describe("RemoteOpenTargets", () => {
146 sshd: { ipv4: true, ipv6: true },
147 tailscale: TAILSCALE_UP,
148 hostname: "bb-1",
149 + username: "t3-user",
150 });
151 expect(targets).toEqual([
128 - { kind: "tailscale", host: "bb-1.tail1234.ts.net" },
129 - { kind: "mdns", host: "bb-1.local" },
152 + { kind: "tailscale", host: "bb-1.tail1234.ts.net", username: "t3-user" },
153 + { kind: "mdns", host: "bb-1.local", username: "t3-user" },
154 ]);
155 }),
156 );
@@ -137,8 +161,9 @@ describe("RemoteOpenTargets", () => {
161 sshd: { ipv4: false, ipv6: true },
162 tailscale: TAILSCALE_DOWN,
163 hostname: "bb-1",
164 + username: "t3-user",
165 });
141 - expect(targets).toEqual([{ kind: "mdns", host: "bb-1.local" }]);
166 + expect(targets).toEqual([{ kind: "mdns", host: "bb-1.local", username: "t3-user" }]);
167 }),
168 );
169
@@ -148,8 +173,9 @@ describe("RemoteOpenTargets", () => {
173 sshd: { ipv4: true, ipv6: false },
174 tailscale: TAILSCALE_DOWN,
175 hostname: "bb-1",
176 + username: "t3-user",
177 });
152 - expect(targets).toEqual([{ kind: "mdns", host: "bb-1.local" }]);
178 + expect(targets).toEqual([{ kind: "mdns", host: "bb-1.local", username: "t3-user" }]);
179 }),
180 );
181
@@ -159,8 +185,28 @@ describe("RemoteOpenTargets", () => {
185 sshd: { ipv4: true, ipv6: true },
186 tailscale: TAILSCALE_DOWN,
187 hostname: "bb-1.example.com",
188 + username: "t3-user",
189 + });
190 + expect(targets).toEqual([{ kind: "mdns", host: "bb-1.local", username: "t3-user" }]);
191 + }),
192 + );
193 +
194 + it.effect("still advertises hostname targets when the OS login lookup fails", () =>
195 + Effect.gen(function* () {
196 + const userInfo = vi.spyOn(mutableOs, "userInfo").mockImplementation(() => {
197 + throw new Error("No passwd entry for this UID");
198 });
163 - expect(targets).toEqual([{ kind: "mdns", host: "bb-1.local" }]);
199 + NodeModule.syncBuiltinESMExports();
200 + const targets = yield* resolveTargets({
201 + sshd: { ipv4: true, ipv6: true },
202 + tailscale: TAILSCALE_UP,
203 + hostname: "bb-1",
204 + });
205 + expect(userInfo).toHaveBeenCalled();
206 + expect(targets).toEqual([
207 + { kind: "tailscale", host: "bb-1.tail1234.ts.net" },
208 + { kind: "mdns", host: "bb-1.local" },
209 + ]);
210 }),
211 );
212 });
apps/server/src/environment/RemoteOpenTargets.ts
+16 -3
@@ -28,6 +28,7 @@ export const make = Effect.gen(function* () {
28 net.hasListenerOnHost(SSH_PORT, "::1"),
29 (ipv4, ipv6) => ipv4 || ipv6,
30 );
31 + const username = yield* HostProcess.Username;
32
33 const magicDnsName = yield* readTailscaleStatus.pipe(
34 Effect.map((status) => status.magicDnsName),
@@ -47,13 +48,21 @@ export const make = Effect.gen(function* () {
48 Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
49 ))
50 ) {
50 - targets.push({ kind: "tailscale", host: magicDnsName });
51 + targets.push({
52 + kind: "tailscale",
53 + host: magicDnsName,
54 + ...(username === null ? {} : { username }),
55 + });
56 }
57 return targets;
58 }
59
60 if (magicDnsName !== null) {
56 - targets.push({ kind: "tailscale", host: magicDnsName });
61 + targets.push({
62 + kind: "tailscale",
63 + host: magicDnsName,
64 + ...(username === null ? {} : { username }),
65 + });
66 }
67
68 // os.hostname() may already be an FQDN (macOS often reports
@@ -61,7 +70,11 @@ export const make = Effect.gen(function* () {
70 const hostname = yield* HostProcess.Hostname;
71 const shortHostname = hostname.split(".")[0]?.trim();
72 if (shortHostname !== undefined && shortHostname.length > 0) {
64 - targets.push({ kind: "mdns", host: `${shortHostname}.local` });
73 + targets.push({
74 + kind: "mdns",
75 + host: `${shortHostname}.local`,
76 + ...(username === null ? {} : { username }),
77 + });
78 }
79
80 return targets;
apps/web/src/components/chat/OpenInPicker.tsx
+1 -1
@@ -251,7 +251,7 @@ export const OpenInPicker = memo(function OpenInPicker({
251 if (remote.mode === "remote-links") {
252 const url = buildRemoteOpenUrl({
253 editor,
254 - host: remote.host.host,
254 + ...remote.host,
255 absolutePath: openInCwd,
256 isFile: openInCwdIsFile,
257 });
apps/web/src/remoteOpen.test.ts
+71 -18
@@ -29,7 +29,7 @@ describe("resolveRemoteOpenState", () => {
29 expect(
30 resolveRemoteOpenState({
31 target: primaryTarget("http://127.0.0.1:8000"),
32 - sshAlias: null,
32 + sshTarget: null,
33 isDesktopRenderer: false,
34 remoteOpenTargets: TAILSCALE_TARGETS,
35 }),
@@ -40,7 +40,7 @@ describe("resolveRemoteOpenState", () => {
40 expect(
41 resolveRemoteOpenState({
42 target: primaryTarget("https://sol.tail1234.ts.net"),
43 - sshAlias: null,
43 + sshTarget: null,
44 isDesktopRenderer: false,
45 remoteOpenTargets: TAILSCALE_TARGETS,
46 }),
@@ -56,7 +56,7 @@ describe("resolveRemoteOpenState", () => {
56 expect(
57 resolveRemoteOpenState({
58 target: primaryTarget("http://172.29.112.1:14369"),
59 - sshAlias: null,
59 + sshTarget: null,
60 isDesktopRenderer: true,
61 remoteOpenTargets: TAILSCALE_TARGETS,
62 }),
@@ -71,26 +71,79 @@ describe("resolveRemoteOpenState", () => {
71 label: "WSL (Ubuntu)",
72 connectionId: "local:wsl-1",
73 }),
74 - sshAlias: null,
74 + sshTarget: null,
75 isDesktopRenderer: false,
76 remoteOpenTargets: TAILSCALE_TARGETS,
77 }),
78 ).toEqual({ mode: "local-exec" });
79 });
80
81 - it("prefers the desktop SSH alias over server-advertised hosts", () => {
81 + it("leaves a bare desktop SSH alias for the editor to resolve through SSH config", () => {
82 + const state = resolveRemoteOpenState({
83 + target: new SshConnectionTarget({ environmentId, label: "sol", connectionId: "ssh-1" }),
84 + sshTarget: { alias: "sol", username: null },
85 + isDesktopRenderer: true,
86 + remoteOpenTargets: [
87 + { kind: "tailscale", host: "sol.tail1234.ts.net", username: "server-user" },
88 + ],
89 + });
90 + expect(state).toEqual({ mode: "remote-links", host: { kind: "ssh-alias", host: "sol" } });
91 + if (state.mode !== "remote-links") throw new Error("Expected a remote link");
92 expect(
83 - resolveRemoteOpenState({
84 - target: new SshConnectionTarget({
85 - environmentId,
86 - label: "sol",
87 - connectionId: "ssh-1",
88 - }),
89 - sshAlias: "sol",
90 - isDesktopRenderer: true,
91 - remoteOpenTargets: TAILSCALE_TARGETS,
92 - }),
93 - ).toEqual({ mode: "remote-links", host: { kind: "ssh-alias", host: "sol" } });
93 + buildRemoteOpenUrl({ editor: "vscode", ...state.host, absolutePath: "/work/project" }),
94 + ).toBe("vscode://vscode-remote/ssh-remote+sol/work/project");
95 + expect(
96 + buildRemoteOpenUrl({ editor: "zed", ...state.host, absolutePath: "/work/project" }),
97 + ).toBe("zed://ssh/sol/work/project");
98 + expect(
99 + buildRemoteOpenUrl({ editor: "idea", ...state.host, absolutePath: "/work/project" }),
100 + ).toBe(
101 + "jetbrains://gateway/ssh/environment?h=sol&launchIde=true&ideHint=IU&projectHint=%2Fwork%2Fproject",
102 + );
103 + });
104 +
105 + it.each([
106 + { alias: "server", username: "admin-user" },
107 + { alias: "admin-user@server", username: null },
108 + { alias: "old-user@server", username: "admin-user" },
109 + { alias: "admin-user@server", username: "" },
110 + { alias: "admin-user@server", username: " " },
111 + ])("keeps one login username in editor links for $alias (username: '$username')", (sshTarget) => {
112 + const state = resolveRemoteOpenState({
113 + target: new SshConnectionTarget({ environmentId, label: "server", connectionId: "ssh-1" }),
114 + sshTarget,
115 + isDesktopRenderer: true,
116 + remoteOpenTargets: TAILSCALE_TARGETS,
117 + });
118 + expect(state.mode).toBe("remote-links");
119 + if (state.mode !== "remote-links") throw new Error("Expected a remote link");
120 + expect(
121 + buildRemoteOpenUrl({ editor: "vscode", ...state.host, absolutePath: "/work/project" }),
122 + ).toBe("vscode://vscode-remote/ssh-remote+admin-user%40server/work/project");
123 + expect(
124 + buildRemoteOpenUrl({ editor: "zed", ...state.host, absolutePath: "/work/project" }),
125 + ).toBe("zed://ssh/admin-user@server/work/project");
126 + expect(
127 + buildRemoteOpenUrl({ editor: "idea", ...state.host, absolutePath: "/work/project" }),
128 + ).toBe(
129 + "jetbrains://gateway/ssh/environment?h=server&launchIde=true&ideHint=IU&projectHint=%2Fwork%2Fproject&u=admin-user",
130 + );
131 + });
132 +
133 + it("uses the advertised login username in editor links over a relay", () => {
134 + const state = resolveRemoteOpenState({
135 + target: new RelayConnectionTarget({ environmentId, label: "server" }),
136 + sshTarget: null,
137 + isDesktopRenderer: false,
138 + remoteOpenTargets: [
139 + { kind: "tailscale", host: "server.tail1234.ts.net", username: "admin-user" },
140 + ],
141 + });
142 + expect(state.mode).toBe("remote-links");
143 + if (state.mode !== "remote-links") throw new Error("Expected a remote link");
144 + expect(
145 + buildRemoteOpenUrl({ editor: "cursor", ...state.host, absolutePath: "/work/project" }),
146 + ).toBe("cursor://vscode-remote/ssh-remote+admin-user%40server.tail1234.ts.net/work/project");
147 });
148
149 it("reports unavailable when a remote environment advertises no hosts", () => {
@@ -98,7 +151,7 @@ describe("resolveRemoteOpenState", () => {
151 expect(
152 resolveRemoteOpenState({
153 target: new RelayConnectionTarget({ environmentId, label: "sol" }),
101 - sshAlias: null,
154 + sshTarget: null,
155 isDesktopRenderer: false,
156 remoteOpenTargets,
157 }),
@@ -110,7 +163,7 @@ describe("resolveRemoteOpenState", () => {
163 expect(
164 resolveRemoteOpenState({
165 target: null,
113 - sshAlias: null,
166 + sshTarget: null,
167 isDesktopRenderer: false,
168 remoteOpenTargets: undefined,
169 }),
apps/web/src/remoteOpen.ts
+24 -6
@@ -19,6 +19,7 @@ import { environmentPresentations } from "~/state/presentation";
19 export interface RemoteOpenHost {
20 readonly kind: "ssh-alias" | RemoteOpenTarget["kind"];
21 readonly host: string;
22 + readonly username?: string;
23 }
24
25 export type RemoteOpenState =
@@ -50,7 +51,7 @@ function parseHostname(url: string): string | null {
51
52 export function resolveRemoteOpenState(input: {
53 readonly target: ConnectionTarget | null;
53 - readonly sshAlias: string | null;
54 + readonly sshTarget: { readonly alias: string; readonly username: string | null } | null;
55 readonly remoteOpenTargets: ReadonlyArray<RemoteOpenTarget> | undefined;
56 readonly isDesktopRenderer: boolean;
57 }): RemoteOpenState {
@@ -72,8 +73,21 @@ export function resolveRemoteOpenState(input: {
73 return LOCAL_EXEC;
74 }
75
75 - if (input.sshAlias !== null && input.sshAlias.length > 0) {
76 - return { mode: "remote-links", host: { kind: "ssh-alias", host: input.sshAlias } };
76 + if (input.sshTarget !== null && input.sshTarget.alias.length > 0) {
77 + const { alias } = input.sshTarget;
78 + const userSeparator = alias.lastIndexOf("@");
79 + const host = userSeparator === -1 ? alias : alias.slice(userSeparator + 1);
80 + const username =
81 + input.sshTarget.username?.trim() ||
82 + (userSeparator === -1 ? null : alias.slice(0, userSeparator));
83 + return {
84 + mode: "remote-links",
85 + host: {
86 + kind: "ssh-alias",
87 + host,
88 + ...(username === null ? {} : { username }),
89 + },
90 + };
91 }
92 const advertised = input.remoteOpenTargets?.[0];
93 if (advertised !== undefined) {
@@ -85,7 +99,11 @@ export function resolveRemoteOpenState(input: {
99 function remoteOpenStatesEqual(previous: RemoteOpenState, next: RemoteOpenState): boolean {
100 if (previous.mode !== next.mode) return false;
101 if (previous.mode !== "remote-links" || next.mode !== "remote-links") return true;
88 - return previous.host.kind === next.host.kind && previous.host.host === next.host.host;
102 + return (
103 + previous.host.kind === next.host.kind &&
104 + previous.host.host === next.host.host &&
105 + previous.host.username === next.host.username
106 + );
107 }
108
109 // The presentation changes with every server config push and reconnect. This
@@ -102,8 +120,8 @@ const remoteOpenResolutionAtom = Atom.family((environmentId: EnvironmentId) =>
120 const next: RemoteOpenResolution = {
121 state: resolveRemoteOpenState({
122 target: entry.target,
105 - sshAlias:
106 - profile !== null && profile._tag === "SshConnectionProfile" ? profile.target.alias : null,
123 + sshTarget:
124 + profile !== null && profile._tag === "SshConnectionProfile" ? profile.target : null,
125 remoteOpenTargets: presentation?.serverConfig?.remoteOpenTargets,
126 isDesktopRenderer: window.desktopBridge !== undefined,
127 }),
packages/contracts/src/editor.ts
+13 -2
@@ -180,6 +180,7 @@ export const remoteSchemeForEditor = (id: EditorId): string | undefined => {
180 export const buildRemoteOpenUrl = (input: {
181 readonly editor: EditorId;
182 readonly host: string;
183 + readonly username?: string;
184 readonly absolutePath: string;
185 readonly isFile?: boolean;
186 }): string | undefined => {
@@ -195,6 +196,9 @@ export const buildRemoteOpenUrl = (input: {
196 ideHint: editor.jetbrainsProductCode,
197 projectHint: input.absolutePath.replaceAll("\\", "/"),
198 });
199 + if (input.username !== undefined) {
200 + params.set("u", input.username);
201 + }
202 return `${scheme}://gateway/ssh/environment?${params.toString()}`;
203 }
204 // Windows server paths (`C:\...`) appear as `/C:/...` in vscode-remote URIs.
@@ -208,11 +212,17 @@ export const buildRemoteOpenUrl = (input: {
212 // POSIX path that happens to start with `/C:` is left alone.
213 const zedPath = /^[Cc]:[\\/]/.test(input.absolutePath) ? rootedPath.slice(3) : rootedPath;
214 const encodedZedPath = zedPath.split("/").map(encodeURIComponent).join("/");
211 - return `${scheme}://ssh/${encodedHost}${encodedZedPath}`;
215 + // Zed reads this segment as ssh URL userinfo, so the `@` stays literal.
216 + const zedDestination =
217 + input.username === undefined
218 + ? encodedHost
219 + : `${encodeURIComponent(input.username)}@${encodedHost}`;
220 + return `${scheme}://ssh/${zedDestination}${encodedZedPath}`;
221 }
222 const encodedPath = rootedPath.split("/").map(encodeURIComponent).join("/");
223 + const destination = input.username === undefined ? input.host : `${input.username}@${input.host}`;
224 // VS Code opens a bare vscode-remote path as a folder; a trailing position makes it open the file.
215 - return `${scheme}://vscode-remote/ssh-remote+${encodedHost}${encodedPath}${input.isFile ? ":1:1" : ""}`;
225 + return `${scheme}://vscode-remote/ssh-remote+${encodeURIComponent(destination)}${encodedPath}${input.isFile ? ":1:1" : ""}`;
226 };
227
228 export const RemoteOpenTargetKind = Schema.Literals(["tailscale", "mdns"]);
@@ -221,6 +231,7 @@ export type RemoteOpenTargetKind = typeof RemoteOpenTargetKind.Type;
231 export const RemoteOpenTarget = Schema.Struct({
232 kind: RemoteOpenTargetKind,
233 host: TrimmedNonEmptyString,
234 + username: Schema.optionalKey(TrimmedNonEmptyString),
235 });
236 export type RemoteOpenTarget = typeof RemoteOpenTarget.Type;
237
packages/shared/src/HostProcess.ts
+10
@@ -19,6 +19,16 @@ export const Hostname = Context.Reference<string>("@t3tools/shared/HostProcess/H
19 defaultValue: () => NodeOS.hostname(),
20 });
21
22 +export const Username = Context.Reference<string | null>("@t3tools/shared/HostProcess/Username", {
23 + defaultValue: () => {
24 + try {
25 + return NodeOS.userInfo().username.trim() || null;
26 + } catch {
27 + return null;
28 + }
29 + },
30 +});
31 +
32 export const HomeDirectory = Context.Reference<string>(
33 "@t3tools/shared/HostProcess/HomeDirectory",
34 {