@devries-cameron20 / t3code Mirror · read-only / commits / 57f5d84073
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, 01:45 UTC

fix(server): agent-device no longer launches the desktop app from Codex shells (#18301)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Krishna Vijay committed Oct 19, 2026 at 13:18 UTC 57f5d84073b04be029958a8efa3a517de06d48e1
2 files changed +53 -3
apps/server/src/device/AgentDeviceShim.ts
+3 -3
@@ -29,7 +29,7 @@ if (!informational && !(hasValue("--config") && hasValue("--session"))) {
29 console.error("Call device_open first and include its --config and --session flags.");
30 process.exit(1);
31 }
32 -const env = { ...process.env };
32 +const env = { ...process.env, ELECTRON_RUN_AS_NODE: "1" };
33 delete env.AGENT_DEVICE_DAEMON_BASE_URL;
34 delete env.AGENT_DEVICE_DAEMON_AUTH_TOKEN;
35 delete env.AGENT_DEVICE_CONFIG;
@@ -39,13 +39,13 @@ child.on("exit", code => { process.exitCode = code ?? 1; });
39 `,
40 );
41 if (platform === "win32") {
42 - const script = `@echo off\r\n"${node}" "${launcherPath}" %*\r\n`;
42 + const script = `@echo off\r\nsetlocal EnableExtensions DisableDelayedExpansion\r\nset "ELECTRON_RUN_AS_NODE=1"\r\n"${node}" "${launcherPath}" %*\r\n`;
43 yield* fs.writeFileString(path.join(shimDir, "agent-device.cmd"), script);
44 } else {
45 const command = [node, launcherPath]
46 .map((value) => "'" + value.replaceAll("'", "'\"'\"'") + "'")
47 .join(" ");
48 - const script = `#!/bin/sh\nexec ${command} "$@"\n`;
48 + const script = `#!/bin/sh\nexport ELECTRON_RUN_AS_NODE=1\nexec ${command} "$@"\n`;
49 const shimPath = path.join(shimDir, "agent-device");
50 yield* fs.writeFileString(shimPath, script);
51 yield* fs.chmod(shimPath, 0o755);
apps/server/src/device/AgentDeviceTarget.test.ts
+50
@@ -17,6 +17,56 @@ import {
17 const exec = NodeUtil.promisify(NodeChildProcess.execFile);
18
19 describe("host-bound agent commands", () => {
20 + it.effect.skipIf(HostProcess.Platform.defaultValue() === "win32")(
21 + "runs both desktop hops as Node with a stripped environment, preserving arguments and exit code",
22 + () =>
23 + Effect.gen(function* () {
24 + const fs = yield* FileSystem.FileSystem;
25 + const path = yield* Path.Path;
26 + const temp = yield* fs.makeTempDirectoryScoped({ prefix: "t3-device-target-" });
27 + const dir = path.join(temp, "quotes '\" $HOME `literal`");
28 + yield* fs.makeDirectory(dir);
29 + const desktopApp = path.join(dir, "T3 Code");
30 + // Dropping Node mode after checking it forces each hop to set it independently.
31 + yield* fs.writeFileString(
32 + desktopApp,
33 + `#!/bin/sh
34 +if [ "\${ELECTRON_RUN_AS_NODE:-}" != "1" ]; then
35 + echo "started the desktop app" >&2
36 + exit 134
37 +fi
38 +unset ELECTRON_RUN_AS_NODE
39 +exec '${process.execPath.replaceAll("'", "'\"'\"'")}' "$@"
40 +`,
41 + );
42 + yield* fs.chmod(desktopApp, 0o755);
43 + const entryPath = path.join(dir, "cli.mjs");
44 + yield* fs.writeFileString(
45 + entryPath,
46 + "console.log(JSON.stringify(process.argv.slice(2))); process.exitCode = 23;",
47 + );
48 + const shim = yield* ensureAgentDeviceShim({ entryPath, stateDir: dir }).pipe(
49 + Effect.provideService(HostProcess.ExecutablePath, desktopApp),
50 + Effect.provideService(HostProcess.IsExecutable, false),
51 + );
52 + const args = [
53 + "snapshot",
54 + "--config",
55 + path.join(dir, "config.json"),
56 + "--session",
57 + "a!b!c",
58 + "",
59 + ];
60 + yield* Effect.promise(() =>
61 + expect(
62 + exec(path.join(shim, "agent-device"), args, {
63 + env: { PATH: process.env.PATH ?? "", HOME: temp },
64 + }),
65 + ).rejects.toMatchObject({ code: 23, stdout: `${JSON.stringify(args)}\n`, stderr: "" }),
66 + );
67 + }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
68 + );
69 +
70 it.effect("runs two hosts concurrently and only updates the reconnected host", () =>
71 Effect.gen(function* () {
72 const fs = yield* FileSystem.FileSystem;