Fix GUI layout/crash bugs; add operator features, tests, and dev loop

Round 1 (bug fixes + test harness):
- Fix table rendering in the top-left corner: the dvlc was never added to the
  sizer; add it (proportion 1) and re-run layout; drop the space-eating stretch.
- Fix abort on dialog buttons: the dialog root sizers passed ALIGN_CENTRE_VERTICAL
  to a vertical sizer, tripping a wx consistency assert whose handler pumps a
  nested event loop, re-entering dispatch while it held the App RefCell borrow.
  Remove the invalid flags; split dispatch into two phases with try_borrow_mut.
- Fix header-click sort mapping when columns are hidden (use display_columns);
  drag-reorder splices back into the full order without dropping hidden columns.
- Add offline fixtures + ALKANE_FAKE_SCAN and ALKANE_SELFTEST modes; scripts
  ui-selftest.sh and ui-screenshot.sh; AGENTS.md documents the dev loop.

Round 2 (operator requests):
- Redesigned color-coded KPI cards; light/dark mode follows the system theme.
- SI-formatted hashrate/power on the KPIs and columns (685 TH/s, 21.3 kW).
- Scan ranges accept CIDR, single IP, and A.B.C.D-E.F.G.H / A.B.C.D-N ranges;
  oversized ranges (> 1,000,000 addresses) are rejected.
- Scan progress bar over the table + status-bar text; out-of-range miners are
  dropped when a scan starts.
- Columns panel exposes every scannable MinerData metric (All / None / Defaults).
- Excel-style filter panel: per-category value checklists, per-column All/None,
  Apply / Reset / Cancel, blank handling.
- Sort direction marker in the header (updated in place); double-click a row
  opens the miner in the default browser.

wx-rs: extend the widget bridge (gauge, in-place column title, sort indicator,
browser launch, system appearance/colours, widget colours, item-activated);
patches 0002/0003 regenerated and round-trip validated.

