From 4318c30912e164775d248303a8780e914d716fa8 Mon Sep 17 00:00:00 2001 From: noah Date: Tue, 22 Sep 2026 16:52:24 -0600 Subject: [PATCH] ui: attribute hashboard faults + pools dialog + widths (round 18 #5/#8a/#8c) - #5 Antminer-hardware firmwares (stock/VNish/Braiins/LuxOS) report faults with no component, so a real per-board fault landed on the control-board tooltip instead of the board it names. messages_to_faults now recovers the board index from the self-describing message text ("Chain 2 ...", "hashboard 0 ...", "Slot 1 ...") so the issue shows on the right hashboard's tooltip. WhatsMiner (which does attribute HashBoard{idx}) is unchanged. - #8a The pools dialog is widened so the rightmost "+" preset buttons (Password column) are no longer clipped off a too-narrow dialog. - #8c The pool column headers now span field-width + the 34px "+" button, so the "Address/Account/Worker/Password" titles line up with the boxes below them. board_index unit test + SELFTEST pass. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01Djv3oncM4LxTS5tb61Ako6 --- crates/alkane-gui/src/scan.rs | 51 ++++++++++++++++++++++++++++++++++- crates/alkane-gui/src/ui.rs | 21 +++++++++------ 2 files changed, 63 insertions(+), 9 deletions(-) diff --git a/crates/alkane-gui/src/scan.rs b/crates/alkane-gui/src/scan.rs index 00a23659..441574da 100644 --- a/crates/alkane-gui/src/scan.rs +++ b/crates/alkane-gui/src/scan.rs @@ -478,6 +478,35 @@ fn summarize_messages(messages: &[asic_rs::core::data::message::MinerMessage]) - /// component (round 16 #1/#2/#3), so the Health column can colour and describe /// each icon from the actual per-component faults. Info-severity messages are /// dropped; Error and Warning are kept (only Error drives colour). +/// Best-effort hashboard index from a fault message that names a board (round 18 +/// #5). Only WhatsMiner's asic-rs backends attribute a message to a specific +/// `HashBoard { idx }`; every Antminer-hardware firmware (stock, VNish, Braiins, +/// LuxOS) builds messages with no component, so a real per-board fault would +/// otherwise land on the control-board (brain) tooltip instead of the board it +/// names. The message text is self-describing (e.g. "Chain 2 ... temperature"), +/// so pull the first integer after a board keyword and attribute the fault to that +/// board. Returns None when no board keyword is present. +fn board_index_from_text(text: &str) -> Option { + let lower = text.to_ascii_lowercase(); + // Longest/most-specific keywords first so "hashboard" wins over "board". + for kw in ["hashboard", "hash board", "chain", "slot", "board"] { + let mut from = 0; + while let Some(rel) = lower[from..].find(kw) { + let after = &lower[from + rel + kw.len()..]; + let digits: String = after + .trim_start_matches(|c: char| !c.is_ascii_digit()) + .chars() + .take_while(|c| c.is_ascii_digit()) + .collect(); + if let Ok(n) = digits.parse::() { + return Some(n); + } + from += rel + kw.len(); + } + } + None +} + fn messages_to_faults( messages: &[asic_rs::core::data::message::MinerMessage], ) -> Vec { @@ -500,7 +529,12 @@ fn messages_to_faults( Some(MinerComponent::ControlBoard {}) => FaultComponent::Control, Some(MinerComponent::Fan { idx }) => FaultComponent::Fan(*idx as usize), Some(MinerComponent::HashBoard { idx, .. }) => FaultComponent::Board(*idx as usize), - None => FaultComponent::Other, + // Unattributed (every Antminer-hardware firmware): recover a board + // index from the message text so hashboard faults show on the board + // they name, not the control-board tooltip (round 18 #5). + None => board_index_from_text(text) + .map(FaultComponent::Board) + .unwrap_or(FaultComponent::Other), }; Some(Fault { component, @@ -512,6 +546,21 @@ fn messages_to_faults( .collect() } +#[cfg(test)] +mod board_index_tests { + use super::board_index_from_text; + #[test] + fn extracts_board_index_from_common_fault_texts() { + assert_eq!(board_index_from_text("Chain 2 temperature sensor error"), Some(2)); + assert_eq!(board_index_from_text("hashboard 0 loss of balance"), Some(0)); + assert_eq!(board_index_from_text("Slot 1 error reading chip id."), Some(1)); + assert_eq!(board_index_from_text("Board #3 not responding"), Some(3)); + // No board keyword -> not attributed to a board. + assert_eq!(board_index_from_text("Environment temperature is too high."), None); + assert_eq!(board_index_from_text("Power current error."), None); + } +} + /// Infer whether an Antminer's hashboards carry a per-board PIC MCU from the /// model string (round 14 #2). No firmware (stock cgminer, Vnish, LuxOS, Braiins) /// exposes a PIC flag over the network; PIC-vs-noPIC is fixed by the hashboard diff --git a/crates/alkane-gui/src/ui.rs b/crates/alkane-gui/src/ui.rs index e50458ec..a1de3118 100644 --- a/crates/alkane-gui/src/ui.rs +++ b/crates/alkane-gui/src/ui.rs @@ -1587,16 +1587,19 @@ impl App { l.set_min_size(w, -1); l }; + // Each column on screen is the text field PLUS its 34px "+" button, so each + // header must span field_width + 34 to line up with the boxes below it + // (round 18 #8c). The Pool-label column is 46 to match the row label. + const PLUS_W: i32 = 34; + let widths = [170, 110, 110, 70]; // address, account, worker, password head.add(hl("", 46), 0, sf::BORDER_LEFT, 6); - head.add(hl("Address", 176), 0, sf::BORDER_LEFT, 6); - head.add(hl("Account", 116), 0, sf::BORDER_LEFT, 6); - head.add(hl("Worker", 116), 0, sf::BORDER_LEFT, 6); - head.add(hl("Password", 76), 0, sf::BORDER_LEFT, 6); + head.add(hl("Address", widths[0] + PLUS_W), 0, sf::BORDER_LEFT, 6); + head.add(hl("Account", widths[1] + PLUS_W), 0, sf::BORDER_LEFT, 6); + head.add(hl("Worker", widths[2] + PLUS_W), 0, sf::BORDER_LEFT, 6); + head.add(hl("Password", widths[3] + PLUS_W), 0, sf::BORDER_LEFT, 6); root.add_sizer(head, 0, sf::BORDER_LEFT | sf::BORDER_RIGHT | sf::BORDER_TOP, 6); let mut fields: Vec = Vec::with_capacity(12); - // widths per field type (address, account, worker, password). - let widths = [170, 110, 110, 70]; for row in 0..3usize { let rsizer = Widget::box_sizer(false); let lbl = Widget::static_text(dlg, &format!("Pool {}", row + 1)); @@ -1607,7 +1610,7 @@ impl App { input.set_min_size(widths[field], -1); rsizer.add(input, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_LEFT, 6); let plus = Widget::button(dlg, "+", ID_POOL_PLUS_BASE + (row * 4 + field) as i32); - plus.set_min_size(34, -1); // wide enough that the "+" glyph isn't clipped + plus.set_min_size(PLUS_W, -1); // wide enough that the "+" glyph isn't clipped rsizer.add(plus, 0, sf::ALIGN_CENTRE_VERTICAL, 0); fields.push(input); } @@ -1619,7 +1622,9 @@ impl App { btns.add(Widget::button(dlg, "Cancel", ID_POOLS_CANCEL), 0, sf::BORDER_ALL, 6); root.add_sizer(btns, 0, sf::EXPAND | sf::BORDER_ALL, 6); root.set_sizer_on(dlg); - dlg.set_min_size(560, 220); // round 16 #5: narrower; fit() grows to content + // Wide enough for the label + all four field+button columns so the "+" + // buttons on the right (Password) are never clipped (round 18 #8a). + dlg.set_min_size(700, 220); dlg.fit(dlg); self.pools_dialog = dlg; self.pool_fields = fields;