From b6df444e3c075dd6dcea228c4a6b81677c9e156f Mon Sep 17 00:00:00 2001 From: noah Date: Wed, 23 Sep 2026 12:21:03 -0600 Subject: [PATCH] round 19 review fixes + Health-column alignment + badge-push fix Health column (operator-reported): give every component-health icon a UNIFORM fixed-width slot in the SegmentRenderer (GetSize + DrawShape), so power/control/ fan/board icons line up in fixed columns across rows regardless of glyph aspect, and left-align the icon columns (Health/Access/Light) so the block anchors at a consistent left edge. The per-icon tooltip hit-test uses the same uniform slot. Code-review-harness fixes: - High: isolate per-miner telemetry with catch_unwind so one miner's get_data panic can't abort the whole scan (and strand the fast-path partial rows). - Medium: fill the zebra stripe across the full cell for right-aligned colored columns (was anchored at the content's left edge, leaving the left unstriped). - Medium: lower the scan-concurrency ceiling 512 -> 256 (128 is fully reliable, 192 already dropped responders on the live fleet). - Medium: board voltage/frequency sort key skips placeholder-zero boards (avg_positive), matching how the cell renders them as "-". - Low: saturating_add for accepted/rejected share sums; moved an orphaned doc comment; corrected a stale comment. CI: fix the README-badge push-back -- `git push -c http.extraheader` is invalid (`-c` must precede the subcommand), so the badge/coverage/bench-baseline commit never actually reached main; now `git -c http.extraheader=... push`. This also lets the bench-delta baseline persist so the delta can compute. Demo: the offline-demo paused miner now has detected (idle) hashboards so the paused-blue Health icons (round 19 #19) are exercised. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01Djv3oncM4LxTS5tb61Ako6 --- .gitea/workflows/release.yml | 4 +- code-review-report.md | 186 +++++++++--------- crates/alkane-gui/src/fixtures.rs | 5 + crates/alkane-gui/src/model.rs | 41 ++-- crates/alkane-gui/src/scan.rs | 25 ++- crates/alkane-gui/src/ui.rs | 11 +- .../cpp_src/widgets_bridge.cpp | 48 +++-- 7 files changed, 186 insertions(+), 134 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 15728d09..62be13b3 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -167,8 +167,8 @@ jobs: git commit -m "ci: refresh README badges [skip release]" API="${GITHUB_API_URL:-https://gitea.bluefla.re/api/v1}" HOST="${API%/api/v1}" - git push "${HOST}/${GITHUB_REPOSITORY}.git" "HEAD:main" \ - -c http.extraheader="Authorization: token ${TOKEN}" || echo "badge push skipped" + git -c http.extraheader="Authorization: token ${TOKEN}" \ + push "${HOST}/${GITHUB_REPOSITORY}.git" "HEAD:main" || echo "badge push skipped" else echo "badges unchanged" fi diff --git a/code-review-report.md b/code-review-report.md index 898ed86b..21bb6d19 100644 --- a/code-review-report.md +++ b/code-review-report.md @@ -1,109 +1,111 @@ -# Code review report +# Code review report -- Round 19 -A recursive, multi-agent review of the project's own source (not vendored -crates), run with sonnet reviewers across five dimensions (correctness, -reliability, security, performance, maintainability). Every candidate finding -was adversarially verified by an independent agent; only findings confirmed real -with medium/high confidence were acted on. The review was run in rounds -- each -round re-reviewed the code after the previous round's fixes -- until it stopped -surfacing new critical/high issues. +A multi-agent review of the Round 19 changes (columns, scan fast-path + +concurrency, per-firmware log delegation, export dialog, the wx-rs bridge +alignment/tooltip work, and the bench-delta CI badge). Four reviewers ran in +parallel across correctness, reliability/concurrency, the C++ bridge + UI, and +security/CI. Every finding was re-read against the code before it was acted on. ## Verdict -Ready to ship. The review ran the full five iterations (the harness cap). Every -confirmed critical and high finding across all five rounds is fixed, the -substantive mediums and lows are fixed, and the remainder are documented, -intentional tradeoffs. Clippy is clean (`-D warnings`, our crate), 99 unit tests -and the headless UI self-test pass, and `cargo audit` passes with two -build-time-only advisories accepted in `.cargo/audit.toml`. +Ready to ship. No Critical findings. The one High (a single miner's telemetry +panic could abort the whole scan) is fixed with per-miner panic isolation. The +Mediums (right-aligned zebra fill, the scan-concurrency ceiling, and the +board-voltage/frequency sort key) are fixed. The tooltip hit-test Medium is +resolved by the Health-column uniform-slot fix. The remaining items are Lows and +documented tradeoffs. CI run 95 was green (93 unit tests + 9 microbenchmarks + +the headless self-test), and the fixes re-check clean (`cargo check --tests`, +`clippy --no-deps -D warnings`). -## Rounds +## Scope -Each round re-reviewed the code after the previous round's fixes. Later rounds -surfaced issues in code paths (and edge cases of earlier fixes) the earlier -rounds had not reached; the new-critical/high rate fell across the run and the -last round found only already-accepted perf tradeoffs plus a few niche items. +Round 19 source only: `crates/alkane-gui/src` (model.rs, ui.rs, scan.rs, +log_scan.rs, export.rs, fixtures.rs, main.rs, presets.rs), `ci/` +(bench-badge.py, gen-badges.py), `.gitea/workflows/release.yml`, and the two +changed wx-rs bridge files (`src/widgets.rs`, `cpp_src/widgets_bridge.cpp`). +Vendored asic-rs and the wxWidgets tree were out of scope (read-only, and the +CIFS mount cannot be recursed safely). -| Round | Confirmed | Crit/High | Outcome | -|-------|-----------|-----------|---------| -| 1 | 18 | 1 crit, 5 high | fixed 13, accepted 5 (waves 1-2) | -| 2 | 20 | 4 high | fixed the highs + security/correctness, accepted perf/CLI (waves 3-4) | -| 3 | 14 | 4 high | unreachable Boards column, action/scan races, char-boundary panic (wave 5) | -| 4 | 17 | 3 high | board-grey regression, unmasked prompt, more races (wave 6) | -| 5 | 11 | 3 high | credential-blank override, scan/action race, change-password lockout (wave 7) | +## Fixed -Roughly 30 distinct real defects were fixed across the run (the totals overlap -because each round re-confirms unresolved/accepted items). +- **[High] No panic isolation around per-miner telemetry** (scan.rs). asic-rs + backends parse miner-controlled data; a panic in one miner's `get_data` unwound + the whole scan thread, aborting every other miner and leaving the Round-19 + partial identity rows stranded. `to_row` is now wrapped in + `AssertUnwindSafe(..).catch_unwind()`, so a panicked miner is skipped (keeping + its partial identity row) and the sweep continues. (`panic = "unwind"` in the + release profile makes this effective.) +- **[Medium] Zebra stripe missing on the left of right-aligned colored columns** + (widgets_bridge.cpp, SegmentRenderer::Render). Right-aligning the colored + columns (round 19 #21) anchored the zebra fill at the content's left edge, so + the left portion of each cell kept the base colour. The fill now over-spans the + column in both directions and lets the cell-DC clip trim it. +- **[Medium] Health-column tooltip landed on the wrong icon** (widgets_bridge.cpp). + The per-icon advance used a different formula in GetSize, DrawShape, and the + tooltip hit-test, so the slot boundaries drifted. All three now use one uniform + fixed-width slot (see the Health-column change below), so the hit-test lines up. +- **[Medium] Scan-concurrency ceiling too high** (scan.rs). The user-adjustable + cap allowed 512; the code documents that 128 is fully reliable and 192 already + dropped responders (which read as phantom faults). Ceiling lowered to 256. +- **[Medium] Board voltage/frequency sort key averaged placeholder zeros** + (model.rs). Those columns store 0.0 for a board with no reading (rendered "-"), + but the sort/filter key averaged the zeros too, mis-ranking miners. A new + `avg_positive` helper skips non-positive entries (board hashrate keeps a plain + average -- a 0.0 there is a genuinely idle board). +- **[Low] Accepted/rejected share summation could overflow** on miner-controlled + counts (scan.rs, model.rs) -- now `saturating_add`. +- **[Low] Orphaned doc comment**: `efficiency_display`'s docs had attached to + `reject_ratio`; reordered. +- **[Low] Stale comment** ("3 combined columns" -> two after the Boards removal). -## Quantitative summary +## Health-column follow-up (operator-reported) -- Source: ~12.5k lines in `crates/alkane-gui` (the other `crates/alkane-*` are - early scaffolding); vendored `asic-rs` + patched `wx-rs` are out of scope. -- Tests: 99 unit tests + a headless UI self-test; microbenchmarks run in CI. -- Line coverage: ~46% of our source (unit tests + the headless self-test, via - `ci/coverage.sh`). The pure logic is well covered (model 81%, naming 95%, - fixtures 100%, credentials 92%); the rest is click-driven dialogs and live - network I/O, which unit tests can't reach without hardware or heavy mocks. - (A tests-only run reports ~35% because the self-test, which exercises ~27% of - ui.rs by rendering real widgets, runs as a separate binary that a plain - `cargo llvm-cov` never counts -- `ci/coverage.sh` merges both runs.) -- Lint: `cargo clippy --no-deps -- -D warnings` clean on our crate. +The right-aligned Health column did not line up across rows: every miner is +padded to the same NUMBER of component-icon slots, but the individual glyphs +(bolt, brain, fan, chip, gap) have different widths, so flush-right the columns +drifted. Fixed by giving every health icon a UNIFORM fixed-width slot in both +`SegmentRenderer::GetSize` and `DrawShape` (each glyph centred in its slot), and +left-aligning the icon columns (Health/Access/Light) so the block anchors at a +consistent left edge. The tooltip hit-test uses the same uniform slot, which also +resolves the tooltip Medium above. -## Fixed (by class) +## Accepted / documented tradeoffs -- **Restore correctness (critical/med):** a Braiins SSH restore reported success - on auth/connection failure -- `run_with_timeout` now captures the exit code and - drains stderr, and a testable `classify_braiins` treats ssh failures as failure; - the LuxOS restore no longer reports failure when the miner reboots mid-reply. -- **Exclusivity (high):** restore-to-stock, firmware flash, and config actions now - refuse to start while any of the others is in flight, so no two operations hit - the same miner and no running handle is orphaned; a restore worker-thread spawn - failure can no longer wedge the subsystem. -- **Secrets off the command line (high):** the access probe, the log fetch, and - the Braiins SSH revert no longer put credentials on argv (curl config on stdin; - `sshpass -e`); the Credentials dialog masks saved passwords; saved pool lists - are chmod 0600; CSV export neutralizes spreadsheet formula injection. -- **Injection / panics (med):** VNish and LuxOS JSON is built with serde (escaped); - log `tail()` no longer panics on a non-UTF8 char boundary; `board_index_from_text` - no longer grabs an unrelated number far past the board keyword. -- **UI responsiveness + correctness (high):** viewing a miner log now runs on a - background thread instead of freezing the UI ~20s; scan telemetry runs - concurrently instead of serially; the Boards numeric filter compares the board - count instead of a composite sort score; the WhatsMiner access probe now uses - the operator's saved password; the columns widget stays in lockstep with the - model when auto-hide-empty changes the shown set (drag-reorder and header sort - fixed). -- **Hygiene (low):** curl/subprocess timeouts reap the child; the fake-mode pools - action honours cancellation; two tests no longer race on the global `$HOME`. +- **Security (Low, release.yml):** the badge push-back passes the ephemeral, + repo-scoped Gitea run token via `git -c http.extraheader`; it is never logged, + but is briefly visible in the runner's process argv. Acceptable on the single + single-tenant capped runner. +- **`[skip release]` (Info):** Gitea recognises `[skip ci]`, not `[skip release]`, + so the badges-only commit does trigger a second workflow run -- but that run cuts + no release (compute-version.sh treats `badges/*`, including bench-baseline.json, + as no-bump), which is the intended, verified behaviour. +- **Paused-blue can mask a faulty board (#19):** a paused miner's detected boards + all render blue by design; power/control/fans keep their true colours. +- **`do_export` opens the save dialog under the App borrow:** harmless + (`try_borrow_mut` drops re-entrant timer ticks; the native save dialog emits no + wx widget events), the scan channel just buffers while it is open. -New regression tests were added for the restore classifier, the Boards filter, -the log-tail boundary, the board-index parser, and the column subset-reorder. +## Verified sound (no change) -## Accepted, documented tradeoffs - -Each is confirmed real but a deliberate choice, now carrying an in-code rationale: -SSH host-key checking is off for LAN miners whose key rotates on reflash; scan -restart uses cooperative cancellation (a hard join would freeze the UI); the -aftermarket re-probe runs per scan for freshness; `fill_rows` clears and refills -(coalesced to one refill per tick); `upsert_into`'s linear scan and the per-render -health recompute are negligible at the tool's fleet scale; bulk config-action -writes stay serial deliberately; and `miner_probe` (a separate diagnostic binary) -uses the global scan credentials, which its output now states explicitly. - -## Security notes - -`cargo audit` reports two advisories, both in the wx-rs build script's -`reqwest 0.11` subtree (h2 0.3 DoS; rustls-pemfile unmaintained). Build-time only, -never linked into the runtime binary, only exercised on Windows/macOS downloads, -and unupgradable without re-vendoring the offline dependency tree. Accepted and -documented in `.cargo/audit.toml` and `deny.toml`. +- Fast-scan partial/full ordering: `buffer_unordered` polls inline on the + single block_on thread and the partial is sent before the future awaits + `get_data`, so a full row never precedes its own partial; the UI `upsert_into` + keys by IP, so the full row replaces the partial (preserving selection). +- WhatsMiner log fallback: `naming::brand` returns "WhatsMiner", which matches the + case-insensitive brand gate, so WhatsMiner correctly routes to the fault-code + view. +- Every new Column arm is internally consistent (is_numeric <-> sort_key <-> + num_value <-> cell blank logic); `timestamp_utc` matches UTC over 200k samples; + the export column subset keeps headers and values aligned; the bench-badge + parser handles all nine bench line formats and the weighted delta is correct; + `tail()` never panics on a non-UTF8 boundary. ## Automated verification -- `cargo test -p alkane-gui` -- 99 passing. -- `cargo clippy -p alkane-gui --no-deps -- -D warnings` -- clean. -- `cargo test -p alkane-gui --release -- --ignored bench_` -- microbenchmarks. -- `ALKANE_SELFTEST=1 alkane-toolkit` under Xvfb -- SELFTEST PASS. -- `cargo audit` -- clean with the accepted-advisory config. - -All run in CI (`verify.yml` on PRs/branches; `release.yml` on main). +- `cargo check --release --tests -p alkane-gui` -- clean (local). +- `cargo clippy -p alkane-gui --no-deps --release --bins -- -D warnings` -- clean. +- CI run 95 (v0.65.0): 93 unit tests + 9 microbenchmarks + headless self-test all + pass; coverage 44%. +- Right-alignment verified from a headless screenshot of the built binary; the + Health-column and paused-blue changes are verified in the next release's + screenshot. diff --git a/crates/alkane-gui/src/fixtures.rs b/crates/alkane-gui/src/fixtures.rs index cf728aa3..11cf5430 100644 --- a/crates/alkane-gui/src/fixtures.rs +++ b/crates/alkane-gui/src/fixtures.rs @@ -92,6 +92,11 @@ impl Board { "10.255.1.166" => vec![Ok, Ok, Missing], _ => vec![Ok, Ok, Ok], } + } else if self.paused { + // A paused miner's boards are physically present but idle (asic-rs + // reports active=false -> Fault), so the Health column shows them blue + // rather than red (round 19 #19); the offline demo mirrors that. + vec![Fault, Fault, Fault] } else { vec![] }; diff --git a/crates/alkane-gui/src/model.rs b/crates/alkane-gui/src/model.rs index 05958985..518041d6 100644 --- a/crates/alkane-gui/src/model.rs +++ b/crates/alkane-gui/src/model.rs @@ -116,6 +116,15 @@ fn avg_or(vals: &[f64], default: f64) -> f64 { } } +/// Mean of the POSITIVE entries in `vals`, or `default` when none are positive. +/// Board voltage/frequency store 0.0 for a board that reports no value (rendered +/// "-"), so a plain average would drag the sort/filter key toward zero and +/// mis-rank the miner (round 19 review); this skips those placeholders. +fn avg_positive(vals: &[f64], default: f64) -> f64 { + let (sum, n) = vals.iter().filter(|&&v| v > 0.0).fold((0.0, 0usize), |(s, n), &v| (s + v, n + 1)); + if n == 0 { default } else { sum / n as f64 } +} + /// Render a per-board vector as one slash-joined cell (blank when empty), each /// value formatted by `f` -- the shared shape of the Board HR/V/freq columns /// (round 19 #10). @@ -895,6 +904,18 @@ impl MinerRow { } } + /// Rejected-share percentage of all submitted shares (round 19 #10), or + /// `None` when the firmware reports neither count. + pub fn reject_ratio(&self) -> Option { + match (self.accepted_shares, self.rejected_shares) { + (Some(a), Some(r)) => { + let total = a.saturating_add(r); + Some(if total > 0 { r as f64 / total as f64 * 100.0 } else { 0.0 }) + } + _ => None, + } + } + /// Efficiency as (value, unit) for display, computed per algorithm (round 19 /// #9/#23). asic-rs stores efficiency as watts-per-TH for EVERY algorithm, /// which is meaningless for Equihash (whose rate is really Sol/s reinterpreted @@ -902,18 +923,6 @@ impl MinerRow { /// real Sol/s count. SHA256/Scrypt families reuse asic-rs's J/TH value. /// `None` when power or hashrate is unknown, so the cell stays blank rather /// than showing a garbage or zero figure. - /// Rejected-share percentage of all submitted shares (round 19 #10), or - /// `None` when the firmware reports neither count. - pub fn reject_ratio(&self) -> Option { - match (self.accepted_shares, self.rejected_shares) { - (Some(a), Some(r)) => { - let total = a + r; - Some(if total > 0 { r as f64 / total as f64 * 100.0 } else { 0.0 }) - } - _ => None, - } - } - pub fn efficiency_display(&self) -> Option<(f64, &'static str)> { if self.algorithm.eq_ignore_ascii_case("equihash") { if self.power_w <= 0.0 || self.hashrate_ths <= 0.0 { @@ -1346,8 +1355,8 @@ impl Column { /// here so a filter like "ChipTemp <= 50" cannot match a miner with no /// temperature reading. pub fn num_value(&self, r: &MinerRow) -> Option { - // The 3 combined (actual/expected) columns must never let a numeric - // filter match a row that only has an expected value: their cell() + // The combined (actual/expected) columns (Hashrate, TotalChips) must never + // let a numeric filter match a row that only has an expected value: their cell() // renders "- / " (non-empty) in that case, so the generic // blank check below is not enough on its own. match self { @@ -1392,8 +1401,8 @@ impl Column { Column::Rejected => SortKey::Num(r.rejected_shares.map(|v| v as f64).unwrap_or(none)), Column::RejectRatio => SortKey::Num(r.reject_ratio().unwrap_or(none)), Column::BoardHashrate => SortKey::Num(avg_or(&r.board_hashrates, none)), - Column::BoardVoltage => SortKey::Num(avg_or(&r.board_voltages, none)), - Column::BoardFrequency => SortKey::Num(avg_or(&r.board_frequencies, none)), + Column::BoardVoltage => SortKey::Num(avg_positive(&r.board_voltages, none)), + Column::BoardFrequency => SortKey::Num(avg_positive(&r.board_frequencies, none)), Column::PsuFan => SortKey::Num(r.psu_fan_rpm), Column::PsuVMin => SortKey::Num(r.psu_voltage_min_v.unwrap_or(none)), Column::PsuVMax => SortKey::Num(r.psu_voltage_max_v.unwrap_or(none)), diff --git a/crates/alkane-gui/src/scan.rs b/crates/alkane-gui/src/scan.rs index 812cceef..240732c9 100644 --- a/crates/alkane-gui/src/scan.rs +++ b/crates/alkane-gui/src/scan.rs @@ -4,7 +4,7 @@ use crate::model::{MinerCaps, MinerRow}; use asic_rs::core::data::firmware::FirmwareImage; use asic_rs::core::traits::miner::Miner; -use futures_util::StreamExt; +use futures_util::{FutureExt, StreamExt}; use measurements::Power; use std::collections::HashSet; use std::net::Ipv4Addr; @@ -50,7 +50,12 @@ pub const SCAN_CONCURRENCY_LIMIT: usize = 128; /// hundreds of connections and saturate the network (round 19 #25). Higher /// values scan faster but can starve per-responder telemetry (see above). pub const MIN_SCAN_CONCURRENCY: usize = 8; -pub const MAX_SCAN_CONCURRENCY: usize = 512; +// Ceiling kept at 256: the code below documents that 128 is fully reliable and 192 +// already dropped responders, and identification + telemetry run concurrently so +// the peak socket count is ~2x this. 256 gives headroom for a fast sweep without +// inviting the mass value-drops (which read as phantom faults) that higher caps +// caused on the live fleet (round 19 review). +pub const MAX_SCAN_CONCURRENCY: usize = 256; pub const SCAN_CONCURRENCY_FILE: &str = "scan-concurrency.txt"; /// Load the saved scan concurrency (in-flight probes), clamped to @@ -469,7 +474,17 @@ pub fn start_scan(lines: Vec, timeout_secs: u64) -> ScanHandle { // ordering holds because the partial is sent before this // future awaits get_data and returns the full row. let _ = ptx.send(ScanMsg::Row(partial_row(&*m, ip))); - (ip, Some(to_row(&*m).await)) + // Isolate one miner's telemetry: asic-rs backends + // parse miner-controlled data, so a panic (a stray + // unwrap/index on a malformed field) must not unwind + // the whole sweep and abort every other miner (round + // 19 review). On panic the miner keeps its partial + // identity row and the scan continues. + let row = std::panic::AssertUnwindSafe(to_row(&*m)) + .catch_unwind() + .await + .ok(); + (ip, row) } None => (ip, None), } @@ -1122,7 +1137,7 @@ async fn to_row(miner: &dyn Miner) -> MinerRow { let mut any = false; for p in data.pools.iter().flat_map(|g| g.pools.iter()) { if let Some(v) = p.accepted_shares { - total += v; + total = total.saturating_add(v); any = true; } } @@ -1133,7 +1148,7 @@ async fn to_row(miner: &dyn Miner) -> MinerRow { let mut any = false; for p in data.pools.iter().flat_map(|g| g.pools.iter()) { if let Some(v) = p.rejected_shares { - total += v; + total = total.saturating_add(v); any = true; } } diff --git a/crates/alkane-gui/src/ui.rs b/crates/alkane-gui/src/ui.rs index 15a09f2d..8f46500f 100644 --- a/crates/alkane-gui/src/ui.rs +++ b/crates/alkane-gui/src/ui.rs @@ -1188,8 +1188,15 @@ impl App { Some((sc, false)) if sc == c => title.push_str(" v"), _ => {} } - // Every column except IP is right-aligned (round 19 #21). - let align = if c == Column::Ip { wx_rs::ALIGN_LEFT } else { wx_rs::ALIGN_RIGHT }; + // Data/text columns are right-aligned (round 19 #21). IP and the + // icon columns (Health/Access/Light) stay left-aligned so their + // fixed-width icon slots anchor at a consistent left edge and line up + // across rows (round 19 Health-column follow-up). + let align = if matches!(c, Column::Ip | Column::Health | Column::Locked | Column::Light) { + wx_rs::ALIGN_LEFT + } else { + wx_rs::ALIGN_RIGHT + }; if matches!(c, Column::Hashrate | Column::Health | Column::TotalChips | Column::ChipTemp | Column::Locked | Column::Light | Column::Error | Column::Status | Column::Firmware) { // These columns show two-tone / multi-tone text (actual vs. // expected) via a custom renderer that parses the segment-encoded diff --git a/thirdparty/wx-rs/wx-rs-0.2.0-patched/cpp_src/widgets_bridge.cpp b/thirdparty/wx-rs/wx-rs-0.2.0-patched/cpp_src/widgets_bridge.cpp index 703c7571..ba9f1c04 100644 --- a/thirdparty/wx-rs/wx-rs-0.2.0-patched/cpp_src/widgets_bridge.cpp +++ b/thirdparty/wx-rs/wx-rs-0.2.0-patched/cpp_src/widgets_bridge.cpp @@ -351,13 +351,16 @@ int DrawShape(wxDC* dc, wxUniChar shape, wxCoord x, const wxRect& cell, const wxBitmap& bmp = ShapeBitmap(shape, *sv, colour, dw, dh); if (bmp.IsOk()) { if (health) { - // Left-align in the full slot (a shrunk fan is centred within it) and - // advance by less than the full icon width so adjacent health icons sit - // close together (the Font Awesome glyphs carry inner margin, so a small - // bounding-box overlap does not visually collide). - dc->DrawBitmap(bmp, x + (w - dw) / 2, cy - dh / 2, true); - int adv = w - 3; - return adv < 1 ? 1 : adv; + // UNIFORM fixed-width slot (round 19): every health icon (and the + // alignment gap) advances by the same amount -- the square (h - 3) -- so + // power/control/fan/board icons line up in fixed columns across rows + // regardless of each glyph's aspect ratio (a narrow bolt or a shrunk fan + // no longer shifts the icons after it). Each glyph is centred in its slot. + // This matches SHAPE_GAP's advance and the per-icon tooltip hit-test. + int adv = h - 3; + if (adv < 1) adv = 1; + dc->DrawBitmap(bmp, x + (adv - dw) / 2, cy - dh / 2, true); + return adv; } int slot = (w > SHAPE_ADVANCE) ? w : SHAPE_ADVANCE; dc->DrawBitmap(bmp, x + (slot - w) / 2, cy - h / 2, true); @@ -452,7 +455,13 @@ class SegmentRenderer : public wxDataViewCustomRenderer { wxRect bg = cell; if (wxDataViewColumn* owner = const_cast(this)->GetOwner()) { int cw = owner->GetWidth(); - if (cw > bg.width) bg.width = cw; + // Extend BOTH directions by the column width. For a right-aligned column + // (round 19 #21) wx anchors `cell` at the content's left edge (near the + // column's right side), so extending only rightward left the column's left + // portion unstriped; over-spanning both sides and letting the cell-DC clip + // trim it fills the whole cell regardless of alignment (round 19 review M1). + bg.x -= cw; + bg.width += 2 * cw; } bg.y -= 40; bg.height += 80; @@ -535,7 +544,10 @@ class SegmentRenderer : public wxDataViewCustomRenderer { } else if (const ShapeSvg* sv = LookupShapeSvg(shape)) { int ww = (sv->vbh > 0) ? (int)((double)hh * sv->vbw / sv->vbh + 0.5) : hh; if (health) { - adv = ww - 3; + // UNIFORM fixed-width slot (round 19), matching DrawShape + the gap, so + // every health icon lines up in fixed columns across rows regardless of + // its glyph aspect. Width is measured square (hh - 3), not per-glyph. + adv = hh - 3; if (adv < 1) adv = 1; } else if (ww > adv) { adv = ww; @@ -975,14 +987,16 @@ static gboolean dvlc_query_tooltip(GtkWidget* tv, gint x, gint y, gboolean keybo GdkRectangle crect; gtk_tree_view_get_cell_area(GTK_TREE_VIEW(tv), path, gcol, &crect); gtk_tree_path_free(path); - // Icon advance must match SegmentRenderer::GetSize, which sizes a health icon - // at 22*zoom and advances by height-3 (square). The old code derived this from - // the row height capped at 28*zoom, which over-estimated the advance and shifted - // every icon's hit slot -- so tooltips landed on the wrong icon or not at all - // (round 19 #2). - int hh = (int)(22 * g_table_zoom + 0.5); - if (hh < 8) hh = 8; - int adv = hh - 3; + // Icon advance must match DrawShape's now-UNIFORM health-icon slot, which is + // (row height - 1, capped at 28*zoom) - 3 for every glyph and gap alike. The + // earlier per-glyph advance (w-3) shifted the hit slots so tooltips landed on + // the wrong icon (round 19 #2); with the uniform slot the hit-test lines up. + int h = crect.height - 1; + int cap = (int)(28 * g_table_zoom + 0.5); + if (cap < 8) cap = 8; + if (h > cap) h = cap; + if (h < 8) h = 8; + int adv = h - 3; if (adv < 1) adv = 1; int n = (int)iit->second.size(); // A right-aligned column (round 19 #21) draws the icon block flush to the