fix(tui): use contrast-aware foreground for paste summary badge#27969
Open
kagura-agent wants to merge 1 commit into
Open
fix(tui): use contrast-aware foreground for paste summary badge#27969kagura-agent wants to merge 1 commit into
kagura-agent wants to merge 1 commit into
Conversation
When the theme background is transparent (e.g. system theme or custom themes with alpha=0), the paste badge `[Pasted ~N lines]` text becomes invisible because it uses theme.background as its foreground color. Use selectedForeground() to compute a readable black/white foreground based on the warning color luminance when the background is transparent, falling back to theme.background for opaque themes (preserving existing behavior). Fixes anomalyco#27968
6 tasks
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.
Issue for this PR
Closes #27968
Type of change
What does this PR do?
The paste summary badge (
[Pasted ~N lines]) usestheme.backgroundas its text color. When the theme background is transparent (alpha=0) — as in the built-insystemtheme or custom themes with transparent backgrounds — the text becomes invisible against thetheme.warningbadge background.This swaps the hardcoded
theme.backgroundforeground forselectedForeground(theme, theme.warning), which already exists in the same file and handles this exact case: whenbackground.a === 0, it computes a readable black/white color based on the target color luminance. For opaque themes, it falls back totheme.background— same behavior as before.1-line change, no new code — reuses the existing contrast helper.
How did you verify your code works?
selectedForeground()returnstheme.backgroundfor opaque themes (unchanged behavior) and computes luminance-based contrast for transparent themesbun test test/cli/tui/ test/config/tui— 31 pass (10 fail are pre-existing dependency issues: missingimmer,htmlparser2packages)Screenshots / recordings
N/A — terminal transparency rendering, verified by code inspection.
Checklist