Skip to content

fix: improve terminal contrast in light themes (Tango Light + xterm minimumContrastRatio) - #5986

Merged
Jinwoo-H merged 3 commits into
stablyai:mainfrom
zhangqinzhong:fix/light-theme-ansi-contrast
Jun 22, 2026
Merged

Jinwoo-H merged 3 commits into
stablyai:mainfrom
zhangqinzhong:fix/light-theme-ansi-contrast

Conversation

@zhangqinzhong

@zhangqinzhong zhangqinzhong commented Jun 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The Builtin Tango Light theme had 9 ANSI colors with contrast ratios below 3:1 against its white (#ffffff) background. CLI tools that render body text, file contents, and headers using ANSI white/bright-white produced unreadable output in light mode.

Fix

  • Theme colors (defaults.ts): darkened 9 low-contrast ANSI colors to readable Tango palette shades (all now ≥4.4:1 on white)
  • Renderer safety net (pane-terminal-options.ts): enabled xterm.js minimumContrastRatio: 4.5, which auto-adjusts low-contrast foreground colors at render time for ALL themes including custom imports
  • Tests: added contrast assertions for Tango Light key colors, and a test that minimumContrastRatio is enabled

Screenshots

No visual change — the terminal theme picker and settings UI are unaffected.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test

AI Review Report

Code review performed with AI agent:

  • Cross-platform: ✅ no platform-specific code, color values only
  • SSH/remote: ✅ theme rendering identical in local and SSH terminals
  • Agent compatibility: ✅ no agent-specific behavior changed
  • Keyboard shortcuts / labels / paths / shell: ✅ not affected
  • Performance: ✅ minimumContrastRatio is xterm.js built-in, negligible overhead
  • UI quality: ✅ all colors now pass WCAG AA (≥4.5:1) on white background

Security Audit

  • No input handling, command execution, path traversal, auth, secrets, dependency, or IPC risks.
  • This change only modifies static terminal color constants and a single xterm.js option (minimumContrastRatio).

Notes

  • No platform-specific behavior. Theme colors apply identically on macOS, Linux, and Windows.

X: @askrygg

🤖 Generated with Claude Code

vhudsongit and others added 2 commits June 21, 2026 22:49
Nine ANSI colors had contrast ratios below 3:1 against the white
background, making CLI output unreadable in light mode. Darkened
to readable Tango shades while keeping the warm palette identity.

Co-Authored-By: Claude <[email protected]>
xterm.js minimumContrastRatio (4.5) auto-adjusts low-contrast ANSI
foreground colors at render time — a safety net for all themes,
including custom imports. Added test coverage for this option and
for the Tango Light ANSI color contrast assertions.

Co-Authored-By: Claude <[email protected]>
@ghost

ghost commented Jun 21, 2026 •

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 2 individual chapters for you:

Title
1 Darken Tango Light ANSI colors for readability
2 Enable xterm.js minimum contrast ratio safety net
Open in Stage

Chapters generated by Stage for commit 6322eb9 on Jun 21, 2026 3:07pm UTC.

@coderabbitai

coderabbitai Bot commented Jun 21, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Two complementary changes address ANSI color readability on light terminal themes. The Builtin Tango Light entry in DEFAULT_TERMINAL_THEMES has several near-white ANSI hex values (yellow, cyan, white, brightBlack, and related bright variants) replaced with darker alternatives, accompanied by a comment explaining the Claude-style preview context. Separately, buildDefaultTerminalOptions() now includes minimumContrastRatio: 4.5 in its returned xterm options object. Each change is covered by new tests: a contrast-ratio suite for the light theme's cyan, white, brightCyan, and brightWhite colors, and a unit assertion for the new xterm option value.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: fixing terminal contrast in light themes through both the Tango Light theme update and xterm minimumContrastRatio setting.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description follows the repository template with all required sections completed: Summary, Screenshots, Testing, AI Review Report, Security Audit, and Notes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Jinwoo-H Jinwoo-H left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks good.\n\nVerified locally:\n- focused terminal theme/options tests pass\n- typecheck and lint pass\n- light terminal preview renders with the built-in light theme\n- xterm applies the 4.5 minimum contrast correction for low-contrast ANSI cells\n\nThe runtime contrast guard is the key piece here because it also covers custom/imported terminal themes.

@Jinwoo-H
Jinwoo-H merged commit 41add74 into stablyai:main Jun 22, 2026
AmethystLiang added a commit that referenced this pull request Jul 21, 2026
…luminance (#7934) (#9599)

* fix(terminal): gate xterm contrast correction by theme mode (#7934)

minimumContrastRatio: 4.5 (added in #5986 to rescue invisible
white/bright-white ANSI text on light backgrounds) was applied globally,
over-correcting vibrant ANSI colors on dark themes. Keep 4.5 on light
themes; disable it (1) on dark themes.

applyTerminalAppearance re-gates it in its per-pane loop, so live
auto/system dark<->light flips are handled for free. buildDefaultTerminalOptions
keeps 4.5 as the initial value so the first paint on a light theme never
flashes low-contrast text. Supersedes #7939.

Co-authored-by: Orca <[email protected]>

* fix(terminal): gate contrast correction by terminal background luminance

Contrast correction rescues white text on light backgrounds but over-corrects
on dark. The previous mode-based gate failed when the terminal theme didn't
match the app mode (e.g., terminalUseSeparateLightTheme=false). Now gates by
the theme's background luminance via isTerminalBackgroundLight() instead.

* refactor(terminal): extract contrast correction gating into shared helpe

Centralizes the minimumContrastRatio gating logic (#7934) into a
dedicated module so both the settings preview and live terminal
appearance apply the same contrast-by-luminance rule, preventing drift.
Adds value-gating to skip redundant writes that would clear xterm's
contrast cache on re-applies.

---------

Co-authored-by: Orca <[email protected]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…inimumContrastRatio) (stablyai#5986)

* fix: darken Builtin Tango Light ANSI colors for readability

Nine ANSI colors had contrast ratios below 3:1 against the white
background, making CLI output unreadable in light mode. Darkened
to readable Tango shades while keeping the warm palette identity.

Co-Authored-By: Claude <[email protected]>

* fix: enable xterm minimumContrastRatio and add light theme tests

xterm.js minimumContrastRatio (4.5) auto-adjusts low-contrast ANSI
foreground colors at render time — a safety net for all themes,
including custom imports. Added test coverage for this option and
for the Tango Light ANSI color contrast assertions.

Co-Authored-By: Claude <[email protected]>

* chore: trigger CI re-run

---------

Co-authored-by: zhangqinzhong <[email protected]>
Co-authored-by: Claude <[email protected]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…luminance (stablyai#7934) (stablyai#9599)

* fix(terminal): gate xterm contrast correction by theme mode (stablyai#7934)

minimumContrastRatio: 4.5 (added in stablyai#5986 to rescue invisible
white/bright-white ANSI text on light backgrounds) was applied globally,
over-correcting vibrant ANSI colors on dark themes. Keep 4.5 on light
themes; disable it (1) on dark themes.

applyTerminalAppearance re-gates it in its per-pane loop, so live
auto/system dark<->light flips are handled for free. buildDefaultTerminalOptions
keeps 4.5 as the initial value so the first paint on a light theme never
flashes low-contrast text. Supersedes stablyai#7939.

Co-authored-by: Orca <[email protected]>

* fix(terminal): gate contrast correction by terminal background luminance

Contrast correction rescues white text on light backgrounds but over-corrects
on dark. The previous mode-based gate failed when the terminal theme didn't
match the app mode (e.g., terminalUseSeparateLightTheme=false). Now gates by
the theme's background luminance via isTerminalBackgroundLight() instead.

* refactor(terminal): extract contrast correction gating into shared helpe

Centralizes the minimumContrastRatio gating logic (stablyai#7934) into a
dedicated module so both the settings preview and live terminal
appearance apply the same contrast-by-luminance rule, preventing drift.
Adds value-gating to skip redundant writes that would clear xterm's
contrast cache on re-applies.

---------

Co-authored-by: Orca <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants