The best way to control Claude Code, Codex and more from any computer or phone
fix(server): open projects in a new VS Code window (#34480)
Julius Marminge committed
Nov 11, 2026 at 16:01 UTC
3af501840b841a6247fae9c20ea409b597f5b64a
2 files changed
+51
-2
apps/server/src/process/externalLauncher.test.ts
+40
@@ -182,6 +182,46 @@ it.effect.skipIf(windowsHost)(
182
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
183
);
184
185
+// A project opened from T3 must not replace the editor's last active window.
186
+it.effect.skipIf(windowsHost)(
187
+ "opens a project folder in a new VS Code window and a file in the existing one",
188
+ () =>
189
+ Effect.gen(function* () {
190
+ const fileSystem = yield* FileSystem.FileSystem;
191
+ const path = yield* Path.Path;
192
+ const binDir = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-editors-" });
193
+ const project = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-project-" });
194
+ const codePath = path.join(binDir, "code");
195
+ yield* fileSystem.writeFileString(codePath, "#!/bin/sh\n");
196
+ yield* fileSystem.chmod(codePath, 0o755);
197
+ const file = `${path.join(project, "file.ts")}:3:7`;
198
+
199
+ const spawned: ChildProcess.StandardCommand[] = [];
200
+ yield* Effect.gen(function* () {
201
+ const launcher = yield* ExternalLauncher.ExternalLauncher;
202
+ yield* launcher.launchEditor({ editor: "vscode", cwd: project });
203
+ yield* launcher.launchEditor({ editor: "vscode", cwd: file });
204
+ }).pipe(
205
+ Effect.provide(
206
+ layerTest({
207
+ platform: "linux",
208
+ env: { PATH: binDir, DISPLAY: ":0" },
209
+ onSpawn: (command) => spawned.push(command),
210
+ }),
211
+ ),
212
+ Effect.provideService(HostProcess.Environment, { PATH: binDir, DISPLAY: ":0" }),
213
+ );
214
+
215
+ assert.deepEqual(
216
+ spawned.map((command) => command.args),
217
+ [
218
+ ["--new-window", project],
219
+ ["--goto", file],
220
+ ],
221
+ );
222
+ }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
223
+);
224
+
225
// Windows drive letters cannot resolve the POSIX editor stub.
226
it.effect.skipIf(windowsHost)(
227
"a Linux editor launch without a display takes the desktop session's display from the systemd user manager",
apps/server/src/process/externalLauncher.ts
+11
-2
@@ -139,6 +139,7 @@ function parseTargetPathAndPosition(target: string): Option.Option<TargetPathAnd
139
function resolveCommandEditorArgs(
140
editor: (typeof EDITORS)[number],
141
target: string,
142
+ isDirectory: boolean,
143
): ReadonlyArray<string> {
144
const parsedTarget = parseTargetPathAndPosition(target);
145
@@ -146,7 +147,9 @@ function resolveCommandEditorArgs(
147
case "direct-path":
148
return [target];
149
case "goto":
149
- return Option.isSome(parsedTarget) ? ["--goto", target] : [target];
150
+ if (Option.isSome(parsedTarget)) return ["--goto", target];
151
+ // Without a window flag, VS Code's window settings may replace the user's last active window.
152
+ return isDirectory ? ["--new-window", target] : [target];
153
case "line-column":
154
return Option.match(parsedTarget, {
155
onNone: () => [target],
@@ -485,11 +488,17 @@ const resolveEditorLaunch = Effect.fn("resolveEditorLaunch")(function* (
488
});
489
}
490
const { command, baseArgs } = resolved.value;
491
+ const isDirectory =
492
+ editorDef.launchStyle === "goto" &&
493
+ (yield* (yield* FileSystem.FileSystem).stat(input.cwd).pipe(
494
+ Effect.map((info) => info.type === "Directory"),
495
+ Effect.orElseSucceed(() => false),
496
+ ));
497
return {
498
editor: editorDef.id,
499
target: input.cwd,
500
command,
492
- args: [...baseArgs, ...resolveCommandEditorArgs(editorDef, input.cwd)],
501
+ args: [...baseArgs, ...resolveCommandEditorArgs(editorDef, input.cwd, isDirectory)],
502
};
503
}
504