From f2aafb63a61d0c795e2698aa6ade09abd2baa53a Mon Sep 17 00:00:00 2001 From: Jussi Elo Date: Wed, 4 Nov 2026 09:09:19 +0000 Subject: [PATCH 1/4] ROCMAI-853: delete the dead instances card grid and the heatmap module The Instances Observe tab has drawn its per-instance table (`draw_table`) since the five-tab redesign; the older full-screen card grid (`draw`, `draw_card`, `draw_card_grid`, `compact_line`, the kv-cache heatmap block and its layout helpers, and the card `hit_test`) has had no production caller since then. Nothing outside tests reached it: `draw` was only imported by a test module in `instance_detail.rs`, `hit_test` is not wired in the mouse handling (which routes only the Rocm and Serving tabs), and `ui::heatmap` was used only by the grid's kv-cache block. Removes from `ui/tabs/instances.rs`: `draw`, `compute_heatmap_height`, `draw_card_grid`, `draw_kv_heatmap`, `label_width_for`, `build_kv_heatmap_rows`, `pick_cols`, `status_role`, `draw_card`, `compact_line`, `hit_test` and `point_in_rect`, with the tests that only exercised them. Removes the `ui/heatmap.rs` module (`Heatmap`, `HeatmapRow`, `truncate_to`) and its declaration. The tests that also cover live code stay: the empty-state test now renders through `draw_table`, which shares `draw_empty` with the old entry point, and the instance-detail VRAM test keeps its detail-modal half, since `draw_detail` renders the same used/total string. `draw_table`, `draw_empty`, `sorted_instances`, `clamp_sel`, `status_meta` and the shared test fixtures are unchanged. Signed-off-by: Jussi Elo --- crates/rocm-dash-tui/src/ui/heatmap.rs | 346 ---------- .../rocm-dash-tui/src/ui/instance_detail.rs | 11 - crates/rocm-dash-tui/src/ui/mod.rs | 1 - crates/rocm-dash-tui/src/ui/tabs/instances.rs | 592 +----------------- 4 files changed, 8 insertions(+), 942 deletions(-) delete mode 100644 crates/rocm-dash-tui/src/ui/heatmap.rs diff --git a/crates/rocm-dash-tui/src/ui/heatmap.rs b/crates/rocm-dash-tui/src/ui/heatmap.rs deleted file mode 100644 index 973895e467..0000000000 --- a/crates/rocm-dash-tui/src/ui/heatmap.rs +++ /dev/null @@ -1,346 +0,0 @@ -// Copyright © Advanced Micro Devices, Inc., or its affiliates. -// -// SPDX-License-Identifier: MIT - -//! 2-D heatmap widget. -//! -//! Each row is a series of `f64` values. Each cell renders as a single -//! character whose background color is interpolated across the gradient -//! stops by `value / row_max`. Optional left labels are rendered in the -//! widget's `label_style`. When the matrix is wider than the area, the -//! widget right-aligns (drops the oldest columns) — the most-recent -//! samples are always visible, which matches how the rest of the dashboard -//! presents history. -//! -//! Designed for "metric × time" matrices: per-GPU detail (util/temp/power/ -//! vram% × time), per-instance kv-cache × time, etc. - -use ratatui::buffer::Buffer; -use ratatui::layout::Rect; -use ratatui::style::{Color, Style}; -use ratatui::widgets::Widget; - -use crate::ui::gradient::lerp3_t; - -#[derive(Debug, Clone)] -pub struct HeatmapRow { - pub label: String, - pub data: Vec, - /// Per-row max for normalization. If zero or negative, the cell renders - /// as `track_bg`. - pub max: f64, - /// Optional per-row gradient override. Falls back to the widget-level - /// `stops` when None. - pub stops: Option<[Color; 3]>, -} - -impl HeatmapRow { - pub fn new(label: impl Into, data: Vec, max: f64) -> Self { - Self { - label: label.into(), - data, - max, - stops: None, - } - } - - #[must_use] - pub const fn stops(mut self, start: Color, mid: Color, end: Color) -> Self { - self.stops = Some([start, mid, end]); - self - } -} - -pub struct Heatmap<'a> { - rows: &'a [HeatmapRow], - stops: [Color; 3], - track_bg: Color, - label_style: Style, - label_width: u16, -} - -impl<'a> Heatmap<'a> { - pub fn new(rows: &'a [HeatmapRow]) -> Self { - // Pick a sensible default label width: longest label + 1 padding, - // capped at 12. Callers can override with `label_width`. - let default_label_w = rows - .iter() - .map(|r| r.label.chars().count() as u16) - .max() - .unwrap_or(0) - .saturating_add(1) - .min(12); - Self { - rows, - stops: [ - Color::Rgb(0x1a, 0xa0, 0x1a), - Color::Rgb(0xf5, 0x9e, 0x0b), - Color::Rgb(0xed, 0x1c, 0x24), - ], - track_bg: Color::Reset, - label_style: Style::default(), - label_width: default_label_w, - } - } - - #[must_use] - pub const fn stops(mut self, start: Color, mid: Color, end: Color) -> Self { - self.stops = [start, mid, end]; - self - } - - #[must_use] - pub const fn track_bg(mut self, c: Color) -> Self { - self.track_bg = c; - self - } - - #[must_use] - pub const fn label_style(mut self, s: Style) -> Self { - self.label_style = s; - self - } - - #[must_use] - pub const fn label_width(mut self, w: u16) -> Self { - self.label_width = w; - self - } -} - -impl Widget for Heatmap<'_> { - fn render(self, area: Rect, buf: &mut Buffer) { - if area.width == 0 || area.height == 0 || self.rows.is_empty() { - return; - } - let label_w = self.label_width.min(area.width); - let data_w = area.width.saturating_sub(label_w); - if data_w == 0 { - // No room for cells — just render labels. - for (i, row) in self.rows.iter().enumerate() { - if i as u16 >= area.height { - break; - } - let y = area.y + i as u16; - let truncated = truncate_to(&row.label, label_w as usize); - buf.set_string(area.x, y, &truncated, self.label_style); - } - return; - } - - for (i, row) in self.rows.iter().enumerate() { - if i as u16 >= area.height { - break; - } - let y = area.y + i as u16; - - // Label. - if label_w > 0 { - let truncated = truncate_to(&row.label, label_w as usize); - buf.set_string(area.x, y, &truncated, self.label_style); - } - - // Right-align data: drop oldest columns when wider than `data_w`. - let data_len = row.data.len(); - let visible = data_w as usize; - let start = data_len.saturating_sub(visible); - let slice = &row.data[start..]; - let row_stops = row.stops.unwrap_or(self.stops); - - for (cx, v) in slice.iter().enumerate() { - let x = area.x + label_w + cx as u16; - let bg = if row.max > 0.0 && *v > 0.0 { - let t = (*v / row.max).clamp(0.0, 1.0); - lerp3_t(row_stops, t) - } else { - self.track_bg - }; - if let Some(cell) = buf.cell_mut((x, y)) { - cell.set_char(' '); - cell.set_style(Style::default().bg(bg)); - } - } - // Pad any leftover data area with track_bg so previous frames - // don't bleed through when a row has fewer samples than width. - let painted = slice.len() as u16; - for cx in painted..data_w { - let x = area.x + label_w + cx; - if let Some(cell) = buf.cell_mut((x, y)) { - cell.set_char(' '); - cell.set_style(Style::default().bg(self.track_bg)); - } - } - } - } -} - -fn truncate_to(s: &str, max: usize) -> String { - if s.chars().count() <= max { - format!("{s:, max: f64) -> HeatmapRow { - HeatmapRow::new(label, data, max) - } - - #[test] - fn empty_rows_render_nothing() { - let rows: Vec = Vec::new(); - let mut buf = Buffer::empty(Rect::new(0, 0, 10, 3)); - Heatmap::new(&rows).render(buf.area, &mut buf); - // No panic, no styled cells. - for y in 0..3 { - for x in 0..10 { - let cell = buf.cell((x, y)).unwrap(); - assert!(matches!(cell.style().bg, Some(Color::Reset) | None)); - } - } - } - - #[test] - fn default_label_width_is_longest_plus_one_capped() { - let rows = vec![ - row("util", vec![1.0], 100.0), - row("temperature", vec![1.0], 100.0), - row("pwr", vec![1.0], 100.0), - ]; - let h = Heatmap::new(&rows); - // "temperature" is 11 chars; +1 = 12, cap = 12. - assert_eq!(h.label_width, 12); - } - - #[test] - fn cells_use_per_row_gradient_when_set() { - let row_red_only = row("a", vec![50.0], 100.0).stops( - Color::Rgb(255, 0, 0), - Color::Rgb(255, 0, 0), - Color::Rgb(255, 0, 0), - ); - let rows = vec![row_red_only]; - let mut buf = Buffer::empty(Rect::new(0, 0, 5, 1)); - Heatmap::new(&rows) - .label_width(2) - .render(buf.area, &mut buf); - // x = 2 (after label_w=2) is the first data cell. - let cell = buf.cell((2, 0)).unwrap(); - assert_eq!(cell.style().bg, Some(Color::Rgb(255, 0, 0))); - } - - #[test] - fn zero_max_or_zero_value_paints_track_bg() { - let rows = vec![row("a", vec![0.0, 50.0], 0.0)]; - let track = Color::Rgb(20, 20, 20); - let mut buf = Buffer::empty(Rect::new(0, 0, 4, 1)); - Heatmap::new(&rows) - .label_width(2) - .track_bg(track) - .render(buf.area, &mut buf); - // Both cells should be track_bg because row.max == 0. - assert_eq!(buf.cell((2, 0)).unwrap().style().bg, Some(track)); - assert_eq!(buf.cell((3, 0)).unwrap().style().bg, Some(track)); - } - - #[test] - fn right_aligns_when_data_wider_than_area() { - // Width 5 = label(2) + data(3). 5 samples → keeps the last 3. - let mut rows = vec![row("a", vec![10.0, 20.0, 30.0, 40.0, 50.0], 50.0)]; - rows[0] = rows[0].clone().stops( - Color::Rgb(0, 0, 100), - Color::Rgb(0, 100, 0), - Color::Rgb(100, 0, 0), - ); - let mut buf = Buffer::empty(Rect::new(0, 0, 5, 1)); - Heatmap::new(&rows) - .label_width(2) - .render(buf.area, &mut buf); - // The leftmost data cell should reflect value 30 (the 3rd-newest). - let cell30 = buf.cell((2, 0)).unwrap(); - let cell40 = buf.cell((3, 0)).unwrap(); - let cell50 = buf.cell((4, 0)).unwrap(); - // 30/50 = 0.6 → past midpoint, mid→end interp; 50/50 = 1.0 → end stop. - assert_eq!(cell50.style().bg, Some(Color::Rgb(100, 0, 0))); - // 40/50 = 0.8 → mid→end at t=0.6. - assert!(matches!(cell40.style().bg, Some(Color::Rgb(_, _, _)))); - // 30/50 = 0.6 → mid→end at t=0.2 → mostly green-ish. - assert!(matches!(cell30.style().bg, Some(Color::Rgb(_, _, _)))); - } - - #[test] - fn truncates_label_when_too_long() { - let rows = vec![row("temperature", vec![50.0], 100.0)]; - let mut buf = Buffer::empty(Rect::new(0, 0, 10, 1)); - Heatmap::new(&rows) - .label_width(4) - .render(buf.area, &mut buf); - let s: String = (0..4) - .map(|x| { - buf.cell((x, 0)) - .unwrap() - .symbol() - .chars() - .next() - .unwrap_or(' ') - }) - .collect(); - assert_eq!(s, "temp"); - } - - #[test] - fn rows_beyond_height_are_dropped() { - let rows = vec![ - row("a", vec![50.0], 100.0), - row("b", vec![50.0], 100.0), - row("c", vec![50.0], 100.0), - ]; - let mut buf = Buffer::empty(Rect::new(0, 0, 4, 2)); - Heatmap::new(&rows) - .label_width(2) - .render(buf.area, &mut buf); - // Row 2 ("c") wasn't rendered — y=2 doesn't exist in a 2-row area, - // but more importantly the widget didn't panic. - assert_eq!(buf.area.height, 2); - } - - #[test] - fn renders_label_only_when_no_room_for_cells() { - let rows = vec![row("a", vec![50.0], 100.0)]; - let mut buf = Buffer::empty(Rect::new(0, 0, 2, 1)); - Heatmap::new(&rows) - .label_width(4) - .render(buf.area, &mut buf); - // label_w(4) > area.width(2) → clamped to area.width, no data cells. - // No assertion on the data — but make sure the label glyph appears at x=0. - let first = buf - .cell((0, 0)) - .unwrap() - .symbol() - .chars() - .next() - .unwrap_or(' '); - assert_eq!(first, 'a'); - } - - #[test] - fn label_style_is_applied() { - use ratatui::style::Modifier; - let rows = vec![row("a", vec![10.0], 100.0)]; - let mut buf = Buffer::empty(Rect::new(0, 0, 5, 1)); - let style = Style::default() - .fg(Color::Rgb(123, 45, 67)) - .add_modifier(Modifier::BOLD); - Heatmap::new(&rows) - .label_width(2) - .label_style(style) - .render(buf.area, &mut buf); - let cell_style = buf.cell((0, 0)).unwrap().style(); - assert_eq!(cell_style.fg, Some(Color::Rgb(123, 45, 67))); - assert!(cell_style.add_modifier.contains(Modifier::BOLD)); - } -} diff --git a/crates/rocm-dash-tui/src/ui/instance_detail.rs b/crates/rocm-dash-tui/src/ui/instance_detail.rs index 46c1bb06cf..863d9a34e2 100644 --- a/crates/rocm-dash-tui/src/ui/instance_detail.rs +++ b/crates/rocm-dash-tui/src/ui/instance_detail.rs @@ -383,7 +383,6 @@ fn render_footer(f: &mut Frame, area: Rect, inst: &Instance, theme: &Theme, scro #[cfg(test)] mod tests { use super::*; - use crate::ui::tabs::instances::draw; use crate::ui::tabs::instances::tests::{ buffer_text, mk_inst, mk_inst_obs, mk_state, obs, state_with_snap, }; @@ -407,16 +406,6 @@ mod tests { m.insert(inst.container_id.clone(), inst); let state = mk_state(m, 0); - // Card grid: the VRAM line fires only because vram_total_mb > 0. - let mut term = Terminal::new(TestBackend::new(160, 48)).unwrap(); - term.draw(|f| draw(f, f.area(), &state, &state.theme)) - .unwrap(); - let grid = buffer_text(&term); - assert!( - grid.contains(&vram), - "card grid must render the used / total MiB VRAM string; got:\n{grid}" - ); - // Detail modal: shows the quantization value and the VRAM pair. let mut term = Terminal::new(TestBackend::new(160, 48)).unwrap(); term.draw(|f| { diff --git a/crates/rocm-dash-tui/src/ui/mod.rs b/crates/rocm-dash-tui/src/ui/mod.rs index 3bfdaa5c16..8604392cc3 100644 --- a/crates/rocm-dash-tui/src/ui/mod.rs +++ b/crates/rocm-dash-tui/src/ui/mod.rs @@ -18,7 +18,6 @@ mod footer; pub mod format; pub mod gradient; mod header; -pub mod heatmap; mod help_modal; pub mod install_manager; mod instance_detail; diff --git a/crates/rocm-dash-tui/src/ui/tabs/instances.rs b/crates/rocm-dash-tui/src/ui/tabs/instances.rs index 3b5d8a1b7f..d549767119 100644 --- a/crates/rocm-dash-tui/src/ui/tabs/instances.rs +++ b/crates/rocm-dash-tui/src/ui/tabs/instances.rs @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: MIT -//! Instances Observe sub-panel — full-screen instance grid with kv-cache / requests / args. -//! The detail modal (model / partition / launch_args / env / log) lives in +//! Instances Observe sub-panel — the per-instance metrics table. The detail +//! modal (model / partition / launch_args / env / log) lives in //! `ui/instance_detail.rs`. use ratatui::Frame; @@ -14,43 +14,12 @@ use ratatui::widgets::{Cell, Paragraph, Row, Table}; use rocm_dash_core::metrics::{Instance, InstanceStatus, ObservationFreshness}; -use crate::app::{AppState, ConnState, KeyAction}; +use crate::app::{AppState, ConnState}; use crate::ui::format; use crate::ui::panel::{self, BoxRole}; -use crate::ui::theme::{Theme, instance_status_tone}; +use crate::ui::theme::Theme; use crate::ui::widgets::trunc; -pub fn draw(f: &mut Frame, area: Rect, state: &AppState, theme: &Theme) { - if state.instances.is_empty() { - draw_empty(f, area, state, theme); - return; - } - - let instances = sorted_instances(&state.instances); - let sel = clamp_sel(state.instance_sel, instances.len()); - - // When we have ≥2 instances AND ≥3 snapshots in history, surface a - // kv-cache × time heatmap above the card grid. Single-instance / cold- - // start cases skip the heatmap so we don't waste rows on something - // tautological. - let show_heatmap = instances.len() >= 2 && state.history.len() >= 3; - let (heatmap_area, grid_area) = if show_heatmap { - let heatmap_rows = compute_heatmap_height(instances.len(), area.height); - let split = Layout::default() - .direction(Direction::Vertical) - .constraints([Constraint::Length(heatmap_rows), Constraint::Min(0)]) - .split(area); - (Some(split[0]), split[1]) - } else { - (None, area) - }; - - if let Some(heat_area) = heatmap_area { - draw_kv_heatmap(f, heat_area, state, &instances, theme); - } - draw_card_grid(f, grid_area, &instances, sel, theme); -} - /// AI-serving per-instance table (Phase 5 Observe view). /// /// Columns: model · throughput (tok/s) · tok/watt · TTFT · TPOT · power · queue @@ -205,137 +174,8 @@ pub fn draw_table(f: &mut Frame, area: Rect, state: &AppState, theme: &Theme) { } } -/// How tall to make the heatmap block. -/// Each row of the table = one instance; +2 for borders + 1 for footer hint. -fn compute_heatmap_height(n_instances: usize, total_height: u16) -> u16 { - // Cap at total/2 so the card grid still gets meaningful space. - let max = (total_height / 2).max(5); - (n_instances as u16 + 3).min(max).max(5) -} - -fn draw_card_grid(f: &mut Frame, area: Rect, instances: &[&Instance], sel: usize, theme: &Theme) { - let cols = pick_cols(area.width); - let rows = instances.len().div_ceil(cols); - if rows == 0 { - return; - } - let row_constraints: Vec = (0..rows) - .map(|_| Constraint::Ratio(1, rows as u32)) - .collect(); - let row_slots = Layout::default() - .direction(Direction::Vertical) - .constraints(row_constraints) - .split(area); - - for (row_idx, row_slot) in row_slots.iter().enumerate() { - let col_constraints: Vec = (0..cols) - .map(|_| Constraint::Ratio(1, cols as u32)) - .collect(); - let col_slots = Layout::default() - .direction(Direction::Horizontal) - .constraints(col_constraints) - .split(*row_slot); - for (col_idx, cell) in col_slots.iter().enumerate() { - let idx = row_idx * cols + col_idx; - if let Some(inst) = instances.get(idx) { - draw_card(f, *cell, inst, theme, idx == sel); - } - } - } -} - -fn draw_kv_heatmap( - f: &mut Frame, - area: Rect, - state: &AppState, - instances: &[&Instance], - theme: &Theme, -) { - use crate::ui::heatmap::Heatmap; - - let title = format!( - "kv-cache % · {} instances · last {} ticks", - instances.len(), - state.history.len(), - ); - let inner = panel::bento(f, area, Some(&title), BoxRole::Secondary, false, theme); - if inner.height == 0 { - return; - } - - let rows = build_kv_heatmap_rows(&state.history, instances); - if rows.is_empty() { - f.render_widget( - Paragraph::new(Line::from(Span::styled( - "no kv-cache samples yet — start a vLLM container and wait a tick", - Style::default().fg(theme.muted), - ))), - inner, - ); - return; - } - - let heat = Heatmap::new(&rows) - .stops(theme.ok, theme.warn, theme.err) - .track_bg(theme.surface_2) - .label_style(Style::default().fg(theme.muted)) - .label_width(label_width_for(instances)); - f.render_widget(heat, inner); -} - -/// Width budget for instance labels in the heatmap, capped so the data -/// region stays usable on narrow terminals. -fn label_width_for(instances: &[&Instance]) -> u16 { - instances - .iter() - .map(|i| i.container_name.chars().count() as u16) - .max() - .unwrap_or(0) - .saturating_add(1) - .clamp(8, 20) -} - -/// Build one heatmap row per instance: kv-cache % over each snapshot in -/// history. Instances missing from a given snapshot contribute 0 at that -/// column (renders as `track_bg` because of the zero-value guard). -/// Pure — exposed for tests. -pub(crate) fn build_kv_heatmap_rows( - history: &std::collections::VecDeque, - instances: &[&Instance], -) -> Vec { - use crate::ui::heatmap::HeatmapRow; - - let mut out = Vec::with_capacity(instances.len()); - for inst in instances { - let id = &inst.container_id; - let label = inst.container_name.clone(); - let data: Vec = history - .iter() - .map(|snap| { - snap.instances - .iter() - .find(|i| &i.container_id == id) - .and_then(|i| i.kv_cache_usage_pct.map(f64::from)) - .unwrap_or(0.0) - }) - .collect(); - out.push(HeatmapRow::new(label, data, 100.0)); - } - out -} - -const fn pick_cols(width: u16) -> usize { - if width >= 160 { - 3 - } else if width >= 100 { - 2 - } else { - 1 - } -} - /// Sort instances deterministically by container_name so that an index from -/// AppState always maps to the same card in the grid. +/// AppState always maps to the same row in the table. pub(in crate::ui) fn sorted_instances( instances: &std::collections::HashMap, ) -> Vec<&Instance> { @@ -359,12 +199,6 @@ pub(in crate::ui) const fn status_meta( (theme.instance_status_color(status), status.label()) } -/// Map an instance status to a bento box role so unselected cards take a -/// health-driven border color. -const fn status_role(status: InstanceStatus) -> BoxRole { - BoxRole::from_tone(instance_status_tone(status)) -} - fn draw_empty(f: &mut Frame, area: Rect, state: &AppState, theme: &Theme) { let body = if state.conn.is_in_process() { "no instance registry on this platform · vLLM containers aren't available here" @@ -384,232 +218,6 @@ fn draw_empty(f: &mut Frame, area: Rect, state: &AppState, theme: &Theme) { f.render_widget(p, inner); } -fn draw_card(f: &mut Frame, area: Rect, inst: &Instance, theme: &Theme, selected: bool) { - let (_, status_text) = status_meta(inst.status, theme); - let name = trunc(&inst.container_name, 24); - let title = format!("{name} · {status_text}"); - - // Selected card reads as the primary/actionable surface; others take a - // status-driven role so the grid varies by health. - let role = if selected { - BoxRole::Primary - } else { - status_role(inst.status) - }; - - let inner = panel::bento(f, area, Some(&title), role, false, theme); - if inner.height == 0 || inner.width == 0 { - return; - } - - let inner_w = inner.width as usize; - - // Too short -> compact one-liner. Highlight still flows through the border. - if inner.height < 5 { - let line = compact_line(inst, theme, inner_w); - f.render_widget(Paragraph::new(line), inner); - return; - } - - let port_str = inst.port.map_or_else(|| "-".into(), |p| p.to_string()); - let gpus_str = if inst.gpu_ids.is_empty() { - "-".to_string() - } else if inst.gpu_ids.len() == 1 { - inst.gpu_ids[0].clone() - } else { - inst.gpu_ids.join(",") - }; - - let kv = format::pct_opt(inst.kv_cache_usage_pct); - let run = format::reqs_opt(inst.running_reqs); - let wait = format::reqs_opt(inst.waiting_reqs); - - let mut lines: Vec = Vec::with_capacity(8); - - // 1. model - lines.push(Line::from(vec![ - Span::styled("model ", Style::default().fg(theme.muted)), - Span::styled( - trunc(&inst.model_name, inner_w.saturating_sub(6).max(1)), - Style::default().fg(theme.fg), - ), - ])); - - // 2. port · tp · gpus - lines.push(Line::from(vec![ - Span::styled(format!("port {port_str}"), Style::default().fg(theme.fg)), - Span::styled(" · ", Style::default().fg(theme.muted)), - Span::styled( - format!("tp {}", inst.tensor_parallel_size), - Style::default().fg(theme.fg), - ), - Span::styled(" · ", Style::default().fg(theme.muted)), - Span::styled( - format!("gpus {}", trunc(&gpus_str, 20)), - Style::default().fg(theme.accent), - ), - ])); - - // 3. kv_cache / run / wait - lines.push(Line::from(vec![ - Span::styled("kv_cache ", Style::default().fg(theme.muted)), - Span::styled(kv, Style::default().fg(theme.fg)), - Span::styled(" · run ", Style::default().fg(theme.muted)), - Span::styled(run, Style::default().fg(theme.fg)), - Span::styled(" · wait ", Style::default().fg(theme.muted)), - Span::styled(wait, Style::default().fg(theme.fg)), - ])); - - // 4. efficiency: tok/W · gen throughput - lines.push(Line::from(vec![ - Span::styled("tok/W ", Style::default().fg(theme.muted)), - Span::styled( - format::tokens_per_watt_cell(inst.tokens_per_watt, inst.gen_tps_observation.as_ref()), - Style::default().fg(theme.accent), - ), - Span::styled(" · gen ", Style::default().fg(theme.muted)), - Span::styled( - format::gen_tps_compact(inst.gen_tps, inst.gen_tps_observation.as_ref()), - Style::default().fg(theme.fg), - ), - ])); - - // 5. vram (only if total > 0) - if inst.vram_total_mb > 0 { - lines.push(Line::from(vec![ - Span::styled("vram ", Style::default().fg(theme.muted)), - Span::styled( - format::mib_pair(inst.vram_used_mb, inst.vram_total_mb), - Style::default().fg(theme.fg), - ), - ])); - } - - // 5. args - let args_joined = inst - .launch_args - .iter() - .take(4) - .cloned() - .collect::>() - .join(" "); - let args_display = if args_joined.is_empty() { - "(none)".to_string() - } else { - trunc(&args_joined, inner_w.saturating_sub(6).max(1)) - }; - lines.push(Line::from(vec![ - Span::styled("args: ", Style::default().fg(theme.muted)), - Span::styled(args_display, Style::default().fg(theme.muted)), - ])); - - // 6. env count - lines.push(Line::from(vec![ - Span::styled("env: ", Style::default().fg(theme.muted)), - Span::styled( - format!("{} vars", inst.env_vars.len()), - Style::default().fg(theme.muted), - ), - ])); - - // 7. log file (optional) - if let Some(log) = inst.log_file.as_deref() { - lines.push(Line::from(vec![ - Span::styled("log: ", Style::default().fg(theme.muted)), - Span::styled( - trunc(log, inner_w.saturating_sub(5).max(1)), - Style::default().fg(theme.muted), - ), - ])); - } - - f.render_widget(Paragraph::new(lines), inner); -} - -fn compact_line<'a>(inst: &'a Instance, theme: &Theme, max_w: usize) -> Line<'a> { - let (status_color, _) = status_meta(inst.status, theme); - let port = inst.port.map_or_else(|| "-".into(), |p| p.to_string()); - let gpus = if inst.gpu_ids.is_empty() { - "-".to_string() - } else { - inst.gpu_ids.join(",") - }; - let raw = format!( - "{} · {} · :{} · tp{} · gpus {}", - inst.container_name, inst.model_name, port, inst.tensor_parallel_size, gpus - ); - Line::from(Span::styled( - trunc(&raw, max_w), - Style::default().fg(status_color), - )) -} - -/// Detail modal: summary + launch_args + env_vars + log footer. -/// -/// Resolve a click at `(x, y)` inside the Instances Observe sub-panel body. Returns a -/// `KeyAction` to dispatch, or `None` when the click misses everything -/// actionable. -/// -/// Re-runs the same Layout split as `draw` so card rects line up exactly with -/// what the user sees. Clicking the already-selected card opens the detail -/// modal (acts as a double-click affordance); clicking any other card moves -/// the selection cursor by the delta to that card. -pub fn hit_test(area: Rect, x: u16, y: u16, state: &AppState) -> Option { - if state.instances.is_empty() { - return None; - } - if x < area.x || x >= area.x + area.width || y < area.y || y >= area.y + area.height { - return None; - } - - let instances = sorted_instances(&state.instances); - let cols = pick_cols(area.width); - let rows = instances.len().div_ceil(cols); - if rows == 0 || cols == 0 { - return None; - } - - let sel = clamp_sel(state.instance_sel, instances.len()); - - let row_constraints: Vec = (0..rows) - .map(|_| Constraint::Ratio(1, rows as u32)) - .collect(); - let row_slots = Layout::default() - .direction(Direction::Vertical) - .constraints(row_constraints) - .split(area); - - for (row_idx, row_slot) in row_slots.iter().enumerate() { - let col_constraints: Vec = (0..cols) - .map(|_| Constraint::Ratio(1, cols as u32)) - .collect(); - let col_slots = Layout::default() - .direction(Direction::Horizontal) - .constraints(col_constraints) - .split(*row_slot); - for (col_idx, cell) in col_slots.iter().enumerate() { - let idx = row_idx * cols + col_idx; - if idx >= instances.len() { - continue; - } - if point_in_rect(*cell, x, y) { - if idx == sel { - return Some(KeyAction::OpenDetail); - } - let delta = idx.cast_signed() - sel.cast_signed(); - return Some(KeyAction::Move(delta)); - } - } - } - None -} - -/// Pure point-in-rect check using half-open coordinates (right/bottom edges -/// are exclusive), matching ratatui's own rect semantics. -const fn point_in_rect(r: Rect, x: u16, y: u16) -> bool { - x >= r.x && x < r.x + r.width && y >= r.y && y < r.y + r.height -} - #[cfg(test)] pub(in crate::ui) mod tests { use super::*; @@ -665,7 +273,7 @@ pub(in crate::ui) mod tests { version: ConnState::in_process_version("0.0.0"), }; let mut term = Terminal::new(TestBackend::new(80, 20)).unwrap(); - term.draw(|f| draw(f, f.area(), &state, &state.theme)) + term.draw(|f| draw_table(f, f.area(), &state, &state.theme)) .unwrap(); let grid = buffer_text(&term); assert!( @@ -678,16 +286,6 @@ pub(in crate::ui) mod tests { ); } - #[test] - fn pick_cols_scales_with_width() { - assert_eq!(pick_cols(60), 1); - assert_eq!(pick_cols(99), 1); - assert_eq!(pick_cols(100), 2); - assert_eq!(pick_cols(159), 2); - assert_eq!(pick_cols(160), 3); - assert_eq!(pick_cols(300), 3); - } - #[test] fn status_meta_maps_each_variant() { let theme = Theme::default_dark(); @@ -746,19 +344,6 @@ pub(in crate::ui) mod tests { assert_eq!(v[sel].container_name, "zeta"); } - #[test] - fn point_in_rect_uses_half_open_semantics() { - let r = Rect::new(10, 5, 4, 3); - assert!(point_in_rect(r, 10, 5)); - assert!(point_in_rect(r, 13, 7)); - // Right and bottom edges are exclusive. - assert!(!point_in_rect(r, 14, 5)); - assert!(!point_in_rect(r, 10, 8)); - // Outside. - assert!(!point_in_rect(r, 9, 5)); - assert!(!point_in_rect(r, 10, 4)); - } - pub(in crate::ui) fn mk_state(instances: HashMap, sel: usize) -> AppState { AppState { services_past_attempts: 0, @@ -850,167 +435,6 @@ pub(in crate::ui) mod tests { } } - fn mk_state_with(names: &[&str], sel: usize) -> AppState { - mk_state(map_with(names), sel) - } - - #[test] - fn hit_test_returns_none_when_empty() { - let s = mk_state(HashMap::new(), 0); - let area = Rect::new(0, 0, 80, 20); - assert_eq!(hit_test(area, 5, 5, &s), None); - } - - #[test] - fn hit_test_returns_none_when_outside_area() { - let s = mk_state_with(&["a", "b"], 0); - let area = Rect::new(10, 5, 80, 20); - // Above area. - assert_eq!(hit_test(area, 50, 4, &s), None); - // Left of area. - assert_eq!(hit_test(area, 9, 10, &s), None); - // Right edge exclusive. - assert_eq!(hit_test(area, 90, 10, &s), None); - // Bottom edge exclusive. - assert_eq!(hit_test(area, 50, 25, &s), None); - } - - #[test] - fn hit_test_on_selected_card_opens_detail() { - // Narrow width forces 1 col; two cards stack vertically. - // sel = 0 → click the first (top) card. - let s = mk_state_with(&["alpha", "bravo"], 0); - let area = Rect::new(0, 0, 60, 20); // width 60 → cols=1, rows=2 - let action = hit_test(area, 10, 2, &s); - assert_eq!(action, Some(KeyAction::OpenDetail)); - } - - #[test] - fn hit_test_on_other_card_returns_move_with_delta() { - // Two cards stacked vertically; sel=0 → clicking bottom card moves +1. - let s = mk_state_with(&["alpha", "bravo"], 0); - let area = Rect::new(0, 0, 60, 20); // cols=1, rows=2 → each row ~10 tall - let action = hit_test(area, 10, 15, &s); - assert_eq!(action, Some(KeyAction::Move(1))); - } - - #[test] - fn hit_test_returns_negative_delta_when_clicking_earlier_card() { - // sel=1 (bravo) → clicking alpha at top yields delta -1. - let s = mk_state_with(&["alpha", "bravo"], 1); - let area = Rect::new(0, 0, 60, 20); - let action = hit_test(area, 10, 2, &s); - assert_eq!(action, Some(KeyAction::Move(-1))); - } - - #[test] - fn hit_test_grid_layout_2_cols_picks_correct_card() { - // width 120 → cols=2; 4 instances → rows=2. - let s = mk_state_with(&["a", "b", "c", "d"], 0); - let area = Rect::new(0, 0, 120, 20); - // Top-right card is index 1 → delta +1 from sel=0. - let action = hit_test(area, 90, 2, &s); - assert_eq!(action, Some(KeyAction::Move(1))); - // Bottom-left card is index 2 → delta +2. - let action = hit_test(area, 10, 15, &s); - assert_eq!(action, Some(KeyAction::Move(2))); - // Bottom-right card is index 3 → delta +3. - let action = hit_test(area, 90, 15, &s); - assert_eq!(action, Some(KeyAction::Move(3))); - } - - fn mk_inst_kv(id: &str, name: &str, kv: Option) -> Instance { - Instance { - container_id: id.into(), - container_name: name.into(), - kv_cache_usage_pct: kv, - ..Default::default() - } - } - - fn mk_snap(insts: Vec) -> rocm_dash_core::metrics::Snapshot { - rocm_dash_core::metrics::Snapshot { - instances: insts, - ..Default::default() - } - } - - #[test] - #[allow(clippy::float_cmp)] - fn heatmap_rows_track_kv_cache_per_snapshot() { - let i_a = mk_inst_kv("a", "alpha", Some(10.0)); - let i_b = mk_inst_kv("b", "beta", Some(20.0)); - let history: std::collections::VecDeque<_> = vec![ - mk_snap(vec![ - mk_inst_kv("a", "alpha", Some(5.0)), - mk_inst_kv("b", "beta", Some(15.0)), - ]), - mk_snap(vec![ - mk_inst_kv("a", "alpha", Some(50.0)), - mk_inst_kv("b", "beta", Some(80.0)), - ]), - ] - .into_iter() - .collect(); - let live = vec![&i_a, &i_b]; - let rows = build_kv_heatmap_rows(&history, &live); - assert_eq!(rows.len(), 2); - assert_eq!(rows[0].label, "alpha"); - assert_eq!(rows[0].data, vec![5.0, 50.0]); - assert_eq!(rows[1].label, "beta"); - assert_eq!(rows[1].data, vec![15.0, 80.0]); - // Max is fixed at 100 — kv-cache is already a percentage. - assert_eq!(rows[0].max, 100.0); - } - - #[test] - fn heatmap_row_missing_instance_in_snap_yields_zero() { - // Instance b only existed in the second snapshot. - let i_a = mk_inst_kv("a", "alpha", Some(0.0)); - let i_b = mk_inst_kv("b", "beta", Some(0.0)); - let history: std::collections::VecDeque<_> = vec![ - mk_snap(vec![mk_inst_kv("a", "alpha", Some(10.0))]), - mk_snap(vec![ - mk_inst_kv("a", "alpha", Some(20.0)), - mk_inst_kv("b", "beta", Some(30.0)), - ]), - ] - .into_iter() - .collect(); - let live = vec![&i_a, &i_b]; - let rows = build_kv_heatmap_rows(&history, &live); - assert_eq!(rows[0].data, vec![10.0, 20.0]); - // b is missing from snap[0] → 0.0 padding. - assert_eq!(rows[1].data, vec![0.0, 30.0]); - } - - #[test] - fn heatmap_row_none_kv_cache_yields_zero() { - let i_a = mk_inst_kv("a", "alpha", None); - let history: std::collections::VecDeque<_> = - vec![mk_snap(vec![mk_inst_kv("a", "alpha", None)])] - .into_iter() - .collect(); - let live = vec![&i_a]; - let rows = build_kv_heatmap_rows(&history, &live); - assert_eq!(rows[0].data, vec![0.0]); - } - - #[test] - fn label_width_caps_to_useful_range() { - let short_id = mk_inst_kv("a", "x", None); - let long_id = mk_inst_kv("b", "this-is-a-very-long-container-name", None); - assert_eq!(label_width_for(&[&short_id]), 8); - assert_eq!(label_width_for(&[&long_id]), 20); - } - - #[test] - fn heatmap_height_caps_to_half_panel() { - assert_eq!(compute_heatmap_height(4, 30), 7); // 4+3 - assert_eq!(compute_heatmap_height(20, 16), 8); // capped at half - assert_eq!(compute_heatmap_height(1, 30), 5); // floor at 5 - } - /// Flatten a rendered TestBackend buffer into one newline-joined string so /// substring assertions can confirm what reached the screen. pub(in crate::ui) fn buffer_text( @@ -1056,8 +480,8 @@ pub(in crate::ui) mod tests { } // ── EAI-7960: observation-aware renderer tests ─────────────────────────── - // RED: assert held marker "*" in table/card output, freshness in detail. - // These fail until draw_table / draw_card / render_summary use the new + // RED: assert held marker "*" in table output, freshness in detail. + // These fail until draw_table / render_summary use the new // gen_tps_cell / gen_tps_compact / gen_tps_detail_freshness formatters. use chrono::{TimeZone, Utc}; From 919b53c7a31d363f26dcbbc82a164ba5bfa6f6b4 Mon Sep 17 00:00:00 2001 From: Jussi Elo Date: Wed, 4 Nov 2026 09:16:06 +0000 Subject: [PATCH 2/4] ROCMAI-853: remove the unused pct_opt and reqs_opt formatters `pct_opt` and `reqs_opt` were only called by the deleted instance card, so nothing in production reads them any more; their only remaining users were their own unit tests. `pct` and `si`, which they wrapped, still have production callers and stay. Signed-off-by: Jussi Elo --- crates/rocm-dash-tui/src/ui/format.rs | 30 --------------------------- 1 file changed, 30 deletions(-) diff --git a/crates/rocm-dash-tui/src/ui/format.rs b/crates/rocm-dash-tui/src/ui/format.rs index 08a52d6350..6cba392614 100644 --- a/crates/rocm-dash-tui/src/ui/format.rs +++ b/crates/rocm-dash-tui/src/ui/format.rs @@ -100,14 +100,6 @@ pub fn pct(value: f32) -> String { } } -/// `Option` percentage → `-` when None. -pub fn pct_opt(value: Option) -> String { - match value { - Some(v) => pct(v), - None => "-".to_string(), - } -} - /// SI-suffixed number: 1234 → "1.23 k", 1_234_567 → "1.23 M". /// Below 1000 returns the raw integer with no suffix. pub fn si(value: f64) -> String { @@ -201,15 +193,6 @@ pub fn duration(seconds: f64) -> String { } } -/// Request counter rendered with SI suffix for big numbers and `-` for None. -pub fn reqs_opt(value: Option) -> String { - match value { - Some(v) if v >= 1_000 => si(f64::from(v)), - Some(v) => v.to_string(), - None => "-".to_string(), - } -} - /// Power in watts. One decimal, always trailing `W`. pub fn watts(value: f32) -> String { format!("{value:.1} W") @@ -514,12 +497,6 @@ mod tests { assert_eq!(pct(100.0), "100.0%"); } - #[test] - fn pct_opt_handles_none() { - assert_eq!(pct_opt(None), "-"); - assert_eq!(pct_opt(Some(75.0)), "75.0%"); - } - #[test] fn si_scales_into_k_m_b() { assert_eq!(si(0.0), "0"); @@ -586,13 +563,6 @@ mod tests { assert_eq!(duration(3700.0), "1h 1m 40s"); } - #[test] - fn reqs_opt_collapses_big_counts() { - assert_eq!(reqs_opt(None), "-"); - assert_eq!(reqs_opt(Some(5)), "5"); - assert_eq!(reqs_opt(Some(12_000)), "12.00 k"); - } - #[test] fn watts_and_celsius_and_mhz() { assert_eq!(watts(123.4), "123.4 W"); From 1dd71eb8eff74459a0497d34042bf108b92f9b01 Mon Sep 17 00:00:00 2001 From: Jussi Elo Date: Wed, 4 Nov 2026 09:25:22 +0000 Subject: [PATCH 3/4] ROCMAI-853: remove BoxRole::from_tone and BoxRole::Danger, which only the deleted card used `BoxRole::from_tone` derived a card border from a status tone, and its only production caller was the instance card's `status_role`. With the card grid gone it has no caller (just its own two tests), and `BoxRole::Danger` was constructed only by `from_tone`, so it is never constructed either. Removes both, their tests, the `StatusTone` import in `panel.rs`, and the two places that describe them: the doc on `instance_status_tone` and the shared-components note in AGENTS.md. `instance_status_tone` and `Theme::instance_status_color` are unchanged and still drive the status text color. This is a separate commit from the card-grid deletion so it can be dropped on its own if a bordered status card is wanted again; `from_tone` was added shortly before the grid was found to be dead. Signed-off-by: Jussi Elo --- AGENTS.md | 2 +- crates/rocm-dash-tui/src/ui/panel.rs | 64 +--------------------------- crates/rocm-dash-tui/src/ui/theme.rs | 3 +- 3 files changed, 3 insertions(+), 66 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index a364a74483..09c6a923d4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -260,7 +260,7 @@ dash-TUI, in `crates/rocm-dash-tui/src/ui/`: - **[`job_console.rs`](crates/rocm-dash-tui/src/ui/job_console.rs)**'s `draw_job_console`/`on_console_key` — the shared "a job is running" surface (streamed output, status header, Ctrl+C cancels/`q` always closes/Esc-Enter dismiss a finished job); every operational manager already routes through this instead of building its own console - **[`spinner.rs`](crates/rocm-dash-tui/src/ui/spinner.rs)**'s `spinner_frame`/`parse_progress_pct` — the braille animation and percentage parsing `job_console.rs` renders with - **[`panel.rs`](crates/rocm-dash-tui/src/ui/panel.rs)**'s `bento`/`popup` — bordered, titled panels; prefer these over an inline `Block::default()`. Popup geometry and framing live here too: `centered_rect`/`centered_width` size and place a popup, `draw_popup_frame` clears and frames it, and `grey_overlay` dims the backdrop -- **[`theme.rs`](crates/rocm-dash-tui/src/ui/theme.rs)**'s `StatusTone` and `Theme::tone_color` — the shared status→color mapping. A status enum gets one exhaustive `fn …_tone(status) -> StatusTone` beside them (`job_status_tone`, `instance_status_tone`) and a `Theme::…_color` wrapper (`job_status_color`, `instance_status_color`); screens call the wrapper (or `tone_color(…)` on a tone) instead of an inline `match … => theme.ok/warn/err`. `BoxRole::from_tone` in [`panel.rs`](crates/rocm-dash-tui/src/ui/panel.rs) derives a card border from the same tone. To color a new status enum, add its tone function there rather than a bespoke match per screen +- **[`theme.rs`](crates/rocm-dash-tui/src/ui/theme.rs)**'s `StatusTone` and `Theme::tone_color` — the shared status→color mapping. A status enum gets one exhaustive `fn …_tone(status) -> StatusTone` beside them (`job_status_tone`, `instance_status_tone`) and a `Theme::…_color` wrapper (`job_status_color`, `instance_status_color`); screens call the wrapper (or `tone_color(…)` on a tone) instead of an inline `match … => theme.ok/warn/err`. To color a new status enum, add its tone function there rather than a bespoke match per screen - **[`widgets.rs`](crates/rocm-dash-tui/src/ui/widgets.rs)**'s `apply_char_key`/`apply_char_key_filtered` — the append-only text-field edit (`Char` appends, `Backspace` pops one char); call it from a form's key handler instead of writing another `push`/`pop` match arm. The `_filtered` form takes a predicate to refuse some chars (a digits-only port); there is no cursor or mid-string editing. The Chat tab's input is the one exception: its keys are first mapped to a `KeyAction` by the pure, separately tested table in [`actions.rs`](crates/rocm-dash-tui/src/app/actions.rs), which also applies them **Two different components are both informally "the spinner"; they are not interchangeable.** The CLI's [`cli_progress.rs`](apps/rocm/src/cli_progress.rs) `Spinner`/`AnimatedSpinner` above is TTY/stderr-gated for a plain terminal and lives in `apps/rocm`. The dash-TUI's [`spinner.rs`](crates/rocm-dash-tui/src/ui/spinner.rs) above is a pure frame/percentage helper rendered through `job_console.rs` inside a ratatui frame loop, and lives in `crates/rocm-dash-tui`. A dash-TUI screen needs the latter. diff --git a/crates/rocm-dash-tui/src/ui/panel.rs b/crates/rocm-dash-tui/src/ui/panel.rs index 35dec223d7..7bacd7f50a 100644 --- a/crates/rocm-dash-tui/src/ui/panel.rs +++ b/crates/rocm-dash-tui/src/ui/panel.rs @@ -32,7 +32,7 @@ use ratatui::widgets::{ Block, BorderType, Borders, Clear, Padding, Scrollbar, ScrollbarOrientation, ScrollbarState, }; -use crate::ui::theme::{StatusTone, Theme}; +use crate::ui::theme::Theme; /// Semantic role of a box. Drives the border color + tint. #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -45,8 +45,6 @@ pub enum BoxRole { Success, /// Caution (warn). Warning, - /// Error / danger (err). - Danger, /// Low-emphasis: logs, context, footnotes (muted). Muted, /// Generic chrome (border). @@ -54,26 +52,6 @@ pub enum BoxRole { } impl BoxRole { - /// The role whose border color matches a [`StatusTone`], so a status-driven - /// card takes its border from the same tone as the status text instead of - /// a second, parallel status-to-role match. - /// - /// [`StatusTone::Neutral`] is the one exception: its text color is the - /// foreground (`theme.fg`), but no role draws a border in the foreground - /// color, so it maps to [`BoxRole::Neutral`] (generic chrome, `theme.border`). - #[must_use] - pub const fn from_tone(tone: StatusTone) -> Self { - match tone { - StatusTone::Neutral => Self::Neutral, - StatusTone::Muted => Self::Muted, - StatusTone::Info => Self::Secondary, - StatusTone::Accent => Self::Primary, - StatusTone::Warning => Self::Warning, - StatusTone::Success => Self::Success, - StatusTone::Error | StatusTone::Alert => Self::Danger, - } - } - /// Base border color for this role. #[must_use] pub const fn color(self, theme: &Theme) -> Color { @@ -82,7 +60,6 @@ impl BoxRole { Self::Secondary => theme.accent_2, Self::Success => theme.ok, Self::Warning => theme.warn, - Self::Danger => theme.err, Self::Muted => theme.muted, Self::Neutral => theme.border, } @@ -793,43 +770,4 @@ mod tests { assert_eq!(super::centered_width(100, u16::MAX, area), w); } } - - #[test] - fn from_tone_border_matches_the_tone_color() { - // A status-driven card's border must be the same color as the status - // text for every tone a status enum can map to. - let theme = Theme::default_dark(); - for tone in [ - StatusTone::Muted, - StatusTone::Info, - StatusTone::Accent, - StatusTone::Warning, - StatusTone::Success, - StatusTone::Error, - StatusTone::Alert, - ] { - assert_eq!( - BoxRole::from_tone(tone).color(&theme), - theme.tone_color(tone), - "{tone:?}" - ); - } - } - - #[test] - fn from_tone_neutral_is_the_documented_exception() { - // `Neutral` text is `theme.fg`, but no border role is the foreground - // color, so the border falls back to generic chrome. Pinned so the - // exception in `from_tone`'s docs stays true. - let theme = Theme::default_dark(); - assert_eq!(BoxRole::from_tone(StatusTone::Neutral), BoxRole::Neutral); - assert_eq!( - BoxRole::from_tone(StatusTone::Neutral).color(&theme), - theme.border - ); - assert_ne!( - BoxRole::from_tone(StatusTone::Neutral).color(&theme), - theme.tone_color(StatusTone::Neutral) - ); - } } diff --git a/crates/rocm-dash-tui/src/ui/theme.rs b/crates/rocm-dash-tui/src/ui/theme.rs index bb188f775c..d875802791 100644 --- a/crates/rocm-dash-tui/src/ui/theme.rs +++ b/crates/rocm-dash-tui/src/ui/theme.rs @@ -268,8 +268,7 @@ impl Theme { } } -/// Tone for an [`InstanceStatus`], shared by [`Theme::instance_status_color`] -/// and `BoxRole::from_tone` (the Instances tab's health-driven card border). +/// Tone for an [`InstanceStatus`], behind [`Theme::instance_status_color`]. /// `Starting` is the warning tone because it is a background in-progress state /// the user is not necessarily watching (see `docs/ux-guidelines.md`), unlike a /// foreground running job, which is accent. Exhaustive, so a new variant forces From 1ddc5c9341b3b93f2a491795b7918369c8429510 Mon Sep 17 00:00:00 2001 From: Jussi Elo Date: Thu, 5 Nov 2026 06:32:50 +0000 Subject: [PATCH 4/4] docs(dash): drop the remaining mentions of the deleted heatmap and card grid Comment-only. The demo generator's phase offset, the board-power threshold note, the instance cursor doc, the instance detail module doc, the launch-args doc and the gen_tps_compact doc named the instances card grid or the heatmap module that the earlier commits delete. Each now describes what the dashboard draws today: the Observe table, the per-GPU utilization sparklines, and the temperature and power colors. Signed-off-by: Jussi Elo --- crates/rocm-dash-daemon/src/demo.rs | 5 +++-- crates/rocm-dash-tui/src/app/mod.rs | 2 +- crates/rocm-dash-tui/src/ui/format.rs | 2 +- crates/rocm-dash-tui/src/ui/instance_detail.rs | 2 +- crates/rocm-dash-tui/src/ui/widgets.rs | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/rocm-dash-daemon/src/demo.rs b/crates/rocm-dash-daemon/src/demo.rs index 80b7332e73..2690aa4ef9 100644 --- a/crates/rocm-dash-daemon/src/demo.rs +++ b/crates/rocm-dash-daemon/src/demo.rs @@ -186,7 +186,8 @@ struct ContainerSpec { tp: u32, port: u16, /// Phase of the activity sinusoid in seconds — staggers the three - /// instances so the heatmap and per-GPU sparklines aren't synchronised. + /// instances so their curves in the Observe table (throughput, queue, + /// kv-cache) and the per-GPU utilization sparklines aren't synchronised. phase_s: f64, /// Mean kv-cache utilization (0..100) around which it oscillates. kv_mean: f32, @@ -199,7 +200,7 @@ struct ContainerSpec { req_mean: u32, /// Quantization label shown in the detail modal. quantization: Option<&'static str>, - /// Launch args excerpt rendered in the instance card / detail modal. + /// Launch args excerpt rendered in the instance detail modal. launch_args: &'static [&'static str], } diff --git a/crates/rocm-dash-tui/src/app/mod.rs b/crates/rocm-dash-tui/src/app/mod.rs index ebda3311cc..2336b98d32 100644 --- a/crates/rocm-dash-tui/src/app/mod.rs +++ b/crates/rocm-dash-tui/src/app/mod.rs @@ -117,7 +117,7 @@ pub struct AppState { /// Whether the active domain tab's focus is on the Actions list or the /// Details pane. `→`/Enter moves focus into Details; `←`/Esc returns to it. pub pane_focus: PaneFocus, - /// Cursor into the sorted Instances grid. + /// Cursor into the sorted Instances table. pub instance_sel: usize, /// Cursor into the bench_rows VecDeque (0 = oldest, len-1 = newest). pub bench_sel: usize, diff --git a/crates/rocm-dash-tui/src/ui/format.rs b/crates/rocm-dash-tui/src/ui/format.rs index 6cba392614..6cbd7bc538 100644 --- a/crates/rocm-dash-tui/src/ui/format.rs +++ b/crates/rocm-dash-tui/src/ui/format.rs @@ -245,7 +245,7 @@ pub fn gen_tps_cell(tps: Option, obs: Option<&ObservationMetadata>) -> Stri } } -/// Full-unit gen_tps for cards, pane rows, and services views. +/// Full-unit gen_tps for pane rows and services views. /// Mirrors [`tps_opt`] format and appends [`HELD_MARKER`] when metadata is Held. /// /// - `None` → `"-"` diff --git a/crates/rocm-dash-tui/src/ui/instance_detail.rs b/crates/rocm-dash-tui/src/ui/instance_detail.rs index 863d9a34e2..8da9bb84bb 100644 --- a/crates/rocm-dash-tui/src/ui/instance_detail.rs +++ b/crates/rocm-dash-tui/src/ui/instance_detail.rs @@ -7,7 +7,7 @@ //! //! Split out of `ui/tabs/instances.rs`. It reads `sorted_instances`, //! `clamp_sel` and `status_meta` from there, which stay single-sourced beside -//! the table and card code that also use them; nothing in `instances.rs` calls +//! the table code that also uses them; nothing in `instances.rs` calls //! back into this module. `ui/mod.rs` calls `draw_detail` for `Modal::Detail` //! on the Observe tab and writes the returned max scroll offset to //! `AppState::instance_detail_max_scroll`. diff --git a/crates/rocm-dash-tui/src/ui/widgets.rs b/crates/rocm-dash-tui/src/ui/widgets.rs index dd9765fa63..ca5da108fe 100644 --- a/crates/rocm-dash-tui/src/ui/widgets.rs +++ b/crates/rocm-dash-tui/src/ui/widgets.rs @@ -18,7 +18,7 @@ pub const TEMP_CRIT_C: f32 = 80.0; /// Board-power warning threshold (W). At or above → warn color. /// -/// Fixed semantic thresholds make heatmap/gauge colors mean "near the limit" +/// Fixed semantic thresholds make temperature and power colors mean "near the limit" /// rather than "near the largest value seen this session". Tuned for /// MI355X-class parts (TDP ~750 W); the demo generator peaks ~740 W at 100% /// util. No per-GPU TDP exists in the data model, so these are constants.