Compare commits

...
3 Commits
Author SHA1 Message Date
noahandClaude Opus 4.8 7f802c568f Scan progress: smooth per-address counter (was jumping ~1%/second)
The scan counter jumped in big steps (e.g. +45 for a 4590-address scan) because
(a) progress was only emitted every total/100 addresses and (b) the drain timer
ran once per second, so the gauge only refreshed ~1 Hz. The +45 was total/100, not
a chosen value.

Fix, both cheap:
- scan.rs emits progress per address (throttled only above 5000 addresses to bound
  channel traffic) instead of every 1%.
- ui.rs runs the scan/drain timer at 200 ms (5 Hz) so the counter climbs smoothly;
  drain_scan coalesces the many per-address updates into ONE gauge/status update
  per drain (no extra repaints). A tick accumulator keeps the once-per-second work
  (auto-rescan countdown, idle status) at 1 Hz despite the faster tick.

Net: the counter now climbs several times a second in small increments; overhead
is negligible (unbounded mpsc sends are cheap and the gauge still repaints once per
tick). No user-facing setting added -- the smoothness is size-independent.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Djv3oncM4LxTS5tb61Ako6
2026-09-22 09:21:33 -06:00
noahandClaude Opus 4.8 86338062a5 Round 17 B (part 2, GUI): timezone / change-password / factory-reset dialogs + BOS fix
Wire G10/G11/G12 into the GUI (they already had CLI verbs in part 1):
- MinerCaps gains timezone / change_password / factory_reset (probed from the
  matching supports_*() at scan time; intersect + any_control + is_empty updated).
- ConfigAction gains Timezone(String) / ChangePassword(String) / FactoryReset with
  labels + apply arms. Timezone/FactoryReset go through apply_action(&dyn Miner);
  ChangePassword takes &mut self so it runs on the owned miner in the action loop.
- ui.rs: a shared PromptKind (Power/Tuning/Timezone/Password) generalises the
  value prompt (timezone is IANA-validated before firing; password is non-empty);
  factory-reset uses the confirm dialog with a strong WIPES-config/DHCP warning.
  New gated context-menu items: Set timezone, Change password, Factory reset.

Backend fix (asic-rs patch 0015): BOS send_command treated an empty 2xx body as a
parse error, so change_password reported Ok(false) on success. Empty 2xx is now
Null (success). Found + fixed while live-verifying G11.

Verified live on Braiins 10.4.1.27: full change-password round-trip (root ->
bftest2 -> read with new pw -> restore root), all Ok(true), unit left on root/root.
Timezone shares the CLI-verified set_timezone_config path. Factory-reset is wired +
gated but intentionally NOT live-fired: its behaviour is unrecoverable per firmware
(can revert LuxOS to stock / reset network to DHCP and lose the unit) -- needs a
truly sacrificial console-attached unit. GUI selftest + 89 unit tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Djv3oncM4LxTS5tb61Ako6
2026-09-22 08:58:00 -06:00
noahandClaude Opus 4.8 c4c85d5b3d Round 17 B (part 1, CLI): timezone / change-password / factory-reset verbs (G10/G11/G12)
Round B wires the already-complete SupportsTimezoneConfig / ChangePassword /
FactoryReset backends to the toolkit. Part 1 adds the committed CLI surface
(GUI dialogs follow in part 2):
- `timezone <ip> [<IANA>]` - read (no arg) or set the timezone (gated on
  supports_timezone_config: Braiins/VNish/ePIC).
- `passwd <ip> <newpass>`  - change the web/API password (gated).
- `factoryreset <ip>`      - factory reset (gated).
Each is capability-gated and the usage banner marks passwd/factoryreset DANGEROUS.

Verified live: timezone set/read/restore end-to-end on Braiins 10.4.1.83
(set America/Edmonton -> read back -> restore Etc/GMT, all Ok). change-password
and factory-reset are implemented + gated but NOT live-run: both are destructive
on the shared corpus (change-password breaks the default auth every other test
relies on; factory-reset can reset a unit to DHCP and lose its IP) -- they need a
dedicated sacrificial/console-attached unit to verify live.

