GUI round 8a: no phantom-offline rows, hashrate/temp conditional formatting, multi-range parse, uniform KPI cards
build-test-release / release (push) Successful in 10m18s

First slice of the round-8 batch (Linux; Windows/macOS builds deferred to a
dedicated platform round per the design discussion). Feature/format changes
with no C++ bridge dependency; the bridge-dependent items (scroll-hold, zebra +
default-colour rework, header menu, rubber-band select, tooltips, presets,
frozen columns, plus the new asic-rs columns) follow in 8b/8c.

- Offline recognition (reverses the round-6 interpretation): the scanner no
  longer fabricates a row for an address with no miner. Only miners that
  actually respond become rows; a responding non-mining miner is "not hashing".
  Removed the MinerRow.offline field, MinerRow::offline(), the "offline" status,
  and the synthetic fixture/fake-scan offline rows. The bench fleet is now 9
  rows (was 10); KPI not-hashing is 1.
- Hashrate conditional format: the scale now bottoms out at 50% (full red at
  <=50% of expected, amber at 75%, green at 100%+), matching "green = 100%,
  red = 50% or lower".
- Hashrate cell format: prefix-only unit, no space, no spaces around the slash
  (e.g. "60.0T/200T", "80.5T/95.0T") instead of "60.0 TH/s / 200 TH/s". The
  combined-cell encoder now builds from formatted parts rather than re-splitting
  a joined string on " / ", so hashrate ("/") and count columns (" / ") each
  keep their own separator.
- Chip temperature: new blue-to-red conditional scale (cool blue at/below 40 C
  to hot red at/above 90 C); the Chip temp column is now a coloured cell.
- Multi-range scan input: each octet may be a range, so "10.1-9.1.1-255" expands
  to the 9 /24s (cartesian per-octet parse). CIDR / full-range / short-range
  forms are preserved.
- KPI header: every card is now a uniform size with its value + label centred.
- Right-click menu: "Fault light on/off" relabelled to "Flash lights on/off"
  (the underlying asic-rs set_fault_light call is unchanged).

Tests updated for the new formats/counts; new unit tests for the 50%-100% ratio
scale, the blue-to-red temp scale, the parts-based combined encoder, and the
per-octet range parser. cargo check --release --tests is clean; CI runs the
release build + tests + headless self-test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y8h447BPyJR4fioYZvQ9bh
This commit is contained in:
2026-09-17 16:26:19 -06:00
co-authored by Claude Opus 4.8
parent cdd605c189
commit 9dc4e25a28
4 changed files with 268 additions and 204 deletions
+116 -65
View File
@@ -100,10 +100,11 @@ fn tint_toward(base: (u8, u8, u8), target: (u8, u8, u8), f: f64) -> (u8, u8, u8)
}
/// Colour for a combined actual/expected ratio (Hashrate/Hashboards/
/// TotalChips): red at 0, amber at 0.5, green at 1.0+, clamped and
/// interpolated linearly between those stops.
/// TotalChips): full red at 50% (or below), amber at 75%, green at 100%+,
/// interpolated linearly -- calibrated so a miner running at half its expected
/// output reads as clearly bad, and 100% reads green.
fn ratio_color(pal: &Palette, ratio: f64) -> (u8, u8, u8) {
let t = ratio.clamp(0.0, 1.0);
let t = ((ratio - 0.5) / 0.5).clamp(0.0, 1.0);
if t <= 0.5 {
tint_toward(pal.red, pal.amber, t / 0.5)
} else {
@@ -111,6 +112,12 @@ fn ratio_color(pal: &Palette, ratio: f64) -> (u8, u8, u8) {
}
}
/// Colour for a chip-temperature reading: cool blue at/below 40 C fading to hot
/// red at/above 90 C, so a hot miner reads red at a glance.
fn temp_color(pal: &Palette, temp_c: f64) -> (u8, u8, u8) {
tint_toward(pal.accent, pal.red, ((temp_c - 40.0) / 50.0).clamp(0.0, 1.0))
}
/// Colour for one cooling-fan RPM: muted grey (stopped/unknown) fading to
/// accent blue as the RPM approaches 6000 (comfortably above a healthy fan's
/// typical ceiling, so a spinning fan reads as a clear, saturated blue).
@@ -118,21 +125,37 @@ fn fan_color(pal: &Palette, rpm: f64) -> (u8, u8, u8) {
tint_toward(pal.label, pal.accent, (rpm / 6000.0).clamp(0.0, 1.0))
}
/// Build the segment-encoded cell text for a combined actual/expected column
/// (Hashrate/Hashboards/TotalChips): when both halves are known (`plain`
/// contains " / " and a ratio was computable), colour just the actual half by
/// how it compares to expected and leave the separator + expected half in the
/// default colour. Anything else (blank, actual-only, or no ratio) falls back
/// to one plain, uncoloured segment so the encoding always round-trips to the
/// same text `decode_segments_plain` would read back.
fn encode_combined_cell(pal: &Palette, plain: &str, ratio: Option<f64>) -> String {
match (plain.split_once(" / "), ratio) {
(Some((actual, expected)), Some(ratio)) => encode_segments(&[
(Some(ratio_color(pal, ratio)), actual.to_string()),
(None, " / ".to_string()),
(None, expected.to_string()),
/// Build the segment-encoded cell for a combined actual/expected column
/// (Hashrate/Hashboards/TotalChips) from its already-formatted parts: the
/// actual half is coloured by `ratio` when both halves are known, the separator
/// `sep` and the expected half stay the default text colour, and an unknown
/// actual shows "-". Round-trips (via decode_segments_plain) to the same plain
/// text the model's combined cell produces.
fn encode_combined_cell(
pal: &Palette,
actual: Option<String>,
expected: Option<String>,
sep: &str,
ratio: Option<f64>,
) -> String {
match (actual, expected) {
(None, None) => encode_segments(&[(None, String::new())]),
(Some(a), None) => encode_segments(&[(None, a)]),
(a, Some(e)) => encode_segments(&[
(ratio.map(|r| ratio_color(pal, r)), a.unwrap_or_else(|| "-".to_string())),
(None, sep.to_string()),
(None, e),
]),
_ => encode_segments(&[(None, plain.to_string())]),
}
}
/// Segment-encoded Chip-temp cell: the reading coloured on the blue-to-red
/// temperature scale (blank cell stays blank).
fn encode_temp_cell(pal: &Palette, plain: &str, temp_c: f64) -> String {
if plain.is_empty() {
encode_segments(&[(None, String::new())])
} else {
encode_segments(&[(Some(temp_color(pal, temp_c)), plain.to_string())])
}
}
@@ -199,7 +222,7 @@ fn kind_color(pal: &Palette, k: ColorKind) -> (u8, u8, u8) {
/// what each status "looks like".
fn status_kind_color(pal: &Palette, status: &str) -> (u8, u8, u8) {
match status {
"offline" | "not hashing" => pal.red,
"not hashing" => pal.red,
"paused" => pal.accent,
"slow" => pal.amber,
"hashing" => pal.green,
@@ -208,8 +231,8 @@ fn status_kind_color(pal: &Palette, status: &str) -> (u8, u8, u8) {
}
/// A miner row's text colour, by status: green = hashing, amber = slow, blue =
/// paused, red = offline/not hashing. This both conveys status and separates
/// rows visually (GTK's native zebra/alt-row support is unreliable and fights
/// paused, red = not hashing. This both conveys status and separates rows
/// visually (GTK's native zebra/alt-row support is unreliable and fights
/// selection).
fn status_color(pal: &Palette, r: &MinerRow) -> (u8, u8, u8) {
status_kind_color(pal, r.status())
@@ -343,6 +366,8 @@ pub fn build(frame: Widget) -> App {
let vc = kind_color(&pal, kind);
let card = Widget::panel(panel);
card.set_bg(pal.card_bg.0, pal.card_bg.1, pal.card_bg.2);
// Uniform size so every KPI box is identical regardless of its content.
card.set_min_size(128, 62);
let cs = Widget::box_sizer(true);
let value = Widget::static_text(card, "0");
value.set_font_size(19);
@@ -353,10 +378,21 @@ pub fn build(frame: Widget) -> App {
lbl.set_font_size(9);
lbl.set_fg(pal.label.0, pal.label.1, pal.label.2);
lbl.set_bg(pal.card_bg.0, pal.card_bg.1, pal.card_bg.2);
cs.add(value, 0, sf::BORDER_LEFT | sf::BORDER_TOP | sf::BORDER_RIGHT, 12);
cs.add(lbl, 0, sf::BORDER_LEFT | sf::BORDER_BOTTOM | sf::BORDER_RIGHT, 12);
// Centre both texts horizontally: a stretch spacer on each side (no
// ALIGN_CENTRE_HORIZONTAL flag exists in the bridge).
let centre = |w: Widget| {
let row = Widget::box_sizer(false);
row.add_stretch(1);
row.add(w, 0, sf::ALIGN_CENTRE_VERTICAL, 0);
row.add_stretch(1);
row
};
cs.add_stretch(1);
cs.add_sizer(centre(value), 0, sf::EXPAND | sf::BORDER_LEFT | sf::BORDER_TOP | sf::BORDER_RIGHT, 8);
cs.add_sizer(centre(lbl), 0, sf::EXPAND | sf::BORDER_LEFT | sf::BORDER_BOTTOM | sf::BORDER_RIGHT, 8);
cs.add_stretch(1);
cs.set_sizer_on(card);
kpi_row.add(card, 1, sf::EXPAND | sf::BORDER_ALL, 4);
kpi_row.add(card, 0, sf::BORDER_ALL, 4);
kpi_cards.push((card, value, lbl, kind));
(card, value)
};
@@ -521,7 +557,7 @@ impl App {
Some((sc, false)) if sc == c => title.push_str(" v"),
_ => {}
}
if matches!(c, Column::Hashrate | Column::Hashboards | Column::TotalChips | Column::Cooling) {
if matches!(c, Column::Hashrate | Column::Hashboards | Column::TotalChips | Column::ChipTemp | Column::Cooling) {
// These columns show two-tone / multi-tone text (actual vs.
// expected, or one colour per fan) via a custom renderer that
// parses the segment-encoded cell value fill_rows writes.
@@ -561,34 +597,40 @@ impl App {
let r = &self.rows[ri];
for (ci, c) in cols.iter().enumerate() {
let encoded = match c {
// Gate the ratio on the ACTUAL being known: an unknown actual
// (hashrate 0.0 sentinel / None count) renders as "- / <expected>"
// and must fall through to the plain, uncoloured segment rather
// than paint the "-" solid red as if the miner were at 0%.
// Combined columns are built from parts: the ratio is gated
// on the ACTUAL being known, so an unknown actual renders as
// "-/<expected>" in the default colour rather than a red 0%.
Column::Hashrate => {
let actual = format_hashrate_ths(r.hashrate_ths);
let expected = format_hashrate_ths(r.expected_ths);
let ratio = (r.hashrate_ths > 0.0)
.then(|| actual_expected_ratio(r.hashrate_ths, r.expected_ths))
.flatten();
encode_combined_cell(&self.pal, &c.cell(r), ratio)
encode_combined_cell(&self.pal, actual, expected, "/", ratio)
}
Column::Hashboards => {
let actual = r.hashboards.map(|v| v.to_string());
let expected = r.expected_hashboards.map(|v| v.to_string());
let ratio = r.hashboards.and_then(|a| {
actual_expected_ratio(
a as f64,
r.expected_hashboards.map(|v| v as f64).unwrap_or(0.0),
)
});
encode_combined_cell(&self.pal, &c.cell(r), ratio)
encode_combined_cell(&self.pal, actual, expected, " / ", ratio)
}
Column::TotalChips => {
let actual = r.total_chips.map(|v| v.to_string());
let expected = r.expected_chips.map(|v| v.to_string());
let ratio = r.total_chips.and_then(|a| {
actual_expected_ratio(
a as f64,
r.expected_chips.map(|v| v as f64).unwrap_or(0.0),
)
});
encode_combined_cell(&self.pal, &c.cell(r), ratio)
encode_combined_cell(&self.pal, actual, expected, " / ", ratio)
}
Column::ChipTemp => encode_temp_cell(&self.pal, &c.cell(r), r.chip_temp_c),
Column::Cooling => encode_cooling_cell(&self.pal, &r.fan_rpms),
_ => continue,
};
@@ -712,8 +754,8 @@ impl App {
if !caps.is_empty() {
let sfx = if n == 1 { String::new() } else { format!(" ({n})") };
if caps.fault_light {
menu.menu_append(ID_CTX_LIGHT_ON, &format!("Fault light on{sfx}"));
menu.menu_append(ID_CTX_LIGHT_OFF, &format!("Fault light off{sfx}"));
menu.menu_append(ID_CTX_LIGHT_ON, &format!("Flash lights on{sfx}"));
menu.menu_append(ID_CTX_LIGHT_OFF, &format!("Flash lights off{sfx}"));
}
if caps.pause {
menu.menu_append(ID_CTX_PAUSE, &format!("Pause mining{sfx}"));
@@ -837,7 +879,7 @@ impl App {
Err(e) => wx_rs::set_status_text(&format!("failed to read firmware image: {e}")),
}
}
// Fault light is harmless -> apply immediately.
// Flashing the identify light is harmless -> apply immediately.
ID_CTX_LIGHT_ON => self.start_action(self.selected_ip_list(), scan::ConfigAction::FaultLight(true)),
ID_CTX_LIGHT_OFF => self.start_action(self.selected_ip_list(), scan::ConfigAction::FaultLight(false)),
// Disruptive to running hardware -> confirm first.
@@ -1979,10 +2021,10 @@ impl App {
// 1. KPI values: independent, hand-computed from the fixtures. The
// labels are static; the value widgets carry the numbers.
let want_kpis = [
(self.kpi_total, "Total", "10"),
(self.kpi_total, "Total", "9"),
(self.kpi_hashing, "Hashing", "6"),
(self.kpi_slow, "Slow", "1"),
(self.kpi_not, "Not hashing", "2"),
(self.kpi_not, "Not hashing", "1"),
(self.kpi_paused, "Paused", "1"),
(self.kpi_hashrate, "Hashrate", "685 TH/s"),
(self.kpi_power, "Est. power", "21.3 kW"),
@@ -2000,8 +2042,8 @@ impl App {
// 2. Row count in the store matches the (unfiltered) fixture count.
let want_rows = self.view_idx.len();
check("table row count == 10",
t.dvlc_row_count() == 10 && want_rows == 10,
check("table row count == 9",
t.dvlc_row_count() == 9 && want_rows == 9,
format!("store={}, view={}", t.dvlc_row_count(), want_rows));
// 3. Every store cell equals what the model produced for that row/col
@@ -2014,7 +2056,7 @@ impl App {
for (j, c) in cols.iter().enumerate() {
let want = c.cell(r);
let raw = t.dvlc_get_cell(disp_row, j).unwrap_or_default();
let got = if matches!(c, Column::Hashrate | Column::Hashboards | Column::TotalChips | Column::Cooling) {
let got = if matches!(c, Column::Hashrate | Column::Hashboards | Column::TotalChips | Column::ChipTemp | Column::Cooling) {
decode_segments_plain(&raw)
} else {
raw
@@ -2048,8 +2090,8 @@ impl App {
if let (Some(row), Some(_)) = (find("10.255.1.149"), status_col) {
check("S21 Pro (.149) is slow", cell(row, status_col) == "slow",
format!("status=\"{}\"", cell(row, status_col)));
check("S21 Pro (.149) hashrate == 60.0 TH/s / 200 TH/s",
cell(row, hr_col) == "60.0 TH/s / 200 TH/s",
check("S21 Pro (.149) hashrate == 60.0T/200T",
cell(row, hr_col) == "60.0T/200T",
format!("hashrate=\"{}\"", cell(row, hr_col)));
} else {
check("S21 Pro (.149) present", false, "row not found".into());
@@ -2068,16 +2110,6 @@ impl App {
} else {
check("WardenOS-dev (.115) present", false, "row not found".into());
}
// The synthetic unreachable row must classify as offline with a blank
// hashrate (round-6 offline-recognition path).
if let Some(row) = find("10.255.1.199") {
check("offline row (.199) is offline", cell(row, status_col) == "offline",
format!("status=\"{}\"", cell(row, status_col)));
check("offline row (.199) blank hashrate", cell(row, hr_col).is_empty(),
format!("hashrate=\"{}\"", cell(row, hr_col)));
} else {
check("offline row (.199) present", false, "row not found".into());
}
check("IP is the first column", ip_col == Some(0),
format!("ip col index = {ip_col:?}"));
// default view is IP-ascending -- compare against the model's own
@@ -2177,13 +2209,24 @@ mod tests {
#[test]
fn ratio_color_stops_and_clamping() {
let p = test_pal();
assert_eq!(ratio_color(&p, 0.0), p.red, "0% -> red");
assert_eq!(ratio_color(&p, 0.5), p.amber, "50% -> amber");
// Scale bottoms out at 50%: red at/below 0.5, amber at 0.75, green at 1.0+.
assert_eq!(ratio_color(&p, 0.5), p.red, "50% -> full red");
assert_eq!(ratio_color(&p, 0.25), p.red, "below 50% -> still full red");
assert_eq!(ratio_color(&p, 0.75), p.amber, "75% -> amber");
assert_eq!(ratio_color(&p, 1.0), p.green, "100% -> green");
assert_eq!(ratio_color(&p, -3.0), p.red, "clamped below 0");
assert_eq!(ratio_color(&p, 9.0), p.green, "clamped above 1 (overperforming -> green)");
}
#[test]
fn temp_color_blue_to_red_scale() {
let p = test_pal();
assert_eq!(temp_color(&p, 40.0), p.accent, "cool -> blue");
assert_eq!(temp_color(&p, 20.0), p.accent, "clamped below 40 C");
assert_eq!(temp_color(&p, 90.0), p.red, "hot -> red");
assert_eq!(temp_color(&p, 110.0), p.red, "clamped above 90 C");
assert_eq!(temp_color(&p, 65.0), tint_toward(p.accent, p.red, 0.5), "midpoint blend");
}
#[test]
fn fan_color_grey_to_blue_scale() {
let p = test_pal();
@@ -2196,22 +2239,30 @@ mod tests {
#[test]
fn combined_cell_unknown_actual_is_not_coloured_red() {
let p = test_pal();
// Unknown actual ("-") with no ratio must take the plain, uncoloured
// branch -- not paint the "-" solid red as a 0% miner would be.
let unknown = encode_combined_cell(&p, "- / 200 TH/s", None);
assert_eq!(unknown, encode_segments(&[(None, "- / 200 TH/s".to_string())]));
assert_eq!(decode_segments_plain(&unknown), "- / 200 TH/s");
// Unknown actual with a known expected shows "-" in the DEFAULT colour
// (no ratio) -- not a red 0%. Hashrate uses a no-space "/" separator.
let unknown = encode_combined_cell(&p, None, Some("200T".to_string()), "/", None);
assert_eq!(
unknown,
encode_segments(&[(None, "-".to_string()), (None, "/".to_string()), (None, "200T".to_string())])
);
assert_eq!(decode_segments_plain(&unknown), "-/200T");
// A known ratio colours only the actual half; the slash + expected stay
// uncoloured, and it still round-trips to the same plain text.
let known = encode_combined_cell(&p, "60.0 TH/s / 200 TH/s", Some(0.3));
// the default colour, and it round-trips to the plain "actual/expected".
let known =
encode_combined_cell(&p, Some("60.0T".to_string()), Some("200T".to_string()), "/", Some(0.3));
let expected = encode_segments(&[
(Some(ratio_color(&p, 0.3)), "60.0 TH/s".to_string()),
(None, " / ".to_string()),
(None, "200 TH/s".to_string()),
(Some(ratio_color(&p, 0.3)), "60.0T".to_string()),
(None, "/".to_string()),
(None, "200T".to_string()),
]);
assert_eq!(known, expected);
assert_eq!(decode_segments_plain(&known), "60.0 TH/s / 200 TH/s");
assert_eq!(decode_segments_plain(&known), "60.0T/200T");
// Actual-only (no expected) is a single uncoloured segment.
let actual_only = encode_combined_cell(&p, Some("95.0T".to_string()), None, "/", None);
assert_eq!(decode_segments_plain(&actual_only), "95.0T");
}
#[test]