@devries-cameron20 / t3code Mirror · read-only / commits / 31be3e9b49
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 23, 03:00 UTC

fix(server): apps opened from T3 Code no longer inherit ELECTRON_RUN_AS_NODE (#20206)

Jord committed Oct 18, 2026 at 21:05 UTC 31be3e9b49de98c36ababde73a8d81b5850f5a6a
2 files changed +55 -1
apps/server/src/process/externalLauncher.test.ts
+46
@@ -122,6 +122,52 @@ it.effect("launches the default browser through the platform command", () => {
122 );
123 });
124
125 +it.effect.skipIf(windowsHost)(
126 + "launched browsers and editors do not inherit ELECTRON_RUN_AS_NODE",
127 + () =>
128 + Effect.gen(function* () {
129 + const fileSystem = yield* FileSystem.FileSystem;
130 + const path = yield* Path.Path;
131 + const binDir = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-editors-" });
132 + const codePath = path.join(binDir, "code");
133 + yield* fileSystem.writeFileString(codePath, "#!/bin/sh\n");
134 + yield* fileSystem.chmod(codePath, 0o755);
135 +
136 + const spawned: ChildProcess.StandardCommand[] = [];
137 + yield* Effect.gen(function* () {
138 + const launcher = yield* ExternalLauncher.ExternalLauncher;
139 + yield* launcher.launchBrowser("https://example.com");
140 + yield* launcher.launchEditor({ editor: "vscode", cwd: "/workspace" });
141 + }).pipe(
142 + Effect.provide(
143 + layerTest({
144 + platform: "linux",
145 + env: { PATH: binDir, DISPLAY: ":0" },
146 + onSpawn: (command) => spawned.push(command),
147 + }),
148 + ),
149 + Effect.provideService(HostProcess.Environment, {
150 + PATH: binDir,
151 + DISPLAY: ":0",
152 + ELECTRON_RUN_AS_NODE: "1",
153 + }),
154 + );
155 +
156 + assert.deepEqual(
157 + spawned.map((command) => ({
158 + command: command.command,
159 + env: command.options.env,
160 + extendEnv: command.options.extendEnv,
161 + })),
162 + ["xdg-open", "code"].map((command) => ({
163 + command,
164 + env: { PATH: binDir, DISPLAY: ":0" },
165 + extendEnv: false,
166 + })),
167 + );
168 + }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
169 +);
170 +
171 it.effect.each(["win32", "linux"] as const)(
172 "launches the browser through PowerShell on %s",
173 (platform) => {
apps/server/src/process/externalLauncher.ts
+9 -1
@@ -663,7 +663,15 @@ const launchAndUnref = Effect.fn("externalLauncher.launchAndUnref")(function* (
663 onError: (cause: unknown) => ExternalLauncherError,
664 ): Effect.fn.Return<void, ExternalLauncherError, ChildProcessSpawner.ChildProcessSpawner> {
665 const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
666 - const command = ChildProcess.make(launch.command, launch.args, launch.options);
666 + // The desktop app runs this server with ELECTRON_RUN_AS_NODE. A launched file
667 + // manager or browser passes its environment on to everything started from it,
668 + // so any Electron app opened from there would start as plain Node and exit.
669 + const { ELECTRON_RUN_AS_NODE: _runAsNode, ...env } = yield* HostProcess.Environment;
670 + const command = ChildProcess.make(launch.command, launch.args, {
671 + ...launch.options,
672 + env,
673 + extendEnv: false,
674 + });
675
676 yield* spawner.spawn(command).pipe(
677 Effect.flatMap((handle) => handle.unref),