The best way to control Claude Code, Codex and more from any computer or phone
fix(shared): Open in Zed ignores the OpenZFS zed daemon on Linux (#33479)
Julius Marminge committed
Nov 10, 2026 at 22:50 UTC
2163d41409f0a41ac2afa59ef7e2c937ba777325
4 files changed
+123
-14
apps/desktop/src/app/DesktopApp.test.ts
+2
@@ -7,6 +7,7 @@ import * as Layer from "effect/Layer";
7
import * as FileSystem from "effect/FileSystem";
8
import * as Path from "effect/Path";
9
import * as HttpClient from "effect/http/HttpClient";
10
+import { ChildProcessSpawner } from "effect/process";
11
import * as NetService from "@t3tools/shared/Net";
12
import * as Fiber from "effect/Fiber";
13
import * as Option from "effect/Option";
@@ -213,6 +214,7 @@ it.effect.each([false, true])(
214
Effect.provide(
215
Layer.mergeAll(
216
Layer.mock(BrowserImport.BrowserImport, {}),
217
+ Layer.mock(ChildProcessSpawner.ChildProcessSpawner, {}),
218
Layer.mock(DesktopBackendConfiguration.DesktopBackendConfiguration, {}),
219
Layer.mock(DesktopCliCommand.DesktopCliCommand, {}),
220
Layer.mock(DesktopClientSettings.DesktopClientSettings, {}),
apps/server/src/process/externalLauncher.test.ts
+78
-1
@@ -517,7 +517,7 @@ it.effect.skipIf(windowsHost)("prefers zeditor in a later Linux fallback directo
517
] as const) {
518
yield* fs.makeDirectory(dir, { recursive: true });
519
const executable = path.join(dir, name);
520
- yield* fs.writeFileString(executable, "#!/bin/sh\n");
520
+ yield* fs.writeFileString(executable, "#!/bin/sh\necho 'Zed 0.200.0'\n");
521
yield* fs.chmod(executable, 0o755);
522
}
523
const editor = EDITORS.find((editor) => editor.id === "zed")!;
@@ -545,6 +545,83 @@ it.effect.skipIf(windowsHost)("prefers zeditor in a later Linux fallback directo
545
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
546
);
547
548
+it.effect.skipIf(windowsHost)("does not offer the OpenZFS zed daemon as Zed on Linux", () =>
549
+ Effect.gen(function* () {
550
+ const fs = yield* FileSystem.FileSystem;
551
+ const path = yield* Path.Path;
552
+ const home = yield* fs.makeTempDirectoryScoped({ prefix: "t3-zed-zfs-" });
553
+ const binDir = path.join(home, "bin");
554
+ const systemBin = path.join(home, "system-bin");
555
+ yield* fs.makeDirectory(binDir, { recursive: true });
556
+ yield* fs.makeDirectory(systemBin, { recursive: true });
557
+ const zfsZed = path.join(binDir, "zed");
558
+ // OpenZFS zed only takes short options: `--version` is rejected with usage on stderr.
559
+ yield* fs.writeFileString(
560
+ zfsZed,
561
+ "#!/bin/sh\necho \"Invalid option '--'\" >&2\necho 'Usage: zed [OPTION]...' >&2\nexit 1\n",
562
+ );
563
+ yield* fs.chmod(zfsZed, 0o755);
564
+ const editor = EDITORS.find((editor) => editor.id === "zed")!;
565
+ const resolve = resolveEditorCommand(editor, { HOME: home, PATH: binDir }).pipe(
566
+ Effect.provideService(HostProcess.Platform, "linux"),
567
+ Effect.provideService(Path.Path, {
568
+ ...path,
569
+ join: (...parts) =>
570
+ path.join(
571
+ ...parts.map((part) =>
572
+ ["/usr/local/bin", "/usr/bin", "/snap/bin"].includes(part) ? systemBin : part,
573
+ ),
574
+ ),
575
+ }),
576
+ );
577
+ assert.deepEqual(yield* resolve, Option.none());
578
+
579
+ const zedEditor = path.join(home, ".local/bin/zed");
580
+ yield* fs.makeDirectory(path.dirname(zedEditor), { recursive: true });
581
+ yield* fs.writeFileString(zedEditor, "#!/bin/sh\necho 'Zed 0.200.0'\n");
582
+ yield* fs.chmod(zedEditor, 0o755);
583
+ assert.deepEqual(yield* resolve, Option.some({ command: zedEditor, baseArgs: [] }));
584
+ }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
585
+);
586
+
587
+it.effect.skipIf(windowsHost)("does not open Zed with the OpenZFS zed daemon on Linux", () =>
588
+ Effect.gen(function* () {
589
+ const fs = yield* FileSystem.FileSystem;
590
+ const path = yield* Path.Path;
591
+ const home = yield* fs.makeTempDirectoryScoped({ prefix: "t3-zed-zfs-launch-" });
592
+ const binDir = path.join(home, "bin");
593
+ yield* fs.makeDirectory(binDir, { recursive: true });
594
+ yield* fs.writeFileString(path.join(binDir, "zed"), "#!/bin/sh\nexit 1\n");
595
+ yield* fs.chmod(path.join(binDir, "zed"), 0o755);
596
+
597
+ const spawned: ChildProcess.StandardCommand[] = [];
598
+ const exit = yield* Effect.gen(function* () {
599
+ const launcher = yield* ExternalLauncher.ExternalLauncher;
600
+ return yield* launcher.launchEditor({ editor: "zed", cwd: "/workspace" }).pipe(Effect.exit);
601
+ }).pipe(
602
+ Effect.provide(
603
+ layerTest({
604
+ platform: "linux",
605
+ env: { HOME: home, PATH: binDir },
606
+ onSpawn: (command) => spawned.push(command),
607
+ spawnResult: (command) => (command.args[0] === "--version" ? { exitCode: 1 } : undefined),
608
+ }),
609
+ ),
610
+ );
611
+ assert.isTrue(Exit.isFailure(exit));
612
+ if (Exit.isFailure(exit)) {
613
+ assert.instanceOf(
614
+ Cause.squash(exit.cause),
615
+ ExternalLauncher.ExternalLauncherCommandNotFoundError,
616
+ );
617
+ }
618
+ assert.deepEqual(
619
+ spawned.map((command) => command.args),
620
+ [["--version"]],
621
+ );
622
+ }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
623
+);
624
+
625
it.effect.each([
626
{ editor: "webstorm", installPath: "Applications/WebStorm 2026.2.app/Contents/MacOS/webstorm" },
627
{ editor: "idea", installPath: "Applications/IntelliJ IDEA 2026.1.4.app/Contents/MacOS/idea" },
apps/server/src/process/externalLauncher.ts
+7
-6
@@ -477,13 +477,14 @@ const resolveEditorLaunch = Effect.fn("resolveEditorLaunch")(function* (
477
}
478
479
if (editorDef.commands) {
480
- const { command, baseArgs } = Option.getOrElse(
481
- yield* resolveEditorCommand(editorDef, env),
482
- () => ({
480
+ const resolved = yield* resolveEditorCommand(editorDef, env);
481
+ if (Option.isNone(resolved)) {
482
+ return yield* new ExternalLauncherCommandNotFoundError({
483
+ editor: editorDef.id,
484
command: editorDef.commands[0],
484
- baseArgs: "baseArgs" in editorDef ? editorDef.baseArgs : [],
485
- }),
486
- );
485
+ });
486
+ }
487
+ const { command, baseArgs } = resolved.value;
488
return {
489
editor: editorDef.id,
490
target: input.cwd,
packages/shared/src/editor.ts
+36
-7
@@ -3,9 +3,11 @@ import * as Effect from "effect/Effect";
3
import * as FileSystem from "effect/FileSystem";
4
import * as Option from "effect/Option";
5
import * as Path from "effect/Path";
6
+import * as Stream from "effect/Stream";
7
+import { ChildProcess, ChildProcessSpawner } from "effect/process";
8
9
import * as HostProcess from "./HostProcess.ts";
8
-import { isCommandAvailable } from "./shell.ts";
10
+import { isCommandAvailable, resolveCommandPath } from "./shell.ts";
11
12
type Editor = (typeof EDITORS)[number];
13
@@ -25,6 +27,28 @@ const isVersionedBundle = (entry: string, name: string) => {
27
return /^\d[\d.]*$/.test(entry.slice(name.length + 1, -".app".length));
28
};
29
30
+// OpenZFS's event daemon is also named zed; it rejects `--version` instead of starting.
31
+const isZedEditor = Effect.fn("editor.isZedEditor")(
32
+ function* (command: string) {
33
+ const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
34
+ const handle = yield* spawner.spawn(
35
+ ChildProcess.make(command, ["--version"], {
36
+ stdin: "ignore",
37
+ stderr: "ignore",
38
+ forceKillAfter: "1 second",
39
+ }),
40
+ );
41
+ const [stdout, exitCode] = yield* Effect.all(
42
+ [handle.stdout.pipe(Stream.decodeText(), Stream.runHead), handle.exitCode],
43
+ { concurrency: "unbounded" },
44
+ );
45
+ return exitCode === 0 && Option.getOrElse(stdout, () => "").startsWith("Zed");
46
+ },
47
+ Effect.scoped,
48
+ Effect.timeout("2 seconds"),
49
+ Effect.catchCause(() => Effect.succeed(false)),
50
+);
51
+
52
export const resolveEditorCommand = Effect.fn("editor.resolveEditorCommand")(function* (
53
editor: Editor,
54
env: NodeJS.ProcessEnv,
@@ -143,14 +167,19 @@ export const resolveEditorCommand = Effect.fn("editor.resolveEditorCommand")(fun
167
}
168
169
if (preferBundle) candidates.push(...editor.commands);
170
+ const rejected = new Set<string>();
171
for (const candidate of candidates) {
147
- if (yield* isCommandAvailable(candidate, { env })) {
148
- return Option.some({
149
- command: candidate,
150
- baseArgs:
151
- editor.id === "kiro" && (platform === "darwin" || platform === "win32") ? [] : baseArgs,
152
- });
172
+ const resolved = yield* resolveCommandPath(candidate, { env });
173
+ if (resolved === null || rejected.has(resolved)) continue;
174
+ if (preferZeditor && path.basename(candidate) === "zed" && !(yield* isZedEditor(resolved))) {
175
+ rejected.add(resolved);
176
+ continue;
177
}
178
+ return Option.some({
179
+ command: candidate,
180
+ baseArgs:
181
+ editor.id === "kiro" && (platform === "darwin" || platform === "win32") ? [] : baseArgs,
182
+ });
183
}
184
return Option.none();
185
});