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

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

fix(scripts): dev runner ignores the parent T3 server's port and host (#36019)

Julius Marminge committed Nov 12, 2026 at 21:49 UTC f9cadccadf4f6d6e37b005b7fec143c70cadbd6c
2 files changed +60 -10
scripts/dev-runner.test.ts
+46
@@ -1,5 +1,6 @@
1 // @effect-diagnostics nodeBuiltinImport:off - builds real worktree layouts on disk.
2 import * as NodeServices from "@effect/platform-node/NodeServices";
3 +import * as NodeChildProcess from "node:child_process";
4 import * as NodeFS from "node:fs";
5 import * as NodeOS from "node:os";
6 import * as NodePath from "node:path";
@@ -189,6 +190,51 @@ it.layer(NodeServices.layer)("dev-runner", (it) => {
190 assert.equal(env.HOST, undefined);
191 }),
192 );
193 +
194 + it.effect("drops an inherited T3CODE_HOST and T3CODE_LAN from a parent T3 server", () =>
195 + Effect.gen(function* () {
196 + const env = yield* createDevRunnerEnv({
197 + mode: "dev",
198 + baseEnv: { T3CODE_PORT: "3773", T3CODE_HOST: "0.0.0.0", T3CODE_LAN: "true" },
199 + serverOffset: 0,
200 + webOffset: 0,
201 + t3Home: undefined,
202 + browser: undefined,
203 + autoBootstrapProjectFromCwd: undefined,
204 + logWebSocketEvents: undefined,
205 + host: undefined,
206 + port: undefined,
207 + devUrl: undefined,
208 + });
209 +
210 + assert.equal(env.T3CODE_PORT, "13773");
211 + assert.equal(env.T3CODE_HOST, undefined);
212 + assert.equal(env.T3CODE_LAN, undefined);
213 + }),
214 + );
215 + });
216 +
217 + describe("cli", () => {
218 + it("ignores the parent T3 server's T3CODE_PORT and T3CODE_HOST", () => {
219 + const result = NodeChildProcess.spawnSync(
220 + process.execPath,
221 + ["scripts/dev-runner.ts", "dev:server", "--dry-run"],
222 + {
223 + cwd: NodePath.resolve(import.meta.dirname, ".."),
224 + encoding: "utf8",
225 + env: {
226 + ...process.env,
227 + T3CODE_PORT: "3773",
228 + T3CODE_HOST: "0.0.0.0",
229 + },
230 + },
231 + );
232 +
233 + assert.equal(result.status, 0, result.stderr);
234 + const output = `${result.stdout}${result.stderr}`;
235 + assert.match(output, /serverPort=\d+ /);
236 + assert.notMatch(output, /serverPort=3773 /);
237 + });
238 });
239
240 describe("findFirstAvailableOffset", () => {
scripts/dev-runner.ts
+14 -10
@@ -213,11 +213,6 @@ const optionalBooleanConfig = (name: string): Config.Config<boolean | undefined>
213 Config.option,
214 Config.map((value) => Option.getOrUndefined(value)),
215 );
216 -const optionalPortConfig = (name: string): Config.Config<number | undefined> =>
217 - Config.Port(name).pipe(
218 - Config.option,
219 - Config.map((value) => Option.getOrUndefined(value)),
220 - );
216 const optionalIntegerConfig = (name: string): Config.Config<number | undefined> =>
217 Config.Int(name).pipe(
218 Config.option,
@@ -379,12 +374,15 @@ export const createDevRunnerEnv = Effect.fn("dev-runner.createDevRunnerEnv")(fun
374 delete output.T3CODE_SINGLE_ORIGIN_DEV;
375 delete output.T3CODE_MODE;
376 delete output.T3CODE_NO_BROWSER;
382 - delete output.T3CODE_HOST;
377 delete output.T3CODE_DEV_AUTH_TOKEN;
378 }
379
380 + // Agent shells inherit the parent T3 server's bind settings; only --host widens the dev server.
381 + delete output.T3CODE_LAN;
382 if (!isDesktopMode && host !== undefined) {
383 output.T3CODE_HOST = host;
384 + } else {
385 + delete output.T3CODE_HOST;
386 }
387
388 if (!isDesktopMode) {
@@ -954,13 +952,19 @@ const devRunnerCli = Command.make("dev-runner", {
952 Flag.withFallbackConfig(optionalBooleanConfig("T3CODE_LOG_WS_EVENTS")),
953 ),
954 host: Flag.String("host").pipe(
957 - Flag.withDescription("Server host/interface override (forwards to T3CODE_HOST)."),
958 - Flag.withFallbackConfig(optionalStringConfig("T3CODE_HOST")),
955 + Flag.withDescription(
956 + "Server host/interface override (forwards to T3CODE_HOST). Ambient T3CODE_HOST is ignored: agent shells inherit it from the T3 server that spawned them.",
957 + ),
958 + Flag.optional,
959 + Flag.map(Option.getOrUndefined),
960 ),
961 port: Flag.Int("port").pipe(
962 Flag.withSchema(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 65535 }))),
962 - Flag.withDescription("Server port override (forwards to T3CODE_PORT)."),
963 - Flag.withFallbackConfig(optionalPortConfig("T3CODE_PORT")),
963 + Flag.withDescription(
964 + "Server port override (forwards to T3CODE_PORT). Ambient T3CODE_PORT is ignored: agent shells inherit it from the T3 server that spawned them.",
965 + ),
966 + Flag.optional,
967 + Flag.map(Option.getOrUndefined),
968 ),
969 devUrl: Flag.String("dev-url").pipe(
970 Flag.withSchema(Schema.URLFromString),