From 561c50e5dc6579664ab1de9873fc3f3ba6267eec Mon Sep 17 00:00:00 2001 From: noah Date: Mon, 21 Sep 2026 17:43:45 -0600 Subject: [PATCH] GUI round 16 (#4/#5/#6/#7): UMC OS colour, pool + restore dialog polish, new icons - #4 ePIC miners report their firmware family as "UMC OS"; colour that row light blue in the Firmware column (was falling through to the theme default / black), matching the existing ePIC colour. - #5 Configure-pools dialog: widen the "+" buttons so the glyph shows; the dropdown "add" entry now reads "Add new"; user-added values can be removed via a "Remove saved value" submenu (pool_prefs::remove_saved); dropped the intro tidbit and narrowed the window. - #6 Restore-to-stock confirmation: the miner list is now a height-capped, scrollable text box instead of one unbounded label, so restoring hundreds at once stays usable. Removed the "Flash firmware..." right-click option for now (the in-app flash path is parked while it is reworked). - #7 Replaced the brain (control board) and fan Health icons with the new operator-supplied artwork, image-traced from PNG to SVG (potrace) and stripped of explicit fills so the Health column's per-state recolouring still applies. Headless selftest passes (fixtures render through the real widgets); all GUI unit tests pass. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01Djv3oncM4LxTS5tb61Ako6 --- .../assets/icons/brain-solid-full.svg | 30 +++++- .../assets/icons/fan-solid-full.svg | 39 +++++++- crates/alkane-gui/src/pool_prefs.rs | 15 +++ crates/alkane-gui/src/ui.rs | 91 ++++++++++++------- 4 files changed, 138 insertions(+), 37 deletions(-) diff --git a/crates/alkane-gui/assets/icons/brain-solid-full.svg b/crates/alkane-gui/assets/icons/brain-solid-full.svg index 4a7af7fe..b053cb82 100644 --- a/crates/alkane-gui/assets/icons/brain-solid-full.svg +++ b/crates/alkane-gui/assets/icons/brain-solid-full.svg @@ -1 +1,29 @@ - \ No newline at end of file + + + + + diff --git a/crates/alkane-gui/assets/icons/fan-solid-full.svg b/crates/alkane-gui/assets/icons/fan-solid-full.svg index a0d420f4..0638ccdd 100644 --- a/crates/alkane-gui/assets/icons/fan-solid-full.svg +++ b/crates/alkane-gui/assets/icons/fan-solid-full.svg @@ -1 +1,38 @@ - \ No newline at end of file + + + + + + + + + + + diff --git a/crates/alkane-gui/src/pool_prefs.rs b/crates/alkane-gui/src/pool_prefs.rs index 69d4b1aa..91c4cc16 100644 --- a/crates/alkane-gui/src/pool_prefs.rs +++ b/crates/alkane-gui/src/pool_prefs.rs @@ -95,6 +95,21 @@ pub fn add_saved(field: PoolField, value: &str) -> bool { true } +/// Remove `value` from `field`'s saved list (round 16 #5). Returns true if it was +/// present and removed. Presets cannot be removed (they are not in the saved file). +pub fn remove_saved(field: PoolField, value: &str) -> bool { + let value = value.trim(); + let mut saved = load_saved(field); + let before = saved.len(); + saved.retain(|s| s != value); + if saved.len() == before { + return false; + } + let p = config_path(field.saved_file()); + let _ = std::fs::write(p, saved.join("\n")); + true +} + /// The full dropdown list for a field: presets first, then the user's saved /// values. For the address field each entry is labelled with the pool name. pub fn dropdown_entries(field: PoolField) -> Vec<(String, String)> { diff --git a/crates/alkane-gui/src/ui.rs b/crates/alkane-gui/src/ui.rs index f7245b2f..60c90199 100644 --- a/crates/alkane-gui/src/ui.rs +++ b/crates/alkane-gui/src/ui.rs @@ -82,8 +82,9 @@ const ID_POOLS_CANCEL: i32 = 789; // Pool-field "+" dropdown buttons (round 15 #1): 12 buttons (3 rows x 4 fields), // id = base + row*4 + field. The dropdown menu items use their own id range. const ID_POOL_PLUS_BASE: i32 = 800; -const ID_POOL_MENU_ADD: i32 = 819; // "add current box value to the dropdown" +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. const ID_ACTION_OK: i32 = 740; const ID_ACTION_CANCEL: i32 = 741; @@ -195,7 +196,7 @@ fn firmware_color(family: &str) -> Option<(u8, u8, u8)> { "luxos" | "lux" => (185, 150, 20), // yellow/gold "vnish" => (40, 165, 70), // green "bixbit" => (225, 105, 175), // pink - "epic" => (70, 160, 225), // light blue + "epic" | "umc os" | "umcos" | "umc" => (70, 160, 225), // ePIC PowerPlay / UMC OS: light blue "hive" | "hiveos" => (235, 140, 35), // orange "alkane" => (80, 100, 205), // navy _ => return None, // Stock / unknown -> theme default @@ -1469,15 +1470,11 @@ impl App { menu.menu_append(ID_CTX_POOLS, &format!("Configure pools...{sfx}")); } } - // Firmware flash is offered when AT LEAST ONE selected miner supports - // it (not the full intersection) -- flashing a mixed batch simply - // skips the miners that don't. - let flashable = selected.iter().filter(|r| r.caps.firmware_flash).count(); - if flashable > 0 { - menu.menu_append_separator(); - let sfx = if flashable == 1 { String::new() } else { format!(" ({flashable})") }; - menu.menu_append(ID_CTX_FLASH, &format!("Flash firmware...{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 + + // the vendor installers cover the current workflow. (ID_CTX_FLASH and the + // flash dialog remain in the code, just not surfaced here.) + let _ = ID_CTX_FLASH; self.pending_popup = Some((t, menu)); } @@ -1532,17 +1529,10 @@ impl App { let n = self.selected_ip_list().len(); let frame = Widget::main_frame(); let dlg = Widget::dialog(frame, "Configure pools"); + let _ = n; let root = Widget::box_sizer(true); - root.add( - Widget::static_text( - dlg, - &format!("Set up to 3 pools on {n} selected miner(s). Leave a row blank to skip it; address + account are required for a used row. Use \"+\" for presets; worker placeholders (e.g. {{ip4}}, {{serial}}) expand per miner and insert at the cursor."), - ), - 0, - sf::BORDER_ALL, - 8, - ); - // Column headers. + // Column headers (round 16 #5: no intro tidbit; the "+" presets + worker + // placeholders are self-explanatory in the menus). let head = Widget::box_sizer(false); let hl = |t: &str, w: i32| { let l = Widget::static_text(dlg, t); @@ -1550,15 +1540,15 @@ impl App { l }; head.add(hl("", 46), 0, sf::BORDER_LEFT, 6); - head.add(hl("Address", 210), 0, sf::BORDER_LEFT, 6); - head.add(hl("Account", 150), 0, sf::BORDER_LEFT, 6); - head.add(hl("Worker", 150), 0, sf::BORDER_LEFT, 6); - head.add(hl("Password", 110), 0, sf::BORDER_LEFT, 6); + head.add(hl("Address", 176), 0, sf::BORDER_LEFT, 6); + head.add(hl("Account", 116), 0, sf::BORDER_LEFT, 6); + head.add(hl("Worker", 116), 0, sf::BORDER_LEFT, 6); + head.add(hl("Password", 76), 0, sf::BORDER_LEFT, 6); root.add_sizer(head, 0, sf::BORDER_LEFT | sf::BORDER_RIGHT | sf::BORDER_TOP, 6); let mut fields: Vec = Vec::with_capacity(12); // widths per field type (address, account, worker, password). - let widths = [180, 120, 120, 80]; + let widths = [170, 110, 110, 70]; for row in 0..3usize { let rsizer = Widget::box_sizer(false); let lbl = Widget::static_text(dlg, &format!("Pool {}", row + 1)); @@ -1569,7 +1559,7 @@ impl App { input.set_min_size(widths[field], -1); rsizer.add(input, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_LEFT, 6); let plus = Widget::button(dlg, "+", ID_POOL_PLUS_BASE + (row * 4 + field) as i32); - plus.set_min_size(26, -1); + plus.set_min_size(34, -1); // wide enough that the "+" glyph isn't clipped rsizer.add(plus, 0, sf::ALIGN_CENTRE_VERTICAL, 0); fields.push(input); } @@ -1581,7 +1571,7 @@ impl App { btns.add(Widget::button(dlg, "Cancel", ID_POOLS_CANCEL), 0, sf::BORDER_ALL, 6); root.add_sizer(btns, 0, sf::EXPAND | sf::BORDER_ALL, 6); root.set_sizer_on(dlg); - dlg.set_min_size(760, 260); + dlg.set_min_size(560, 220); // round 16 #5: narrower; fit() grows to content dlg.fit(dlg); self.pools_dialog = dlg; self.pool_fields = fields; @@ -1614,7 +1604,17 @@ impl App { self.pool_menu_values.push(value); } menu.menu_append_separator(); - menu.menu_append(ID_POOL_MENU_ADD, "Add this box's value to the list"); + menu.menu_append(ID_POOL_MENU_ADD, "Add new"); + // Let the user remove values they previously added (round 16 #5); presets + // are built-in and stay. Listed in a submenu keyed by saved-list index. + let saved = crate::pool_prefs::load_saved(field); + if !saved.is_empty() { + let sub = Widget::menu_new(); + for (i, val) in saved.iter().enumerate() { + sub.menu_append(ID_POOL_MENU_REMOVE_BASE + i as i32, val); + } + menu.menu_append_submenu("Remove saved value", sub); + } self.pool_menu_target = target; self.pool_menu_field = field; self.pending_popup = Some((self.pools_dialog, menu)); @@ -1634,6 +1634,17 @@ impl App { } return; } + // Remove a previously-saved value (round 16 #5). + if id >= ID_POOL_MENU_REMOVE_BASE { + let ri = (id - ID_POOL_MENU_REMOVE_BASE) as usize; + let saved = crate::pool_prefs::load_saved(self.pool_menu_field); + if let Some(val) = saved.get(ri) { + if crate::pool_prefs::remove_saved(self.pool_menu_field, val) { + wx_rs::set_status_text("removed from the dropdown list"); + } + } + return; + } let idx = (id - ID_POOL_MENU_BASE) as usize; let Some(value) = self.pool_menu_values.get(idx).cloned() else { return; @@ -1822,24 +1833,34 @@ impl App { let n = targets.len(); let list = targets .iter() - .map(|t| format!(" {} ({})", t.ip, t.firmware)) + .map(|t| format!("{} ({})", t.ip, t.firmware)) .collect::>() .join("\n"); self.pending_restore = targets; let frame = Widget::main_frame(); let dlg = Widget::dialog(frame, "Restore to stock firmware"); let root = Widget::box_sizer(true); - // Simple confirmation (round 15 #11): the list of miners + a one-line - // question, no typed keyword and no long warning tidbit. - let msg = format!("Restore these {n} miner(s) to stock firmware?\n\n{list}"); - root.add(Widget::static_text(dlg, &msg), 0, sf::BORDER_ALL, 12); + // Simple confirmation (round 15 #11): a one-line question + the list of + // miners. The list is a height-capped, scrollable text box (round 16 #6) + // so a selection of hundreds of miners doesn't make the dialog unusably + // tall -- it caps and scrolls instead of growing with the content. + root.add( + Widget::static_text(dlg, &format!("Restore these {n} miner(s) to stock firmware?")), + 0, + sf::BORDER_ALL, + 12, + ); + let listbox = Widget::text_ctrl(dlg, true); + listbox.set_value(&list); + listbox.set_min_size(460, 320); + root.add(listbox, 1, sf::EXPAND | sf::BORDER_LEFT | sf::BORDER_RIGHT, 12); let btns = Widget::box_sizer(false); btns.add_stretch(1); btns.add(Widget::button(dlg, "Restore to stock", ID_RESTORE_OK), 0, sf::BORDER_ALL, 6); btns.add(Widget::button(dlg, "Cancel", ID_RESTORE_CANCEL), 0, sf::BORDER_ALL, 6); root.add_sizer(btns, 0, sf::EXPAND | sf::BORDER_ALL, 6); root.set_sizer_on(dlg); - dlg.set_min_size(420, 180); + dlg.set_min_size(500, 300); dlg.fit(dlg); self.restore_dialog = dlg; Some(dlg)