feat(tui): add theme-configurable text selection colors
Summary
Fixes #5295
Add selection and selectionForeground properties to the theme system to fix poor text selection contrast on light terminals.
Problem
When selecting text to copy on light terminals, the default @opentui/core behavior inverts foreground/background colors. This works for dark themes but produces unreadable selections on light themes (dark text → dark selection background with poor contrast).
Solution
- Add optional
selectionandselectionForegroundproperties to the theme schema - Provide smart fallbacks when not specified:
selectiondefaults to theme'sprimarycolorselectionForegroundauto-calculated based on luminance for contrast
- Pass selection colors to all text-rendering components in the session view
Theme authors can customize these values, but existing themes work without changes due to the fallbacks.
Changes
theme.tsx: Add selection color types, schema support, and fallback logicorng.json: Add explicit selection colors as examplesession/index.tsx: PassselectionBg/selectionFgprops to text components
Screenshots
1.0.137 Unreadable Text Selection:
Examples of PR Solution:
Testing
Tested with opencode and orng themes on light terminal (Ghostty) - selection is now clearly visible with high contrast.
CI Failures
The CI failures (format and test) appear to be pre-existing issues unrelated to this PR - the dev branch shows similar intermittent failures. The format failure is related to SDK generation (openapi.ts not found), and the test failure is in tool.patch, neither of which are touched by this PR.
Notes
This solution was developed with assistance from Claude Opus 4.5 and may not be the preferred approach by maintainers. A simpler solution might involve updating the default selection color handling in @opentui/core itself to better handle light terminal scenarios. However, this PR provides a working solution that I'm using in my local build in the interim, and at minimum demonstrates the issue and one viable fix.