fix(ui): stabilize local header metric row width to prevent jitter (#170)#171
Conversation
Use fixed-width formatted fields for CPU/GPU percentage, temperature, power, and RAM values in the local-mode header metrics row. Each value is right-aligned within a constant-width field so that digit-boundary transitions (e.g. 9.9%→10.0%) no longer shift neighboring segments. Closes #170
Security & Performance ReviewReviewer: Automated analysis Security AnalysisNo security concerns. This PR modifies only format strings for TUI display output. There are no changes to:
The formatting functions ( Performance AnalysisNo performance concerns. The changes are strictly cosmetic adjustments to
None of these paths are hot loops. They execute once per TUI refresh cycle (typically every 1-6 seconds depending on configuration). Edge Case NoteThe fixed-width fields will overflow their padding if values exceed the field width (e.g., power over 999.9W, temperature over 999C). This is acceptable because:
TestsAll 12 VerdictApproved -- no changes needed. |
Implementation Review SummaryIntent
Findings AddressedNone required -- the implementation is correct and complete as submitted. Remaining ItemsNone. Verification
Review DetailsCorrectness: All four formatting changes produce stable display widths across digit boundaries:
Test coverage: Two new tests ( Convention consistency: The right-aligned fixed-width format specifiers ( Edge case note: Power values above 999.9W would exceed the 5-char field width, but this is acceptable for the local header context (single-machine monitoring). The dashboard mode handles multi-kilowatt aggregation separately with kW formatting. Quality checks: |
… header Adds test_format_power_fixed_width and test_format_ram_fixed_separator_position to cover the inline formatting logic in draw_power_sparkline and draw_ram_sparkline, verifying that digit-boundary crossings do not shift column positions.
Use captured variables directly in format! strings per Rust 1.58+ style required by the clippy -D warnings configuration.
PR Finalization CompleteSummary
All checks passing. Ready for merge. |
Summary
" 0.0%"through"100.0%")" 0°C"through"999°C")" 0.0W"through"999.9W")usedportion to the same digit-width astotalso the separator/stays in a fixed column (e.g. always" 0/16GB"through"16/16GB")Test plan
cargo test -p all-smipasses — updated existing assertions and addedtest_format_pct_fixed_widthandtest_format_temp_fixed_display_widthto assert stable byte-lengths across digit boundariescargo clippyclean — no warningscargo fmt --checkclean — formatting unchanged./target/release/all-smi viewin local mode and confirm the metrics row does not shift left/right as values cross 9→10 or 99→100 boundariesCloses #170