diff --git a/crates/alkane-gui/src/access_probe.rs b/crates/alkane-gui/src/access_probe.rs index c8caa6d5..d890f48c 100644 --- a/crates/alkane-gui/src/access_probe.rs +++ b/crates/alkane-gui/src/access_probe.rs @@ -240,23 +240,39 @@ fn wm_aes_ecb_enc(pwd_md5: &str, data: &str) -> Option { fn probe_whatsminer_access(ip: &str, passwords: &[String]) -> Option { let timeout = Duration::from_secs(6); let mut reachable = false; + // A transient error on one candidate must not abandon the others (round 18 #12): + // skip to the next candidate, but remember it happened so we never report a + // confident "locked" when the answer was really indeterminate. + let mut errored = false; for pass in passwords { // 1. get_token (no auth) -> salt / newsalt / time. let tok_resp = match wm_rpc(ip, "{\"command\":\"get_token\"}", timeout) { Ok(s) => s, - Err(_) => return None, + Err(_) => { + errored = true; + continue; + } }; let v: serde_json::Value = match serde_json::from_str(&tok_resp) { Ok(v) => v, - Err(_) => return None, + Err(_) => { + errored = true; + continue; + } }; - let msg = v.get("Msg")?; - let (Some(salt), Some(newsalt), Some(time)) = ( - msg.get("salt").and_then(|s| s.as_str()), - msg.get("newsalt").and_then(|s| s.as_str()), - msg.get("time").and_then(|s| s.as_str()), - ) else { - return None; + let (Some(salt), Some(newsalt), Some(time)) = v + .get("Msg") + .map(|msg| { + ( + msg.get("salt").and_then(|s| s.as_str()), + msg.get("newsalt").and_then(|s| s.as_str()), + msg.get("time").and_then(|s| s.as_str()), + ) + }) + .unwrap_or((None, None, None)) + else { + errored = true; + continue; }; reachable = true; // 2. Derive the md5crypt password hash + write-token from the password. @@ -274,15 +290,19 @@ fn probe_whatsminer_access(ip: &str, passwords: &[String]) -> Option { let payload = format!("{{\"enc\":1,\"data\":\"{enc}\"}}"); let resp = match wm_rpc(ip, &payload, timeout) { Ok(s) => s, - Err(_) => return None, + Err(_) => { + errored = true; + continue; + } }; if resp.contains("\"enc\"") { return Some(false); // accepted -> unlocked/writable } // rejected -> try the next candidate password } - // Reached the miner and every candidate password was rejected -> locked. - if reachable { Some(true) } else { None } + // Only report "locked" when we cleanly reached the miner and every candidate + // was rejected with no transient errors; otherwise the result is indeterminate. + if reachable && !errored { Some(true) } else { None } } #[cfg(test)] diff --git a/crates/alkane-gui/src/credentials.rs b/crates/alkane-gui/src/credentials.rs index c61104e7..36d37c0a 100644 --- a/crates/alkane-gui/src/credentials.rs +++ b/crates/alkane-gui/src/credentials.rs @@ -191,7 +191,12 @@ pub fn clear_firmware_credentials() -> std::io::Result<()> { /// otherwise the backend falls back to its own default auth. With nothing saved /// this is plain `MinerFactory::new()`. pub fn configured_factory() -> MinerFactory { - let mut factory = MinerFactory::new(); + // Apply the operator's configured identification timeout to every factory + // (round 18 #12: config actions / refresh / pools / flash previously used + // asic-rs's 10s default, so on a slow link they could fail to reach miners a + // longer-timeout scan had found). start_scan may still override it explicitly. + let mut factory = + MinerFactory::new().with_identification_timeout_secs(crate::scan::load_scan_timeout().max(1)); let global = load_credentials(); let per_fw = load_firmware_credentials(); if global.is_none() && per_fw.is_empty() { diff --git a/crates/alkane-gui/src/fixtures.rs b/crates/alkane-gui/src/fixtures.rs index fc01f74d..cf728aa3 100644 --- a/crates/alkane-gui/src/fixtures.rs +++ b/crates/alkane-gui/src/fixtures.rs @@ -110,6 +110,8 @@ impl Board { let control_board = crate::naming::control_board_code(self.make, self.board, &model); let cpu = crate::naming::control_board_cpu(self.make, self.board, &model); let board_code = crate::naming::control_board_board(self.make, self.board, &model); + // Computed before `model` is moved into the struct literal below. + let pic_present = crate::scan::infer_pic(&model); MinerRow { ip: self.ip.to_string(), selected: false, @@ -192,13 +194,9 @@ impl Board { // show variety offline). control_board is derived above via naming. algorithm: "SHA256".to_string(), control_board, - pic_present: if self.model_id.contains("S21") { - Some(false) // noPIC example - } else if self.make.eq_ignore_ascii_case("antminer") { - Some(true) - } else { - None // WhatsMiner: unknown over the network - }, + // Use the same PIC inference the live scan uses (round 18 #12: the demo + // previously reimplemented a simplified version that disagreed with it). + pic_present, // Access: idle/view-only units (no worker) shown locked; the rest // unlocked. (Live rows infer this from control capabilities.) write_locked: Some(self.worker.is_empty()), diff --git a/crates/alkane-gui/src/model.rs b/crates/alkane-gui/src/model.rs index acdb18b0..053938af 100644 --- a/crates/alkane-gui/src/model.rs +++ b/crates/alkane-gui/src/model.rs @@ -689,7 +689,13 @@ impl MinerRow { if (0..base.len()).any(board_faulted) { for (i, h) in base.iter_mut().enumerate() { if board_faulted(i) { - *h = CompHealth::Down; + // A genuinely-undetected board stays grey ("not detected") even + // when a fault text names it: a message like "chain N not found" + // describes exactly that missing board, and grey-vs-red is the + // documented distinction (round 18 #12). Only detected boards go red. + if *h != CompHealth::Unreachable { + *h = CompHealth::Down; + } } else if *h == CompHealth::Down { *h = ok; // stall-reddened but not named by the fault codes } @@ -1896,6 +1902,21 @@ mod tests { assert_eq!(rb[0], CompHealth::Ok); // running -> green despite PSU fault assert_eq!(rb[1], CompHealth::Ok); assert_eq!(rb[2], CompHealth::Unreachable); // only the undetected board is grey + + // Round 18 #12: a genuinely-undetected board that is ALSO named by a board + // fault (e.g. a "chain 2 not found" message attributed to Board(2)) must + // stay grey ("not detected"), not turn red -- grey vs red is the + // detected/undetected distinction. + let missing_named = MinerRow { + is_mining: true, + board_status: vec![BoardHealth::Ok, BoardHealth::Ok, BoardHealth::Missing], + faults: vec![fault(FaultComponent::Board(2), "Chain 2 not found, check connection")], + ..Default::default() + }; + let mb = missing_named.board_healths(); + assert_eq!(mb[0], CompHealth::Ok); + assert_eq!(mb[1], CompHealth::Ok); + assert_eq!(mb[2], CompHealth::Unreachable, "undetected board named by a fault stays grey"); } #[test] diff --git a/crates/alkane-gui/src/naming.rs b/crates/alkane-gui/src/naming.rs index c6b2aceb..7d9049a1 100644 --- a/crates/alkane-gui/src/naming.rs +++ b/crates/alkane-gui/src/naming.rs @@ -287,8 +287,10 @@ fn is_s17_era(clean_model: &str) -> bool { /// S19k Pro, and the S21 Pro; everything else AMLogic is the 120mm C76. asic-rs /// cannot tell these apart, so this is a model-family heuristic, not a read. fn is_aml_140mm(clean_model: &str) -> bool { + // Per the doc above: XP-class, the S19k Pro, and the S21 Pro -- NOT every S21 + // (plain S21 / S21+ / S21e are the 120mm C76 board) (round 18 #12). let m = clean_model.trim_start(); - m.contains("XP") || m.starts_with("S19k") || m.starts_with("S21") + m.contains("XP") || m.starts_with("S19k") || m.contains("S21 Pro") } /// Nameplate expected hashrate in Sol/s for an Equihash (Zcash) miner model, when diff --git a/crates/alkane-gui/src/scan.rs b/crates/alkane-gui/src/scan.rs index af901f6e..b0676c64 100644 --- a/crates/alkane-gui/src/scan.rs +++ b/crates/alkane-gui/src/scan.rs @@ -599,7 +599,7 @@ mod board_index_tests { /// /// The one genuinely ambiguous model is the plain "S19j Pro" (both PIC and noPIC /// revisions exist); it is assumed PIC unless the model string says noPIC. -fn infer_pic(model: &str) -> Option { +pub(crate) fn infer_pic(model: &str) -> Option { let m = model.to_lowercase(); if m.contains("nopic") { return Some(false); diff --git a/crates/alkane-gui/src/ui.rs b/crates/alkane-gui/src/ui.rs index a91f89c9..6cd200da 100644 --- a/crates/alkane-gui/src/ui.rs +++ b/crates/alkane-gui/src/ui.rs @@ -2488,7 +2488,14 @@ impl App { PromptKind::Password => format!("New web/API password for {n} miner(s):"), }; root.add(Widget::static_text(dlg, &lbl), 0, sf::BORDER_ALL, 8); - let input = Widget::text_ctrl(dlg, false); + // The change-password prompt masks its field so the new fleet password is + // never shown in the clear (round 18 #12); the numeric/timezone prompts use + // a normal field. + let input = if matches!(kind, PromptKind::Password) { + Widget::password_ctrl(dlg) + } else { + Widget::text_ctrl(dlg, false) + }; input.set_min_size(200, -1); root.add(input, 0, sf::EXPAND | sf::BORDER_LEFT | sf::BORDER_RIGHT, 8); let btns = Widget::box_sizer(false); @@ -3177,12 +3184,15 @@ impl App { /// overlap rather than block the UI by joining the old scan thread (which /// could freeze it for up to the per-miner scan timeout); the probes target /// live miners, so a momentary overlap is harmless. - fn begin_scan(&mut self, lines: Vec) { + /// Returns whether a scan actually started (false if deferred, e.g. mid-flash), + /// so callers don't overwrite the real status with a bogus "scanning..." + /// (round 18 #12). + fn begin_scan(&mut self, lines: Vec) -> bool { // Never probe the network while a firmware flash is uploading: a stray // scan connection to a miner mid-write can interrupt/corrupt the flash. if self.flashing { wx_rs::set_status_text("firmware flash in progress -- scan deferred"); - return; + return false; } if let Some(old) = self.scan.take() { old.stop(); @@ -3190,12 +3200,14 @@ impl App { self.scan = Some(scan::start_scan(lines, self.scan_timeout_secs)); self.scanning = true; self.countdown = 0; + true } /// Start a fresh scan of the saved ranges. fn start_new_scan(&mut self) { - self.begin_scan(scan::load_ranges()); - wx_rs::set_status_text("scanning..."); + if self.begin_scan(scan::load_ranges()) { + wx_rs::set_status_text("scanning..."); + } } /// The table's selection changed (ctrl/shift-click). Mirror it into the