Skip to content

Commit 64a8b5a

Browse files
trevoedwardsclaude
andcommitted
fix(server): Reveal in File Explorer opens a window on Windows again
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
1 parent 42160f2 commit 64a8b5a

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

‎apps/server/src/process/externalLauncher.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,8 @@ it.effect("reveals a file in File Explorer through PowerShell on Windows", () =>
341341
"$ProgressPreference = 'SilentlyContinue'; Start-Process 'explorer.exe' -ArgumentList ('/select,\"' + 'C:\\workspace with spaces\\media\\author''s clip.mp4' + '\"')",
342342
);
343343
assert.equal(spawned.options.shell, false);
344+
// Detached, PowerShell exits without ever starting Explorer.
345+
assert.equal(spawned.options.detached, false);
344346
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
345347
);
346348

‎apps/server/src/process/externalLauncher.ts‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ interface EditorLaunch {
6262
readonly target: string;
6363
readonly command: string;
6464
readonly args: ReadonlyArray<string>;
65+
/** Defaults to detached; see the native Windows reveal for the exception. */
66+
readonly detached?: boolean;
6567
}
6668

6769
interface ProcessLaunch {
@@ -636,11 +638,17 @@ const resolveFileManagerRevealLaunch = Effect.fn("resolveFileManagerRevealLaunch
636638
}
637639

638640
if (platform === "win32") {
639-
return fileExplorerRevealLaunch(
640-
target,
641-
normalizeWindowsFileManagerPath(target),
642-
resolvePowerShellPath(env),
643-
);
641+
// A detached PowerShell (no console) exits 0 without running its command,
642+
// so Explorer never opens. It must share the server's console; it is
643+
// short-lived and Explorer outlives it either way.
644+
return {
645+
...fileExplorerRevealLaunch(
646+
target,
647+
normalizeWindowsFileManagerPath(target),
648+
resolvePowerShellPath(env),
649+
),
650+
detached: false,
651+
};
644652
}
645653

646654
if (
@@ -744,7 +752,7 @@ const launchEditorProcess = Effect.fn("externalLauncher.launchEditorProcess")(fu
744752
command: spawnCommand.command,
745753
args: spawnCommand.args,
746754
options: {
747-
detached: true,
755+
detached: launch.detached ?? true,
748756
shell: spawnCommand.shell,
749757
stdin: "ignore",
750758
stdout: "ignore",

0 commit comments

Comments
 (0)