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
108 terminalId: "setup-default-setup",108 terminalId: "setup-default-setup",
109 cwd: "/repo/worktrees/a",109 cwd: "/repo/worktrees/a",
110 worktreePath: "/repo/worktrees/a",110 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 },
112 });116 });
113 expect(write).toHaveBeenCalledWith({117 expect(write).toHaveBeenCalledWith({
114 threadId: "thread-1",118 threadId: "thread-1",
@@ -207,6 +211,7 @@ describe("ProjectSetupScriptRunner", () => { · 92 unmodified lines
207 env: {211 env: {
208 T3CODE_PROJECT_ROOT: "/repo/project",212 T3CODE_PROJECT_ROOT: "/repo/project",
209 T3CODE_WORKTREE_PATH: "/repo/worktrees/a",213 T3CODE_WORKTREE_PATH: "/repo/worktrees/a",
214 COLORTERM: "",
210 },215 },
211 });216 });
212 expect(write).toHaveBeenCalledWith({217 expect(write).toHaveBeenCalledWith({
apps/server/src/project/ProjectSetupScriptRunner.ts+10−4
@@ -149,10 +149,16 @@ export const make = Effect.gen(function* () { · 148 unmodified lines
149 149
150 const terminalId = input.preferredTerminalId ?? `setup-${script.id}`;150 const terminalId = input.preferredTerminalId ?? `setup-${script.id}`;
151 const cwd = input.worktreePath;151 const cwd = input.worktreePath;
152 const env = projectScriptRuntimeEnv({152 const env = {
153 project: { cwd: project.workspaceRoot },153 ...projectScriptRuntimeEnv({
154 worktreePath: input.worktreePath,154 project: { cwd: project.workspaceRoot },
155 });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 };
156 162
157 yield* terminalManager163 yield* terminalManager
158 .open({164 .open({
apps/server/src/terminal/Manager.test.ts+2−1
@@ -1711,7 +1711,8 @@ it.layer( · 1710 unmodified lines
1711 [undefined, undefined, "truecolor"],1711 [undefined, undefined, "truecolor"],
1712 ["", undefined, "truecolor"],1712 ["", undefined, "truecolor"],
1713 ["24bit", undefined, "24bit"],1713 ["24bit", undefined, "24bit"],
1714 ["24bit", "", "truecolor"],1714 ["24bit", "", ""],
1715 [undefined, "", ""],
1715 ["24bit", "custom", "custom"],1716 ["24bit", "custom", "custom"],
1716 ] as const) {1717 ] as const) {
1717 const env = Object.freeze({ COLORTERM: parentColor });1718 const env = Object.freeze({ COLORTERM: parentColor });
apps/server/src/terminal/Manager.ts+3−2
@@ -1286,8 +1286,9 @@ function createTerminalSpawnEnv( · 1285 unmodified lines
1286 key === "CODEX_HOME" || key === "CLAUDE_CONFIG_DIR" ? expandHomePath(value) : value;1286 key === "CODEX_HOME" || key === "CLAUDE_CONFIG_DIR" ? expandHomePath(value) : value;
1287 }1287 }
1288 }1288 }
1289 // Both PTY backends feed truecolor-capable terminal clients.1289 // An explicit empty override opts out for terminals started without a client.
1290 if (spawnEnv.COLORTERM === undefined || spawnEnv.COLORTERM === "") {1290 // Otherwise both PTY backends feed truecolor-capable terminal clients.
1291 if (!spawnEnv.COLORTERM && runtimeEnv?.COLORTERM === undefined) {
1291 spawnEnv.COLORTERM = "truecolor";1292 spawnEnv.COLORTERM = "truecolor";
1292 }1293 }
1293 return stripAppImageRuntimeEnv(spawnEnv);1294 return stripAppImageRuntimeEnv(spawnEnv);