@devries-cameron20 / t3code-1 / commits / bf3549b7ad
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): boot-started linux servers offer and open the file manager (#33107)

Co-authored-by: maria-rcks <maria@kuuro.net>

Tuomas Seppänen committed Nov 15, 2026 at 06:38 UTC bf3549b7ad1ce87852d70d63f31999e066dc3603
2 files changed +74 -4
apps/server/src/process/externalLauncher.test.ts
+64 -1
@@ -311,6 +311,69 @@ it.effect.skipIf(windowsHost)(
311 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
312 );
313
314 +// Windows drive letters cannot resolve the POSIX xdg stubs.
315 +it.effect.skipIf(windowsHost)(
316 + "a Linux server without a display offers and opens the file manager on the desktop session's display",
317 + () =>
318 + Effect.gen(function* () {
319 + const fileSystem = yield* FileSystem.FileSystem;
320 + const path = yield* Path.Path;
321 + const binDir = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-editors-" });
322 + for (const name of ["xdg-open", "xdg-mime"]) {
323 + const filePath = path.join(binDir, name);
324 + yield* fileSystem.writeFileString(filePath, "#!/bin/sh\n");
325 + yield* fileSystem.chmod(filePath, 0o755);
326 + }
327 +
328 + const fileManager = (sessionEnv: ReadonlyArray<string>) =>
329 + Effect.gen(function* () {
330 + const spawned: ChildProcess.StandardCommand[] = [];
331 + const result = yield* Effect.gen(function* () {
332 + const launcher = yield* ExternalLauncher.ExternalLauncher;
333 + const editors = yield* launcher.resolveAvailableEditors();
334 + const kind = yield* launcher.resolveFileManagerRevealKind();
335 + const opened = yield* launcher
336 + .launchEditor({ editor: "file-manager", cwd: "/workspace" })
337 + .pipe(Effect.exit);
338 + return { offered: editors.includes("file-manager"), kind, opened };
339 + }).pipe(
340 + Effect.provide(
341 + layerTest({
342 + platform: "linux",
343 + env: { PATH: binDir },
344 + onSpawn: (command) => spawned.push(command),
345 + spawnResult: (command) =>
346 + command.command === "busctl"
347 + ? { stdout: JSON.stringify({ type: "as", data: sessionEnv }) }
348 + : command.command === "xdg-mime"
349 + ? { stdout: "org.kde.dolphin.desktop\n" }
350 + : undefined,
351 + }),
352 + ),
353 + Effect.provideService(HostProcess.Environment, { PATH: binDir }),
354 + );
355 + const open = spawned.find((command) => command.command === "xdg-open");
356 + return { ...result, open: open && { args: open.args, env: open.options.env } };
357 + });
358 +
359 + const session = yield* fileManager(["DISPLAY=:0", "HOME=/home/user"]);
360 + assert.equal(session.offered, true);
361 + assert.equal(session.kind, "files");
362 + assert.equal(Exit.isSuccess(session.opened), true);
363 + assert.deepEqual(session.open, {
364 + args: ["/workspace"],
365 + env: { PATH: binDir, DISPLAY: ":0" },
366 + });
367 +
368 + // No one is logged in to a desktop, so there is no screen to open it on.
369 + const headless = yield* fileManager(["HOME=/home/user"]);
370 + assert.equal(headless.offered, false);
371 + assert.equal(headless.kind, undefined);
372 + assert.equal(Exit.isFailure(headless.opened), true);
373 + assert.equal(headless.open, undefined);
374 + }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
375 +);
376 +
377 it.effect("launches an installed editor with platform-safe arguments", () =>
378 Effect.gen(function* () {
379 const fileSystem = yield* FileSystem.FileSystem;
@@ -888,7 +951,7 @@ it.effect.skipIf(windowsHost)("does not open Zed with the OpenZFS zed daemon on
951 Effect.provide(
952 layerTest({
953 platform: "linux",
891 - env: { HOME: home, PATH: binDir },
954 + env: { HOME: home, PATH: binDir, DISPLAY: ":0" },
955 path: withSystemBin(path, systemBin),
956 onSpawn: (command) => spawned.push(command),
957 spawnResult: (command) => (command.args[0] === "--version" ? { exitCode: 1 } : undefined),
apps/server/src/process/externalLauncher.ts
+10 -3
@@ -473,16 +473,23 @@ const resolveBrowserLaunch = Effect.fn("externalLauncher.resolveBrowserLaunch")(
473 return buildBrowserLaunch(target, platform, env);
474 });
475
476 +// Editors and the file manager open on the desktop session, so a boot-started
477 +// server discovers and launches them with that session's display.
478 +const readEditorEnv = Effect.fn("externalLauncher.readEditorEnv")(function* () {
479 + const env = { ...(yield* readBrowserLaunchEnv), ...(yield* readCommandLookupEnv) };
480 + return hasGraphicalLinuxSession(env) ? env : { ...env, ...(yield* readGraphicalSessionEnv()) };
481 +});
482 +
483 const resolveAvailableEditors = Effect.fn("externalLauncher.resolveAvailableEditors")(function* () {
484 const platform = yield* HostProcess.Platform;
478 - const env = { ...(yield* readBrowserLaunchEnv), ...(yield* readCommandLookupEnv) };
485 + const env = yield* readEditorEnv();
486 return yield* buildAvailableEditors(platform, env).pipe(withPathDirectoryListings);
487 });
488
489 const resolveFileManagerRevealKind = Effect.fn("externalLauncher.resolveFileManagerRevealKind")(
490 function* () {
491 const platform = yield* HostProcess.Platform;
485 - const env = { ...(yield* readBrowserLaunchEnv), ...(yield* readCommandLookupEnv) };
492 + const env = yield* readEditorEnv();
493 return yield* fileManagerRevealKindForPlatform(platform, env);
494 },
495 );
@@ -508,7 +515,7 @@ const resolveEditorLaunch = Effect.fn("resolveEditorLaunch")(function* (
515 FileSystem.FileSystem | Path.Path | ChildProcessSpawner.ChildProcessSpawner
516 > {
517 const platform = yield* HostProcess.Platform;
511 - const env = { ...(yield* readBrowserLaunchEnv), ...(yield* readCommandLookupEnv) };
518 + const env = yield* readEditorEnv();
519 yield* Effect.annotateCurrentSpan({
520 "externalLauncher.editor": input.editor,
521 "externalLauncher.cwd": input.cwd,