Skip to content

Hide zero-value sidebar file stats#174

Merged
benvinegar merged 1 commit into
mainfrom
sidebar-hide-zero-deltas
Apr 7, 2026
Merged

Hide zero-value sidebar file stats#174
benvinegar merged 1 commit into
mainfrom
sidebar-hide-zero-deltas

Conversation

@benvinegar

Copy link
Copy Markdown
Member

Summary

  • hide zero-value +0 and -0 badges in the file list sidebar
  • keep sidebar stats right-aligned when a file only has additions or only has deletions
  • add coverage for addition-only, deletion-only, and zero-delta sidebar entries

Testing

  • bun run typecheck
  • bun test
  • bun run test:tty-smoke

@greptile-apps

greptile-apps Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR hides zero-value +0 and -0 badges in the sidebar file list by introducing a formatSidebarStat helper that returns null for zero values, and updating sidebarEntryStats to filter out null entries. Right-alignment is preserved for single-side delta files through justifyContent: flex-end on the stats container.

  • Adds formatSidebarStat in files.ts returning null when a stat value is zero, keeping the sidebar clean of noise
  • Updates FileListEntry interface: additionsText and deletionsText are now string | null
  • sidebarEntryStatsWidth and sidebarEntryStats handle null values correctly; files with all-zero stats receive a zero statsWidth and no stats section renders at all
  • New unit tests in files.test.ts cover addition-only, deletion-only, and zero-delta (rename-only) sidebar entries
  • Integration test in ui-components.test.tsx confirms +0/-0 never appear and valid stats (+2 -1, +5, -3) render correctly

Confidence Score: 5/5

This PR is safe to merge — a focused, well-tested UI polish change with no logic regressions.

All changes are additive and well-covered by new tests. Null propagation is handled correctly throughout the stack from formatSidebarStat through FileListEntry → sidebarEntryStats → sidebarEntryStatsWidth → SidebarPane statsWidth → FileListItem rendering. There are no P0 or P1 issues.

No files require special attention.

Important Files Changed

Filename Overview
src/ui/lib/files.ts Adds formatSidebarStat helper returning null for zero-value stats; updates FileListEntry types and buildSidebarEntries accordingly
src/ui/components/panes/FileListItem.tsx Unchanged rendering logic; correctly consumes null-aware sidebarEntryStats output via truthiness filtering
src/ui/components/panes/SidebarPane.tsx statsWidth computation handles all-zero case cleanly; right-alignment via justifyContent: flex-end is preserved
src/ui/lib/files.test.ts New unit tests cover addition-only, deletion-only, and zero-delta entries for buildSidebarEntries
src/ui/components/ui-components.test.tsx Integration test verifies +0/-0 never render and valid delta badges (+2 -1, +5, -3) display correctly

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[buildSidebarEntries] --> B["formatSidebarStat('+', additions)"]
    A --> C["formatSidebarStat('-', deletions)"]
    B --> D{value > 0?}
    C --> D
    D -->|yes| E["+N / -N string"]
    D -->|no| F[null]
    E --> G["FileListEntry\nadditionsText / deletionsText"]
    F --> G
    G --> H[sidebarEntryStats]
    H --> I{additionsText truthy?}
    H --> J{deletionsText truthy?}
    I -->|yes| K[push addition badge]
    J -->|yes| L[push deletion badge]
    I -->|no| M[skip]
    J -->|no| M
    K --> N[sidebarEntryStatsWidth]
    L --> N
    N --> O["SidebarPane\nstatsWidth = max across entries"]
    O --> P["FileListItem\nflex-end right-aligned stats section"]
Loading

Reviews (1): Last reviewed commit: "Hide zero-value sidebar file stats" | Re-trigger Greptile

@benvinegar
benvinegar merged commit 8c20d41 into main Apr 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant