Fix dashboard disk widget flickering by sorting disks consistently

- Sort physical devices by name to prevent random HashMap iteration order
- Sort partitions within each device by disk index for consistency
- Eliminates flickering caused by disks changing positions randomly

The dashboard storage section now maintains stable disk order across updates.
This commit is contained in:
Christoffer Martinsson 2025-10-20 11:25:45 +02:00
parent 28896d0b1b
commit 8023da2c1e

View File

@ -474,7 +474,11 @@ impl TuiApp {
let mut devices_to_show = Vec::new();
let mut current_line = 0;
for (physical_device, partitions) in &physical_devices {
// Sort physical devices by name for consistent ordering
let mut sorted_devices: Vec<_> = physical_devices.iter().collect();
sorted_devices.sort_by_key(|(device_name, _)| device_name.as_str());
for (physical_device, partitions) in sorted_devices {
let lines_for_this_device = 2 + partitions.len();
if current_line + lines_for_this_device <= available_lines {
devices_to_show.push((physical_device.clone(), partitions.clone()));
@ -541,7 +545,10 @@ impl TuiApp {
chunk_index += 1;
// Usage lines (one per partition/mount point)
for &disk_index in partitions {
// Sort partitions by disk index for consistent ordering
let mut sorted_partitions = partitions.clone();
sorted_partitions.sort();
for &disk_index in &sorted_partitions {
let mount_point = metric_store
.get_metric(hostname, &format!("disk_{}_mount_point", disk_index))
.map(|m| m.value.as_string())