Skip to content

fix(tui): use contrast-aware foreground for paste summary badge#27969

Open
kagura-agent wants to merge 1 commit into
anomalyco:devfrom
kagura-agent:fix/paste-badge-transparent-theme
Open

fix(tui): use contrast-aware foreground for paste summary badge#27969
kagura-agent wants to merge 1 commit into
anomalyco:devfrom
kagura-agent:fix/paste-badge-transparent-theme

Conversation

@kagura-agent
Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #27968

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The paste summary badge ([Pasted ~N lines]) uses theme.background as its text color. When the theme background is transparent (alpha=0) — as in the built-in system theme or custom themes with transparent backgrounds — the text becomes invisible against the theme.warning badge background.

This swaps the hardcoded theme.background foreground for selectedForeground(theme, theme.warning), which already exists in the same file and handles this exact case: when background.a === 0, it computes a readable black/white color based on the target color luminance. For opaque themes, it falls back to theme.background — same behavior as before.

1-line change, no new code — reuses the existing contrast helper.

How did you verify your code works?

  • Verified that selectedForeground() returns theme.background for opaque themes (unchanged behavior) and computes luminance-based contrast for transparent themes
  • Ran bun test test/cli/tui/ test/config/tui — 31 pass (10 fail are pre-existing dependency issues: missing immer, htmlparser2 packages)
  • Reviewed diff: exactly 1 line changed in 1 file

Screenshots / recordings

N/A — terminal transparency rendering, verified by code inspection.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Paste summary label is invisible with transparent/system themes

1 participant