Verified: 22 unit tests + a 13-check headless UI self-test, plus a live scan
against the bench fleet.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y8h447BPyJR4fioYZvQ9bh
This commit is contained in:
2026-09-16 16:24:05 -06:00
co-authored by Claude Opus 4.8
parent 53ee49e90a
commit d1ab6aa72a
13 changed files with 2136 additions and 251 deletions
@@ -14,6 +14,10 @@
#include <wx/dialog.h>
#include <wx/timer.h>
#include <wx/vector.h>
#include <wx/gauge.h>
#include <wx/settings.h>
#include <wx/utils.h>
#include <wx/app.h>
typedef void (*WxWidgetEventFn)(int kind, long p1, long p2);
static WxWidgetEventFn g_widget_event = nullptr;
@@ -26,6 +30,7 @@ enum WxWidgetEventKind {
WxEV_DVLC_HEADER_CLICK = 5,
WxEV_DVLC_REORDERED = 6,
WxEV_TIMER_TICK = 7,
WxEV_DVLC_ACTIVATED = 8,
};
extern "C" {
@@ -83,6 +88,17 @@ void wxbr_set_sizer(void* win, void* sizer) {
((wxWindow*)win)->SetSizer((wxSizer*)sizer);
}
// Re-run this window's sizer to (re)position its children. Needed after a
// child window is added to an already-installed sizer (e.g. the table, which
// is created after the frame's sizer is set and rebuilt on column changes).
void wxbr_layout(void* win) { ((wxWindow*)win)->Layout(); }
// Remove a child window from a sizer without destroying the window. Call this
// before destroying a sizer-managed window so the sizer keeps no dangling item.
void wxbr_sizer_detach(void* sizer, void* win) {
((wxSizer*)sizer)->Detach((wxWindow*)win);
}
void wxbr_fit(void* win) { ((wxWindow*)win)->Fit(); }
void wxbr_set_min_size(void* win, int w, int h) {
@@ -102,6 +118,20 @@ void wxbr_set_label(void* win, const char* label) {
else ((wxWindow*)win)->SetLabel(wxString::FromUTF8(label));
}
// Read a control's current label text (used by the headless self-test to read
// back what a KPI static text actually displays).
int wxbr_get_label(void* win, char* buf, int cap) {
wxWindow* w = (wxWindow*)win;
wxStaticText* st = dynamic_cast<wxStaticText*>(w);
wxString s = st ? st->GetLabel() : w->GetLabel();
wxCharBuffer b = s.ToUTF8();
int n = (int)strlen(b.data());
if (n >= cap) n = cap - 1;
memcpy(buf, b.data(), n);
buf[n] = 0;
return n + 1;
}
void wxbr_set_bold(void* win) {
wxWindow* w = (wxWindow*)win;
wxFont f = w->GetFont();
@@ -248,6 +278,19 @@ void* wxbr_dvlc(void* parent) {
lc->Bind(wxEVT_DATAVIEW_COLUMN_REORDERED, [](wxDataViewEvent&) {
if (g_widget_event) g_widget_event(WxEV_DVLC_REORDERED, 0, 0);
});
// Row activation (double-click / Enter): report the row + column so the app
// can, e.g., open the miner's IP in a browser.
lc->Bind(wxEVT_DATAVIEW_ITEM_ACTIVATED, [](wxDataViewEvent& e) {
if (g_widget_event) {
wxDataViewListCtrl* lc =
dynamic_cast<wxDataViewListCtrl*>((wxWindow*)e.GetEventObject());
if (!lc) return;
wxDataViewItem item = e.GetItem();
if (!item.IsOk()) return;
int row = lc->GetStore()->GetRow(item);
g_widget_event(WxEV_DVLC_ACTIVATED, row, (long)e.GetColumn());
}
});
return (void*)lc;
}
@@ -269,7 +312,9 @@ void wxbr_dvlc_append_row(void* win, int nvals, const char** vals) {
wxVector<wxVariant> values;
for (int i = 0; i < nvals; i++) {
if (i == 0)
values.push_back(wxVariant(false)); // toggle column (checkbox)
// toggle column (checkbox): vals[0] carries the checked state as "1"/"0"
// so a refresh preserves the row selection instead of clearing it.
values.push_back(wxVariant(vals[0] && vals[0][0] == '1'));
else if (vals[i])
values.push_back(wxVariant(wxString::FromUTF8(vals[i])));
else
@@ -313,6 +358,30 @@ int wxbr_dvlc_col_count(void* win) {
return (int)((wxDataViewListCtrl*)win)->GetColumnCount();
}
// Update a column's header text in place (creation index) without recreating
// the control -- used to refresh the ASCII sort marker on a sort click.
void wxbr_dvlc_set_col_title(void* win, int col, const char* title) {
wxDataViewCtrl* dv = (wxDataViewCtrl*)win;
if (col < 0 || (unsigned)col >= dv->GetColumnCount()) return;
wxDataViewColumn* c = dv->GetColumn(col);
if (c) c->SetTitle(wxString::FromUTF8(title));
}
// Show/clear the native sort arrow on a column (creation index). The app does
// its own sorting; this only draws the indicator so the header shows which
// column is the sort key and in which direction.
void wxbr_dvlc_set_sort_indicator(void* win, int col, int active, int ascending) {
wxDataViewCtrl* dv = (wxDataViewCtrl*)win;
if (col < 0 || (unsigned)col >= dv->GetColumnCount()) return;
wxDataViewColumn* c = dv->GetColumn(col);
if (!c) return;
if (active) {
c->SetSortOrder(ascending != 0);
} else if (c->IsSortKey()) {
c->UnsetAsSortKey();
}
}
// model column index (creation order) currently shown at display position pos
int wxbr_dvlc_col_at_pos(void* win, int pos) {
wxDataViewCtrl* dv = (wxDataViewCtrl*)win;
@@ -345,6 +414,76 @@ void* wxbr_timer(int id, int ms) {
return (void*)t;
}
// ---- gauge (progress bar) ---------------------------------------------------
void* wxbr_gauge(void* parent, int range) {
wxGauge* g = new wxGauge((wxWindow*)parent, wxID_ANY, range < 1 ? 1 : range,
wxDefaultPosition, wxSize(-1, 6),
wxGA_HORIZONTAL | wxGA_SMOOTH);
return (void*)g;
}
void wxbr_gauge_set_range(void* win, int range) {
((wxGauge*)win)->SetRange(range < 1 ? 1 : range);
}
void wxbr_gauge_set_value(void* win, int value) {
((wxGauge*)win)->SetValue(value);
}
void wxbr_gauge_pulse(void* win) { ((wxGauge*)win)->Pulse(); }
// ---- show / hide any window -------------------------------------------------
void wxbr_show(void* win, int shown) { ((wxWindow*)win)->Show(shown != 0); }
// ---- open a URL in the default browser --------------------------------------
int wxbr_launch_browser(const char* url) {
return wxLaunchDefaultBrowser(wxString::FromUTF8(url)) ? 1 : 0;
}
// ---- appearance / dark mode -------------------------------------------------
void wxbr_set_appearance_system() {
#if wxCHECK_VERSION(3, 3, 0)
if (wxTheApp) wxTheApp->SetAppearance(wxApp::Appearance::System);
#endif
}
int wxbr_is_dark() {
return wxSystemSettings::GetAppearance().IsDark() ? 1 : 0;
}
// Fetch a theme colour so custom widgets follow light/dark. which:
// 0=window bg, 1=window text, 2=highlight, 3=button face, 4=grey text.
void wxbr_system_color(int which, unsigned char* r, unsigned char* g,
unsigned char* b) {
wxSystemColour idx = wxSYS_COLOUR_WINDOW;
switch (which) {
case 0: idx = wxSYS_COLOUR_WINDOW; break;
case 1: idx = wxSYS_COLOUR_WINDOWTEXT; break;
case 2: idx = wxSYS_COLOUR_HIGHLIGHT; break;
case 3: idx = wxSYS_COLOUR_BTNFACE; break;
case 4: idx = wxSYS_COLOUR_GRAYTEXT; break;
default: idx = wxSYS_COLOUR_WINDOW; break;
}
wxColour c = wxSystemSettings::GetColour(idx);
*r = c.Red();
*g = c.Green();
*b = c.Blue();
}
// ---- widget colours (for the KPI cards) -------------------------------------
void wxbr_set_bg(void* win, int r, int g, int b) {
((wxWindow*)win)->SetBackgroundColour(wxColour(r, g, b));
}
void wxbr_set_fg(void* win, int r, int g, int b) {
((wxWindow*)win)->SetForegroundColour(wxColour(r, g, b));
}
// ---- deferred destroy (safe from event handlers) ----------------------------
void wxbr_destroy(void* win) { ((wxWindow*)win)->Destroy(); }