Skip to content

fix: widen process list TIME+ column to prevent Command drift#151

Merged
inureyes merged 1 commit into
mainfrom
fix/process-list-time-alignment
Apr 8, 2026
Merged

fix: widen process list TIME+ column to prevent Command drift#151
inureyes merged 1 commit into
mainfrom
fix/process-list-time-alignment

Conversation

@inureyes

@inureyes inureyes commented Apr 8, 2026

Copy link
Copy Markdown
Member

Summary

Fixes misalignment between the TIME+ and Command columns in the process list (view mode), where rows containing TIME+ values of 9+ characters push the Command column to the right and break alignment with the header and with rows that have shorter times.

Root cause

src/ui/process_renderer.rs sets fixed_widths[11] = 8 for the TIME+ column, but format_cpu_time can produce values up to 10 characters long ("8760:00:00", hitting the 365-day cap). Values like "213:16:04" (9 chars), "194:49:38" (9 chars), "100:18:34" (9 chars) all overflow the 8-char column.

The format specifier {time_plus:>time_w$} is a minimum width, not a maximum — when a value is longer than time_w, it expands and pushes Command right. Rows with 7-char times (e.g., " 1:22:59") get padded to 8, but rows with 9-char times expand by 1. This compounds in print_process_row_colored where current_pos = col_end is computed assuming no overflow, so output_pos (actual rendered position) drifts from the logical column grid.

Fix

  • Widen fixed_widths[11] from 8 to 10 so all possible TIME+ values right-align cleanly in the column, keeping Command at a consistent position across header and every row.
  • Document the width invariant on format_cpu_time so future changes to the output format are aware of the column-width dependency.
  • Add a regression test test_format_cpu_time_max_width_fits_time_column that enforces the invariant: every boundary value from 0s to 365 days must fit within the 10-char column. If the cap is ever lifted or the format changes, this test will fail loudly.

Test plan

  • cargo test --lib (211 passed, including the new regression test)
  • cargo clippy --lib (clean)
  • cargo fmt --check (clean)
  • Manually verified the invariant: max output "8760:00:00" = 10 chars

Before / after

Before (from the reported screenshot):

  94794 inureyes      4  +0   422G    9M R   0.0  0.0          213:16:04 [privatecloudcomputed]
  84445 inureyes     31  +0   492G  541M R   0.3  0.4            1:17:43 [claude]

213:16:04 (9 chars) overflows the 8-char column, pushing [privatecloudcomputed] one column right of [claude].

After:

  94794 inureyes      4  +0   422G    9M R   0.0  0.0            213:16:04 [privatecloudcomputed]
  84445 inureyes     31  +0   492G  541M R   0.3  0.4              1:17:43 [claude]

All TIME+ values right-align within the 10-char column and Command starts at the same position on every row.

The TIME+ column was fixed at 8 chars, but format_cpu_time can produce
values up to 10 chars ("8760:00:00" at the 365-day cap). Values like
"213:16:04" (9 chars) overflow the column and push the Command column
right, so rows with 9-char times no longer align with the header or
with rows that have shorter times.

Widen fixed_widths[11] from 8 to 10 so all possible TIME+ values
right-align cleanly in the column and Command stays at a consistent
position. Document the width invariant in format_cpu_time and add a
regression test that enforces the maximum output width.
@inureyes inureyes added type:bug Something isn't working status:review Under review priority:medium Medium priority issue labels Apr 8, 2026
@inureyes inureyes merged commit 2ddd47a into main Apr 8, 2026
4 checks passed
@inureyes inureyes deleted the fix/process-list-time-alignment branch April 8, 2026 13:42
@inureyes inureyes self-assigned this Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:medium Medium priority issue status:review Under review type:bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant