feat(sidebar): show agent comment counts per file#206
Conversation
Greptile SummaryAdds a compact Confidence Score: 5/5Safe to merge — all findings are P2 style suggestions with no correctness or data-integrity impact. All three comments are non-blocking: a misleading variable name, a minor theme-key semantic choice, and a redundant test. The core logic — counting annotations and rendering the badge before diff stats — is correct and well-covered by the updated tests. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[DiffFile with agent.annotations] --> B[buildSidebarEntries]
B --> C{annotations.length > 0?}
C -- yes --> D[agentCommentsText = '*N']
C -- no --> E[agentCommentsText = null]
D --> F[FileListEntry]
E --> F
F --> G[sidebarEntryStats]
G --> H{agentCommentsText?}
H -- yes --> I[push agent-comment stat first]
H -- no --> J[skip]
I --> K[push addition stat]
J --> K
K --> L[push deletion stat]
L --> M[FileListItem renders badges]
M --> N{stat.kind}
N -- agent-comment --> O[fg: theme.fileModified]
N -- addition --> P[fg: theme.badgeAdded]
N -- deletion --> Q[fg: theme.badgeRemoved]
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/ui/lib/files.ts
Line: 142
Comment:
**Misleading variable name `hunkCommentCount`**
The variable name implies it's counting distinct hunks that have comments, but it actually counts total annotation objects. The inline comment ("Count comment annotations, not distinct hunks") even highlights the mismatch — the comment exists to correct the misleading name. A name like `annotationCount` or `agentCommentCount` would make the intent self-evident without needing the clarifying comment.
```suggestion
const annotationCount = file.agent?.annotations.length ?? 0;
```
And update line 148 accordingly:
```
agentCommentsText: annotationCount > 0 ? `*${annotationCount}` : null,
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: src/ui/components/panes/FileListItem.tsx
Line: 119-127
Comment:
**`theme.fileModified` is semantically off for the agent-comment badge**
`fileModified` names the color used for the "M" state icon that appears on modified files. Using it for the agent-comment badge means both glyphs ("M" and "`*n`") render identically on a modified file, which blurs their distinct meanings. `theme.noteBorder` already carries the "agent/note context" semantic and is already purple across all themes — it's a more precise choice:
```suggestion
fg={
stat.kind === "agent-comment"
? theme.noteBorder
: stat.kind === "addition"
? theme.badgeAdded
: theme.badgeRemoved
}
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: src/ui/lib/files.test.ts
Line: 93-117
Comment:
**Redundant test case**
This test and the one immediately above ("includes compact per-file comment counts before diff stats") share identical structure — both supply 3 annotations and assert `agentCommentsText: "*3"`. The only structural difference is that one annotation here targets `newRange: [20, 20]`, which is out of range for a 3-line file. If the intent is to verify that out-of-bounds annotations are still counted, the test name and a brief comment should say so explicitly; otherwise this test can simply be removed to avoid duplicating coverage.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "feat(sidebar): show agent comment counts..." | Re-trigger Greptile |
|
|
||
| // Count comment annotations, not distinct hunks, so the sidebar matches what the user | ||
| // can actually see listed in the review session for that file. | ||
| const hunkCommentCount = file.agent?.annotations.length ?? 0; |
There was a problem hiding this comment.
Misleading variable name
hunkCommentCount
The variable name implies it's counting distinct hunks that have comments, but it actually counts total annotation objects. The inline comment ("Count comment annotations, not distinct hunks") even highlights the mismatch — the comment exists to correct the misleading name. A name like annotationCount or agentCommentCount would make the intent self-evident without needing the clarifying comment.
| const hunkCommentCount = file.agent?.annotations.length ?? 0; | |
| const annotationCount = file.agent?.annotations.length ?? 0; |
And update line 148 accordingly:
agentCommentsText: annotationCount > 0 ? `*${annotationCount}` : null,
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/ui/lib/files.ts
Line: 142
Comment:
**Misleading variable name `hunkCommentCount`**
The variable name implies it's counting distinct hunks that have comments, but it actually counts total annotation objects. The inline comment ("Count comment annotations, not distinct hunks") even highlights the mismatch — the comment exists to correct the misleading name. A name like `annotationCount` or `agentCommentCount` would make the intent self-evident without needing the clarifying comment.
```suggestion
const annotationCount = file.agent?.annotations.length ?? 0;
```
And update line 148 accordingly:
```
agentCommentsText: annotationCount > 0 ? `*${annotationCount}` : null,
```
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Renamed the local variable to agentCommentCount so it matches the actual per-file comment count being rendered, and dropped the now-unnecessary clarifying comment.
Responded by Pi using gpt-5.3-codex.
| <text | ||
| fg={ | ||
| stat.kind === "agent-comment" | ||
| ? theme.fileModified | ||
| : stat.kind === "addition" | ||
| ? theme.badgeAdded | ||
| : theme.badgeRemoved | ||
| } | ||
| > |
There was a problem hiding this comment.
theme.fileModified is semantically off for the agent-comment badge
fileModified names the color used for the "M" state icon that appears on modified files. Using it for the agent-comment badge means both glyphs ("M" and "*n") render identically on a modified file, which blurs their distinct meanings. theme.noteBorder already carries the "agent/note context" semantic and is already purple across all themes — it's a more precise choice:
| <text | |
| fg={ | |
| stat.kind === "agent-comment" | |
| ? theme.fileModified | |
| : stat.kind === "addition" | |
| ? theme.badgeAdded | |
| : theme.badgeRemoved | |
| } | |
| > | |
| fg={ | |
| stat.kind === "agent-comment" | |
| ? theme.noteBorder | |
| : stat.kind === "addition" | |
| ? theme.badgeAdded | |
| : theme.badgeRemoved | |
| } |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/ui/components/panes/FileListItem.tsx
Line: 119-127
Comment:
**`theme.fileModified` is semantically off for the agent-comment badge**
`fileModified` names the color used for the "M" state icon that appears on modified files. Using it for the agent-comment badge means both glyphs ("M" and "`*n`") render identically on a modified file, which blurs their distinct meanings. `theme.noteBorder` already carries the "agent/note context" semantic and is already purple across all themes — it's a more precise choice:
```suggestion
fg={
stat.kind === "agent-comment"
? theme.noteBorder
: stat.kind === "addition"
? theme.badgeAdded
: theme.badgeRemoved
}
```
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
Good call — I switched the badge color to theme.noteBorder so the purple *n reads as note context rather than sharing the modified-file icon color.
Responded by Pi using gpt-5.3-codex.
| test("buildSidebarEntries counts all comments attached to a file", () => { | ||
| const withComments = createTestDiffFile({ | ||
| id: "all-comments", | ||
| path: "src/ui/all-comments.ts", | ||
| before: lines("const alpha = 1;", "const beta = 2;", "const gamma = 3;"), | ||
| after: lines("const alpha = 10;", "const beta = 2;", "const gamma = 30;"), | ||
| agent: { | ||
| path: "src/ui/all-comments.ts", | ||
| annotations: [ | ||
| { summary: "First note", newRange: [1, 1] }, | ||
| { summary: "Second note", newRange: [1, 1] }, | ||
| { summary: "Third note", newRange: [20, 20] }, | ||
| ], | ||
| }, | ||
| }); | ||
|
|
||
| const [entry] = buildSidebarEntries([withComments]).filter((item) => item.kind === "file"); | ||
|
|
||
| expect(entry).toMatchObject({ | ||
| name: "all-comments.ts", | ||
| agentCommentsText: "*3", | ||
| additionsText: "+2", | ||
| deletionsText: "-2", | ||
| }); | ||
| }); |
There was a problem hiding this comment.
This test and the one immediately above ("includes compact per-file comment counts before diff stats") share identical structure — both supply 3 annotations and assert agentCommentsText: "*3". The only structural difference is that one annotation here targets newRange: [20, 20], which is out of range for a 3-line file. If the intent is to verify that out-of-bounds annotations are still counted, the test name and a brief comment should say so explicitly; otherwise this test can simply be removed to avoid duplicating coverage.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/ui/lib/files.test.ts
Line: 93-117
Comment:
**Redundant test case**
This test and the one immediately above ("includes compact per-file comment counts before diff stats") share identical structure — both supply 3 annotations and assert `agentCommentsText: "*3"`. The only structural difference is that one annotation here targets `newRange: [20, 20]`, which is out of range for a 3-line file. If the intent is to verify that out-of-bounds annotations are still counted, the test name and a brief comment should say so explicitly; otherwise this test can simply be removed to avoid duplicating coverage.
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
Agreed. I kept the coverage but made the intent explicit by renaming the test to call out that off-range comments still count toward the per-file badge and added a short inline note in the fixture.
Responded by Pi using gpt-5.3-codex.
Summary
*nsidebar badge for files with agent comments+/-diff stats so review metadata stays visually distinct from line churnTesting
This PR description was generated by Pi using gpt-5.3-codex