Repository navigation
fix(terminal): gate xterm contrast correction by terminal background luminance (#7934) - #9599
Merged
Merged
Conversation
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]>
Contributor
📝 WalkthroughWalkthroughTerminal contrast correction now uses 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
Contributor
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 54224828-ab03-487f-b7a6-a6a151c5b3ae
📒 Files selected for processing (5)
src/renderer/src/components/settings/TerminalSettingsPreview.tsxsrc/renderer/src/components/terminal-pane/terminal-appearance.test.tssrc/renderer/src/components/terminal-pane/terminal-appearance.tssrc/renderer/src/lib/pane-manager/pane-lifecycle.test.tssrc/renderer/src/lib/pane-manager/pane-terminal-options.ts
This was referenced Jul 20, 2026
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.
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.
AmethystLiang
added a commit
that referenced
this pull request
Jul 23, 2026
* fix(terminal): restore a dark-background contrast floor Fully disabling xterm minimumContrastRatio on dark backgrounds (#9599) left near-background body text unreadable — Antigravity paints #262b30 on #1e242a (~1.1:1). Keep light backgrounds at WCAG-AA 4.5 and use a milder dark floor (3) so dark-on-dark body text is lifted without the full light-bg correction strength. Fixes #10104 * fix(terminal): extend dark-bg contrast floor to preview + mobile terminals The dark-background minimumContrastRatio floor (#10104) is applied per `new Terminal()` construction site. Beyond the live pane, agent output also renders in the dashboard popout preview and the mobile WebView, which were still at the floor-1 default, so Antigravity output stayed unreadable there. - AgentTerminalPreview: gate via resolveTerminalMinimumContrastRatio - mobile WebView: port the gate as resolveTerminalContrastFloor (Chrome-74 JS) - tests: builtin-catalog guard + mobile vm-harness coverage Co-authored-by: Orca <[email protected]> --------- Co-authored-by: Jinjing <[email protected]> Co-authored-by: Orca <[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]>
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
* fix(terminal): restore a dark-background contrast floor Fully disabling xterm minimumContrastRatio on dark backgrounds (stablyai#9599) left near-background body text unreadable — Antigravity paints #262b30 on #1e242a (~1.1:1). Keep light backgrounds at WCAG-AA 4.5 and use a milder dark floor (3) so dark-on-dark body text is lifted without the full light-bg correction strength. Fixes stablyai#10104 * fix(terminal): extend dark-bg contrast floor to preview + mobile terminals The dark-background minimumContrastRatio floor (stablyai#10104) is applied per `new Terminal()` construction site. Beyond the live pane, agent output also renders in the dashboard popout preview and the mobile WebView, which were still at the floor-1 default, so Antigravity output stayed unreadable there. - AgentTerminalPreview: gate via resolveTerminalMinimumContrastRatio - mobile WebView: port the gate as resolveTerminalContrastFloor (Chrome-74 JS) - tests: builtin-catalog guard + mobile vm-harness coverage Co-authored-by: Orca <[email protected]> --------- Co-authored-by: Jinjing <[email protected]> Co-authored-by: Orca <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #7934. Gates xterm's
minimumContrastRatioby the terminal's composed background luminance instead of exposing a user setting: 4.5 on light backgrounds, disabled (1) on dark backgrounds.Why
minimumContrastRatio: 4.5was added in #5986 to rescue invisible white/bright-white ANSI text on light (white) backgrounds. But it was applied globally, so on dark themes it over-corrects — distorting/dulling vibrant ANSI colors that were already perfectly readable. That's the user complaint in #7934.Why background luminance, not app theme mode (the first commit gated by mode; the second switches the signal): either theme slot can hold either kind of theme. With
terminalUseSeparateLightThemeoff ("match dark mode"), light app mode still renders the dark terminal theme — mode-gating would keep the over-correction exactly where #7934 complains about it. Conversely, a light theme selected asterminalThemeDarkwould lose the white-text rescue. Gating onisTerminalBackgroundLight()over the composed theme background (translucent backgrounds composited against the app surface) resolves both configurations correctly.minimumContrastRatiois a pure render-side setting — it does not change buffer/cell data — so gating it is safe and requires no cross-process/SSH plumbing.Visual comparison
Same ANSI output, same theme (Orca's default Ghostty dark), same xterm build — the only variable is
minimumContrastRatio(4.5 = correction on, 1 = off):brightBlack#666666is only ~2.4:1 against#282c34), so dim/secondary TUI text loses its hierarchy and reads like body text; red is washed toward pink; white-on-red/blue badge foregrounds get nudged.1, ANSI white/bright-white body text (how agent CLIs print) vanishes into the background; at4.5it's rescued to a readable gray. That's the original bug class the setting was added for in fix: improve terminal contrast in light themes (Tango Light + xterm minimumContrastRatio) #5986.How dramatic the dark-side difference looks depends on the theme — palettes that already clear 4.5:1 barely change. Dim/secondary text is the case that's visibly wrong on virtually every dark theme.
In-app validation
The two Terminal settings previews rendering live in the app, confirming the gate resolves per background (unchanged behavior; captured while validating the code path):
Light Mode Preview — white background ⇒
minimumContrastRatio = 4.5(correction on; ANSI white/bright-white body text stays readable):Dark Mode Preview — dark background ⇒
minimumContrastRatio = 1(correction off; vibrant ANSI palette preserved as the theme author designed):Changes (renderer-only)
terminal-appearance.ts—applyTerminalAppearance()now writes a value-gatedminimumContrastRatioderived fromisTerminalBackgroundLight(theme?.background, { appSurface: appearance.mode }), right alongside the existingoptions.themegating. This path re-runs on every theme flip — including auto/system dark↔light — so live switching is handled for free.pane-terminal-options.ts—buildDefaultTerminalOptions()keeps4.5as the initial value so the first paint on a light background never flashes low-contrast text before appearance-apply runs.TerminalSettingsPreview.tsx— mirrors the same background-luminance gating so the settings preview matches live panes when the preview theme toggle flips.Deliberately not touched: no
GlobalSettingsfield, no settings UI, andsrc/main/daemon/headless-emulator.tsis left alone (the headless emulator mirrors options for buffer parity, andminimumContrastRatiohas no effect on cell data).Supersedes #7939
That PR took a "make it configurable" approach we decided against. Background-gating needs no new user-facing knob.
Trade-off
A poorly-designed dark theme with genuinely low-contrast ANSI colors is no longer auto-rescued. That trade is intentional — the reported problem is over-correction on dark backgrounds, where the global rescue was doing more harm than good.
Tests
terminal-appearance.test.ts— apply-path coverage asserting light ⇒ 4.5, dark ⇒ 1, re-gating on a live flip, plus the two mismatch configs: "match dark mode" (light app + dark terminal theme ⇒1) and a light theme filling the dark slot (⇒4.5).pane-lifecycle.test.ts— updated the default-options test to document that 4.5 is the light-background initial value.tsconfig.tc.web), oxlint, and oxfmt all clean.Made with Orca 🐋