Repository navigation
feat(terminal): make the contrast floor user-configurable (#10754) - #18126
Conversation
📝 WalkthroughWalkthroughAdds an optional Priority: ➖ Normal — Impact reflects medium issue severity. Severity of issue fixed: Medium Merge Risk: 🔵 Low · up to Terminal contrast now supports automatic, off, and custom targets across clients. Entering Off through the precise custom input can lose the user’s previous target, and the setting label localization concern remains open; both should be addressed before release. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 17.65% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 24 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1📝 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: 38ed32e0-e6f9-4a0b-988b-08154e719935
📒 Files selected for processing (22)
mobile/src/terminal/terminal-webview-theme-injected.test.tsmobile/src/terminal/terminal-webview-theme-injected.tssrc/main/persistence/applying-settings/settings-update-terminal-contrast.test.tssrc/main/persistence/applying-settings/settings-update.tssrc/renderer/src/components/dashboard-popout/preview-terminal-options.test.tssrc/renderer/src/components/dashboard-popout/preview-terminal-options.tssrc/renderer/src/components/settings/SettingsFormControls.number-field.test.tsxsrc/renderer/src/components/settings/SettingsFormControls.tsxsrc/renderer/src/components/settings/TerminalRenderingSection.tsxsrc/renderer/src/components/settings/TerminalSettingsPreview.tsxsrc/renderer/src/components/settings/setting-labels.tssrc/renderer/src/components/settings/terminal-typography-search.tssrc/renderer/src/components/terminal-pane/terminal-appearance.test.tssrc/renderer/src/components/terminal-pane/terminal-appearance.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/lib/terminal-contrast-correction.test.tssrc/renderer/src/lib/terminal-contrast-correction.tssrc/renderer/src/runtime/sync-runtime-graph/mobile-terminal-theme.test.tssrc/renderer/src/runtime/sync-runtime-graph/mobile-terminal-theme.tssrc/shared/global-settings-types.tssrc/shared/runtime-mobile-session-tab-contracts.tssrc/shared/terminal-minimum-contrast-settings.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.
| terminalFastScrollSensitivity: 'Fast Scroll Speed', | ||
| terminalTuiScrollSensitivity: 'TUI Scroll Speed', | ||
| terminalBackgroundOpacity: 'Background Opacity', | ||
| terminalMinimumContrastRatio: 'Minimum Contrast Ratio', |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Localize the new setting label.
SETTING_LABELS adds a hard-coded English label. Use the existing intent-named minimumContrast.title translation key so this label follows the active locale.
Based on learnings: newly added user-facing strings in renderer settings code must use intent-named localization IDs.
Source: Learnings
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- User-configurable contrast floor — new optional
terminalMinimumContrastRatiosetting;undefinedkeeps the automatic background-luminance floor (4.5 light / 3 dark),1disables correction, other values pin the floor, all clamped to xterm's [1, 21] via sharednormalizeTerminalMinimumContrastRatio. - Resolver override —
resolveTerminalMinimumContrastRatiogains anoverrideargument that wins over the luminance gate; all three consumers (live panes, dashboard preview, settings preview) now pass it. - Persistence-boundary clamp —
settings-update.tsnormalizes the field on write so desktop IPC, web RPC, and the CLI can't hand xterm an out-of-range or non-finite floor; a hand-edited profile stays clamped by the resolver too. - Settings UI —
NumberFieldgains opt-inonClear/placeholder, and a new Terminal → Rendering row with dynamic helper text plus search keywords/catalog entry. - Mobile parity — the resolved floor is published as a new optional field on
RuntimeMobileTerminalTheme; the injected webview prefers it and falls back to the luminance gate when absent, so old hosts/clients stay compatible without negotiation.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Refreshed the mobile payload checksum fixture — updated
EXPECTED_LENGTH/EXPECTED_SHA256interminal-webview-payload-hash.test.tsto match the emitted WebView document, resolving the failed mobileverifyCI job. - Clarified the pinned-ratio helper copy — the
pinnedstring now reads "Targets {{ratio}}:1 contrast for foreground colors, where possible." instead of "Foreground colors are lifted until they reach …", removing the overpromise for backgrounds where the target is unachievable. The fallback inTerminalRenderingSection.tsxanden.jsonstay in sync.
Both changes are fixtures/copy only — no resolver, settings, persistence, or mobile-injection logic changed since the prior review.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
The xterm minimumContrastRatio floor was hardcoded (3 on dark backgrounds, 4.5 on light) and applied to every pane with no way out, so TUIs that use deliberately low contrast were rewritten: Powerline separators drawn in the neighbouring segment's background became visible seams, and dimmed secondary text lost its hierarchy. Adds an optional `terminalMinimumContrastRatio` setting under Settings -> Terminal -> Rendering. Blank keeps today's automatic, background-luminance gated floor; 1 disables correction entirely (matching VS Code's documented `terminal.integrated.minimumContrastRatio` and iTerm2's off-by-default Minimum Contrast); values are clamped to xterm's 1-21 range. The floor is resolved in one place, so live panes, the Appearance preview and the dashboard terminal preview all follow it, and the existing value-gated write still avoids clearing xterm's contrast cache on no-op re-applies. The clamp also lives at the persistence boundary that every writer crosses, so a hand-edited profile or CLI write can never hand xterm a non-finite option. Mobile mirrors the desktop gate, so the resolved floor travels with the terminal theme payload as a new optional field; hosts that omit it leave older and newer clients on the luminance gate. Fixes #10754. Co-authored-by: Nyanako <[email protected]>
c82bde5 to
ee33b92
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Rebased onto
main(c1e15c4008) — the previously reported merge conflicts are resolved. History was consolidated to3fcd2101d2(feature) +ee33b92964(fixture/copy), and the PR's own files are byte-identical to the prior-reviewed headc82bde5: resolver override, settings UI, persistence clamp, and mobile publication are all unchanged. - No new behavioral surface — the shared type/component files (
global-settings-types.ts,runtime-mobile-session-tab-contracts.ts,SettingsFormControls.tsx,terminal-appearance.ts) only picked up unrelatedmaindrift (cursor-blink suspension, MiniMax region,classNamepassthrough), none of which alters the contrast-floor logic.
No inline comments this pass. CI should be allowed to run against the rebased head before merge.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 9b047cb9-296c-4961-8fe9-af0b86676a0a
📒 Files selected for processing (6)
src/renderer/src/components/settings/TerminalContrastSetting.test.tsxsrc/renderer/src/components/settings/TerminalContrastSetting.tsxsrc/renderer/src/components/settings/TerminalRenderingSection.tsxsrc/renderer/src/components/settings/setting-labels.tssrc/renderer/src/components/settings/terminal-typography-search.tssrc/renderer/src/i18n/locales/en.json
🚧 Files skipped from review as they are similar to previous changes (3)
- src/renderer/src/components/settings/setting-labels.ts
- src/renderer/src/i18n/locales/en.json
- src/renderer/src/components/settings/terminal-typography-search.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
| max={MAX_TERMINAL_CONTRAST_RATIO} | ||
| step={0.1} | ||
| suffix=":1" | ||
| onChange={(ratio) => updateSettings({ terminalMinimumContrastRatio: ratio })} |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Preserve the custom target when precise input selects Off.
When a user enters 1, save the preceding custom target before writing the Off sentinel. Line 117 bypasses selectMode, so lastCustomValue remains at its initial fallback. A stored target of 7 then restores as 4.5 after the user selects Custom again.
Add a regression case that enters 1 from custom mode and verifies that Custom restores the prior target in src/renderer/src/components/settings/TerminalContrastSetting.test.tsx.
…e main static analysis The 7 auto.components.settings.TerminalPane.minimumContrast.* entries added by #18126 have zero call sites; the shipped component reads settings.contrast.*. Because the runtime-required catalog classifies any key with no literal-default call site as required, the orphans broke 'Verify runtime-required localization catalog' on main and red-lit every PR in the repo. Deleting them is the root-cause fix: regenerating would instead add dead strings to the boot bundle. On main+delete, --fix regenerates a byte-identical catalog and the CI step exits 0. Merged with 'test / tests node 24 3/8' red: that failure is an unrelated main break from the #19542/#19551 collision, not from this change.
The contrast floor is user-configurable upstream (stablyai#18126) and the POSIX query-reply ordering fix shipped as stablyai#15559/stablyai#15578, so neither needs tracking anymore.

Fixes #10754. Based on @Nanako0129’s #10760; their co-author credit is retained.
Change
Orca’s automatic contrast correction brightens intentionally dim TUI text and Powerline styling. Settings → Terminal → Rendering → Color Contrast now offers three plain-language choices:
Returning to Automatic removes the stored override in one click. Custom remembers its previous target while switching modes within the mounted settings control. Slider changes save on commit; arrow keys adjust the target. Exact input is bounded to 1–21, and entering 1 selects Off. The slider starts at 1.1 so reaching its lower end does not collapse the Custom controls.
The underlying optional
terminalMinimumContrastRatioremains compatible: absent = Automatic, 1 = Off, other valid numbers = Custom. No new setting or wire field is introduced by this UX revision.Settings screenshots — current UI
Fresh hidden Electron/CDP captures from the implementation in
c997d35f96. These replace the earlier blank-input screenshots. They show the full settings page and surrounding options, with no settings search filter unless explicitly labeled.Automatic — a recommended default, with no number to manage.
Off — preserve the colors chosen by the program in one click.
Custom — progressively reveals a slider and precise value field.
More settings proof: custom values, bounds, light mode, search, and narrow layout
Custom target 7 — also verified to survive Off → Automatic → Custom.
Entering 99 clamps to 21.
Light mode, Automatic.
Light mode, Custom.
Search for “powerline” finds the control.
Narrower window, Custom.
Terminal rendering proof
The renderer behavior is unchanged by the UX revision. These existing captures used the same live PTY and terminal instance in a folder workspace, with the original issue’s ANSI foreground/background samples. “Auto” and “1” in the earlier measurements map to today’s Automatic and Off choices.
Automatic: the seam sample becomes readable and deliberately dim text is brightened.
Off: the seam sample becomes nearly invisible and secondary text stays dim.
The 520 × 22 sample spanning all seven background swatches had 0 changed pixels in every dark-mode state. Terminal identity and buffer text were preserved. These measurements establish foreground correction, not a palette/background change; they were captured before the new mode control.
Light theme and background-based defaults — 3 screenshots
The floor follows the composed terminal background, not the app’s light/dark mode. The capture script reads 4.5 for both light-background Auto cases and 1 for the disabled case.
Light terminal background: automatic ratio is 4.5
Light terminal background: 1 disables correction here too
Light theme in the dark theme slot: full app context
Appearance preview — 2 screenshots
Both values were entered in the Terminal setting before navigating to Appearance. The preview uses the same resolver as live panes.
Appearance preview with the target set to 21
Appearance preview with correction disabled at 1
Mobile document rendering — 2 screenshots; not a phone test
The complete generated mobile WebView HTML was loaded in an iframe inside the hidden Electron renderer, initialized through its actual message handler, and updated with a
set-thememessage. It rendered the same ANSI sample with no captured engine/runtime errors. This exercises the document and its bundled xterm, not React Native pairing, an iPhone, or an Android device.Mobile WebView document: Auto
Mobile WebView document: published override 1
Full desktop context — 2 uncropped screenshots
Full Orca window: Auto
Full Orca window: correction off
Review map and comparison with #10760
terminal-minimum-contrast-setting.spec.ts) and an explicit value-gated dashboard appearance helper. The E2E is not ported here; this PR’s dashboard constructor reads the override when the existing settings/theme effect reruns.Start with
TerminalContrastSetting.tsxfor mode selection and custom tuning, thenterminal-minimum-contrast-settings.tsandterminal-contrast-correction.tsfor numeric validation/defaults. Desktop consumers areterminal-appearance.ts,TerminalSettingsPreview.tsx, andpreview-terminal-options.ts. Mobile publication and reading live inmobile-terminal-theme.tsandterminal-webview-theme-injected.ts.Verification
Current UX revision:
ORCA_BACKGROUND_LAUNCH=1 pnpm tc:web— passed.git diff --check— passed.Rebased rendering implementation: full
pnpm tc, 65 focused desktop tests, and 21 focused mobile tests passed onee33b92964, rebased ontomainatc1e15c4008. Earlier actual-source mobile VM validation covered 18 dark/light/invalid/clamp cases. The complete mobile document also rendered without captured engine errors in an Electron iframe (screenshots above); this is not phone/pairing validation.The earlier mobile payload checksum CI failure was reproduced and fixed by updating the expected document length/hash after validating the intentional injected-JS change. CI must pass on the latest head before merge.
Compatibility and limits
settings.updateRPC.minimum-contrastimport remains out of scope.New screenshots are GitHub attachments uploaded using
gh pr edit --attach(CLI 2.100.0). The terminal and mobile galleries retain their earlier capture provenance; obsolete settings screenshots have been removed from this description.