Add light theme support via toml config#3
Open
dimroc wants to merge 3 commits intoaha-app:mainfrom
Open
Conversation
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.
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
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.
Why
oit's footer status bar uses dark RGB backgrounds (Color::Rgb(40,40,40)instatus_bar.rs,Color::Rgb(30,30,30)incommand_input.rs), and the process color palette inprocess_colors.rsrelies 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.rsalready calls out the dark-terminal assumption — this PR makes it a real choice instead of a constraint.What
Introduces a single, simple toml option:
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
src/ui/theme.rs— aThemestruct holds named tokens (footer bg/fg, muted, accent, selection bg/fg, process palette, fallback) plusTheme::dark(),Theme::light(), andTheme::from_config(Option<&str>).Config— addstheme: Option<String>(skip-serialize-if-none, no migration needed).App— gainstheme: Theme, populated from config inmain.rsbefore any color setup.ProcessColors::new— now takespalette: &[Color]andfallback: Colorfrom the active theme instead of a hardcoded module-level palette. Precomputes ANSI start-codes per process and supports 24-bitColor::RgbandColor::Indexedso the light palette's RGB colors render inline in log lines (the dark palette still maps to standard 16-color ANSI exactly as before).status_bar.rs,command_input.rs, and the three selection blocks inlog_viewer.rsread tokens offapp.themeinstead of hardcoded RGB values. OtherColor::DarkGrayborders/separators were left alone — they're readable on both backgrounds; we can revisit if needed.Backwards compatibility
dark— visually identical to today.themefield is optional; missing/None → dark. Dark tokens preserve the previous exact RGB values.*.snap.newproduced).Tests
cargo test— 487 unit + 562 lib + all integration suites green.src/config.rs—test_theme_loads_from_config,test_theme_defaults_to_none_when_missingsrc/ui/theme.rs—from_configparsing (case-insensitive, unknown → dark, None → dark) and light-palette orderingsrc/ui/process_colors.rs—test_light_palette_assignment,test_rgb_color_emits_truecolor_ansi; existing dark-palette tests refactored to pass the palette explicitlyManual verification
cargo build --releasetheme = "light"to a project's.overitall.toml, runoitin a light terminal — the[TAIL]footer line and the "Press : for commands…" hint are readable.Docs
README.mdConfiguration Options table updated.man/oit.1updated.oit --initnow generates a .toml with a # theme = "dark" hint