GUI round 2: selection, scan loop, column management, dark-mode fix
- Fixed "Scan ranges" button label (no longer grows with the range list). - Dark-mode KPI cards: derive colours from the live system theme luminance instead of is_dark(), which mis-detected some GTK dark themes. - Removed the checkbox column; the table is multi-select (wxDV_MULTIPLE, ctrl/shift-click), with the selection tracked by IP so it survives refreshes. - Replaced Rescan with Play / Pause / Stop; added an editable auto-rescan interval (scan-ranges dialog; ~/.config/alkane-toolkit/auto-rescan-secs.txt) with a timer-driven countdown scheduler. - Status bar shows the last-probed IP during a scan and a countdown to the next scan when idle (dropped the "scan complete" text). - Default sort is IP-ascending with a header chevron; IP is column 0, sortable. - Choose-columns dialog is a wxRearrangeCtrl (check to show; up/down or drag to reorder) exposing every metric, including Pool 1/2/3 URL + worker. - Column drag-reorder moves the whole column with its data on drop. - Row separator lines (wxDV_ROW_LINES). GTK3 native has no zebra striping; a GTK4-forward zebra-CSS hook and pkg-config gtk cflags are in place. Scan engine: parse each configured pool's (url, worker); Progress carries the last-probed IP. Model: Column::Sel removed; Pool1/2/3 columns; default IP sort. wx-rs bridge: multi-select + selection/context-menu events + get_selections, alternating-row + zebra-CSS hooks, in-place column title, rearrangeable list, and popup-menu primitives (for the upcoming right-click config menu). Patches 0001-0003 regenerated and round-trip validated. Review fixes: scan loop no longer sticks "scanning" if a thread ends without Done (channel-disconnect handling + Stop force-reset); Play no longer starts a second scan; stale selections pruned on rescan; column apply order/visibility applied atomically. Verified: 22 unit tests, a 14-check headless UI self-test, and interaction checks (multi-select, column rearrange/drag, play/pause/stop, dark mode). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y8h447BPyJR4fioYZvQ9bh
This commit is contained in:
@@ -14,8 +14,9 @@ pub enum ScanMsg {
|
||||
/// A new scan started: `total` addresses to probe, and the exact set of
|
||||
/// target IPs (as strings) so the UI can drop miners no longer in range.
|
||||
Started { total: usize, targets: HashSet<String> },
|
||||
/// Progress update: `done` of `total` addresses probed.
|
||||
Progress { done: usize, total: usize },
|
||||
/// Progress update: `done` of `total` addresses probed; `ip` is the most
|
||||
/// recently probed address (activity indicator).
|
||||
Progress { done: usize, total: usize, ip: String },
|
||||
/// A miner was identified.
|
||||
Row(MinerRow),
|
||||
/// The scan finished (label is informational).
|
||||
@@ -26,7 +27,27 @@ pub enum ScanMsg {
|
||||
|
||||
pub const CONFIG_DIR: &str = ".config/alkane-toolkit";
|
||||
pub const RANGES_FILE: &str = "scan-ranges.txt";
|
||||
pub const AUTO_FILE: &str = "auto-rescan-secs.txt";
|
||||
pub const DEFAULT_RANGE: &str = "10.255.1.0/24";
|
||||
/// Default seconds between automatic rescans.
|
||||
pub const DEFAULT_AUTO_SECS: u64 = 300;
|
||||
|
||||
/// Load the auto-rescan interval in seconds (0 = disabled).
|
||||
pub fn load_auto_secs() -> u64 {
|
||||
std::fs::read_to_string(config_path(AUTO_FILE))
|
||||
.ok()
|
||||
.and_then(|s| s.trim().parse().ok())
|
||||
.unwrap_or(DEFAULT_AUTO_SECS)
|
||||
}
|
||||
|
||||
/// Save the auto-rescan interval in seconds.
|
||||
pub fn save_auto_secs(secs: u64) -> std::io::Result<()> {
|
||||
let p = config_path(AUTO_FILE);
|
||||
if let Some(dir) = p.parent() {
|
||||
std::fs::create_dir_all(dir)?;
|
||||
}
|
||||
std::fs::write(p, secs.to_string())
|
||||
}
|
||||
|
||||
pub fn config_path(file: &str) -> PathBuf {
|
||||
let home = std::env::var("HOME").unwrap_or_else(|_| ".".into());
|
||||
@@ -222,7 +243,7 @@ pub fn start_scan(lines: Vec<String>) -> Receiver<ScanMsg> {
|
||||
if tx.send(ScanMsg::Row(row)).is_err() {
|
||||
return;
|
||||
}
|
||||
let _ = tx.send(ScanMsg::Progress { done: i + 1, total });
|
||||
let _ = tx.send(ScanMsg::Progress { done: i + 1, total, ip: String::new() });
|
||||
}
|
||||
let _ = tx.send(ScanMsg::Done("fixtures".into()));
|
||||
})
|
||||
@@ -273,7 +294,7 @@ pub fn start_scan(lines: Vec<String>) -> Receiver<ScanMsg> {
|
||||
let mut stream = factory.scan_stream_with_ip();
|
||||
let mut done = 0usize;
|
||||
let step = (total / 100).max(1); // throttle progress messages
|
||||
while let Some((_ip, miner)) = stream.next().await {
|
||||
while let Some((ip, miner)) = stream.next().await {
|
||||
done += 1;
|
||||
if let Some(miner) = miner {
|
||||
let row = to_row(&*miner).await;
|
||||
@@ -282,7 +303,7 @@ pub fn start_scan(lines: Vec<String>) -> Receiver<ScanMsg> {
|
||||
}
|
||||
}
|
||||
if done % step == 0 || done == total {
|
||||
let _ = tx.send(ScanMsg::Progress { done, total });
|
||||
let _ = tx.send(ScanMsg::Progress { done, total, ip: ip.to_string() });
|
||||
}
|
||||
}
|
||||
let _ = tx.send(ScanMsg::Done(format!("{total} addresses")));
|
||||
@@ -332,6 +353,18 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
|
||||
let pool_url = active_pool
|
||||
.and_then(|p| p.url.as_ref().map(|u| u.to_string()))
|
||||
.unwrap_or_default();
|
||||
// Each configured pool's (url, worker), in order, across all pool groups.
|
||||
let pools: Vec<(String, String)> = data
|
||||
.pools
|
||||
.iter()
|
||||
.flat_map(|g| g.pools.iter())
|
||||
.map(|p| {
|
||||
(
|
||||
p.url.as_ref().map(|u| u.to_string()).unwrap_or_default(),
|
||||
p.user.clone().unwrap_or_default(),
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
let firmware = match (&data.device_info.firmware, &data.firmware_version) {
|
||||
(fw, Some(v)) if !fw.is_empty() => format!("{fw} {v}"),
|
||||
(fw, Some(v)) => format!("{fw}{v}"),
|
||||
@@ -383,6 +416,7 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
|
||||
expected_hashboards: data.expected_hashboards.map(|v| v as u32),
|
||||
worker,
|
||||
pool_url,
|
||||
pools,
|
||||
best_share: data.best_share,
|
||||
session_best_share: data.session_best_share,
|
||||
uptime_secs: data.uptime.map(|d| d.as_secs()).unwrap_or(0),
|
||||
|
||||
Reference in New Issue
Block a user