Skip to content
TypeScript

fix(server): opening a folder in File Explorer no longer lands on the wrong folder (#18549)

Aqua2e8d70b2323a
diff --git a/apps/server/src/process/externalLauncher.test.ts b/apps/server/src/process/externalLauncher.test.ts
index 17fa5c1b760..21c7547374d 100644
--- a/apps/server/src/process/externalLauncher.test.ts
+++ b/apps/server/src/process/externalLauncher.test.ts
@@ -302,6 +302,34 @@ it.effect("launches Cursor in classic IDE mode through the Windows command shim"
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
);
+it.effect("opens a folder in File Explorer with Windows separators", () =>
+ Effect.gen(function* () {
+ const fileSystem = yield* FileSystem.FileSystem;
+ const path = yield* Path.Path;
+ const binDir = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-editors-" });
+ yield* fileSystem.writeFileString(path.join(binDir, "explorer.EXE"), "");
+
+ let spawned: ChildProcess.StandardCommand | undefined;
+ yield* Effect.gen(function* () {
+ const launcher = yield* ExternalLauncher.ExternalLauncher;
+ yield* launcher.launchEditor({ editor: "file-manager", cwd: "C:/workspace/project" });
+ }).pipe(
+ Effect.provide(
+ layerTest({
+ platform: "win32",
+ env: { PATH: binDir, PATHEXT: ".COM;.EXE;.BAT;.CMD" },
+ onSpawn: (command) => {
+ spawned = command;
+ },
+ }),
+ ),
+ );
+
+ assert.ok(spawned);
+ assert.deepEqual(spawned.args, ["C:\\workspace\\project"]);
+ }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
+);
+
it.effect.skipIf(windowsHost)("reveals a file in Finder with open -R on macOS", () =>
Effect.gen(function* () {
const fileSystem = yield* FileSystem.FileSystem;
diff --git a/apps/server/src/process/externalLauncher.ts b/apps/server/src/process/externalLauncher.ts
index 31c33958684..13062253235 100644
--- a/apps/server/src/process/externalLauncher.ts
+++ b/apps/server/src/process/externalLauncher.ts
@@ -553,7 +553,11 @@ const resolveEditorLaunch = Effect.fn("resolveEditorLaunch")(function* (
args:
command === "explorer.exe" && env.WSL_DISTRO_NAME !== undefined
? [resolveWslFileManagerPath(input.cwd, env.WSL_DISTRO_NAME)]
- : [input.cwd],
+ : platform === "win32"
+ ? // Explorer reads `/` as a switch, so `C:/repo` silently opens
+ // a default folder instead of the target.
+ [normalizeWindowsFileManagerPath(input.cwd)]
+ : [input.cwd],
};
});