Skip to content

feat(tui): add light color scheme with auto-detect and JSON config - #14

Open
dragonee wants to merge 1 commit into
KamilSupera:developfrom
dragonee:feat/color-themes
Open

feat(tui): add light color scheme with auto-detect and JSON config#14
dragonee wants to merge 1 commit into
KamilSupera:developfrom
dragonee:feat/color-themes

Conversation

@dragonee

Copy link
Copy Markdown

What & why

The TUI ships a single hardcoded, dark-only "Blade Runner amber" theme that is unreadable on light/white terminal backgrounds. This adds a second, light-optimized scheme while keeping the existing dark one byte-for-byte unchanged.

How

  • Palette → lipgloss.AdaptiveColor{Dark, Light} (internal/tui/view.go). The Dark variants are the original hex (dark output is identical to before); the Light variants are a warm palette tuned for contrast on white. The duplicated inline #1a1305 (9 sites) is folded into colOnAccent / colSurface0 so badge/tab text stays legible in both modes.
  • Non-palette subsystems get the resolved dark/light flag via a new internal/tui/theme.go (SetTheme): glamour markdown (dark/light standard style), chroma syntax highlighting (dark vs. light style list), and the spinner color.
  • Startup resolution (cmd/prcheck/main.go): the scheme is resolved once, before Bubble Tea enters AltScreen, and frozen with lipgloss.SetHasDarkBackground. The auto path detects the terminal background there — sidestepping the AltScreen OSC-query deadlock documented in markdown.go — and falls back to dark when the terminal doesn't answer.
  • Config (internal/config): new PRCHECK_THEME env var (auto|dark|light, default auto) plus an optional JSON config file at os.UserConfigDir()/prcheck/config.json, parsed with stdlib encoding/json. Env overrides the file; a missing/malformed file is non-fatal.

Notes

  • No new dependency (stdlib encoding/json; glamour/chroma/lipgloss already vendored).
  • Default auto means existing users on dark terminals see no change.

Testing

  • go build ./..., go vet ./..., gofmt clean.
  • New internal/config/file_test.go: file/env precedence, malformed-file tolerance, theme normalization.
  • All TUI tests including goldens pass. Verified the palette switches deterministically: dark renders #ffb000, light renders #b25e00, toggled by SetHasDarkBackground.

🤖 Generated with Claude Code

The TUI shipped a single hardcoded, dark-only "Blade Runner amber" theme
that was unreadable on light/white terminal backgrounds. Add a second,
light-optimized scheme while keeping the dark one byte-for-byte unchanged.

- Convert the col* palette to lipgloss.AdaptiveColor{Dark, Light}; Dark
  keeps the original hex, Light is a warm palette tuned for white
  backgrounds. Fold the duplicated inline #1a1305 into colOnAccent /
  colSurface0 so badge text stays legible in both modes.
- Route the resolved dark/light flag (internal/tui/theme.go: SetTheme) to
  the three subsystems that don't read the palette: glamour markdown
  (dark/light standard style), chroma syntax highlighting (dark vs light
  style list), and the spinner color.
- Resolve the scheme once at startup, before Bubble Tea takes the screen,
  and freeze it with lipgloss.SetHasDarkBackground — the "auto" path
  detects the terminal background there to avoid the AltScreen OSC-query
  deadlock documented in markdown.go; dark is the fallback.
- Config: add PRCHECK_THEME (auto|dark|light, default auto) plus an
  optional JSON config file at os.UserConfigDir()/prcheck/config.json,
  parsed with stdlib encoding/json. Env overrides the file; a missing or
  malformed file is non-fatal.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dragonee
dragonee requested a review from KamilSupera as a code owner July 23, 2026 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant