GUI round 11 (batch 1): default columns, control-board split cleanup, Stock/Env fixes, relative sort, consistent zebra + focus-dimming, hashboard/light dots, access icon
build-test-release / release (push) Failing after 10m39s

Table/model (Rust):
- #12: default columns are now IP, Model, Errors, Hashrate, Power, Chip temp,
  Firmware, CPU, Boards, Access, in that display order (initial ViewState and the
  built-in "Default" preset both updated).
- #14: removed the Control board column (CPU + Board replace it); the underlying
  control-board string stays on MinerRow for the SSH PIC probe.
- #6 (part 1): firmware family strips the vendor word asic-rs prepends on stock
  firmware ("AntMiner Stock" -> "Stock"), moving it into FW Version.
- #17: air-cooled miners' ambient reading routes to a new "Env temp" column
  instead of "Fluid temp" (asic-rs reports ambient in its fluid field and has no
  cooling-type flag; cooling type is inferred from the model name).
- #16: relative-hashrate (actual/expected) sort -- the Hashrate header cycles
  absolute-asc/desc then relative-asc/desc, with right-click menu entries;
  HashrateRel is a sort-only pseudo-column.

Rendering (wx-rs SegmentRenderer bridge, mirrored to patches/0003 per ADR 0003):
- #3: the per-row zebra background now fills the whole column-wide cell (wx
  shrinks a custom renderer's rect to the content size, so the earlier fill
  covered only the text; Render now fills GetOwner()->GetWidth() and wxGTK clips
  it to the cell).
- #1/#7: uncoloured segments (combined-cell slashes, "Stock" firmware) take the
  tree widget's themed text colour at its live GTK state, so they dim on
  window-backdrop like the native cells.
- #10: the Boards column renders per-hashboard status dots (green hashing / red
  faulted / grey undetected, board 1 rightmost); the Light column renders a
  yellow locate dot while flashing.
- #13: the Access column renders a padlock icon (green open = writable, red
  closed = view-only) instead of "locked"/"unlocked" text.

Shapes draw from control-char sentinels (never emoji/pictographs), font-
independent. Self-test verifies the icon columns structurally. 82 unit tests
pass.

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-18 17:24:09 -06:00
co-authored by Claude Opus 4.8
parent 86638e870f
commit f87e519959
8 changed files with 595 additions and 84 deletions
+122 -29
View File
@@ -78,6 +78,10 @@ const ID_HDR_SORT_DESC: i32 = 761;
const ID_HDR_HIDE: i32 = 762;
const ID_HDR_AUTOSIZE: i32 = 763;
const ID_HDR_COLUMNS: i32 = 764;
// Relative-hashrate (actual/expected) sort, offered on the Hashrate header only
// (round 11 #16).
const ID_HDR_SORT_REL_ASC: i32 = 765;
const ID_HDR_SORT_REL_DESC: i32 = 766;
// Ticks (~seconds) to keep an action's result on the status bar before the
// idle/countdown status takes over again.
const ACTION_RESULT_TICKS: u8 = 8;
@@ -232,6 +236,55 @@ fn encode_flag_cell(plain: &str, color: Option<(u8, u8, u8)>) -> String {
encode_segments(&[(color, plain.to_string())])
}
/// Shape-sentinel strings the SegmentRenderer draws as small vector icons rather
/// than text (round 11 #10/#13). These byte values MUST match the SHAPE_* set in
/// widgets_bridge.cpp. They are control characters, never emoji/pictographs.
const SHAPE_DOT: &str = "\u{0007}";
const SHAPE_LOCK: &str = "\u{0002}";
const SHAPE_UNLOCK: &str = "\u{0003}";
/// Boards column: one status dot per hashboard (round 11 #10). Board 1 is the
/// rightmost dot, so boards render high-position-first (left to right). green =
/// present and hashing, red = present but idle/faulty, grey = not detected.
fn encode_board_dots(pal: &Palette, status: &[crate::model::BoardHealth]) -> String {
use crate::model::BoardHealth;
if status.is_empty() {
return encode_segments(&[(None, String::new())]);
}
let segs: Vec<(Option<(u8, u8, u8)>, String)> = status
.iter()
.rev()
.map(|h| {
let color = match h {
BoardHealth::Ok => pal.green,
BoardHealth::Fault => pal.red,
BoardHealth::Missing => pal.label,
};
(Some(color), SHAPE_DOT.to_string())
})
.collect();
encode_segments(&segs)
}
/// Access column: a green open padlock (writable) or red closed padlock
/// (view-only); blank when the lock state is unknown (round 11 #13).
fn encode_access_icon(pal: &Palette, write_locked: Option<bool>) -> String {
match write_locked {
Some(true) => encode_segments(&[(Some(pal.red), SHAPE_LOCK.to_string())]),
Some(false) => encode_segments(&[(Some(pal.green), SHAPE_UNLOCK.to_string())]),
None => encode_segments(&[(None, String::new())]),
}
}
/// Light column: a yellow dot while the miner's locate light is flashing, else
/// blank (round 11 #10).
fn encode_light_dot(pal: &Palette, flashing: Option<bool>) -> String {
match flashing {
Some(true) => encode_segments(&[(Some(pal.amber), SHAPE_DOT.to_string())]),
_ => encode_segments(&[(None, String::new())]),
}
}
/// Build the segment-encoded cell text for the Cooling column: each fan's RPM
/// gets its own grey-to-blue colour by speed, and the "/" separators between
/// them stay in the default text colour.
@@ -703,7 +756,7 @@ impl App {
Some((sc, false)) if sc == c => title.push_str(" v"),
_ => {}
}
if matches!(c, Column::Hashrate | Column::Hashboards | Column::TotalChips | Column::ChipTemp | Column::Cooling | Column::Locked | Column::Error | Column::Status | Column::Firmware) {
if matches!(c, Column::Hashrate | Column::Hashboards | Column::TotalChips | Column::ChipTemp | Column::Cooling | Column::Locked | Column::Light | Column::Error | Column::Status | Column::Firmware) {
// 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.
@@ -756,17 +809,8 @@ impl App {
.flatten();
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, actual, expected, " / ", ratio)
}
// Boards column: per-hashboard health dots (round 11 #10).
Column::Hashboards => encode_board_dots(&self.pal, &r.board_status),
Column::TotalChips => {
let actual = r.total_chips.map(|v| v.to_string());
let expected = r.expected_chips.map(|v| v.to_string());
@@ -780,15 +824,11 @@ impl App {
}
Column::ChipTemp => encode_board_temps_cell(&self.pal, &r.board_temps, r.chip_temp_c),
Column::Cooling => encode_cooling_cell(&self.pal, &r.fan_rpms),
Column::Locked => {
// green = unlocked/writable, red = locked/view-only.
let color = match r.write_locked {
Some(true) => Some(self.pal.red),
Some(false) => Some(self.pal.green),
None => None,
};
encode_flag_cell(&c.cell(r), color)
}
// Access column: a padlock icon, green open (writable) / red
// closed (view-only) (round 11 #13).
Column::Locked => encode_access_icon(&self.pal, r.write_locked),
// Light column: a yellow locate dot while flashing (round 11 #10).
Column::Light => encode_light_dot(&self.pal, r.light_flashing),
Column::Error => {
let color = (!r.errors.is_empty()).then_some(self.pal.red);
encode_flag_cell(&c.cell(r), color)
@@ -1304,9 +1344,8 @@ impl App {
/// actions (power limit / tuning %) return a prompt dialog to show modally.
fn on_menu_item(&mut self, id: i32) -> Option<Widget> {
match id {
ID_HDR_SORT_ASC | ID_HDR_SORT_DESC | ID_HDR_HIDE | ID_HDR_AUTOSIZE | ID_HDR_COLUMNS => {
return self.on_header_menu(id)
}
ID_HDR_SORT_ASC | ID_HDR_SORT_DESC | ID_HDR_SORT_REL_ASC | ID_HDR_SORT_REL_DESC
| ID_HDR_HIDE | ID_HDR_AUTOSIZE | ID_HDR_COLUMNS => return self.on_header_menu(id),
ID_CTX_OPEN => {
for ip in self.selected_ip_list() {
wx_rs::launch_browser(&format!("http://{ip}"));
@@ -1930,10 +1969,23 @@ impl App {
return;
}
let col = cols[creation_idx];
self.view.sort = match self.view.sort {
Some((c, true)) if c == col => Some((col, false)),
Some((c, false)) if c == col => None,
_ => Some((col, true)),
self.view.sort = if col == Column::Hashrate {
// The Hashrate header cycles through four modes: absolute asc, absolute
// desc, relative (actual/expected) asc, relative desc, then unsorted
// (round 11 #16).
match self.view.sort {
Some((Column::Hashrate, true)) => Some((Column::Hashrate, false)),
Some((Column::Hashrate, false)) => Some((Column::HashrateRel, true)),
Some((Column::HashrateRel, true)) => Some((Column::HashrateRel, false)),
Some((Column::HashrateRel, false)) => None,
_ => Some((Column::Hashrate, true)),
}
} else {
match self.view.sort {
Some((c, true)) if c == col => Some((col, false)),
Some((c, false)) if c == col => None,
_ => Some((col, true)),
}
};
// Update the header marker in place + re-sort rows. Avoids destroying and
// recreating the whole control on every sort click (janky on big fleets).
@@ -1951,6 +2003,12 @@ impl App {
let menu = Widget::menu_new();
menu.menu_append(ID_HDR_SORT_ASC, &format!("Sort {} ascending", col.title()));
menu.menu_append(ID_HDR_SORT_DESC, &format!("Sort {} descending", col.title()));
// The Hashrate column also offers a relative (actual/expected) sort
// (round 11 #16).
if col == Column::Hashrate {
menu.menu_append(ID_HDR_SORT_REL_ASC, "Sort relative hashrate ascending");
menu.menu_append(ID_HDR_SORT_REL_DESC, "Sort relative hashrate descending");
}
menu.menu_append_separator();
menu.menu_append(ID_HDR_AUTOSIZE, "Auto-size this column");
// The fixed IP column can't be hidden.
@@ -1976,6 +2034,16 @@ impl App {
self.update_headers();
self.fill_rows();
}
ID_HDR_SORT_REL_ASC => {
self.view.sort = Some((Column::HashrateRel, true));
self.update_headers();
self.fill_rows();
}
ID_HDR_SORT_REL_DESC => {
self.view.sort = Some((Column::HashrateRel, false));
self.update_headers();
self.fill_rows();
}
ID_HDR_HIDE if !self.view.is_fixed(col) => {
self.view.visible.remove(&col);
self.rebuild_table();
@@ -2002,6 +2070,11 @@ impl App {
match self.view.sort {
Some((sc, true)) if sc == *c => title.push_str(" ^"),
Some((sc, false)) if sc == *c => title.push_str(" v"),
// The relative-hashrate sort is a pseudo-column; mark it on the
// Hashrate header with a "%" so the mode is visible (round 11 #16).
Some((Column::HashrateRel, asc)) if *c == Column::Hashrate => {
title.push_str(if asc { " %^" } else { " %v" })
}
_ => {}
}
t.dvlc_set_col_title(i, &title);
@@ -2731,9 +2804,15 @@ impl App {
for (disp_row, &ri) in self.view_idx.iter().enumerate() {
let r = &self.rows[ri];
for (j, c) in cols.iter().enumerate() {
// Icon/dot columns (round 11 #10/#13) render shape sentinels, not
// text, so they don't round-trip to c.cell(r); they're verified
// structurally in the icon-column spot-check below.
if matches!(c, Column::Hashboards | Column::Locked | Column::Light) {
continue;
}
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::ChipTemp | Column::Cooling | Column::Locked | Column::Error | Column::Status | Column::Firmware) {
let got = if matches!(c, Column::Hashrate | Column::TotalChips | Column::ChipTemp | Column::Cooling | Column::Error | Column::Status | Column::Firmware) {
decode_segments_plain(&raw)
} else {
raw
@@ -2764,6 +2843,20 @@ impl App {
None => String::new(),
}
};
// Icon columns (round 11 #10/#13): the store carries shape sentinels
// (dots / padlock), not text -- verify they are present.
let boards_col = cols.iter().position(|c| *c == Column::Hashboards);
let access_col = cols.iter().position(|c| *c == Column::Locked);
if let (Some(bc), Some(row)) = (boards_col, find("10.255.1.166")) {
let raw = t.dvlc_get_cell(row, bc).unwrap_or_default();
check("Boards column renders dot sentinels for a mining miner",
raw.contains('\u{0007}'), format!("cell={raw:?}"));
}
if let (Some(ac), Some(row)) = (access_col, find("10.255.1.112")) {
let raw = t.dvlc_get_cell(row, ac).unwrap_or_default();
check("Access column renders a closed-padlock sentinel for a locked miner",
raw.contains('\u{0002}'), format!("cell={raw:?}"));
}
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)));