feat: show PR diff line counts#1958
Conversation
Greptile SummaryThis PR adds a
Confidence Score: 4/5Safe 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
|
| 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; |
There was a problem hiding this 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;
| 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.
Summary
Validation