Skip to content

fix(ui): stabilize local header metric row width to prevent left-right jitter #170

Description

@inureyes

Problem / Background

In local view, the top metrics row under the host summary bar shifts left and right as live values change.

The affected row is the compact local-mode summary line that renders:

  • CPU
  • GPU
  • RAM
  • Pwr
  • Tmp

When one metric crosses a digit boundary, neighboring segments move. Typical examples:

  • 9.9% -> 10.0%
  • 99.9% -> 100.0%
  • 99°C -> 100°C
  • 9.9W -> 10.0W
  • RAM used / total strings changing visible width

This makes the local header look unstable even though the rest of the TUI is stationary.

Suspected Code Location

  • src/ui/local_header.rs
  • especially the formatting path around draw_metrics_line() and the per-metric helpers

Expected Behavior

The local header metrics row should have stable horizontal layout across refreshes.

  • Each metric segment should reserve enough width for its value field.
  • Braille sparklines should stay aligned frame-to-frame.
  • One metric growing from 2 digits to 3 digits should not push the following metrics sideways.

Proposed Fix

Use fixed-width or explicitly padded value fields for each metric segment in the local header.

Examples:

  • CPU/GPU percentage fields should reserve width for 100.0%
  • temperature should reserve width for 100°C or a similarly safe upper bound
  • power should reserve width for a stable watt display field
  • RAM should reserve a stable used/total field width, or split/pad the numeric portion so the segment width is constant

If needed, compute display widths once and right-pad or left-pad before writing colored text.

Acceptance Criteria

  • In local mode, the CPU/GPU/RAM/Pwr/Tmp row stays horizontally stable during refreshes.
  • Transitions like 9.9 -> 10.0, 99.9 -> 100.0, and 99 -> 100 do not move neighboring segments.
  • Braille sparklines remain aligned across refreshes.
  • No regression in color rendering or metric content.
  • cargo test and cargo clippy pass.

Notes

This is specifically about the local-mode compact summary header introduced by the local TUI redesign, not the lower Activity panel.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions