feat: btop-style height gradient colors for multi-row Activity graphs (#279)
## Summary Multi-row braille history graphs in the local Activity panel (added in PR #277) rendered every terminal row in the same single theme color, so spikes did not visually stand out with height the way btop's height-colored graphs do. This adds a btop-style bottom-to-top color gradient to those graphs: the bottom row keeps the metric's base theme color, and rows above it shift through Yellow toward Red. ## What changed - Added `graph_row_color(row_from_bottom, rows, base) -> Color` in `src/ui/activity_panel.rs`, a pure helper that maps a row's bottom-based position to a color from a 3-anchor palette `[base, GAUGE_MEDIUM_COLOR, GAUGE_HIGH_COLOR]` (Yellow and Red, reused from `src/ui/renderers/widgets/gauges.rs`) via `palette[row_from_bottom * 3 / rows]`, guarding `rows == 0`. - Wired the helper into `multirow_graph_lines` so each row's braille sparkline segment is colored by its bottom-based index; `sparkline_braille_rows` returns rows top-first, so the index is converted before the lookup. Only the sparkline segment changes color; the current-value annotation, axis label, borders, and left margin keep their existing colors. - Both call sites, the CPU graph in `activity_panel.rs` and `draw_gpu_util_graph` in `src/ui/gpu_sparkline_panel.rs`, get the gradient automatically since they both go through `multirow_graph_lines`; no palette logic is duplicated at either call site. Compact 2-per-line rows, single-row sparklines, and the header are untouched. - Updated the `multirow_graph_lines` doc comment to describe the gradient. - Added unit tests for `graph_row_color` covering rows = 1, 2, 3, 4, 6, and 32 (bottom row always base, top row always red once rows >= 3, monotonic band order, `rows == 0` does not panic), plus a rendering test on `multirow_graph_lines` asserting the three rows of a 3-row render carry mutually distinct ANSI SGR escape sequences, with the bottom row carrying the base color's escape and the top row carrying the red escape. ## Test plan - [x] `cargo test --lib ui::activity_panel` (32 passed, including 9 new tests) - [x] `cargo test --lib ui::gpu_sparkline_panel` (28 passed, unmodified) - [x] `cargo check --lib --tests` - [x] `cargo clippy --lib --tests -- -D warnings` - [x] `cargo fmt` Closes #278
J
Jeongkyu Shin committed
cb7e8aa64590c018fb7ec64cd21a6f60e0e2fd85
Parent: a61386e
Committed by GitHub <noreply@github.com>
on 7/20/2026, 2:39:12 AM