Skip to content

Commit 18ef719

Browse files
fix(terminal): one regression test for the T3 Code terminal identity
Co-Authored-By: Claude Fable 5.1 <[email protected]>
1 parent a9e5e44 commit 18ef719

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

‎apps/server/src/terminal/Manager.test.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import * as ProcessRunner from "../processRunner.ts";
4545
import * as ServerSettings from "../serverSettings.ts";
4646
import * as TerminalManager from "./Manager.ts";
4747
import * as PtyAdapter from "@t3tools/shared/PtyAdapter";
48+
import packageJson from "../../package.json" with { type: "json" };
4849

4950
vi.mock("effect/SynchronizedRef", async (importOriginal) => {
5051
const original = await importOriginal<typeof SynchronizedRef>();
@@ -2145,6 +2146,28 @@ it.layer(
21452146
}),
21462147
);
21472148

2149+
it.effect("identifies as T3 Code unless the terminal env overrides it", () =>
2150+
Effect.gen(function* () {
2151+
const env = Object.freeze({ TERM_PROGRAM: "Apple_Terminal", TERM_PROGRAM_VERSION: "455" });
2152+
const { manager, ptyAdapter } = yield* createManager(5, { env });
2153+
2154+
yield* manager.open(openInput());
2155+
expect(ptyAdapter.spawnInputs[0]?.env).toMatchObject({
2156+
TERM_PROGRAM: "t3code",
2157+
TERM_PROGRAM_VERSION: packageJson.version,
2158+
});
2159+
expect(env.TERM_PROGRAM).toBe("Apple_Terminal");
2160+
2161+
yield* manager.restart(
2162+
restartInput({ env: { TERM_PROGRAM: "", TERM_PROGRAM_VERSION: "custom-version" } }),
2163+
);
2164+
expect(ptyAdapter.spawnInputs[1]?.env).toMatchObject({
2165+
TERM_PROGRAM: "",
2166+
TERM_PROGRAM_VERSION: "custom-version",
2167+
});
2168+
}),
2169+
);
2170+
21482171
it.effect("filters app runtime env variables from terminal sessions", () =>
21492172
Effect.gen(function* () {
21502173
const { manager, ptyAdapter } = yield* createManager(5, {

‎apps/server/src/terminal/Manager.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,8 @@ function createTerminalSpawnEnv(
12711271
if (shouldExcludeTerminalEnvKey(key)) continue;
12721272
spawnEnv[key] = value;
12731273
}
1274+
// The server inherits its launcher's identity (e.g. Apple_Terminal); shells
1275+
// and tools inside the integrated terminal should see T3 Code instead.
12741276
spawnEnv.TERM_PROGRAM = "t3code";
12751277
spawnEnv.TERM_PROGRAM_VERSION = packageJson.version;
12761278
if (runtimeEnv) {

0 commit comments

Comments
 (0)