Skip to content

Add light theme support via toml config#3

Open
dimroc wants to merge 3 commits intoaha-app:mainfrom
dimroc:feature/light-theme
Open

Add light theme support via toml config#3
dimroc wants to merge 3 commits intoaha-app:mainfrom
dimroc:feature/light-theme

Conversation

@dimroc
Copy link
Copy Markdown

@dimroc dimroc commented Apr 16, 2026

Before After
Screenshot 2026-04-16 at 12 10 13 PM Screenshot 2026-04-16 at 1 05 38 PM

Why

oit's footer status bar uses dark RGB backgrounds (Color::Rgb(40,40,40) in status_bar.rs, Color::Rgb(30,30,30) in command_input.rs), and the process color palette in process_colors.rs relies on light/bright variants (LightGreen, LightYellow, LightCyan, …). On a light-background terminal these wash out: the footer hint line is illegible and process names blend into the background.

The existing comment in process_colors.rs already calls out the dark-terminal assumption — this PR makes it a real choice instead of a constraint.

What

Introduces a single, simple toml option:

theme = "light"   # or "dark" (default)

Unknown values silently fall back to dark, so existing configs are untouched.

Light palette

Takes color inspiration from gruvbox light. Avoids bright variants, picks darker hues with good contrast on cream/white backgrounds:
Blue, Magenta, Rgb(0,120,0), Rgb(120,80,0), Rgb(0,100,140), Rgb(140,0,140), Rgb(0,100,100), Rgb(160,0,80), Rgb(80,80,140), Rgb(100,60,100)

Implementation

  • New src/ui/theme.rs — a Theme struct holds named tokens (footer bg/fg, muted, accent, selection bg/fg, process palette, fallback) plus Theme::dark(), Theme::light(), and Theme::from_config(Option<&str>).
  • Config — adds theme: Option<String> (skip-serialize-if-none, no migration needed).
  • App — gains theme: Theme, populated from config in main.rs before any color setup.
  • ProcessColors::new — now takes palette: &[Color] and fallback: Color from the active theme instead of a hardcoded module-level palette. Precomputes ANSI start-codes per process and supports 24-bit Color::Rgb and Color::Indexed so the light palette's RGB colors render inline in log lines (the dark palette still maps to standard 16-color ANSI exactly as before).
  • Widget updates: status_bar.rs, command_input.rs, and the three selection blocks in log_viewer.rs read tokens off app.theme instead of hardcoded RGB values. Other Color::DarkGray borders/separators were left alone — they're readable on both backgrounds; we can revisit if needed.

Backwards compatibility

  • Default theme is dark — visually identical to today.
  • The theme field is optional; missing/None → dark. Dark tokens preserve the previous exact RGB values.
  • No snapshot tests were affected (verified — no *.snap.new produced).

Tests

  • cargo test — 487 unit + 562 lib + all integration suites green.
  • New tests:
    • src/config.rstest_theme_loads_from_config, test_theme_defaults_to_none_when_missing
    • src/ui/theme.rsfrom_config parsing (case-insensitive, unknown → dark, None → dark) and light-palette ordering
    • src/ui/process_colors.rstest_light_palette_assignment, test_rgb_color_emits_truecolor_ansi; existing dark-palette tests refactored to pass the palette explicitly

Manual verification

  1. cargo build --release
  2. Add theme = "light" to a project's .overitall.toml, run oit in a light terminal — the [TAIL] footer line and the "Press : for commands…" hint are readable.
  3. Remove the line, restart — dark behavior unchanged.

Docs

  • README.md Configuration Options table updated.
  • man/oit.1 updated.
  • oit --init now generates a .toml with a # theme = "dark" hint

Introduce a `theme = "dark" | "light"` option (default: dark) so the TUI is
readable on light-background terminals. The footer status bar and command
input previously used dark RGB backgrounds, and the process palette relied on
bright variants that wash out on light terminals.

A new `Theme` struct centralizes footer bg/fg, muted/accent text, selection
colors, and the process color palette. `ProcessColors` now takes a palette
plus fallback color from the active theme, and emits 24-bit ANSI for RGB
colors so the light palette renders correctly inline in log lines.
@dimroc dimroc marked this pull request as draft April 16, 2026 19:56
dimroc added 2 commits April 16, 2026 13:11
Footer text was rendering with the terminal default fg because ratatui's
`Paragraph::style()` does not propagate fg to inner `Span::raw(...)`. Apply
`footer_fg` explicitly to every footer span instead.

Replace the light palette with gruvbox-light tones: bg2 footer, fg1 text,
faded accents/success/error/info, and a new process palette built from
gruvbox faded blue/purple/green/orange/aqua/yellow/red/brown for legible
distinct colors on cream backgrounds. Status messages and the
[TAIL]/[SCROLL]/REC indicators now read from theme tokens so they adapt
across themes.

`oit --init` appends a `# theme = "dark"  # or "light"` hint to the
generated `.overitall.toml`, matching the cargo-init convention of
seeding helpful commented defaults.
- Remove unused ThemeMode enum and mode field (only referenced in tests)
- ProcessColors::new takes &Theme instead of palette+fallback pair
- Replace write/read/contains-guard/write dance in init_config with OpenOptions::append
- Bind selection_bg/fg once at top of draw_log_viewer instead of per-line reads
- Drop obvious/narrating comments on theme field, set_theme, init_process_colors
@dimroc dimroc marked this pull request as ready for review April 16, 2026 20:22
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