fix(tui): normalize legacy Terminal.app colors - #17695
Conversation
0e22ac4 to
91a0527
Compare
There was a problem hiding this comment.
Pull request overview
This PR adjusts TUI color behavior for legacy/light macOS Terminal.app by (1) normalizing theme foreground colors into readable ANSI256 buckets (while preserving banner/accent intent), (2) aligning Ink/chalk RGB/hex downgrades with Rich’s 256-color mapping, and (3) changing how “dim” text is rendered on Apple Terminal.
Changes:
- Add Apple Terminal light-mode heuristics and theme foreground normalization to ANSI256 for legacy/light profiles.
- Make Ink
colorize()optionally downgrade hex/rgb to Rich-compatible ANSI256 on legacy Apple Terminal (without forcing truecolor). - Change
forceTruecolorto only apply when explicitly opted in; adjust dim rendering behavior + add tests.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| ui-tui/src/theme.ts | Adds ANSI256 normalization logic for selected foreground theme colors on legacy/light Apple Terminal; updates default theme selection/skin mapping. |
| ui-tui/src/lib/forceTruecolor.ts | Reworks truecolor forcing to be explicit-only via HERMES_TUI_TRUECOLOR. |
| ui-tui/src/entry.tsx | Updates first-import note to match the new targeted truecolor behavior. |
| ui-tui/src/tests/theme.test.ts | Adds coverage for Apple Terminal light default + theme normalization behavior. |
| ui-tui/src/tests/forceTruecolor.test.ts | Updates tests for explicit-only truecolor forcing and env precedence. |
| ui-tui/packages/hermes-ink/src/ink/components/Text.tsx | Disables ANSI dim by default on Apple Terminal and introduces a dim color fallback. |
| ui-tui/packages/hermes-ink/src/ink/components/Text.test.ts | Adds tests for Apple Terminal dim behavior and fallback color. |
| ui-tui/packages/hermes-ink/src/ink/colorize.ts | Adds Rich-compatible 256-color downgrade for hex/rgb on legacy Apple Terminal. |
| ui-tui/packages/hermes-ink/src/ink/colorize.test.ts | Adds tests for downgrade gating + color-number mapping parity with Rich. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
91a0527 to
025acf4
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
025acf4 to
4ef31a8
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4ef31a8 to
8bd65dc
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Keep light Terminal.app TUI colors readable by normalizing non-banner theme tokens into ANSI256-safe buckets while preserving truecolor terminals.
8bd65dc to
7ed8cfe
Compare
Keep light Terminal.app TUI colors readable by normalizing non-banner theme tokens into ANSI256-safe buckets while preserving truecolor terminals.
Keep light Terminal.app TUI colors readable by normalizing non-banner theme tokens into ANSI256-safe buckets while preserving truecolor terminals.
Keep light Terminal.app TUI colors readable by normalizing non-banner theme tokens into ANSI256-safe buckets while preserving truecolor terminals.
Keep light Terminal.app TUI colors readable by normalizing non-banner theme tokens into ANSI256-safe buckets while preserving truecolor terminals.
Keep light Terminal.app TUI colors readable by normalizing non-banner theme tokens into ANSI256-safe buckets while preserving truecolor terminals.
Keep light Terminal.app TUI colors readable by normalizing non-banner theme tokens into ANSI256-safe buckets while preserving truecolor terminals.
Keep light Terminal.app TUI colors readable by normalizing non-banner theme tokens into ANSI256-safe buckets while preserving truecolor terminals.
Keep light Terminal.app TUI colors readable by normalizing non-banner theme tokens into ANSI256-safe buckets while preserving truecolor terminals.
Summary
HERMES_TUI_DIMoverrides preserved.Test plan
npm test -- src/__tests__/theme.test.ts packages/hermes-ink/src/ink/colorize.test.ts packages/hermes-ink/src/ink/components/Text.test.ts src/__tests__/forceTruecolor.test.tsnpm run type-check --prefix ui-tuinpx eslint src/theme.ts src/__tests__/theme.test.ts packages/hermes-ink/src/ink/colorize.ts packages/hermes-ink/src/ink/colorize.test.ts packages/hermes-ink/src/ink/components/Text.tsx packages/hermes-ink/src/ink/components/Text.test.ts src/lib/forceTruecolor.ts src/__tests__/forceTruecolor.test.ts