diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-18 19:23:54 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-18 19:23:54 +0200 |
| commit | 3cc9d42252b7d5f9c24c10ef748cff1d2e1bbd67 (patch) | |
| tree | 1118ef7b2cf4988780e0c3fbc4ec64a4ae211e13 /internal/display/disk.go | |
| parent | f7887117c5269ed0336cc058c78c4b222e0e6b34 (diff) | |
fix: make disk bars visible when idle, filter zram devices, add rendering test
- Draw dim purple background (#180028) instead of black so disk bar slots
are visible even when the disk is idle
- First sample no longer returns early; records baseline and still draws
the bar background
- Filter out zram devices from whole-disk detection
- Add TestDiskBar_Rendering: end-to-end pixel test verifying purple bars
appear after two disk data samples
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/display/disk.go')
| -rw-r--r-- | internal/display/disk.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/internal/display/disk.go b/internal/display/disk.go index 0143b68..9d03ba9 100644 --- a/internal/display/disk.go +++ b/internal/display/disk.go @@ -18,7 +18,7 @@ var nvmePartition = regexp.MustCompile(`^nvme\d+n\d+p\d+$`) // isWholeDisk returns true if the device name represents a whole disk (not a partition, // loop, ram, or device-mapper device). Used to filter /proc/diskstats entries. func isWholeDisk(name string) bool { - if strings.HasPrefix(name, "loop") || strings.HasPrefix(name, "ram") || strings.HasPrefix(name, "dm-") { + if strings.HasPrefix(name, "loop") || strings.HasPrefix(name, "ram") || strings.HasPrefix(name, "dm-") || strings.HasPrefix(name, "zram") { return false } if partitionSuffix.MatchString(name) { @@ -116,22 +116,23 @@ func updateDiskPeak(snap map[string]*stats.HostStats, state *runState, diskMax f // drawDiskBarSmoothed draws a single disk bar with read (top, purple) and write (bottom, // darker purple). Returns the current DiskStamp to be stored as previous for the next frame. func drawDiskBarSmoothed(renderer *sdl.Renderer, cur stats.DiskStamp, cfg *runState, smoothed *struct{ readPct, writePct float64 }, prev stats.DiskStamp, factor float64, barW, x, y, barH int32, extended bool) stats.DiskStamp { - // Clear this slot to black - renderer.SetDrawColor(constants.Black.R, constants.Black.G, constants.Black.B, 255) + // Clear this slot to a dim purple so the bar is visible even when idle. + // This distinguishes "disk bar present but idle" from background. + renderer.SetDrawColor(0x18, 0x00, 0x28, 255) renderer.FillRect(&sdl.Rect{X: x, Y: y, W: barW, H: barH}) // Only recompute when the collector has provided new data (same guard as net bars). if cur.Stamp > prev.Stamp && prev.Stamp > 0 { prev = smoothDiskUtilization(cur, prev, cfg, smoothed, factor) - } else if prev.Stamp == 0 { - // First sample: record but don't draw yet (no delta available) - return cur + } else if prev.Stamp == 0 && cur.Stamp > 0 { + // First sample: record it but can't compute delta yet. + prev = cur } drawDiskHalves(renderer, smoothed, x, y, barW, barH) // In extended mode, overlay a utilization % line - if extended { + if extended && prev.Stamp > 0 { drawDiskUtilLine(renderer, cur, prev, cfg, x, y, barW, barH) } return prev |
