History

fix(server): avoid color probe hangs in setup terminals

Julius Marminge committed 2 months ago

Commit e1da3351 parent 00d61094 files · +21 −8Browse files

Unified · Split

4 files
  1. apps/server/src/project/ProjectSetupScriptRunner.test.ts +6 −1
  2. apps/server/src/project/ProjectSetupScriptRunner.ts +10 −4
  3. apps/server/src/terminal/Manager.test.ts +2 −1
  4. apps/server/src/terminal/Manager.ts +3 −2
apps/server/src/project/ProjectSetupScriptRunner.test.ts+6−1
@@ -108,7 +108,11 @@ describe("ProjectSetupScriptRunner", () => { · 107 unmodified lines
108108 terminalId: "setup-default-setup",
109109 cwd: "/repo/worktrees/a",
110110 worktreePath: "/repo/worktrees/a",
111− env: { T3CODE_PROJECT_ROOT: "/repo/project", T3CODE_WORKTREE_PATH: "/repo/worktrees/a" },
111+ env: {
112+ T3CODE_PROJECT_ROOT: "/repo/project",
113+ T3CODE_WORKTREE_PATH: "/repo/worktrees/a",
114+ COLORTERM: "",
115+ },
112116 });
113117 expect(write).toHaveBeenCalledWith({
114118 threadId: "thread-1",
@@ -207,6 +211,7 @@ describe("ProjectSetupScriptRunner", () => { · 92 unmodified lines
207211 env: {
208212 T3CODE_PROJECT_ROOT: "/repo/project",
209213 T3CODE_WORKTREE_PATH: "/repo/worktrees/a",
214+ COLORTERM: "",
210215 },
211216 });
212217 expect(write).toHaveBeenCalledWith({
apps/server/src/project/ProjectSetupScriptRunner.ts+10−4
@@ -149,10 +149,16 @@ export const make = Effect.gen(function* () { · 148 unmodified lines
149149
150150 const terminalId = input.preferredTerminalId ?? `setup-${script.id}`;
151151 const cwd = input.worktreePath;
152− const env = projectScriptRuntimeEnv({
153− project: { cwd: project.workspaceRoot },
154− worktreePath: input.worktreePath,
155− });
152+ const env = {
153+ ...projectScriptRuntimeEnv({
154+ project: { cwd: project.workspaceRoot },
155+ worktreePath: input.worktreePath,
156+ }),
157+ // Setup runs before a client necessarily attaches. Truecolor probing in
158+ // tools such as vp can wait for terminal replies that nobody can send.
159+ // Keep TERM's 256-color support without advertising truecolor here.
160+ COLORTERM: "",
161+ };
156162
157163 yield* terminalManager
158164 .open({
apps/server/src/terminal/Manager.test.ts+2−1
@@ -1711,7 +1711,8 @@ it.layer( · 1710 unmodified lines
17111711 [undefined, undefined, "truecolor"],
17121712 ["", undefined, "truecolor"],
17131713 ["24bit", undefined, "24bit"],
1714− ["24bit", "", "truecolor"],
1714+ ["24bit", "", ""],
1715+ [undefined, "", ""],
17151716 ["24bit", "custom", "custom"],
17161717 ] as const) {
17171718 const env = Object.freeze({ COLORTERM: parentColor });
apps/server/src/terminal/Manager.ts+3−2
@@ -1286,8 +1286,9 @@ function createTerminalSpawnEnv( · 1285 unmodified lines
12861286 key === "CODEX_HOME" || key === "CLAUDE_CONFIG_DIR" ? expandHomePath(value) : value;
12871287 }
12881288 }
1289− // Both PTY backends feed truecolor-capable terminal clients.
1290− if (spawnEnv.COLORTERM === undefined || spawnEnv.COLORTERM === "") {
1289+ // An explicit empty override opts out for terminals started without a client.
1290+ // Otherwise both PTY backends feed truecolor-capable terminal clients.
1291+ if (!spawnEnv.COLORTERM && runtimeEnv?.COLORTERM === undefined) {
12911292 spawnEnv.COLORTERM = "truecolor";
12921293 }
12931294 return stripAppImageRuntimeEnv(spawnEnv);