Skip to content

Commit 89ee69e

Browse files
fix(server): advertise truecolor in the integrated terminal (pingdotgg#7680)
Co-authored-by: Julius Marminge <[email protected]>
1 parent 82f64cd commit 89ee69e

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,6 +1687,31 @@ it.layer(
16871687
}),
16881688
);
16891689

1690+
it.effect.each(["linux", "darwin", "win32"] as const)(
1691+
"advertises truecolor before the PTY backend on %s without replacing explicit values",
1692+
(platform) =>
1693+
Effect.gen(function* () {
1694+
for (const [parentColor, runtimeColor, expected] of [
1695+
[undefined, undefined, "truecolor"],
1696+
["", undefined, "truecolor"],
1697+
["24bit", undefined, "24bit"],
1698+
["24bit", "", "truecolor"],
1699+
["24bit", "custom", "custom"],
1700+
] as const) {
1701+
const env = Object.freeze({ COLORTERM: parentColor });
1702+
const { manager, ptyAdapter } = yield* createManager(5, {
1703+
shellResolver: () => "/bin/sh",
1704+
env,
1705+
}).pipe(Effect.provide(withHostPlatform(platform)));
1706+
yield* manager.open(
1707+
openInput({ env: runtimeColor === undefined ? {} : { COLORTERM: runtimeColor } }),
1708+
);
1709+
expect(ptyAdapter.spawnInputs[0]?.env.COLORTERM).toBe(expected);
1710+
expect(env.COLORTERM).toBe(parentColor);
1711+
}
1712+
}),
1713+
);
1714+
16901715
it.effect("filters app runtime env variables from terminal sessions", () =>
16911716
Effect.gen(function* () {
16921717
const { manager, ptyAdapter } = yield* createManager(5, {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,10 @@ function createTerminalSpawnEnv(
12701270
spawnEnv[key] = value;
12711271
}
12721272
}
1273+
// Both PTY backends feed truecolor-capable terminal clients.
1274+
if (spawnEnv.COLORTERM === undefined || spawnEnv.COLORTERM === "") {
1275+
spawnEnv.COLORTERM = "truecolor";
1276+
}
12731277
return stripAppImageRuntimeEnv(spawnEnv);
12741278
}
12751279

0 commit comments

Comments
 (0)