Also: ci/compute-version.sh now treats crates/alkane-gui/src/bin/* as a UI change
so CLI-tool changes trigger a release.

Note: the VNish timezone READ errors ("Unrecognised VNish timezone GMT, expected
GMT+N/-N") is a pre-existing vnish backend parse quirk, separate from this wiring.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Djv3oncM4LxTS5tb61Ako6
2026-09-21 22:58:43 -06:00
9 changed files with 325 additions and 40 deletions
+2 -1
View File
@@ -30,7 +30,8 @@ ui=false; backend=false
while IFS= read -r f; do
[ -z "$f" ] && continue
case "$f" in
crates/alkane-gui/src/ui.rs|crates/alkane-gui/src/fixtures.rs|thirdparty/wx-rs/*)
crates/alkane-gui/src/ui.rs|crates/alkane-gui/src/fixtures.rs|thirdparty/wx-rs/*|\
crates/alkane-gui/src/bin/*)
ui=true ;;
crates/alkane-core/*|crates/alkane-discovery/*|crates/alkane-access/*|\
crates/alkane-flash/*|crates/alkane-artifacts/*|crates/alkane-cli/*|\
+95
View File
@@ -348,6 +348,94 @@ async fn lifecycle(ip_s: &str, verb: &str) {
}
}
/// Read (no tz arg) or set the miner's timezone (round 16 / G10). Capability-gated.
async fn timezone(ip_s: &str, tz: Option<&str>) {
use asic_rs::core::config::timezone::{Tz, TimezoneConfig};
let Ok(ip) = ip_s.parse::<std::net::IpAddr>() else {
eprintln!("bad ip {ip_s}");
return;
};
match factory().scan_miner(ip).await {
Ok(Some(m)) => {
if !m.supports_timezone_config() {
eprintln!("{ip}: timezone config not supported");
return;
}
if let Some(tz_s) = tz {
let Ok(zone) = tz_s.parse::<Tz>() else {
eprintln!("bad IANA timezone '{tz_s}' (e.g. America/Edmonton)");
return;
};
let cfg = TimezoneConfig {
timezone: Some(zone),
available: Vec::new(),
};
match m.set_timezone_config(cfg).await {
Ok(v) => println!("{ip} set timezone {zone} -> Ok({v})"),
Err(e) => println!("{ip} set timezone -> Err: {e:#}"),
}
}
match m.get_timezone_config().await {
Ok(c) => println!(
"{ip} timezone now: {:?} ({} available)",
c.timezone.map(|t| t.to_string()),
c.available.len()
),
Err(e) => println!("{ip} read timezone -> Err: {e:#}"),
}
}
Ok(None) => eprintln!("no miner at {ip}"),
Err(e) => eprintln!("scan_miner {ip}: {e}"),
}
}
/// Change the miner's web/API password (round 16 / G11). Capability-gated.
/// DANGEROUS: a failed change can lock the toolkit out -- use a dedicated unit.
async fn passwd(ip_s: &str, newpass: &str) {
let Ok(ip) = ip_s.parse::<std::net::IpAddr>() else {
eprintln!("bad ip {ip_s}");
return;
};
match factory().scan_miner(ip).await {
Ok(Some(mut m)) => {
if !m.supports_change_password() {
eprintln!("{ip}: change password not supported");
return;
}
match m.change_password(newpass).await {
Ok(v) => println!("{ip} change_password -> Ok({v})"),
Err(e) => println!("{ip} change_password -> Err: {e:#}"),
}
}
Ok(None) => eprintln!("no miner at {ip}"),
Err(e) => eprintln!("scan_miner {ip}: {e}"),
}
}
/// Factory-reset the miner (round 16 / G12). Capability-gated. DESTRUCTIVE:
/// wipes config and may reset the network (unit can drop off its IP) -- only run
/// on a sacrificial/console-attached unit.
async fn factoryreset(ip_s: &str) {
let Ok(ip) = ip_s.parse::<std::net::IpAddr>() else {
eprintln!("bad ip {ip_s}");
return;
};
match factory().scan_miner(ip).await {
Ok(Some(m)) => {
if !m.supports_factory_reset() {
eprintln!("{ip}: factory reset not supported");
return;
}
match m.factory_reset().await {
Ok(v) => println!("{ip} factory_reset -> Ok({v})"),
Err(e) => println!("{ip} factory_reset -> Err: {e:#}"),
}
}
Ok(None) => eprintln!("no miner at {ip}"),
Err(e) => eprintln!("scan_miner {ip}: {e}"),
}
}
fn main() {
let args: Vec<String> = std::env::args().collect();
let rt = match tokio::runtime::Builder::new_current_thread().enable_all().build() {
@@ -379,6 +467,10 @@ fn main() {
rt.block_on(setpools(&args[2], &args[3], &args[4], &args[5]))
}
Some("msgs") if args.len() == 3 => rt.block_on(msgs(&args[2])),
Some("timezone") if args.len() == 3 => rt.block_on(timezone(&args[2], None)),
Some("timezone") if args.len() == 4 => rt.block_on(timezone(&args[2], Some(&args[3]))),
Some("passwd") if args.len() == 4 => rt.block_on(passwd(&args[2], &args[3])),
Some("factoryreset") if args.len() == 3 => rt.block_on(factoryreset(&args[2])),
_ => {
eprintln!(
"miner_probe -- asic-rs config + scan CLI for the alkane-toolkit fleet\n\
@@ -396,6 +488,9 @@ fn main() {
\x20 restart <ip> restart/reboot\n\
\x20 setpl <ip> <watts> set power limit\n\
\x20 setpools <ip> <url> <user> <pass> set the default pool group\n\
\x20 timezone <ip> [<IANA>] read (no arg) or set the timezone\n\
\x20 passwd <ip> <newpass> change the web/API password (DANGEROUS)\n\
\x20 factoryreset <ip> factory reset (DESTRUCTIVE; sacrificial units only)\n\
\n\
Each write verb is capability-gated (skips miners that do not support it).\n\
Credentials: ALKANE_PROBE_USER/PASS or ~/.config/alkane-toolkit/scan-credentials.txt."
+3
View File
@@ -159,6 +159,9 @@ impl Board {
tuning: self.mining,
firmware_flash,
pools: true,
timezone: self.mining,
change_password: true,
factory_reset: true,
},
// Demo values for the round-8/9 columns (synthetic, so the columns
// show variety offline). control_board is derived above via naming.
+14
View File
@@ -219,6 +219,11 @@ pub struct MinerCaps {
/// Whether this miner's driver supports writing pool configuration (probed
/// via `supports_pools_config()` at scan time; round 14 #7).
pub pools: bool,
/// Round 17 B: supports setting the timezone / changing the web password /
/// factory reset (probed via the matching `supports_*()` at scan time).
pub timezone: bool,
pub change_password: bool,
pub factory_reset: bool,
}
impl MinerCaps {
@@ -233,6 +238,9 @@ impl MinerCaps {
tuning: self.tuning && other.tuning,
firmware_flash: self.firmware_flash && other.firmware_flash,
pools: self.pools && other.pools,
timezone: self.timezone && other.timezone,
change_password: self.change_password && other.change_password,
factory_reset: self.factory_reset && other.factory_reset,
}
}
@@ -262,6 +270,9 @@ impl MinerCaps {
|| self.tuning
|| self.firmware_flash
|| self.pools
|| self.timezone
|| self.change_password
|| self.factory_reset
}
}
@@ -2244,6 +2255,9 @@ mod tests {
tuning: true,
firmware_flash: true,
pools: true,
timezone: true,
change_password: true,
factory_reset: true,
};
let idle = MinerCaps { fault_light: true, restart: true, ..Default::default() };
// Two full miners keep every action.
+50 -6
View File
@@ -391,7 +391,10 @@ pub fn start_scan(lines: Vec<String>, timeout_secs: u64) -> ScanHandle {
// get accurate progress plus the responders.
let mut stream = factory.scan_stream_with_ip();
let mut done = 0usize;
let step = (total / 100).max(1); // throttle progress messages
// Emit progress per address for a smoothly-climbing counter; only a
// very large scan (> 5000 addresses) is throttled, to bound channel
// traffic. The UI coalesces these to one gauge update per refresh.
let step = (total / 5000).max(1);
while let Some((ip, miner)) = stream.next().await {
if thread_cancel.load(Ordering::Relaxed) {
return; // Stop / re-scan requested
@@ -651,6 +654,9 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
tuning: miner.supports_set_tuning_percent(),
firmware_flash: miner.supports_upgrade_firmware(),
pools: miner.supports_pools_config(),
timezone: miner.supports_timezone_config(),
change_password: miner.supports_change_password(),
factory_reset: miner.supports_factory_reset(),
};
// PIC vs noPIC (round 14 #2 rework). No firmware exposes a PIC flag over the
// network -- it's a fixed hardware property of the hashboard type -- so infer
@@ -770,6 +776,9 @@ pub enum ConfigAction {
Resume,
PowerLimit(f64), // watts
TuningPercent(u8),
Timezone(String), // IANA zone, e.g. "America/Edmonton" (round 17 B / G10)
ChangePassword(String), // new web/API password (round 17 B / G11)
FactoryReset, // round 17 B / G12
}
impl ConfigAction {
@@ -783,6 +792,9 @@ impl ConfigAction {
ConfigAction::Resume => "resume".into(),
ConfigAction::PowerLimit(w) => format!("power limit {w:.0} W"),
ConfigAction::TuningPercent(p) => format!("tuning {p}%"),
ConfigAction::Timezone(tz) => format!("timezone {tz}"),
ConfigAction::ChangePassword(_) => "change password".into(),
ConfigAction::FactoryReset => "factory reset".into(),
}
}
@@ -797,6 +809,9 @@ impl ConfigAction {
ConfigAction::Resume => "resuming…".into(),
ConfigAction::PowerLimit(_) => "setting power…".into(),
ConfigAction::TuningPercent(_) => "tuning…".into(),
ConfigAction::Timezone(_) => "setting timezone…".into(),
ConfigAction::ChangePassword(_) => "changing password…".into(),
ConfigAction::FactoryReset => "factory resetting…".into(),
}
}
}
@@ -828,6 +843,25 @@ async fn apply_action(miner: &dyn Miner, action: &ConfigAction) -> Result<bool,
ConfigAction::Resume => miner.resume(None).await,
ConfigAction::PowerLimit(w) => miner.set_power_limit(Power::from_watts(*w)).await,
ConfigAction::TuningPercent(p) => miner.set_tuning_percent(*p).await,
ConfigAction::Timezone(tz) => {
use asic_rs::core::config::timezone::{Tz, TimezoneConfig};
match tz.parse::<Tz>() {
Ok(zone) => {
miner
.set_timezone_config(TimezoneConfig {
timezone: Some(zone),
available: Vec::new(),
})
.await
}
Err(_) => return Err(format!("invalid IANA timezone '{tz}'")),
}
}
ConfigAction::FactoryReset => miner.factory_reset().await,
// ChangePassword takes &mut self; handled in the run loop, not here.
ConfigAction::ChangePassword(_) => {
return Err("internal: change-password handled separately".to_string());
}
};
result.map_err(|e| e.to_string())
}
@@ -883,11 +917,21 @@ pub fn start_config_action(ips: Vec<String>, action: ConfigAction) -> ActionHand
let (success, detail) = match ip_s.parse::<std::net::IpAddr>() {
Err(_) => (false, "bad IP".to_string()),
Ok(ip) => match factory.scan_miner(ip).await {
Ok(Some(miner)) => match apply_action(&*miner, &action).await {
Ok(true) => (true, "ok".to_string()),
Ok(false) => (false, "refused".to_string()),
Err(e) => (false, format!("{e}")),
},
Ok(Some(mut miner)) => {
// change_password takes &mut self, so it can't go through
// apply_action(&dyn Miner); run it on the owned miner here.
let outcome = match &action {
ConfigAction::ChangePassword(p) => {
miner.change_password(p).await.map_err(|e| e.to_string())
}
other => apply_action(&*miner, other).await,
};
match outcome {
Ok(true) => (true, "ok".to_string()),
Ok(false) => (false, "refused".to_string()),
Err(e) => (false, format!("{e}")),
}
}
Ok(None) => (false, "no miner at IP".to_string()),
Err(e) => (false, format!("{e}")),
},
+111 -29
View File
@@ -67,6 +67,10 @@ const ID_CTX_RESUME: i32 = 726;
const ID_CTX_TUNING: i32 = 727;
const ID_CTX_POWER: i32 = 728;
const ID_CTX_RESTART: i32 = 729;
// Round 17 B: timezone / change-password / factory-reset config actions.
const ID_CTX_TIMEZONE: i32 = 737;
const ID_CTX_PASSWORD: i32 = 738;
const ID_CTX_FACTORY_RESET: i32 = 739;
const ID_CTX_ACCESS_PROBE: i32 = 731;
// View a miner's log fetched over its firmware API (round 12 #12).
const ID_CTX_VIEW_LOG: i32 = 734;
@@ -85,9 +89,18 @@ const ID_POOL_PLUS_BASE: i32 = 800;
const ID_POOL_MENU_ADD: i32 = 819; // "add new" (adds current box value to the dropdown)
const ID_POOL_MENU_BASE: i32 = 820; // one id per dropdown entry (820 + index)
const ID_POOL_MENU_REMOVE_BASE: i32 = 1000; // one id per removable saved entry (round 16 #5)
// Value-prompt dialog for power-limit / tuning-percent actions.
// Value-prompt dialog for power-limit / tuning-percent / timezone / password.
const ID_ACTION_OK: i32 = 740;
const ID_ACTION_CANCEL: i32 = 741;
/// Which value the shared text/number prompt is collecting (round 17 B).
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum PromptKind {
Power,
Tuning,
Timezone,
Password,
}
// Confirmation dialog for disruptive actions (restart / pause / resume).
const ID_CONFIRM_OK: i32 = 742;
const ID_CONFIRM_CANCEL: i32 = 743;
@@ -115,6 +128,11 @@ const ID_HDR_SORT_REL_DESC: i32 = 766;
const ID_FILTER_COL: i32 = 730;
const ID_FILTER_OP: i32 = 731;
const TIMER_SCAN: i32 = 1;
/// The scan/drain timer fires this often (ms). A fast tick drains the scan channel
/// several times a second so the progress counter climbs smoothly instead of
/// jumping ~1%/s; the once-per-second scheduler work runs every `TICKS_PER_SEC`.
const TICK_MS: i32 = 200;
const TICKS_PER_SEC: u64 = 1000 / TICK_MS as u64;
// Deferred-rebuild ids: run a rebuild from outside the triggering widget's own
// event (destroying a control mid-event is unsafe). See `wx_rs::call_after`.
const DEFER_TABLE: i32 = 1;
@@ -627,6 +645,9 @@ pub struct App {
// Per-miner scan timeout in seconds (round 14 #2).
scan_timeout_secs: u64,
countdown: u64,
/// Counts fast timer ticks; the once-per-second scheduler runs every
/// `TICKS_PER_SEC` of these (the drains run every tick for smooth progress).
tick_accum: u64,
// selection (replaces the old checkbox column), tracked by IP so it
// survives table refreshes during a scan.
selected_ips: HashSet<String>,
@@ -659,7 +680,7 @@ pub struct App {
action_ips: Vec<String>,
action_prompt: Widget,
action_input: Widget,
action_is_power: bool,
action_kind: PromptKind,
action_total: usize,
action_done: usize,
// IPs the current config action targets, re-probed after it completes so the
@@ -970,6 +991,7 @@ pub fn build(frame: Widget) -> App {
auto_secs: scan::load_auto_secs(),
scan_timeout_secs: scan::load_scan_timeout(),
countdown: 0,
tick_accum: 0,
selected_ips: HashSet::new(),
pal,
kpi_cards,
@@ -984,7 +1006,7 @@ pub fn build(frame: Widget) -> App {
action_ips: Vec::new(),
action_prompt: frame,
action_input: frame,
action_is_power: false,
action_kind: PromptKind::Power,
action_total: 0,
action_done: 0,
action_targets: Vec::new(),
@@ -1044,7 +1066,7 @@ pub fn build(frame: Widget) -> App {
app.view = p.view.to_view();
}
app.rebuild_table();
Widget::timer(TIMER_SCAN, 1000);
Widget::timer(TIMER_SCAN, TICK_MS);
app
}
@@ -1469,6 +1491,19 @@ impl App {
if caps.pools {
menu.menu_append(ID_CTX_POOLS, &format!("Configure pools...{sfx}"));
}
if caps.timezone {
menu.menu_append(ID_CTX_TIMEZONE, &format!("Set timezone...{sfx}"));
}
// Destructive / credential-changing actions, set apart (round 17 B).
if caps.change_password || caps.factory_reset {
menu.menu_append_separator();
if caps.change_password {
menu.menu_append(ID_CTX_PASSWORD, &format!("Change password...{sfx}"));
}
if caps.factory_reset {
menu.menu_append(ID_CTX_FACTORY_RESET, &format!("Factory reset...{sfx}"));
}
}
}
// Firmware flash is intentionally not offered for now (round 16 #6): the
// in-app flash path is disabled while it is reworked. Restore-to-stock +
@@ -2079,8 +2114,13 @@ impl App {
ID_CTX_RESUME => return Some(self.build_confirm_dialog(scan::ConfigAction::Resume)),
ID_CTX_RESTART => return Some(self.build_confirm_dialog(scan::ConfigAction::Restart)),
// Value entry is itself the confirmation.
ID_CTX_POWER => return Some(self.build_action_prompt(true)),
ID_CTX_TUNING => return Some(self.build_action_prompt(false)),
ID_CTX_POWER => return Some(self.build_action_prompt(PromptKind::Power)),
ID_CTX_TUNING => return Some(self.build_action_prompt(PromptKind::Tuning)),
ID_CTX_TIMEZONE => return Some(self.build_action_prompt(PromptKind::Timezone)),
ID_CTX_PASSWORD => return Some(self.build_action_prompt(PromptKind::Password)),
ID_CTX_FACTORY_RESET => {
return Some(self.build_confirm_dialog(scan::ConfigAction::FactoryReset))
}
_ => {}
}
None
@@ -2095,9 +2135,17 @@ impl App {
scan::ConfigAction::Restart => ("Restart", "Restart"),
scan::ConfigAction::Pause => ("Pause mining on", "Pause"),
scan::ConfigAction::Resume => ("Resume mining on", "Resume"),
scan::ConfigAction::FactoryReset => ("Factory reset", "Factory reset"),
_ => ("Apply to", "Confirm"),
};
let msg = format!("{verb} {n} selected miner(s)? This affects running hardware.");
let msg = if matches!(action, scan::ConfigAction::FactoryReset) {
format!(
"Factory reset {n} selected miner(s)? This WIPES their configuration (pools, \
tuning, network) and reboots -- a miner may return on DHCP and change IP."
)
} else {
format!("{verb} {n} selected miner(s)? This affects running hardware.")
};
self.pending_confirm = Some((ips, action));
let frame = Widget::main_frame();
let dlg = Widget::dialog(frame, "Confirm action");
@@ -2117,17 +2165,24 @@ impl App {
/// A small modal to enter a power limit (watts) or tuning percent for the
/// selection. Built here, shown modally by `dispatch` outside the App borrow.
fn build_action_prompt(&mut self, is_power: bool) -> Widget {
fn build_action_prompt(&mut self, kind: PromptKind) -> Widget {
self.action_ips = self.selected_ip_list();
self.action_is_power = is_power;
self.action_kind = kind;
let n = self.action_ips.len();
let frame = Widget::main_frame();
let dlg = Widget::dialog(frame, if is_power { "Set power limit" } else { "Set tuning percent" });
let title = match kind {
PromptKind::Power => "Set power limit",
PromptKind::Tuning => "Set tuning percent",
PromptKind::Timezone => "Set timezone",
PromptKind::Password => "Change password",
};
let dlg = Widget::dialog(frame, title);
let root = Widget::box_sizer(true);
let lbl = if is_power {
format!("Power limit in watts for {n} miner(s):")
} else {
format!("Tuning percent (0-100) for {n} miner(s):")
let lbl = match kind {
PromptKind::Power => format!("Power limit in watts for {n} miner(s):"),
PromptKind::Tuning => format!("Tuning percent (0-100) for {n} miner(s):"),
PromptKind::Timezone => format!("IANA timezone (e.g. America/Edmonton) for {n} miner(s):"),
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);
@@ -2151,15 +2206,27 @@ impl App {
/// captured selection) so the operator can correct it.
fn apply_action_prompt(&mut self) {
let val = self.action_input.get_value();
let action = if self.action_is_power {
match val.trim().parse::<f64>() {
let action = match self.action_kind {
PromptKind::Power => match val.trim().parse::<f64>() {
Ok(w) if w > 0.0 && w.is_finite() => Some(scan::ConfigAction::PowerLimit(w)),
_ => None,
}
} else {
match val.trim().parse::<u8>() {
},
PromptKind::Tuning => match val.trim().parse::<u8>() {
Ok(p) if p <= 100 => Some(scan::ConfigAction::TuningPercent(p)),
_ => None,
},
PromptKind::Timezone => {
let tz = val.trim();
// Validate as an IANA zone before firing so a typo doesn't hit the fleet.
if !tz.is_empty() && tz.parse::<asic_rs::core::config::timezone::Tz>().is_ok() {
Some(scan::ConfigAction::Timezone(tz.to_string()))
} else {
None
}
}
PromptKind::Password => {
let p = val.trim();
(!p.is_empty()).then(|| scan::ConfigAction::ChangePassword(p.to_string()))
}
};
match action {
@@ -2169,10 +2236,11 @@ impl App {
self.start_action(ips, a);
}
None => {
let hint = if self.action_is_power {
"enter a positive number of watts"
} else {
"enter a percent from 0 to 100"
let hint = match self.action_kind {
PromptKind::Power => "enter a positive number of watts",
PromptKind::Tuning => "enter a percent from 0 to 100",
PromptKind::Timezone => "enter a valid IANA zone, e.g. America/Edmonton",
PromptKind::Password => "enter a non-empty password",
};
wx_rs::set_status_text(&format!("invalid value - {hint}"));
}
@@ -2561,6 +2629,9 @@ impl App {
pub fn drain_scan(&mut self) {
let Some(handle) = &self.scan else { return };
let mut changed = false;
// Coalesce progress: a fast drain may pull many per-address updates; apply
// only the latest to the gauge/status once, after the loop.
let mut latest_progress: Option<(usize, usize, String)> = None;
loop {
match handle.rx.try_recv() {
Ok(ScanMsg::Started { total, targets }) => {
@@ -2584,12 +2655,7 @@ impl App {
}
Ok(ScanMsg::Progress { done, total, ip }) => {
self.scan_total = total;
self.progress.gauge_set_value(done.min(total) as i32);
let where_ = if ip.is_empty() { String::new() } else { format!(" - scanning {ip}") };
wx_rs::set_status_text(&format!(
"{done}/{total}{where_} ({} found)",
self.rows.len()
));
latest_progress = Some((done, total, ip));
}
Ok(ScanMsg::Row(row)) => {
// Ignore stray rows outside the current target set.
@@ -2633,6 +2699,15 @@ impl App {
}
}
}
// Apply the coalesced progress once (only while still scanning -- a Done/
// Failed in this same drain already finalised the gauge).
if self.scanning {
if let Some((done, total, ip)) = latest_progress {
self.progress.gauge_set_value(done.min(total) as i32);
let where_ = if ip.is_empty() { String::new() } else { format!(" - scanning {ip}") };
wx_rs::set_status_text(&format!("{done}/{total}{where_} ({} found)", self.rows.len()));
}
}
if changed {
self.fill_rows();
}
@@ -2646,6 +2721,13 @@ impl App {
self.drain_refresh();
self.drain_access_probe();
self.drain_restore();
// The drains above run every fast tick (smooth scan progress); the
// auto-rescan scheduler + idle status only need ~1 Hz, so run them once
// per second.
self.tick_accum = self.tick_accum.wrapping_add(1);
if self.tick_accum % TICKS_PER_SEC != 0 {
return;
}
// The bottom-left status is for the scan only (round 15 #8): per-miner
// operation progress lives in the Health column, so operations no longer
// hold or overwrite this line -- only an active scan does.
@@ -0,0 +1,37 @@
Subject: [PATCH 0015] braiins v26_04: treat an empty 2xx body as success (not a parse error)
Found live verifying change-password (round 17 B / G11). The BOS REST setters like
PUT auth/password answer 2xx with an empty body; send_command tried
response.json() on it, which fails, so change_password (which does `.is_ok()`)
reported Ok(false) even though the password DID change. Read the body as text
first: an empty body on a success status is Null (success), a non-empty body must
still parse. Verified live on 10.4.1.27: change root->bftest2 now returns Ok(true),
the new password authenticates, and restore -> root returns Ok(true).
diff --git a/vendor/asic-rs-firmwares-braiins/src/backends/v26_04/web.rs b/vendor/asic-rs-firmwares-braiins/src/backends/v26_04/web.rs
index 624eca4c..3e06b682 100644
--- a/vendor/asic-rs-firmwares-braiins/src/backends/v26_04/web.rs
+++ b/vendor/asic-rs-firmwares-braiins/src/backends/v26_04/web.rs
@@ -57,11 +57,20 @@ impl WebAPIClient for BraiinsWebAPI {
let status = response.status();
if status.is_success() {
- let json_data = response
- .json()
+ // Some setters (e.g. PUT auth/password) answer 2xx with an empty or
+ // non-JSON body. An empty body is success, not a parse error -- treat
+ // it as Null so callers using `.is_ok()` don't read a real success as
+ // failure. A non-empty body must still parse.
+ let body = response
+ .text()
.await
.map_err(|e| BraiinsError::ParseError(e.to_string()))?;
- Ok(json_data)
+ if body.trim().is_empty() {
+ Ok(Value::Null)
+ } else {
+ Ok(serde_json::from_str(&body)
+ .map_err(|e| BraiinsError::ParseError(e.to_string()))?)
+ }
} else {
// The API reports why it rejected a request in the body.
let status = status.as_u16();
File diff suppressed because one or more lines are too long
+12 -3
View File
@@ -57,11 +57,20 @@ impl WebAPIClient for BraiinsWebAPI {
let status = response.status();
if status.is_success() {
let json_data = response
.json()
// Some setters (e.g. PUT auth/password) answer 2xx with an empty or
// non-JSON body. An empty body is success, not a parse error -- treat
// it as Null so callers using `.is_ok()` don't read a real success as
// failure. A non-empty body must still parse.
let body = response
.text()
.await
.map_err(|e| BraiinsError::ParseError(e.to_string()))?;
Ok(json_data)
if body.trim().is_empty() {
Ok(Value::Null)
} else {
Ok(serde_json::from_str(&body)
.map_err(|e| BraiinsError::ParseError(e.to_string()))?)
}
} else {
// The API reports why it rejected a request in the body.
let status = status.as_u16();