GUI + CI: code-review-harness fixes, expanded tests, version-logic tests
build-test-release / release (push) Successful in 5m47s
build-test-release / release (push) Successful in 5m47s
Ran the code-review-harness (four parallel reviewers: correctness, reliability, performance, test-coverage) over the GUI crate and fixed every Critical/High finding, plus grew the test + microbenchmark suite that gates the pipeline. Correctness / reliability fixes: - IP column sorted lexically, not numerically. The default view is IP-ascending but Column::Ip fell through to the generic lowercase-string sort key, so 10.255.1.10 sorted before 10.255.1.2 on every launch. Add a numeric IP sort key (u32, exact in f64) and switch view() to decorate-sort-undecorate so a sort key is computed once per row, not twice per comparison. - Scans had no cancellation. Stop/Apply/Play only dropped the receiver, leaving the background thread probing dead hosts (each waits out an asic-rs timeout), and Play could spawn a second concurrent scan + tokio runtime. Add a ScanHandle with an Arc<AtomicBool> cancel flag the loop checks each iteration, a begin_scan() helper that stops the in-flight scan before starting a new one, and Stop now signals cancellation. - Native column drag never rebuilt the control: column_reordered mutated view.order but skipped rebuild_table(), so the store's creation order diverged from display_columns() and cells rendered under the wrong headers on the next scan tick. Rebuild after applying the reorder. - format_si rounding rolled a mantissa up to "1000" without advancing the SI prefix (999.9 W -> "1000 W", a 4-digit result). Round first, then roll over; [99.95,100) drops its decimal. - start_scan used .expect() on thread spawn, which would panic across the wx FFI boundary; it now sends ScanMsg::Failed and returns the handle. Tests / benchmarks (the pipeline's regression gate): - Unit tests 24 -> 41: format_si/format_uptime boundaries, numeric IP sort, upsert-new-IP, Light three-state + pool-slot-out-of-range cells, filter AND/OR, reorder non-permutation guard; scan.rs parse_cidr/prefix_mask, single-host /32, empty/whitespace, short-range single/reversed, parse_targets aggregate cap + error propagation, validate_ranges, targets_to_cidrs non-contiguous, auto-rescan-secs round-trip. - Microbenchmarks 2 -> 9: view default-sort, sort-by-each-column, filtered view, upsert cold-start, parse_line near MAX_ADDRS, parse_targets many ranges, targets_to_cidrs large range. Floors are 5-10x above local numbers. - New ci/test-compute-version.sh: 9 cases for the X.Y.Z logic (first release, pre-bumped X, backend/UI bumps, docs-only no-op, major-wins-over-UI, backend-wins-over-UI, nested ci/ and thirdparty/wx-rs paths). Wired in as a fast-fail CI step. CI: install libssl-dev + pkg-config (openssl-sys); add xauth so the headless self-test actually launches under xvfb (was aborting on "xauth not found"). Deferred (documented in code-review-report.md, guarded by benches): Cow cells, an ip->index map for upsert. Local: 41 tests + 9 benches + 9 shell tests green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y8h447BPyJR4fioYZvQ9bh
This commit is contained in:
+28
-14
@@ -5,7 +5,6 @@ use crate::model::*;
|
||||
use crate::scan::{self, ScanMsg};
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashSet;
|
||||
use std::sync::mpsc::Receiver;
|
||||
use wx_rs::{Widget, WxEvent, WxEventKind, sizer_flags as sf};
|
||||
|
||||
pub const ID_RANGES: i32 = 101;
|
||||
@@ -90,7 +89,7 @@ pub struct App {
|
||||
pub table: Option<Widget>,
|
||||
table_parent: Widget,
|
||||
root_sizer: Widget,
|
||||
pub scan_rx: Option<Receiver<ScanMsg>>,
|
||||
pub scan: Option<scan::ScanHandle>,
|
||||
pub scanning: bool,
|
||||
scan_total: usize,
|
||||
target_ips: HashSet<String>,
|
||||
@@ -204,7 +203,7 @@ pub fn build(frame: Widget) -> App {
|
||||
table: None,
|
||||
table_parent,
|
||||
root_sizer: root,
|
||||
scan_rx: Some(scan::start_scan(ranges.clone())),
|
||||
scan: Some(scan::start_scan(ranges.clone())),
|
||||
scanning: true,
|
||||
scan_total: 0,
|
||||
target_ips: HashSet::new(),
|
||||
@@ -296,10 +295,10 @@ impl App {
|
||||
}
|
||||
|
||||
pub fn drain_scan(&mut self) {
|
||||
let Some(rx) = &self.scan_rx else { return };
|
||||
let Some(handle) = &self.scan else { return };
|
||||
let mut changed = false;
|
||||
loop {
|
||||
match rx.try_recv() {
|
||||
match handle.rx.try_recv() {
|
||||
Ok(ScanMsg::Started { total, targets }) => {
|
||||
// Drop miners no longer in the target range.
|
||||
let before = self.rows.len();
|
||||
@@ -359,7 +358,7 @@ impl App {
|
||||
self.table_parent.layout();
|
||||
self.countdown = if self.playing { self.auto_secs } else { 0 };
|
||||
}
|
||||
self.scan_rx = None;
|
||||
self.scan = None;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -396,11 +395,21 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
/// Start a fresh scan of the saved ranges.
|
||||
fn start_new_scan(&mut self) {
|
||||
self.scan_rx = Some(scan::start_scan(scan::load_ranges()));
|
||||
/// Cancel any in-flight scan, then start a fresh one over `lines`. Signalling
|
||||
/// the old scan to stop before replacing it prevents two scan threads (and
|
||||
/// two tokio runtimes) probing the network at once.
|
||||
fn begin_scan(&mut self, lines: Vec<String>) {
|
||||
if let Some(old) = self.scan.take() {
|
||||
old.stop();
|
||||
}
|
||||
self.scan = Some(scan::start_scan(lines));
|
||||
self.scanning = true;
|
||||
self.countdown = 0;
|
||||
}
|
||||
|
||||
/// 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...");
|
||||
}
|
||||
|
||||
@@ -483,6 +492,10 @@ impl App {
|
||||
}
|
||||
}
|
||||
self.view.apply_visible_reorder(&new_visible);
|
||||
// Rebuild so the control's column creation order matches the new
|
||||
// display order again; fill_rows/header_click/update_headers all assume
|
||||
// creation order == display_columns(), which the drag alone breaks.
|
||||
self.rebuild_table();
|
||||
}
|
||||
|
||||
/// Build (but do not show) the ranges editor. The caller shows it modally
|
||||
@@ -543,9 +556,7 @@ impl App {
|
||||
let _ = scan::save_auto_secs(secs);
|
||||
}
|
||||
let _ = scan::save_ranges(&lines);
|
||||
self.scan_rx = Some(scan::start_scan(lines.clone()));
|
||||
self.scanning = true;
|
||||
self.countdown = 0;
|
||||
self.begin_scan(lines);
|
||||
wx_rs::set_status_text("scanning...");
|
||||
self.ranges_dialog.close(1);
|
||||
}
|
||||
@@ -757,11 +768,14 @@ impl App {
|
||||
wx_rs::set_status_text(&format!("{} miners - paused", self.rows.len()));
|
||||
}
|
||||
ID_STOP => {
|
||||
// Halt the loop and drop any in-flight scan.
|
||||
// Halt the loop and cancel any in-flight scan (dropping
|
||||
// the receiver alone would leave the thread probing).
|
||||
self.playing = false;
|
||||
self.countdown = 0;
|
||||
self.scanning = false;
|
||||
self.scan_rx = None;
|
||||
if let Some(old) = self.scan.take() {
|
||||
old.stop();
|
||||
}
|
||||
self.progress.show(false);
|
||||
self.table_parent.layout();
|
||||
wx_rs::set_status_text(&format!("{} miners - stopped", self.rows.len()));
|
||||
|
||||
Reference in New Issue
Block a user