@devries-cameron20 / t3code Mirror · read-only / commits / 703810f308
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 21, 12:15 UTC

fix(server): Open in and Reveal open ~/ file links from projects outside the home folder (#31246)

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

MarcoDotIO committed Nov 14, 2026 at 20:46 UTC 703810f3086ef08867ae8148b0baace20fa0bacc
2 files changed +48 -32
apps/server/src/process/externalLauncher.test.ts
+41 -30
@@ -105,36 +105,47 @@ const layerTest = (input: {
105 };
106
107 // macOS command lookup cannot search a Windows drive-letter PATH.
108 -it.effect.skipIf(windowsHost)(
109 - "opens home-relative app bundles using the server home directory",
110 - () =>
111 - Effect.gen(function* () {
112 - const fs = yield* FileSystem.FileSystem;
113 - const path = yield* Path.Path;
114 - const bin = yield* fs.makeTempDirectoryScoped({ prefix: "t3-app-open-" });
115 - yield* fs.writeFileString(path.join(bin, "open"), "#!/bin/sh\n");
116 - yield* fs.chmod(path.join(bin, "open"), 0o755);
117 - const spawned: ChildProcess.StandardCommand[] = [];
118 - yield* Effect.gen(function* () {
119 - const launcher = yield* ExternalLauncher.ExternalLauncher;
120 - for (const cwd of ["~/Applications/My App.app", "/Applications/My App.app"]) {
121 - yield* launcher.launchEditor({ editor: "file-manager", cwd });
122 - }
123 - }).pipe(
124 - Effect.provide(
125 - layerTest({
126 - platform: "darwin",
127 - env: { PATH: bin },
128 - onSpawn: (command) => spawned.push(command),
129 - }),
130 - ),
131 - Effect.provideService(HostProcess.HomeDirectory, "/Users/server"),
132 - );
133 - assert.deepEqual(
134 - spawned.map((command) => command.args),
135 - [["/Users/server/Applications/My App.app"], ["/Applications/My App.app"]],
136 - );
137 - }).pipe(Effect.provide(NodeServices.layer)),
108 +it.effect.skipIf(windowsHost)("opens home-relative targets using the server home directory", () =>
109 + Effect.gen(function* () {
110 + const fs = yield* FileSystem.FileSystem;
111 + const path = yield* Path.Path;
112 + const bin = yield* fs.makeTempDirectoryScoped({ prefix: "t3-app-open-" });
113 + for (const name of ["open", "code", "idea"]) {
114 + yield* fs.writeFileString(path.join(bin, name), "#!/bin/sh\n");
115 + yield* fs.chmod(path.join(bin, name), 0o755);
116 + }
117 + const spawned: ChildProcess.StandardCommand[] = [];
118 + yield* Effect.gen(function* () {
119 + const launcher = yield* ExternalLauncher.ExternalLauncher;
120 + for (const cwd of ["~/Applications/My App.app", "/Applications/My App.app"]) {
121 + yield* launcher.launchEditor({ editor: "file-manager", cwd });
122 + }
123 + yield* launcher.launchEditor({ editor: "vscode", cwd: "~/notes/todo.md:3" });
124 + yield* launcher.launchEditor({
125 + editor: "idea",
126 + cwd: "~/notes/todo.md:3",
127 + projectRoot: "~/notes",
128 + });
129 + }).pipe(
130 + Effect.provide(
131 + layerTest({
132 + platform: "darwin",
133 + env: { PATH: bin },
134 + onSpawn: (command) => spawned.push(command),
135 + }),
136 + ),
137 + Effect.provideService(HostProcess.HomeDirectory, "/Users/server"),
138 + );
139 + assert.deepEqual(
140 + spawned.map((command) => command.args),
141 + [
142 + ["/Users/server/Applications/My App.app"],
143 + ["/Applications/My App.app"],
144 + ["--goto", "/Users/server/notes/todo.md:3"],
145 + ["/Users/server/notes", "--line", "3", "/Users/server/notes/todo.md"],
146 + ],
147 + );
148 + }).pipe(Effect.provide(NodeServices.layer)),
149 );
150
151 it.effect.skipIf(windowsHost)(
apps/server/src/process/externalLauncher.ts
+7 -2
@@ -524,7 +524,7 @@ const resolveEditorLaunch = Effect.fn("resolveEditorLaunch")(function* (
524 return yield* new ExternalLauncherUnsupportedEditorError({ editor: input.editor });
525 }
526
527 - const target = expandHomePath(input.cwd, yield* HostProcess.HomeDirectory);
527 + const target = input.cwd;
528 if (input.reveal === true) {
529 return yield* resolveFileManagerRevealLaunch(target, platform, env, command);
530 }
@@ -731,7 +731,12 @@ const launchEditor = Effect.fn("externalLauncher.launchEditor")(function* (
731 input: LaunchEditorInput,
732 hasStockFolderVerb: Effect.Effect<boolean>,
733 ) {
734 - const launch = yield* resolveEditorLaunch(input);
734 + // Clients send `~/` host paths as written, and launches run without a shell to expand them.
735 + const home = yield* HostProcess.HomeDirectory;
736 + const cwd = expandHomePath(input.cwd, home);
737 + const projectRoot =
738 + input.projectRoot === undefined ? undefined : expandHomePath(input.projectRoot, home);
739 + const launch = yield* resolveEditorLaunch({ ...input, cwd, projectRoot });
740 if (input.editor === "file-manager" && input.reveal === true) {
741 const platform = yield* HostProcess.Platform;
742 if (