Skip to content

feat: show PR diff line counts#1958

Merged
arnestrickmann merged 1 commit into
generalaction:mainfrom
arnestrickmann:emdash/lines-added-and-removed-indicator-a0lhd
May 10, 2026
Merged

feat: show PR diff line counts#1958
arnestrickmann merged 1 commit into
generalaction:mainfrom
arnestrickmann:emdash/lines-added-and-removed-indicator-a0lhd

Conversation

@arnestrickmann
Copy link
Copy Markdown
Contributor

Summary

  • Show added and deleted line counts on each project pull request row
  • Reuse the existing diff line count formatter and hide stats when counts are unavailable

Validation

  • pnpm run format
  • pnpm run lint
  • pnpm run typecheck
  • pnpm run test (fails: existing Featurebase mock is missing NOT_CONFIGURED_ERROR in src/main/core/featurebase/featurebase-issue-provider.test.ts)

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 10, 2026

Greptile Summary

This PR adds a PrDiffStat component that displays the additions and deletions line counts on each PR row, reusing the existing formatDiffLineCount utility. The layout wraps PrMergeLine and the new stat component in a flex row, passing className="flex-1" to keep the merge line from being squeezed.

  • New PrDiffStat component renders +N -N counts in green/red using formatDiffLineCount, with a shrink-0 wrapper to keep it from collapsing.
  • Guard condition (pr.additions == null && pr.deletions == null) uses AND, so the component can render when exactly one count is null, showing a potentially misleading "+0 -X" fallback.

Confidence Score: 4/5

Safe to merge with a small logic fix — the guard condition should use OR so partial null data does not produce misleading '+0 -X' displays.

The change is isolated to a single display component. The null guard allows a partially-null PR stat pair to render with a ?? 0 fallback, contradicting the stated intent to hide stats when unavailable. In practice GitHub always returns additions and deletions together, so this is unlikely to surface immediately, but fixing it aligns the code with the documented intent.

src/renderer/features/projects/components/pr-view/pr-row.tsx — specifically the null guard on line 73

Important Files Changed

Filename Overview
src/renderer/features/projects/components/pr-view/pr-row.tsx Adds PrDiffStat component showing +/- line counts per PR row; wraps PrMergeLine in a flex container. Null guard condition uses AND logic, which can show a misleading "+0 -X" when only one of the two stats is null.
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
src/renderer/features/projects/components/pr-view/pr-row.tsx:73
**Null guard uses AND instead of OR**

The guard `pr.additions == null && pr.deletions == null` only hides the component when *both* counts are absent. If only one field is null (e.g. `additions === null, deletions === 5`), the component renders and the `?? 0` fallback produces a misleading "+0 -5" display. The PR description says "hide stats when counts are unavailable" — that intent matches OR semantics (`||`): render only when *both* values are present.

Consider changing to `if (pr.additions == null || pr.deletions == null) return null;`

```suggestion
  if (pr.additions == null || pr.deletions == null) return null;
```

Reviews (1): Last reviewed commit: "feat: show PR diff line counts" | Re-trigger Greptile

});

function PrDiffStat({ pr }: { pr: PullRequest }) {
if (pr.additions == null && pr.deletions == null) return null;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Null guard uses AND instead of OR

The guard pr.additions == null && pr.deletions == null only hides the component when both counts are absent. If only one field is null (e.g. additions === null, deletions === 5), the component renders and the ?? 0 fallback produces a misleading "+0 -5" display. The PR description says "hide stats when counts are unavailable" — that intent matches OR semantics (||): render only when both values are present.

Consider changing to if (pr.additions == null || pr.deletions == null) return null;

Suggested change
if (pr.additions == null && pr.deletions == null) return null;
if (pr.additions == null || pr.deletions == null) return null;
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/renderer/features/projects/components/pr-view/pr-row.tsx
Line: 73

Comment:
**Null guard uses AND instead of OR**

The guard `pr.additions == null && pr.deletions == null` only hides the component when *both* counts are absent. If only one field is null (e.g. `additions === null, deletions === 5`), the component renders and the `?? 0` fallback produces a misleading "+0 -5" display. The PR description says "hide stats when counts are unavailable" — that intent matches OR semantics (`||`): render only when *both* values are present.

Consider changing to `if (pr.additions == null || pr.deletions == null) return null;`

```suggestion
  if (pr.additions == null || pr.deletions == null) return null;
```

How can I resolve this? If you propose a fix, please make it concise.

@arnestrickmann arnestrickmann merged commit 76aebf8 into generalaction:main May 10, 2026
1 check 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