feat(gui): post-install verify, flash-plan checklist; backend helpers
source / check (pull_request) Skipped
verify / verify-windows (pull_request) Canceled after 0s
verify / verify (pull_request) Canceled after 2m0s

Stock->alkane re-scan flicker: after a successful install the just-installed
boards are held in a "verifying alkane..." state and a stock re-scan row is
suppressed until the board answers as alkane, with a bounded give-up window.
Fixes the board re-scanning as stock before finally showing alkane.

Flash-plan checklist: picking a local .afw in the install dialog now detects
the flash tier and shows a [x]/[ ] checklist of what it overwrites (U-Boot /
Kernel / Userspace), read from the bundle manifest. Verified end-to-end under
a virtual display: a zynq-7010 .afw shows tier 2, U-Boot preserved, kernel and
userspace written.

Backend helpers (alkane-artifacts, additive, unit-tested):
- AfwManifest::flash_plan() -> FlashPlan { tier, writes_uboot, writes_kernel,
  writes_userspace }.
- ReleaseSource::for_repo(owner, repo) and ReleaseInfo::compatible_boards /
  is_compatible_with, for the upcoming any-repo picker with board-compat
  detection.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B1W6qKwKxq3oUPDKWicM6i
This commit is contained in:
2026-11-13 10:56:04 -06:00
co-authored by Claude Opus 4.8
parent f9cd12b374
commit fbf44889ea
3 changed files with 430 additions and 13 deletions
+156 -11
View File
@@ -512,6 +512,38 @@ fn encode_status_icon(pal: &Palette, status: &str) -> String {
encode_segments(&[(Some(status_kind_color(pal, status)), shape.to_string())])
}
/// A read-only flash-plan summary for a local `.afw`: its tier and which regions
/// it overwrites (U-Boot / Kernel / Userspace), from the bundle's own manifest.
/// Shown in the install dialog when a file is picked so the operator sees exactly
/// what the flash touches before starting.
fn afw_plan_text(path: &str) -> String {
use alkane_artifacts::afw::{verify_afw, VerifyOptions};
let opts = VerifyOptions {
allow_unsigned: true,
expect_board: None,
};
match verify_afw(std::path::Path::new(path), &opts) {
Ok(v) => {
let p = v.manifest.flash_plan();
let mark = |b: bool| if b { "[x]" } else { "[ ]" };
format!(
"Flash plan: tier {} (board {}). Overwrites:\n {} U-Boot{}\n {} Kernel\n {} Userspace (rootfs)",
p.tier,
v.manifest.board,
mark(p.writes_uboot),
if p.writes_uboot {
""
} else {
" -- preserved"
},
mark(p.writes_kernel),
mark(p.writes_userspace),
)
}
Err(e) => format!("Could not read flash plan from this file: {e}"),
}
}
/// The colour a component-health state renders in (round 13 #3): grey =
/// unreachable, red = detected but down, yellow = sub-optimal, green = healthy.
fn health_color(pal: &Palette, h: crate::model::CompHealth) -> (u8, u8, u8) {
@@ -842,6 +874,16 @@ pub struct App {
// operation running (refresh, config action, light, firmware, restore, access
// check), its Health cell shows this text instead of the component icons.
op_status: std::collections::HashMap<String, String>,
// IPs of the install currently in flight, so a successful install can arm a
// post-install alkane verification for exactly those boards.
install_targets: HashSet<String>,
// After a successful install a board reboots into alkane; the next scan can
// still catch it mid-reboot answering as stock. Each awaited IP maps to the
// number of scan rounds left to confirm alkane before giving up; while an IP
// waits, a non-alkane row for it is suppressed so the table never flickers to
// stock (the operator sees "verifying alkane..." instead). Issue: post-install
// the row re-scanned as stock before finally showing alkane.
installed_awaiting: HashMap<String, u8>,
// A confirmation dialog for disruptive actions, plus its pending target.
confirm_dialog: Widget,
pending_confirm: Option<(Vec<String>, scan::ConfigAction)>,
@@ -913,6 +955,9 @@ pub struct App {
// release when set; the read-only label beside the button shows it.
install_local_path: Option<String>,
install_local_label: Widget,
// A read-only flash-plan checklist (tier + which regions are overwritten),
// filled from a picked local .afw's manifest.
install_plan_label: Widget,
uninstall_dialog: Widget,
uninstall_pass_input: Widget,
uninstall_firmware_input: Widget,
@@ -1263,6 +1308,8 @@ pub fn build(frame: Widget) -> App {
action_targets: Vec::new(),
pending_password_update: None,
op_status: std::collections::HashMap::new(),
install_targets: HashSet::new(),
installed_awaiting: HashMap::new(),
confirm_dialog: frame,
pending_confirm: None,
flash_confirm_dialog: frame,
@@ -1301,6 +1348,7 @@ pub fn build(frame: Widget) -> App {
install_board: stock_ops::DEFAULT_BOARD.to_string(),
install_local_path: None,
install_local_label: frame,
install_plan_label: frame,
uninstall_dialog: frame,
uninstall_pass_input: frame,
uninstall_firmware_input: frame,
@@ -2755,6 +2803,15 @@ impl App {
12,
);
// Flash-plan checklist: detects the tier and which regions a picked local
// .afw overwrites (U-Boot / Kernel / Userspace).
let plan = Widget::static_text(
dlg,
"Flash plan: pick a local .afw above to see its tier and what it overwrites.",
);
root.add(plan, 0, sf::BORDER_ALL, 12);
self.install_plan_label = plan;
root.add(
Widget::static_text(dlg, "Board password (optional):"),
0,
@@ -2878,6 +2935,9 @@ impl App {
ips.len()
));
self.set_op_status(&ips, "installing...");
// Remember these targets so a successful install arms the post-install
// alkane verification (prevents the stock->alkane re-scan flicker).
self.install_targets = ips.iter().cloned().collect();
self.stock_op = Some(stock_ops::start_install(
ips,
board,
@@ -3019,18 +3079,25 @@ impl App {
let mut oks = 0usize;
let mut fails: Vec<String> = Vec::new();
let mut op_clear: Vec<String> = Vec::new();
// Successfully-installed IPs whose boards should now come up as alkane.
let mut verify_ips: Vec<String> = Vec::new();
let mut progress: Option<String> = None;
loop {
match h.rx.try_recv() {
Ok(StockMsg::Started) => {}
Ok(StockMsg::Progress(s)) => progress = Some(s),
Ok(StockMsg::Result { ip, ok, detail }) => {
if !ip.is_empty() {
op_clear.push(ip.clone());
}
if ok {
oks += 1;
if !ip.is_empty() && self.install_targets.contains(&ip) {
verify_ips.push(ip.clone());
} else if !ip.is_empty() {
op_clear.push(ip.clone());
}
} else {
if !ip.is_empty() {
op_clear.push(ip.clone());
}
fails.push(format!("{ip}: {detail}"));
}
}
@@ -3048,17 +3115,31 @@ impl App {
for ip in &op_clear {
self.op_status.remove(ip);
}
// Arm post-install alkane verification for the boards that installed OK:
// keep a "verifying" status on them and suppress stock re-scan rows until
// they answer as alkane (prevents the stock->alkane flicker).
for ip in &verify_ips {
self.installed_awaiting.insert(ip.clone(), 8);
self.op_status
.insert(ip.clone(), "installed; verifying alkane...".into());
}
if let Some(p) = progress {
wx_rs::set_status_text(&p);
}
if done {
self.stock_op = None;
self.install_targets.clear();
self.op_status
.retain(|_, v| v != "installing..." && v != "restoring...");
}
if !op_clear.is_empty() || done {
if !op_clear.is_empty() || !verify_ips.is_empty() || done {
self.fill_rows();
}
// Kick a dedicated re-probe of the just-installed boards; the row
// suppression below only accepts them once they answer as alkane.
if done && !verify_ips.is_empty() && self.refresh.is_none() && !self.scanning {
self.start_refresh(verify_ips.clone());
}
if done {
if !fails.is_empty() {
// Surface the actual reason, not just a count (issue #38: a bare
@@ -4143,9 +4224,19 @@ impl App {
status = Some(format!("refreshing 0/{total} miner(s)..."));
}
Ok(scan::RefreshMsg::Row(row)) => {
op_clear.push(row.ip.clone());
row.upsert_into(&mut self.rows);
changed = true;
if self.installed_awaiting.contains_key(&row.ip) {
// Accept a just-installed board only once it is alkane.
if crate::alkane_detect::is_alkane(&row) {
self.installed_awaiting.remove(&row.ip);
op_clear.push(row.ip.clone());
row.upsert_into(&mut self.rows);
changed = true;
}
} else {
op_clear.push(row.ip.clone());
row.upsert_into(&mut self.rows);
changed = true;
}
}
Ok(scan::RefreshMsg::Failed { ip, detail }) => {
op_clear.push(ip.clone());
@@ -4175,6 +4266,7 @@ impl App {
self.refresh = None;
// Any stragglers still marked "refreshing..." revert to icons.
self.op_status.retain(|_, v| v != "refreshing...");
Self::tick_installed_awaiting(&mut self.installed_awaiting, &mut self.op_status);
}
// Refresh progress stays in the Health column, not the scan line (#8).
let _ = status;
@@ -4183,6 +4275,34 @@ impl App {
}
}
/// Count down each board awaiting post-install alkane confirmation. When a
/// board's rounds run out, stop suppressing its row and clear the status: the
/// install finished but the board never came up answering as alkane. Takes the
/// two maps directly (not `&mut self`) so it can run while a scan/refresh
/// handle still borrows another field of `self`.
fn tick_installed_awaiting(
awaiting: &mut HashMap<String, u8>,
op_status: &mut HashMap<String, String>,
) {
if awaiting.is_empty() {
return;
}
let mut expired = Vec::new();
for (ip, left) in awaiting.iter_mut() {
*left = left.saturating_sub(1);
if *left == 0 {
expired.push(ip.clone());
}
}
for ip in expired {
awaiting.remove(&ip);
op_status.remove(&ip);
crate::logs::log(format!(
"{ip}: installed, but did not answer as alkane within the verify window"
));
}
}
pub fn drain_scan(&mut self) {
let Some(handle) = &self.scan else { return };
let mut changed = false;
@@ -4221,8 +4341,19 @@ impl App {
Ok(ScanMsg::Row(row)) => {
// Ignore stray rows outside the current target set.
if self.target_ips.is_empty() || self.target_ips.contains(&row.ip) {
row.upsert_into(&mut self.rows);
changed = true;
if self.installed_awaiting.contains_key(&row.ip) {
// Just installed: accept the row only once it answers as
// alkane; a stock mid-reboot answer is suppressed.
if crate::alkane_detect::is_alkane(&row) {
self.installed_awaiting.remove(&row.ip);
self.op_status.remove(&row.ip);
row.upsert_into(&mut self.rows);
changed = true;
}
} else {
row.upsert_into(&mut self.rows);
changed = true;
}
}
}
Ok(ScanMsg::Done(_s)) => {
@@ -4231,8 +4362,17 @@ impl App {
self.progress.show(false);
self.table_parent.layout();
crate::logs::log(format!("scan complete: {} miner(s) found", self.rows.len()));
// Arm the next automatic scan (if the loop is running).
self.countdown = if self.playing { self.auto_secs } else { 0 };
Self::tick_installed_awaiting(&mut self.installed_awaiting, &mut self.op_status);
// Arm the next automatic scan (if the loop is running). While
// boards are still being verified as alkane, re-probe soon
// instead of waiting the full interval.
self.countdown = if !self.installed_awaiting.is_empty() && self.playing {
self.auto_secs.min(12)
} else if self.playing {
self.auto_secs
} else {
0
};
}
Ok(ScanMsg::Failed(e)) => {
self.scanning = false;
@@ -5837,10 +5977,15 @@ impl App {
.unwrap_or_else(|| path.clone());
self.install_local_label
.set_label(&format!("Using local file: {name}"));
self.install_plan_label.set_label(&afw_plan_text(&path));
self.install_local_path = Some(path);
self.install_dialog.layout();
} else {
self.install_local_label
.set_label("(none; using the selected release above)");
self.install_plan_label.set_label(
"Flash plan: pick a local .afw above to see its tier and what it overwrites.",
);
self.install_local_path = None;
}
}