Skip to content

refactor: standardize TUI sub-item indentation across all GPU renderers#184

Merged
inureyes merged 2 commits into
mainfrom
refactor/issue-180-standardize-tui-indent
Apr 17, 2026
Merged

refactor: standardize TUI sub-item indentation across all GPU renderers#184
inureyes merged 2 commits into
mainfrom
refactor/issue-180-standardize-tui-indent

Conversation

@inureyes

Copy link
Copy Markdown
Member

Closes #180

Summary

  • Define two pub(crate) constants in src/ui/renderers/utils.rs:
    • SUB_ITEM_INDENT = " " (6 spaces) — applied to per-instance rows nested under a GPU line
    • SECTION_HEADER_INDENT = " " (2 spaces) — applied to section-header lines that introduce a nested block
  • Apply the constants across the three affected renderers:
    • gpu_renderer.rs: render_thermal_pstate_row and render_hardware_details_row now use SUB_ITEM_INDENT (was 5 spaces, unified to 6)
    • vgpu_renderer.rs: header line uses SECTION_HEADER_INDENT, per-instance rows use SUB_ITEM_INDENT
    • mig_renderer.rs: same pattern as vgpu_renderer

Indent value rationale

Six spaces were chosen for SUB_ITEM_INDENT because two of the three affected renderers (vGPU and MIG) already used that width. The GPU renderer's secondary rows were using 5 spaces; they are unified up to 6 for visual consistency. The 2-space SECTION_HEADER_INDENT matches what both vGPU and MIG renderers already used for their section-header lines — no change in appearance for those, just a named constant replacing the literal.

Indent literals that did NOT map to these two categories

The following 5-space literals in gpu_renderer.rs were intentionally left as literals — they are gauge-bar left-padding (a layout concern, not a sub-item nesting indent) and are shared with the CPU, memory, storage, and chassis renderers which are out of scope for this issue:

  • Line 441: " " before the Util/Mem gauge bars
  • cpu_renderer.rs, memory_renderer.rs, storage_renderer.rs, chassis_renderer.rs: all use 5-space left padding for gauge rows — these belong to a separate, future refactor of the gauge-padding constant

The 2-space literals in gpu_renderer.rs (lines 452, 465, 487) are gauge separators between bars, not section-header indents — left unchanged.

Test plan

  • cargo build passes
  • cargo clippy -- -D warnings passes with no warnings
  • cargo test passes (499 unit + 547 integration tests, 0 failures)

Define two shared constants in src/ui/renderers/utils.rs:
- SUB_ITEM_INDENT ("      ", 6 spaces) for per-instance rows nested under
  a GPU line (thermal/P-state, hardware-details, vGPU, MIG)
- SECTION_HEADER_INDENT ("  ", 2 spaces) for section-header lines

Replace all literal indent strings at the affected sites:
- gpu_renderer: render_thermal_pstate_row and render_hardware_details_row
  now use SUB_ITEM_INDENT (was 5 spaces, unified to 6)
- vgpu_renderer: header line uses SECTION_HEADER_INDENT, instance rows
  use SUB_ITEM_INDENT (was "      [" literal, now split into const + "[")
- mig_renderer: same pattern as vgpu_renderer

Closes #180
@inureyes inureyes added type:refactor Code refactoring priority:low Low priority issue device:nvidia-gpu NVIDIA GPU related type:enhancement New feature or request status:review Under review labels Apr 17, 2026
@inureyes

Copy link
Copy Markdown
Member Author

Implementation Review Summary

Intent

Standardize TUI sub-item indentation across GPU, vGPU, and MIG renderers by introducing SUB_ITEM_INDENT (6 spaces) and SECTION_HEADER_INDENT (2 spaces) in utils.rs, and applying them consistently.

Findings Addressed

  • None auto-fixed (no CRITICAL/HIGH findings).

Remaining Items (LOW — reported, not auto-fixed)

  • src/ui/renderers/gpu_renderer.rs:421 — stale comment says "Keeps the same 5-column indent as the thermal row above." — indent is now 6, not 5. Comment-only drift.
  • src/ui/renderers/gpu_renderer.rs:979 — stale test comment says "After the fixed 5-char indent the next printable character must...". The test body uses trim_start_matches(' ') which is indent-width-agnostic (still passes), so only the wording is misleading.

Both items are pure documentation nits; no behavioral impact. Per configured severity threshold, auto-fix was not applied.

Verification

  • All stated requirements implemented (both constants defined, applied to the three target renderers).
  • No placeholder/mock code remaining.
  • Integrated into project code flow (all three renderers import and use the constants; no dead local indent constants left behind).
  • Project conventions followed (refactor: prefix, English, no co-author trailer, pub(crate) constants with descriptive names and doc comments).
  • Existing modules reused where applicable (centralized in utils.rs).
  • No unintended structural changes (only the four files in scope touched; out-of-scope gauge-bar/column literals correctly left as-is per the author's scope note).
  • Tests pass (cargo build, cargo clippy -- -D warnings, cargo fmt --check, 499 unit + all integration tests).

Additional confirmations

  • SUB_ITEM_INDENT measured at 6 spaces exactly, SECTION_HEADER_INDENT at 2 spaces exactly.
  • Grep confirms the 2-space SECTION_HEADER_INDENT is only used at the two section-header sites (vGPU host:, MIG host:), not at any inline separator or gauge-bar padding site.
  • The 5-space gauge-bar paddings in cpu_renderer.rs, memory_renderer.rs, storage_renderer.rs, chassis_renderer.rs, and gpu_renderer.rs:441 are correctly left as literals (out of scope for this issue).

Update two comments that referenced the pre-unification 5-char indent
to name the shared SUB_ITEM_INDENT constant introduced in this PR.
@inureyes inureyes added status:done Completed and removed status:review Under review labels Apr 17, 2026
@inureyes

Copy link
Copy Markdown
Member Author

PR Finalization Complete

Summary

  • Tests: No new tests needed. Existing tests use trim_start_matches(' ') making them indent-agnostic. All 1,122 tests pass (499 unit + 547 integration + doc/compile tests).
  • Documentation: Internal presentation-layer refactor with no public API change. No README or API documentation updates required.
  • Lint/Format: cargo fmt --check clean. cargo clippy --all-targets -- -D warnings clean. No issues to fix.
  • Build: Clean compile, no warnings.

Status transitions

All checks passing. Ready for merge.

@inureyes inureyes merged commit f8557aa into main Apr 17, 2026
4 checks passed
@inureyes inureyes deleted the refactor/issue-180-standardize-tui-indent branch April 17, 2026 07:25
@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

device:nvidia-gpu NVIDIA GPU related priority:low Low priority issue status:done Completed type:enhancement New feature or request type:refactor Code refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: Standardize TUI sub-item indentation across all GPU renderers

1 participant