From 69441d1aa9ee2f821f44d8a731d7c20260cfecf2 Mon Sep 17 00:00:00 2001 From: Roman Sirokov Date: Tue, 3 Nov 2026 16:35:55 +0200 Subject: [PATCH 1/8] fix(dash-tui): show a placeholder, not -0, for hero T/S with nothing served MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Home hero summed instance gen_tps with Iterator::sum, which returns -0.0 for an empty iterator, and `{:.0}` rendered that as "-0". It was visible whenever no instance reports throughput: always on Windows, where the in-process collectors never send instances, and on Linux when nothing is served. Show "—" when no instance contributes a finite gen_tps, matching the hero's other unmeasured values and the Observe tab's aggregate. An instance reporting 0 tok/s still shows "0". Covered by unit tests in home.rs and a new step on dash-37. Signed-off-by: Roman Sirokov --- crates/rocm-dash-tui/src/ui/tabs/home.rs | 40 ++++++++++++++++++++-- docs/manual-testing.md | 2 ++ tests/e2e-cucumber/features/dash.feature | 5 ++- tests/e2e-cucumber/tests/e2e/dash_steps.rs | 20 +++++++++++ 4 files changed, 63 insertions(+), 4 deletions(-) diff --git a/crates/rocm-dash-tui/src/ui/tabs/home.rs b/crates/rocm-dash-tui/src/ui/tabs/home.rs index f2d42064c2..00bca83127 100644 --- a/crates/rocm-dash-tui/src/ui/tabs/home.rs +++ b/crates/rocm-dash-tui/src/ui/tabs/home.rs @@ -473,19 +473,24 @@ fn draw_hero_right(f: &mut Frame, area: Rect, state: &AppState, theme: &Theme) { // (rendering "NaN"/"inf" in the hero) and could mark the aggregate held // without ever contributing a displayed value — guarded the same way // `gen_tps_cell` guards a single instance's value. - let tps: f64 = state + let tps_samples: Vec = state .instances .values() .filter_map(|i| i.gen_tps) .filter(|v| v.is_finite()) - .sum(); + .collect(); + let tps: f64 = tps_samples.iter().sum(); let any_tps_held = state.instances.values().any(|i| { i.gen_tps.is_some_and(f64::is_finite) && i.gen_tps_observation .as_ref() .is_some_and(|m| m.freshness == rocm_dash_core::metrics::ObservationFreshness::Held) }); - let tps_str = if any_tps_held { + // No instance reporting throughput is "not measured", not a measured 0 — + // and an empty f64 sum is -0.0, which `{:.0}` renders as "-0". + let tps_str = if tps_samples.is_empty() { + "—".to_string() + } else if any_tps_held { format!("{:.0}{}", tps, crate::ui::format::HELD_MARKER) } else { format!("{tps:.0}") @@ -1034,6 +1039,35 @@ mod tests { s } + /// The hero's T/S value, i.e. the text after the "T/S" label up to the + /// panel border on that row. + fn hero_tps_value(out: &str) -> &str { + out.split("T/S") + .nth(1) + .and_then(|s| s.split('│').next()) + .unwrap_or_else(|| panic!("T/S row missing: {out:?}")) + .trim() + } + + #[test] + fn hero_tps_shows_dash_not_negative_zero_when_nothing_reports_throughput() { + // A GPU is reported but no instance is serving: the Windows in-process + // collectors never send instances, and a Linux host with nothing + // running is in the same state. + let out = render(&state_with_gpu(), 160, 30); + assert_eq!(hero_tps_value(&out), "—", "got:\n{out}"); + } + + #[test] + fn hero_tps_shows_zero_when_an_instance_reports_zero_throughput() { + let out = render( + &state_with_instance(instance_with_obs(0.0, Some(fresh_obs()))), + 160, + 30, + ); + assert_eq!(hero_tps_value(&out), "0", "got:\n{out}"); + } + #[test] fn home_held_legend_visible_when_tpw_and_tps_held() { let out = render( diff --git a/docs/manual-testing.md b/docs/manual-testing.md index 1e2e593fb0..7e8e91ec3b 100644 --- a/docs/manual-testing.md +++ b/docs/manual-testing.md @@ -717,6 +717,8 @@ Expected result: present. With more than one adapter (for example a hybrid laptop) VRAM total stays unmeasured and shows `—` in the Home hero and in the GPU wall sidebar, never `0.0%`. +- The hero's `T/S` row reads `—`, never `0` or `-0`: Windows has no + serving-instance view, so no throughput is ever measured there. - Utilization rises under GPU load (run a Lemonade or ComfyUI job) and falls back when it ends. - Hiding `amdadlx64.dll` (for example on a non-AMD GPU host) leaves diff --git a/tests/e2e-cucumber/features/dash.feature b/tests/e2e-cucumber/features/dash.feature index f609516a8f..a9c45e4c96 100644 --- a/tests/e2e-cucumber/features/dash.feature +++ b/tests/e2e-cucumber/features/dash.feature @@ -623,13 +623,16 @@ Feature: Interactive dashboard # placeholder shown before the first snapshot arrives at all, is not covered # here (the unit test `gpu_telemetry_pending_while_connected_but_no_snapshot_yet` # pins it): it closes in well under a second and there's no hook to freeze the daemon - # mid-handshake, so asserting on it would be asserting on a race. + # mid-handshake, so asserting on it would be asserting on a race. Nothing is + # served either, so the T/S row must read "—" too: an empty sum of rates is + # -0.0 in Rust, which used to render as "-0". @id:dash-reports-no-gpu-telemetry @requires-os:linux Scenario: dash-37 - The hero shows placeholders, not fake zeros, when no GPU is detected Given a machine with no GPU When the user opens the dashboard Then the dashboard home view is displayed And the hero reports no GPU telemetry available + And the hero reports no generation throughput When the user quits the dashboard Then the dashboard exits successfully diff --git a/tests/e2e-cucumber/tests/e2e/dash_steps.rs b/tests/e2e-cucumber/tests/e2e/dash_steps.rs index 920534a93a..219d5c331a 100644 --- a/tests/e2e-cucumber/tests/e2e/dash_steps.rs +++ b/tests/e2e-cucumber/tests/e2e/dash_steps.rs @@ -1434,6 +1434,26 @@ async fn hero_reports_no_gpu_telemetry(world: &mut E2eWorld) { } } +#[then("the hero reports no generation throughput")] +async fn hero_reports_no_generation_throughput(world: &mut E2eWorld) { + // Runs after `the hero reports no GPU telemetry available`, which has + // already switched to the wide layout the T/S mini-spark needs. + let tui = session(world); + let screen = tui.screen_text(); + let row = screen + .lines() + .find(|line| line.contains("T/S")) + .unwrap_or_else(|| panic!("no T/S row on screen:\n{screen}")); + let value = row + .split_once("T/S") + .and_then(|(_, rest)| rest.split('│').next()) + .map_or_else(|| panic!("no text after T/S on row:\n{row}"), str::trim); + assert_eq!( + value, "—", + "T/S should show the \"—\" placeholder when nothing is served:\n{row}" + ); +} + #[then("the dashboard reports live GPU telemetry")] async fn gpu_telemetry_displayed(world: &mut E2eWorld) { let tui = session(world); From 46bb93f714fa3106029c5ecc9cc333fca328604d Mon Sep 17 00:00:00 2001 From: Roman Sirokov Date: Wed, 4 Nov 2026 10:20:04 +0200 Subject: [PATCH 2/8] fix(dash-tui): keep the Home hero's readings in a short terminal The hero card drew its contents only when it had six inner rows. In a terminal of about 22 rows (for example the VS Code panel) the Home tab squeezes the hero to five, so the card rendered as an empty box with just its title, even with live GPU telemetry arriving. Lay each hero column out row by row and drop the rows that do not fit, bottom first (legends, then T/S), instead of skipping the whole hero. At 72x14 the hero now shows utilization, VRAM, temperature and power. Signed-off-by: Roman Sirokov --- crates/rocm-dash-tui/src/ui/tabs/home.rs | 43 +++++++++++++++++----- docs/manual-testing.md | 3 ++ tests/e2e-cucumber/tests/e2e/dash_steps.rs | 4 +- 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/crates/rocm-dash-tui/src/ui/tabs/home.rs b/crates/rocm-dash-tui/src/ui/tabs/home.rs index 00bca83127..7524b4e3cf 100644 --- a/crates/rocm-dash-tui/src/ui/tabs/home.rs +++ b/crates/rocm-dash-tui/src/ui/tabs/home.rs @@ -284,7 +284,7 @@ fn draw_activity(f: &mut Frame, area: Rect, state: &AppState, theme: &Theme) { fn draw_hero_band(f: &mut Frame, area: Rect, state: &AppState, theme: &Theme) { let title = node_throughput_title(state); let hero = card(f, area, &title, BoxRole::Secondary, theme); - if hero.width >= 8 && hero.height >= 6 { + if hero.width >= 8 && hero.height >= 1 { let hcols = Layout::default() .direction(Direction::Horizontal) .constraints([Constraint::Percentage(50), Constraint::Percentage(50)]) @@ -295,11 +295,22 @@ fn draw_hero_band(f: &mut Frame, area: Rect, state: &AppState, theme: &Theme) { } } +/// One-row slots for a hero column, top to bottom. Slots past the column's +/// height come back zero-height, so a short terminal drops the bottom rows +/// (the legends first) rather than the whole hero. +fn hero_rows(area: Rect) -> [Rect; 6] { + std::array::from_fn(|i| { + let i = u16::try_from(i).unwrap_or(u16::MAX); + if i < area.height { + Rect::new(area.x, area.y + i, area.width, 1) + } else { + Rect::new(area.x, area.y, area.width, 0) + } + }) +} + fn draw_hero_left(f: &mut Frame, area: Rect, state: &AppState, theme: &Theme) { - let lh = Layout::default() - .direction(Direction::Vertical) - .constraints([Constraint::Length(1); 6]) - .split(area); + let lh = hero_rows(area); f.render_widget( Paragraph::new(Line::from(Span::styled( "GPU UTILIZATION", @@ -381,10 +392,7 @@ fn draw_hero_left(f: &mut Frame, area: Rect, state: &AppState, theme: &Theme) { } fn draw_hero_right(f: &mut Frame, area: Rect, state: &AppState, theme: &Theme) { - let rh = Layout::default() - .direction(Direction::Vertical) - .constraints([Constraint::Length(1); 6]) - .split(area); + let rh = hero_rows(area); // In demo/replay this is not a live feed — say so rather than "LIVE". let (feed_label, feed_color) = if state.simulated { ("SIMULATED · last 60s", theme.warn) @@ -1005,6 +1013,23 @@ mod tests { } } + #[test] + fn hero_keeps_its_readings_in_a_short_terminal() { + // A ~22-row terminal leaves the Home tab ~14 rows, which squeezes the + // hero card below the six rows its columns ask for. The readings must + // still draw (the bottom rows go first), not leave an empty card. + let s = state_with_gpu(); + for h in 12u16..=18 { + let out = render(&s, 72, h); + for label in ["GPU UTILIZATION", "VRAM", "TEMP"] { + assert!( + out.contains(label), + "{label} missing from the hero at height {h}:\n{out}" + ); + } + } + } + fn instance_with_obs(gen_tps: f64, obs: Option) -> Instance { Instance { container_id: "m".into(), diff --git a/docs/manual-testing.md b/docs/manual-testing.md index 7e8e91ec3b..aef56e921e 100644 --- a/docs/manual-testing.md +++ b/docs/manual-testing.md @@ -719,6 +719,9 @@ Expected result: sidebar, never `0.0%`. - The hero's `T/S` row reads `—`, never `0` or `-0`: Windows has no serving-instance view, so no throughput is ever measured there. +- In a short terminal (about 22 rows, e.g. the VS Code panel) the hero still + shows utilization, VRAM, temperature and power; only its lowest rows drop + off. It never renders as an empty box. - Utilization rises under GPU load (run a Lemonade or ComfyUI job) and falls back when it ends. - Hiding `amdadlx64.dll` (for example on a non-AMD GPU host) leaves diff --git a/tests/e2e-cucumber/tests/e2e/dash_steps.rs b/tests/e2e-cucumber/tests/e2e/dash_steps.rs index 219d5c331a..69217933cf 100644 --- a/tests/e2e-cucumber/tests/e2e/dash_steps.rs +++ b/tests/e2e-cucumber/tests/e2e/dash_steps.rs @@ -1382,8 +1382,8 @@ async fn home_view_displayed(world: &mut E2eWorld) { #[then("the hero reports no GPU telemetry available")] async fn hero_reports_no_gpu_telemetry(world: &mut E2eWorld) { let tui = session(world); - // The VRAM/TEMP/POWER mini-sparks only draw in the hero's wide layout - // (`draw_hero_band`'s `hero.width >= 8 && hero.height >= 6` gate). + // The VRAM/TEMP/POWER/T/S rows sit low in the hero, and a short pty + // squeezes the hero until `hero_rows` drops its bottom rows; enlarge first. tui.use_wide_size() .unwrap_or_else(|e| panic!("failed to enlarge the dashboard: {e}")); From caa00747646771cdb17c519d459c291bed5f62f7 Mon Sep 17 00:00:00 2001 From: Roman Sirokov Date: Thu, 5 Nov 2026 11:16:50 +0200 Subject: [PATCH 3/8] fix(dash-tui): drop the held marker with its legend Relaxing the hero's height gate let the T/S and tok/W rows render in a terminal too short for the legend row beneath them, so a held value showed a bare "*" with nothing on screen to define it. At 24 rows -- the default terminal size -- the hero read "T/S 300*" and no legend. Suppress the marker whenever its legend row is unavailable. The reading itself still shows: a held value is real and measured, just from the prior scrape window, so losing the annotation is a smaller cost than an unexplained glyph, and a smaller one still than dropping the reading to make room for the legend. Guarded by hero_never_shows_a_held_marker_without_its_legend, which sweeps the heights rather than pinning the one that happens to break. Signed-off-by: Roman Sirokov --- crates/rocm-dash-tui/src/ui/tabs/home.rs | 42 ++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/crates/rocm-dash-tui/src/ui/tabs/home.rs b/crates/rocm-dash-tui/src/ui/tabs/home.rs index 7524b4e3cf..3a000f97ec 100644 --- a/crates/rocm-dash-tui/src/ui/tabs/home.rs +++ b/crates/rocm-dash-tui/src/ui/tabs/home.rs @@ -357,8 +357,12 @@ fn draw_hero_left(f: &mut Frame, area: Rect, state: &AppState, theme: &Theme) { .as_ref() .is_some_and(|m| m.freshness == rocm_dash_core::metrics::ObservationFreshness::Held) }); + // The marker and the legend that explains it share fate: the legend row + // is the first thing a short hero drops, and a bare "*" with nothing on + // screen to define it is worse than an unannotated prior-window value. + let legend_fits = lh[5].height > 0; let tpw_label = if tpw > 0.0 { - let marker = if any_tpw_held { + let marker = if any_tpw_held && legend_fits { crate::ui::format::HELD_MARKER } else { "" @@ -496,9 +500,12 @@ fn draw_hero_right(f: &mut Frame, area: Rect, state: &AppState, theme: &Theme) { }); // No instance reporting throughput is "not measured", not a measured 0 — // and an empty f64 sum is -0.0, which `{:.0}` renders as "-0". + // The held marker is suppressed with the legend row that explains it, as + // in `draw_hero_left`. + let legend_fits = rh[5].height > 0; let tps_str = if tps_samples.is_empty() { "—".to_string() - } else if any_tps_held { + } else if any_tps_held && legend_fits { format!("{:.0}{}", tps, crate::ui::format::HELD_MARKER) } else { format!("{tps:.0}") @@ -1117,6 +1124,37 @@ mod tests { ); } + #[test] + fn hero_never_shows_a_held_marker_without_its_legend() { + // Squeezing the hero drops the legend row before the value rows, so + // every height has to be checked, not just the roomy one. + let s = state_with_instance(instance_with_obs(300.0, Some(held_obs()))); + let marked_tps = format!("{:.0}{}", 300.0, format::HELD_MARKER); + let marked_tpw = format!("{:.1} tokens / watt{}", 1.0, format::HELD_MARKER); + let mut saw_unmarked_value = false; + for h in 8u16..=30 { + let out = render(&s, 160, h); + if out.contains(&marked_tps) || out.contains(&marked_tpw) { + assert!( + out.contains(format::HELD_LEGEND), + "held marker with no legend to explain it at height {h}:\n{out}" + ); + } + // The reading itself must survive the legend being dropped. + if out.contains("T/S") && !out.contains(format::HELD_LEGEND) { + assert!( + out.contains("300"), + "the T/S reading must stay once the marker is dropped, at height {h}:\n{out}" + ); + saw_unmarked_value = true; + } + } + assert!( + saw_unmarked_value, + "no height rendered T/S without the legend — the squeeze this guards never happened" + ); + } + #[test] fn home_held_legend_absent_when_all_fresh() { let out = render( From ed770660fc674d7ef7540678563794ebbfb0a069 Mon Sep 17 00:00:00 2001 From: Roman Sirokov Date: Thu, 5 Nov 2026 11:26:20 +0200 Subject: [PATCH 4/8] fix(dash-tui): tell a measured zero tok/W from an unmeasured one MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The hero's tok/W aggregate gated its label on `tpw > 0.0`, so an instance genuinely reporting 0.0 tok/W rendered as "—", the same thing shown when nothing reports at all. This is the conflation just fixed on the T/S side, in the aggregate directly beside it. Both aggregates now go through `instance_aggregate`, which returns None only when no instance contributed a finite sample. That makes the distinction expressible, keeps the NaN/Infinity guard in one place, and drops the per-frame Vec the T/S side was allocating only to ask whether any sample existed. Avoiding Iterator::sum is now load-bearing rather than incidental: its f64 identity is -0.0, which is where the original "-0" came from. home_tpw_shows_a_measured_zero_rather_than_a_dash replaces a test that pinned the old behaviour; its setup reported 0.0 tok/W and expected the unmeasured dash. home_tpw_legend_absent_when_no_instance_reports_a_ finite_value keeps the invariant that test was really guarding. Signed-off-by: Roman Sirokov --- crates/rocm-dash-tui/src/ui/tabs/home.rs | 128 ++++++++++++++--------- 1 file changed, 76 insertions(+), 52 deletions(-) diff --git a/crates/rocm-dash-tui/src/ui/tabs/home.rs b/crates/rocm-dash-tui/src/ui/tabs/home.rs index 3a000f97ec..f53be9ffc9 100644 --- a/crates/rocm-dash-tui/src/ui/tabs/home.rs +++ b/crates/rocm-dash-tui/src/ui/tabs/home.rs @@ -104,6 +104,25 @@ fn snap_util(s: &rocm_dash_core::metrics::Snapshot) -> f64 { .fold(0.0, f64::max) } +/// Sums the finite values `pick` yields across instances, or `None` when no +/// instance contributed one. The `Option` is the point: "nothing reported a +/// value" has to stay distinct from "every reporter measured zero", which a +/// bare sum cannot express. A single NaN/Infinity sample is dropped rather +/// than allowed to poison the total, as `gen_tps_cell` does per instance. +/// `Iterator::sum` is deliberately avoided — its `f64` identity is `-0.0`, so +/// an empty iterator sums to `-0.0` and renders as `"-0"`. +fn instance_aggregate(state: &AppState, pick: F) -> Option +where + F: Fn(&rocm_dash_core::metrics::Instance) -> Option, +{ + state + .instances + .values() + .filter_map(pick) + .filter(|v| v.is_finite()) + .fold(None, |acc, v| Some(acc.unwrap_or(0.0) + v)) +} + /// A labeled one-row instrument: `LABEL ▁▂▃▅▆▇ value`. Port of the mock's /// `mini_spark`; `accent` picks the flat throughput tint, else value-gradient. fn mini_spark( @@ -341,16 +360,7 @@ fn draw_hero_left(f: &mut Frame, area: Rect, state: &AppState, theme: &Theme) { // Tokens/watt: summed across running instances when available. // Mark held if any contributing instance has a held gen_tps observation // (tok/W derives from gen_tps; aggregate inherits held status). - // A single NaN/Infinity instance would otherwise poison the whole sum - // (and, for `any_tpw_held`, count as held without ever being displayed) — - // filtered out the same way `tokens_per_watt` is guarded per-instance - // elsewhere in this tab. - let tpw: f64 = state - .instances - .values() - .filter_map(|i| i.tokens_per_watt) - .filter(|v| v.is_finite()) - .sum(); + let tpw = instance_aggregate(state, |i| i.tokens_per_watt); let any_tpw_held = state.instances.values().any(|i| { i.tokens_per_watt.is_some_and(f64::is_finite) && i.gen_tps_observation @@ -361,15 +371,16 @@ fn draw_hero_left(f: &mut Frame, area: Rect, state: &AppState, theme: &Theme) { // is the first thing a short hero drops, and a bare "*" with nothing on // screen to define it is worse than an unannotated prior-window value. let legend_fits = lh[5].height > 0; - let tpw_label = if tpw > 0.0 { - let marker = if any_tpw_held && legend_fits { - crate::ui::format::HELD_MARKER - } else { - "" - }; - format!("⎓ {tpw:.1} tokens / watt{marker}") - } else { - "⎓ tokens / watt —".to_string() + let tpw_label = match tpw { + None => "⎓ tokens / watt —".to_string(), + Some(v) => { + let marker = if any_tpw_held && legend_fits { + crate::ui::format::HELD_MARKER + } else { + "" + }; + format!("⎓ {v:.1} tokens / watt{marker}") + } }; f.render_widget( Paragraph::new(Line::from(Span::styled( @@ -381,10 +392,10 @@ fn draw_hero_left(f: &mut Frame, area: Rect, state: &AppState, theme: &Theme) { lh[4], ); // Show the shared HELD_LEGEND only when the tok/W aggregate is actually - // held AND rendered with a marker — `tpw > 0.0` mirrors the gate on - // `tpw_label` above so a zero-throughput aggregate (which prints + // held AND rendered with a marker — `tpw.is_some()` mirrors the gate on + // `tpw_label` above so an unmeasured aggregate (which prints // "tokens / watt —" with no marker) never shows an unexplained legend. - if tpw > 0.0 && any_tpw_held { + if tpw.is_some() && any_tpw_held { f.render_widget( Paragraph::new(Line::from(Span::styled( format::HELD_LEGEND, @@ -481,34 +492,22 @@ fn draw_hero_right(f: &mut Frame, area: Rect, state: &AppState, theme: &Theme) { false, theme, ); - // A single NaN/Infinity instance would otherwise poison the whole sum - // (rendering "NaN"/"inf" in the hero) and could mark the aggregate held - // without ever contributing a displayed value — guarded the same way - // `gen_tps_cell` guards a single instance's value. - let tps_samples: Vec = state - .instances - .values() - .filter_map(|i| i.gen_tps) - .filter(|v| v.is_finite()) - .collect(); - let tps: f64 = tps_samples.iter().sum(); + let tps = instance_aggregate(state, |i| i.gen_tps); let any_tps_held = state.instances.values().any(|i| { i.gen_tps.is_some_and(f64::is_finite) && i.gen_tps_observation .as_ref() .is_some_and(|m| m.freshness == rocm_dash_core::metrics::ObservationFreshness::Held) }); - // No instance reporting throughput is "not measured", not a measured 0 — - // and an empty f64 sum is -0.0, which `{:.0}` renders as "-0". // The held marker is suppressed with the legend row that explains it, as // in `draw_hero_left`. let legend_fits = rh[5].height > 0; - let tps_str = if tps_samples.is_empty() { - "—".to_string() - } else if any_tps_held && legend_fits { - format!("{:.0}{}", tps, crate::ui::format::HELD_MARKER) - } else { - format!("{tps:.0}") + let tps_str = match tps { + None => "—".to_string(), + Some(v) if any_tps_held && legend_fits => { + format!("{:.0}{}", v, crate::ui::format::HELD_MARKER) + } + Some(v) => format!("{v:.0}"), }; mini_spark(f, rh[4], "T/S ", &tps_str, &[], true, theme); // Show the shared HELD_LEGEND only when the tok/s aggregate is actually @@ -1181,27 +1180,52 @@ mod tests { ); } - #[test] - fn home_tpw_legend_absent_when_aggregate_is_zero_even_if_held() { - // tokens_per_watt sums to 0.0 (the "tokens / watt —" branch, no marker - // rendered) while gen_tps is absent (so the tok/s side never fires - // either). Held metadata alone must not add an unexplained legend. - let inst = Instance { + /// An instance whose only reading is `tokens_per_watt`, held. + fn tpw_only_instance(tokens_per_watt: Option) -> Instance { + Instance { container_id: "m".into(), container_name: "m".into(), status: InstanceStatus::Running, model_name: "m".into(), gpu_ids: vec!["0".into()], gen_tps: None, - tokens_per_watt: Some(0.0), + tokens_per_watt, gen_tps_observation: Some(held_obs()), ..Default::default() - }; - let out = render(&state_with_instance(inst), 160, 30); + } + } + + #[test] + fn home_tpw_shows_a_measured_zero_rather_than_a_dash() { + // An instance that reports 0.0 tok/W measured it; only "no instance + // reported one at all" is unmeasured. Mirrors the tok/s side, which + // renders a reported 0 as "0" and reserves "—" for nothing reporting. + let out = render(&state_with_instance(tpw_only_instance(Some(0.0))), 160, 30); assert!( - !out.contains(format::HELD_LEGEND), - "HELD_LEGEND must not appear when the tok/W aggregate is zero; got:\n{out}" + out.contains(&format!("0.0 tokens / watt{}", format::HELD_MARKER)), + "a measured zero tok/W must render as 0.0, not —; got:\n{out}" ); + assert!( + out.contains(format::HELD_LEGEND), + "the marked zero aggregate must still be explained; got:\n{out}" + ); + } + + #[test] + fn home_tpw_legend_absent_when_no_instance_reports_a_finite_value() { + // The invariant the aggregate change must not break: held metadata + // alone, with nothing finite to mark, must not conjure a legend. + for tpw in [None, Some(f64::NAN), Some(f64::INFINITY)] { + let out = render(&state_with_instance(tpw_only_instance(tpw)), 160, 30); + assert!( + out.contains("tokens / watt —"), + "unmeasured tok/W must read —; got for {tpw:?}:\n{out}" + ); + assert!( + !out.contains(format::HELD_LEGEND), + "HELD_LEGEND must not appear with nothing marked; got for {tpw:?}:\n{out}" + ); + } } #[test] From e8e7e70ce32c0a5e41d90b231f2002b5dd624c12 Mon Sep 17 00:00:00 2001 From: Roman Sirokov Date: Thu, 5 Nov 2026 11:26:42 +0200 Subject: [PATCH 5/8] test(e2e): make the no-throughput hero step self-contained "the hero reports no generation throughput" read the screen immediately and relied on the step before it having called use_wide_size(). Cucumber matches step text globally, so written into any other scenario it would race the first render and panic with "no T/S row on screen". Resize and wait for the T/S row inside the step, as both sibling steps in this file already do. Signed-off-by: Roman Sirokov --- tests/e2e-cucumber/tests/e2e/dash_steps.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/e2e-cucumber/tests/e2e/dash_steps.rs b/tests/e2e-cucumber/tests/e2e/dash_steps.rs index 69217933cf..285ab076be 100644 --- a/tests/e2e-cucumber/tests/e2e/dash_steps.rs +++ b/tests/e2e-cucumber/tests/e2e/dash_steps.rs @@ -1436,9 +1436,21 @@ async fn hero_reports_no_gpu_telemetry(world: &mut E2eWorld) { #[then("the hero reports no generation throughput")] async fn hero_reports_no_generation_throughput(world: &mut E2eWorld) { - // Runs after `the hero reports no GPU telemetry available`, which has - // already switched to the wide layout the T/S mini-spark needs. let tui = session(world); + // Self-contained rather than relying on a preceding step: cucumber matches + // step text globally, so this has to hold wherever it is written. The T/S + // row sits low in the hero and a short pty drops it, so enlarge and wait + // for the redraw before reading the screen. + tui.use_wide_size() + .unwrap_or_else(|e| panic!("failed to enlarge the dashboard: {e}")); + tui.wait_for_screen_where( + "the hero's T/S row", + |screen| screen.contains("T/S"), + default_timeout(), + ) + .await + .unwrap_or_else(|e| panic!("the hero's T/S row did not render: {e}")); + let screen = tui.screen_text(); let row = screen .lines() From 8b4304a4e1d726d539d0be3f3ed2321fc53e7edc Mon Sep 17 00:00:00 2001 From: Roman Sirokov Date: Thu, 5 Nov 2026 11:26:51 +0200 Subject: [PATCH 6/8] docs: move the short-terminal hero check out of the Windows section The hero's row dropping is ratatui layout with no platform gate, but the check sat under "4b. Dashboard Live GPU/CPU/Memory On Windows", where a Linux or WSL tester would not look for it. The e2e scenario resizes to 45 rows precisely so it never exercises a short terminal, so manual testing is the only coverage this behaviour has. New platform-neutral 4c, extended to cover the held marker and its legend appearing and disappearing together. The T/S bullet left in 4b is genuinely Windows-specific. Signed-off-by: Roman Sirokov --- docs/manual-testing.md | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/docs/manual-testing.md b/docs/manual-testing.md index aef56e921e..5f7f39587c 100644 --- a/docs/manual-testing.md +++ b/docs/manual-testing.md @@ -719,9 +719,6 @@ Expected result: sidebar, never `0.0%`. - The hero's `T/S` row reads `—`, never `0` or `-0`: Windows has no serving-instance view, so no throughput is ever measured there. -- In a short terminal (about 22 rows, e.g. the VS Code panel) the hero still - shows utilization, VRAM, temperature and power; only its lowest rows drop - off. It never renders as an empty box. - Utilization rises under GPU load (run a Lemonade or ComfyUI job) and falls back when it ends. - Hiding `amdadlx64.dll` (for example on a non-AMD GPU host) leaves @@ -730,6 +727,29 @@ Expected result: - No other output of this section needs a daemon: `rocm dash` must not report a failed daemon connection. +### 4c. Dashboard Hero In A Short Terminal + +**Any platform.** The hero's row dropping is terminal layout, not a +Windows-specific path, so this reproduces on Linux and WSL too. + +Open a terminal about 22 to 24 rows tall — the VS Code panel is one — and +run: + +``` +rocm dash +``` + +Expected result: + +- The hero still shows utilization, VRAM, temperature and power. It never + renders as an empty box with only its "Node throughput · …" title. +- As the terminal gets shorter the hero loses rows from the bottom only: the + held legend first, then `T/S`. Enlarging it brings them back. +- With a model served whose figures are a scrape window old, the `*` held + marker and the `* = held (prior scrape window)` legend explaining it appear + and disappear together as the terminal is resized. A `*` on a reading with + no legend anywhere on screen is a bug; so is the legend with nothing marked. + ## 5. Reuse Is Exempt From The No-GPU Refusal **Linux or WSL only.** Unlike the rest of this file, the commands below are From 7d052fb0ee055f7bfe614dfa534418f488bcfdf9 Mon Sep 17 00:00:00 2001 From: Roman Sirokov Date: Thu, 5 Nov 2026 11:57:19 +0200 Subject: [PATCH 7/8] test(dash-tui): pin the hero's row drop order, not three labels hero_keeps_its_readings_in_a_short_terminal swept heights 12..=18 but asserted only GPU UTILIZATION, VRAM and TEMP -- the three rows that survive at 12. POWER first appears at 13 and T/S at 15, so neither was covered anywhere, even though the commit message, docs 4c and ROCMAI-861's acceptance criteria all promise power survives the squeeze. A regression confined to the POWER slot stayed green. Assert the invariant instead: the visible rows must form a prefix of the top-down list, so a row is missing only when every row below it is too. That covers POWER and T/S without naming the height each appears at, which would drift as the layout changes. A roomy-hero check keeps it from passing on a card that renders nothing. Verified by zeroing hero_rows' slot 3: the new test fails with "dropped POWER but kept a row below it", where the old assertions passed. Signed-off-by: Roman Sirokov --- crates/rocm-dash-tui/src/ui/tabs/home.rs | 43 +++++++++++++++++------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/crates/rocm-dash-tui/src/ui/tabs/home.rs b/crates/rocm-dash-tui/src/ui/tabs/home.rs index f53be9ffc9..a2513755b4 100644 --- a/crates/rocm-dash-tui/src/ui/tabs/home.rs +++ b/crates/rocm-dash-tui/src/ui/tabs/home.rs @@ -1020,19 +1020,38 @@ mod tests { } #[test] - fn hero_keeps_its_readings_in_a_short_terminal() { - // A ~22-row terminal leaves the Home tab ~14 rows, which squeezes the - // hero card below the six rows its columns ask for. The readings must - // still draw (the bottom rows go first), not leave an empty card. + fn hero_drops_only_its_lowest_rows_in_a_short_terminal() { + // A ~22-row terminal leaves the Home tab fewer rows than the six the + // hero's columns ask for. The readings must still draw, and they must + // go bottom-first: at every height the visible rows form a prefix of + // this list, so one is missing only when all below it are too. That is + // the promise docs/manual-testing.md 4c makes, pinned without naming + // the height each row happens to appear at (POWER at 13, T/S at 15 — + // thresholds that would otherwise drift silently). let s = state_with_gpu(); - for h in 12u16..=18 { - let out = render(&s, 72, h); - for label in ["GPU UTILIZATION", "VRAM", "TEMP"] { - assert!( - out.contains(label), - "{label} missing from the hero at height {h}:\n{out}" - ); - } + let top_down = ["VRAM", "TEMP", "POWER", "T/S"]; + for h in 8u16..=24 { + let out = render(&s, 160, h); + assert!( + out.contains("GPU UTILIZATION"), + "the hero must never render as an empty card, at height {h}:\n{out}" + ); + let present: Vec = top_down.iter().map(|l| out.contains(l)).collect(); + let kept = present.iter().take_while(|p| **p).count(); + assert!( + present[kept..].iter().all(|p| !*p), + "the hero dropped {} but kept a row below it, at height {h}:\n{out}", + top_down[kept] + ); + } + // Without this the prefix check above would pass on a hero that + // renders none of these rows at any height. + let roomy = render(&s, 160, 24); + for label in top_down { + assert!( + roomy.contains(label), + "{label} missing from a hero with room for it:\n{roomy}" + ); } } From 3907b0038ce846b9f91228d960d00c36163acf06 Mon Sep 17 00:00:00 2001 From: Roman Sirokov Date: Mon, 9 Nov 2026 13:29:49 +0200 Subject: [PATCH 8/8] fix(dash): drop an unreachable legend term, and make manual-test 4c runnable Review round on #914. - `tpw.is_some() &&` in the held-legend gate was unreachable-false: `any_tpw_held` already requires an instance with a finite `tokens_per_watt`, and `instance_aggregate` folds exactly those over the same `state.instances` set. Removed rather than left reading as a real second condition. - Manual-test 4c asked the tester to watch the held marker and its legend appear and disappear together, at 22 to 24 rows. The legend is the first row the hero drops and the marker is gated on the legend fitting, so at that height neither is on screen and there is nothing to compare. The step now starts tall and shrinks past the drop. Signed-off-by: Roman Sirokov --- crates/rocm-dash-tui/src/ui/tabs/home.rs | 13 +++++++++---- docs/manual-testing.md | 11 +++++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/crates/rocm-dash-tui/src/ui/tabs/home.rs b/crates/rocm-dash-tui/src/ui/tabs/home.rs index a2513755b4..d21b048765 100644 --- a/crates/rocm-dash-tui/src/ui/tabs/home.rs +++ b/crates/rocm-dash-tui/src/ui/tabs/home.rs @@ -392,10 +392,15 @@ fn draw_hero_left(f: &mut Frame, area: Rect, state: &AppState, theme: &Theme) { lh[4], ); // Show the shared HELD_LEGEND only when the tok/W aggregate is actually - // held AND rendered with a marker — `tpw.is_some()` mirrors the gate on - // `tpw_label` above so an unmeasured aggregate (which prints - // "tokens / watt —" with no marker) never shows an unexplained legend. - if tpw.is_some() && any_tpw_held { + // held, so an unmeasured aggregate (which prints "tokens / watt —" with no + // marker) never shows an unexplained legend. + // + // `any_tpw_held` already implies `tpw.is_some()`: it requires some instance + // with a finite `tokens_per_watt`, and `instance_aggregate` folds exactly + // those into `Some` over the same `state.instances` set. The extra + // `tpw.is_some() &&` term was unreachable-false, so it is gone rather than + // left to read as a real second condition. + if any_tpw_held { f.render_widget( Paragraph::new(Line::from(Span::styled( format::HELD_LEGEND, diff --git a/docs/manual-testing.md b/docs/manual-testing.md index 5f7f39587c..5392823e09 100644 --- a/docs/manual-testing.md +++ b/docs/manual-testing.md @@ -747,8 +747,15 @@ Expected result: held legend first, then `T/S`. Enlarging it brings them back. - With a model served whose figures are a scrape window old, the `*` held marker and the `* = held (prior scrape window)` legend explaining it appear - and disappear together as the terminal is resized. A `*` on a reading with - no legend anywhere on screen is a bug; so is the legend with nothing marked. + and disappear **together** as the terminal is resized. A `*` on a reading + with no legend anywhere on screen is a bug; so is the legend with nothing + marked. + + Check this one by **starting tall and shrinking**, not at the 22-to-24 rows + above. The legend is the first row the hero drops, and the marker is gated on + the legend fitting — so at 22 to 24 rows neither is on screen and there is + nothing to compare. Start around 30 rows, confirm both are present, then + shrink past the drop and confirm both go at once. ## 5. Reuse Is Exempt From The No-GPU Refusal