Skip to content
TypeScript

fix(server): advertise truecolor in the integrated terminal (#7680)

Shubh89ee69e4430b
diff --git a/apps/server/src/terminal/Manager.test.ts b/apps/server/src/terminal/Manager.test.ts
index c99b5a00043..deea3963178 100644
--- a/apps/server/src/terminal/Manager.test.ts
+++ b/apps/server/src/terminal/Manager.test.ts
@@ -1687,6 +1687,31 @@ it.layer(
}),
);
+ it.effect.each(["linux", "darwin", "win32"] as const)(
+ "advertises truecolor before the PTY backend on %s without replacing explicit values",
+ (platform) =>
+ Effect.gen(function* () {
+ for (const [parentColor, runtimeColor, expected] of [
+ [undefined, undefined, "truecolor"],
+ ["", undefined, "truecolor"],
+ ["24bit", undefined, "24bit"],
+ ["24bit", "", "truecolor"],
+ ["24bit", "custom", "custom"],
+ ] as const) {
+ const env = Object.freeze({ COLORTERM: parentColor });
+ const { manager, ptyAdapter } = yield* createManager(5, {
+ shellResolver: () => "/bin/sh",
+ env,
+ }).pipe(Effect.provide(withHostPlatform(platform)));
+ yield* manager.open(
+ openInput({ env: runtimeColor === undefined ? {} : { COLORTERM: runtimeColor } }),
+ );
+ expect(ptyAdapter.spawnInputs[0]?.env.COLORTERM).toBe(expected);
+ expect(env.COLORTERM).toBe(parentColor);
+ }
+ }),
+ );
+
it.effect("filters app runtime env variables from terminal sessions", () =>
Effect.gen(function* () {
const { manager, ptyAdapter } = yield* createManager(5, {
diff --git a/apps/server/src/terminal/Manager.ts b/apps/server/src/terminal/Manager.ts
index fcfdc2bb26c..f04e3c2d897 100644
--- a/apps/server/src/terminal/Manager.ts
+++ b/apps/server/src/terminal/Manager.ts
@@ -1270,6 +1270,10 @@ function createTerminalSpawnEnv(
spawnEnv[key] = value;
}
}
+ // Both PTY backends feed truecolor-capable terminal clients.
+ if (spawnEnv.COLORTERM === undefined || spawnEnv.COLORTERM === "") {
+ spawnEnv.COLORTERM = "truecolor";
+ }
return stripAppImageRuntimeEnv(spawnEnv);
}