Skip to content

Commit dbea5a7

Browse files
authored
fix(ui): make Control UI terminal readable in light mode (#123184)
The light terminal theme reused the dark-background ANSI palette (1.4-2.6:1 contrast on #f7f8fa; brightWhite was 1.06), and the intro banner hardcoded 256-color indices 223/216 that bypass the client theme entirely. Light mode now gets its own darkened ANSI-16 palette (>=4.5:1, bright variants darker for emphasis, brightWhite maps to strongest ink), and the banner emits themable ANSI-16 yellow/bright-red so each mode owns its rendering. Dark mode is visually unchanged.
1 parent f04fdd5 commit dbea5a7

3 files changed

Lines changed: 37 additions & 12 deletions

File tree

‎src/gateway/terminal/intro-banner.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ describe("composeTerminalIntroBanner", () => {
2525
const banner = composeTerminalIntroBanner();
2626

2727
expect(banner).toBe(
28-
`\r\n\x1b[38;5;223mWelcome to the Claw.\x1b[0m\r\n\r\n\x1b[38;5;216m${EXPECTED_ART.join("\r\n")}\r\n\r\n\x1b[0m`,
28+
`\r\n\x1b[33mWelcome to the Claw.\x1b[0m\r\n\r\n\x1b[91m${EXPECTED_ART.join("\r\n")}\r\n\r\n\x1b[0m`,
2929
);
30-
expect(banner.startsWith("\r\n\x1b[38;5;223mWelcome to the Claw.\x1b[0m")).toBe(true);
30+
expect(banner.startsWith("\r\n\x1b[33mWelcome to the Claw.\x1b[0m")).toBe(true);
3131
expect(banner.endsWith("\r\n\r\n\x1b[0m")).toBe(true);
3232
expect(banner.replaceAll("\r\n", "")).not.toContain("\n");
3333
});

‎src/gateway/terminal/intro-banner.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ const TERMINAL_INTRO_ART = [
2222
// Always full art: open-time request.cols is the pre-fit boot grid (the client
2323
// resizes immediately after open), so width gating keyed on it suppressed the
2424
// art on real, wide terminals.
25+
// ANSI-16 colors only: the server can't know the client's light/dark mode, and
26+
// fixed 256-color indices (223/216) bypass the client theme and vanish on light
27+
// backgrounds. Yellow/bright-red stay warm on dark and darken on light.
2528
export function composeTerminalIntroBanner(): string {
26-
const headline = `\x1b[38;5;223mWelcome to the Claw.${RESET}`;
27-
const art = `\x1b[38;5;216m${TERMINAL_INTRO_ART.join("\r\n")}\r\n\r\n`;
29+
const headline = `\x1b[33mWelcome to the Claw.${RESET}`;
30+
const art = `\x1b[91m${TERMINAL_INTRO_ART.join("\r\n")}\r\n\r\n`;
2831
return `\r\n${headline}\r\n\r\n${art}${RESET}`;
2932
}

‎ui/src/components/terminal/terminal-theme.ts‎

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ type TerminalTheme = NonNullable<
88
NonNullable<CreateGhosttyTerminalOptions["terminalOptions"]>["theme"]
99
>;
1010

11-
// ANSI palette tuned to sit on the Control UI's near-black / near-white surfaces.
12-
// Shared 8 + bright 8; foreground/background/cursor are overridden per mode below.
13-
const ANSI = {
11+
// ANSI palettes tuned per mode: colors that read on the near-black surface sit
12+
// at 1.4-2.6:1 on the light surface, so light gets its own darkened set
13+
// (>=4.5:1 on #f7f8fa) instead of sharing the dark palette.
14+
const DARK_ANSI = {
1415
black: "#1b1e26",
1516
red: "#ff6b6b",
1617
green: "#4ec9a8",
@@ -29,6 +30,29 @@ const ANSI = {
2930
brightWhite: "#ffffff",
3031
} as const;
3132

33+
// Same hue identities as DARK_ANSI, darkened for the light surface. Bright
34+
// variants go darker than normal ones so bold/bright text stays emphatic
35+
// instead of washing out; brightWhite maps to the strongest ink, matching
36+
// the light-theme convention in Ghostty/iTerm paired themes.
37+
const LIGHT_ANSI = {
38+
black: "#3a3f4b",
39+
red: "#c62f3d",
40+
green: "#177a5e",
41+
yellow: "#8f6400",
42+
blue: "#1e66d0",
43+
magenta: "#94439c",
44+
cyan: "#0f7487",
45+
white: "#1b1e26",
46+
brightBlack: "#5c6370",
47+
brightRed: "#a3242f",
48+
brightGreen: "#0f664e",
49+
brightYellow: "#755200",
50+
brightBlue: "#1a55ab",
51+
brightMagenta: "#7c3382",
52+
brightCyan: "#0c6070",
53+
brightWhite: "#0a0c10",
54+
} as const;
55+
3256
// Dark mirrors the claw tokens in styles/base.css (`--bg` #0e1015,
3357
// `--accent` #ff5c5c) — keep them in sync when the tokens change. Light is a
3458
// deliberate neutral cool white: the light theme families diverge (ivory,
@@ -47,16 +71,14 @@ export function terminalTheme(mode: "dark" | "light"): TerminalTheme {
4771
const colors = terminalDynamicColors(mode);
4872
if (mode === "light") {
4973
return {
50-
...ANSI,
74+
...LIGHT_ANSI,
5175
...colors,
5276
cursorAccent: "#f7f8fa",
53-
selectionBackground: "rgba(90, 162, 255, 0.30)",
54-
black: "#3a3f4b",
55-
white: "#1b1e26",
77+
selectionBackground: "rgba(30, 102, 208, 0.30)",
5678
};
5779
}
5880
return {
59-
...ANSI,
81+
...DARK_ANSI,
6082
...colors,
6183
cursorAccent: "#0e1015",
6284
selectionBackground: "rgba(90, 162, 255, 0.32)",

0 commit comments

Comments
 (0)