The best way to control Claude Code, Codex and more from any computer or phone
fix(server): reveal opens the default Windows file manager (#19526)
Co-authored-by: Cody Stevens <cody.rageentertainment@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Cody Stevens committed
Oct 19, 2026 at 23:17 UTC
e67b555f20ec8523afe630f9a48b1f699fa2cf6e
2 files changed
+56
-43
apps/server/src/process/externalLauncher.test.ts
+33
-12
@@ -465,16 +465,21 @@ it.effect("reveals a file in File Explorer through PowerShell on Windows", () =>
465
const decodedCommand = Buffer.from(encodedCommand, "base64").toString("utf16le");
466
assert.equal(
467
decodedCommand,
468
- "$ProgressPreference = 'SilentlyContinue'; Start-Process 'explorer.exe' -ArgumentList ('/select,\"' + 'C:\\workspace with spaces\\media\\author''s clip.mp4' + '\"')",
468
+ "$ProgressPreference = 'SilentlyContinue'; $folderVerb = (Get-ItemProperty -LiteralPath 'Registry::HKEY_CLASSES_ROOT\\Directory\\shell' -ErrorAction SilentlyContinue).'(default)'; if ($folderVerb -and $folderVerb -ne 'none') { Invoke-Item -LiteralPath 'C:\\workspace with spaces\\media' } else { Start-Process 'explorer.exe' -ArgumentList ('/select,\"' + 'C:\\workspace with spaces\\media\\author''s clip.mp4' + '\"') }",
469
);
470
assert.equal(spawned.options.shell, false);
471
assert.equal(spawned.options.detached, false);
472
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
473
);
474
475
-for (const kind of ["browser", "reveal"] as const) {
475
+for (const { kind, folderVerb } of [
476
+ { kind: "browser", folderVerb: "none" },
477
+ { kind: "reveal", folderVerb: "none" },
478
+ { kind: "reveal", folderVerb: "" },
479
+ { kind: "reveal", folderVerb: "open" },
480
+] as const) {
481
it.live.skipIf(!windowsHost)(
477
- `completes a ${kind} launch through real PowerShell after the launcher scope closes`,
482
+ `completes a ${kind} launch through real PowerShell after the launcher scope closes (folder verb: ${folderVerb || "empty"})`,
483
() =>
484
Effect.gen(function* () {
485
const tempDir = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-reveal-smoke-"));
@@ -499,22 +504,28 @@ for (const kind of ["browser", "reveal"] as const) {
504
);
505
});
506
502
- const target = "C:/workspace with spaces/media/author's clip.mp4";
507
+ const target = "C:/workspace with spaces/author's media/clip.mp4";
508
yield* Effect.all(
509
[
510
Effect.gen(function* () {
511
const realSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
512
const recordingSpawner = ChildProcessSpawner.make((command) => {
513
assert.ok(ChildProcess.isStandardCommand(command));
514
+ const recorderLiteral = `'${recorderPath.replaceAll("'", "''")}'`;
515
const source = Buffer.from(command.args.at(-1) ?? "", "base64")
516
.toString("utf16le")
511
- .replace("'explorer.exe'", `'${recorderPath.replaceAll("'", "''")}'`);
517
+ .replace("'explorer.exe'", recorderLiteral);
518
+ // Control the association without changing the host registry or opening its file manager.
519
+ const handlers =
520
+ kind === "reveal"
521
+ ? `function Get-ItemProperty { [CmdletBinding()] param([string]$LiteralPath); if ($LiteralPath -ne 'Registry::HKEY_CLASSES_ROOT\\Directory\\shell') { throw 'Unexpected registry path' }; @{ '(default)' = '${folderVerb}' } }; function Invoke-Item { param([string]$LiteralPath); Start-Process ${recorderLiteral} -ArgumentList ('"' + $LiteralPath + '"') }; `
522
+ : "";
523
return realSpawner.spawn(
524
ChildProcess.make(
525
command.command,
526
[
527
...command.args.slice(0, -1),
517
- Buffer.from(source, "utf16le").toString("base64"),
528
+ Buffer.from(handlers + source, "utf16le").toString("base64"),
529
],
530
command.options,
531
),
@@ -537,7 +548,11 @@ for (const kind of ["browser", "reveal"] as const) {
548
recorded.then((value) => {
549
assert.equal(
550
value,
540
- kind === "browser" ? "" : `/select,"${target.replaceAll("/", "\\")}"`,
551
+ kind === "browser"
552
+ ? ""
553
+ : folderVerb === "open"
554
+ ? `"C:\\workspace with spaces\\author's media"`
555
+ : `/select,"${target.replaceAll("/", "\\")}"`,
556
);
557
}),
558
),
@@ -606,7 +621,7 @@ it.effect.skipIf(windowsHost)(
621
const editors = yield* launcher.resolveAvailableEditors();
622
yield* launcher.launchEditor({
623
editor: "file-manager",
609
- cwd: "/home/t3/workspace/media/clip.mp4",
624
+ cwd: "/home/t3/workspace [draft]/author's $media/clip|draft.mp4",
625
reveal: true,
626
});
627
return { kind, editors };
@@ -635,7 +650,7 @@ it.effect.skipIf(windowsHost)(
650
const decodedCommand = Buffer.from(encodedCommand, "base64").toString("utf16le");
651
assert.equal(
652
decodedCommand,
638
- "$ProgressPreference = 'SilentlyContinue'; Start-Process 'explorer.exe' -ArgumentList ('/select,\"' + '\\\\wsl.localhost\\Ubuntu-24.04\\home\\t3\\workspace\\media\\clip.mp4' + '\"')",
653
+ "$ProgressPreference = 'SilentlyContinue'; $folderVerb = (Get-ItemProperty -LiteralPath 'Registry::HKEY_CLASSES_ROOT\\Directory\\shell' -ErrorAction SilentlyContinue).'(default)'; if ($folderVerb -and $folderVerb -ne 'none') { Invoke-Item -LiteralPath '\\\\wsl.localhost\\Ubuntu-24.04\\home\\t3\\workspace [draft]\\author''s $media' } else { Start-Process 'explorer.exe' -ArgumentList ('/select,\"' + '\\\\wsl.localhost\\Ubuntu-24.04\\home\\t3\\workspace [draft]\\author''s $media\\clip|draft.mp4' + '\"') }",
654
);
655
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
656
);
@@ -798,7 +813,7 @@ it.effect.skipIf(windowsHost)(
813
const launcher = yield* ExternalLauncher.ExternalLauncher;
814
yield* launcher.launchEditor({
815
editor: "file-manager",
801
- cwd: '/home/t3/work "quoted"/clip.mp4',
816
+ cwd: '/home/t3/work/clip "quoted".mp4',
817
reveal: true,
818
});
819
}).pipe(
@@ -818,8 +833,14 @@ it.effect.skipIf(windowsHost)(
833
);
834
835
assert.ok(spawned);
821
- assert.equal(spawned.command, "explorer.exe");
822
- assert.deepEqual(spawned.args, ['\\\\wsl.localhost\\Ubuntu-24.04\\home\\t3\\work "quoted"']);
836
+ assert.equal(spawned.command, "powershell.exe");
837
+ assert.equal(spawned.options.detached, true);
838
+ assert.equal(spawned.options.shell, false);
839
+ const source = Buffer.from(spawned.args.at(-1) ?? "", "base64").toString("utf16le");
840
+ assert.equal(
841
+ source,
842
+ `Invoke-Item -LiteralPath '\\\\wsl.localhost\\Ubuntu-24.04\\home\\t3\\work'`,
843
+ );
844
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
845
);
846
apps/server/src/process/externalLauncher.ts
+23
-31
@@ -1,3 +1,4 @@
1
+import * as NodePath from "@effect/platform-node/NodePath";
2
import {
3
EDITORS,
4
ExternalLauncherError,
@@ -561,30 +562,24 @@ const resolveEditorLaunch = Effect.fn("resolveEditorLaunch")(function* (
562
};
563
});
564
564
-/**
565
- * Explorer's contract is the single argument `/select,"<path>"` with only the
566
- * path quoted; Node's default spawn quoting wraps the whole argument when the
567
- * path has spaces and Explorer misparses it, silently opening a fallback
568
- * folder. A single `-ArgumentList` string in Windows PowerShell 5.1 reaches the
569
- * child's command line verbatim, preserving the raw switch.
570
- */
571
-function buildFileExplorerRevealPowerShellSource(explorerCommand: string, target: string): string {
572
- return `$ProgressPreference = 'SilentlyContinue'; Start-Process ${escapePowerShellStringLiteral(explorerCommand)} -ArgumentList ('/select,"' + ${escapePowerShellStringLiteral(target)} + '"')`;
565
+// A replacement manager registers a default Directory shell verb; stock Windows
566
+// uses "none". Explorer needs its /select argument passed verbatim through
567
+// PowerShell because Node's argument quoting changes how Explorer parses it.
568
+function buildFileManagerRevealPowerShellSource(target: string, parent: string): string {
569
+ const literal = escapePowerShellStringLiteral(target);
570
+ return `$ProgressPreference = 'SilentlyContinue'; $folderVerb = (Get-ItemProperty -LiteralPath 'Registry::HKEY_CLASSES_ROOT\\Directory\\shell' -ErrorAction SilentlyContinue).'(default)'; if ($folderVerb -and $folderVerb -ne 'none') { Invoke-Item -LiteralPath ${escapePowerShellStringLiteral(parent)} } else { Start-Process 'explorer.exe' -ArgumentList ('/select,"' + ${literal} + '"') }`;
571
}
572
575
-function fileExplorerRevealLaunch(
573
+function powerShellFileManagerLaunch(
574
target: string,
577
- explorerTarget: string,
575
+ source: string,
576
powershellCommand: string,
577
): EditorLaunch {
578
return {
579
editor: "file-manager",
580
target,
581
command: powershellCommand,
584
- args: [
585
- ...POWERSHELL_ARGUMENTS_PREFIX,
586
- encodeUtf16LeBase64(buildFileExplorerRevealPowerShellSource("explorer.exe", explorerTarget)),
587
- ],
582
+ args: [...POWERSHELL_ARGUMENTS_PREFIX, encodeUtf16LeBase64(source)],
583
};
584
}
585
@@ -607,10 +602,12 @@ const resolveFileManagerRevealLaunch = Effect.fn("resolveFileManagerRevealLaunch
602
}
603
604
if (platform === "win32") {
605
+ const path = yield* Path.Path.pipe(Effect.provide(NodePath.layerWin32));
606
+ const windowsTarget = normalizeWindowsFileManagerPath(target);
607
return {
611
- ...fileExplorerRevealLaunch(
608
+ ...powerShellFileManagerLaunch(
609
target,
613
- normalizeWindowsFileManagerPath(target),
610
+ buildFileManagerRevealPowerShellSource(windowsTarget, path.dirname(windowsTarget)),
611
resolvePowerShellPath(env),
612
),
613
detached: WINDOWS_POWERSHELL_DETACHED,
@@ -624,20 +621,15 @@ const resolveFileManagerRevealLaunch = Effect.fn("resolveFileManagerRevealLaunch
621
) {
622
const explorerTarget = resolveWslFileManagerPath(target, env.WSL_DISTRO_NAME);
623
if (yield* isCommandAvailable(WSL_POWERSHELL_COMMAND, { env })) {
627
- // Explorer's raw switch cannot express a double quote, and unlike
628
- // Windows paths a WSL path may legally contain one: open the containing
629
- // directory in File Explorer instead, matching the advertised
630
- // "file-explorer" kind.
631
- if (explorerTarget.includes('"')) {
632
- const path = yield* Path.Path;
633
- return {
634
- editor: "file-manager",
635
- target,
636
- command: "explorer.exe",
637
- args: [resolveWslFileManagerPath(path.dirname(target), env.WSL_DISTRO_NAME)],
638
- };
639
- }
640
- return fileExplorerRevealLaunch(target, explorerTarget, WSL_POWERSHELL_COMMAND);
624
+ // WSL names may contain quotes that Explorer's /select cannot encode.
625
+ // Open the parent through the shell so replacement managers still apply.
626
+ const path = yield* Path.Path;
627
+ // .NET path parsing rejects characters that are legal in WSL filenames.
628
+ const parent = resolveWslFileManagerPath(path.dirname(target), env.WSL_DISTRO_NAME);
629
+ const source = explorerTarget.includes('"')
630
+ ? `Invoke-Item -LiteralPath ${escapePowerShellStringLiteral(parent)}`
631
+ : buildFileManagerRevealPowerShellSource(explorerTarget, parent);
632
+ return powerShellFileManagerLaunch(target, source, WSL_POWERSHELL_COMMAND);
633
}
634
if (hasGraphicalLinuxSession(env) && (yield* isUsableFileManagerCommand("xdg-open", env))) {
635
const path = yield* Path.Path;