Skip to content

feat(code-review): batch review comments into a single agent prompt#1965

Merged
adboio merged 2 commits intomainfrom
batch-review-comments-1827
May 8, 2026
Merged

feat(code-review): batch review comments into a single agent prompt#1965
adboio merged 2 commits intomainfrom
batch-review-comments-1827

Conversation

@adboio
Copy link
Copy Markdown
Contributor

@adboio adboio commented Apr 30, 2026

problem

closes #1827

when giving agent feedback from a diff, users can only submit one comment at a time

changes

allows batching comments into a "review" for the agent

testing

manually

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 30, 2026

Comments Outside Diff (2)

  1. apps/code/src/renderer/features/code-review/utils/reviewPrompts.ts, line 1184 (link)

    P2 Numbered list in prompt violates "no numbers in list" rule

    The batch prompt uses ${idx + 1}. to enumerate comments. The team rule is to avoid numbered lists in prompts to prevent confusion when user responses contain numbers themselves — use bullets or letters instead.

    Rule Used: In prompts, avoid using numbers in lists to preven... (source)

    Learned From
    PostHog/posthog#31624

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: apps/code/src/renderer/features/code-review/utils/reviewPrompts.ts
    Line: 1184
    
    Comment:
    **Numbered list in prompt violates "no numbers in list" rule**
    
    The batch prompt uses `${idx + 1}.` to enumerate comments. The team rule is to avoid numbered lists in prompts to prevent confusion when user responses contain numbers themselves — use bullets or letters instead.
    
    
    
    **Rule Used:** In prompts, avoid using numbers in lists to preven... ([source](https://app.greptile.com/review/custom-context?memory=1dd45b94-c307-4dd0-a025-5aa16059229b))
    
    **Learned From**
    [PostHog/posthog#31624](https://github.com/PostHog/posthog/pull/31624)
    
    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!

  2. apps/code/src/renderer/features/code-review/components/PendingReviewBar.tsx, line 563-565 (link)

    P2 Drafts cleared before send succeeds

    clearDrafts is called before sendPromptToAgent, so if the send throws the queued comments are silently lost. The PR description says drafts should clear only on a successful send. Swapping the order aligns implementation with stated intent.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: apps/code/src/renderer/features/code-review/components/PendingReviewBar.tsx
    Line: 563-565
    
    Comment:
    **Drafts cleared before send succeeds**
    
    `clearDrafts` is called before `sendPromptToAgent`, so if the send throws the queued comments are silently lost. The PR description says drafts should clear only on a successful send. Swapping the order aligns implementation with stated intent.
    
    
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
Fix the following 3 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 3
apps/code/src/renderer/features/code-review/utils/reviewPrompts.ts:1184
**Numbered list in prompt violates "no numbers in list" rule**

The batch prompt uses `${idx + 1}.` to enumerate comments. The team rule is to avoid numbered lists in prompts to prevent confusion when user responses contain numbers themselves — use bullets or letters instead.

```suggestion
      return `- In file <file path="${escapedPath}" />, ${lineRef} (${sideLabel}):\n${indented}`;
```

### Issue 2 of 3
apps/code/src/renderer/features/code-review/components/InteractiveFileDiff.tsx:375-389
**`handleEditDraft` duplicated across `PatchDiffView` and `FilesDiffView`**

The same callback — look up the draft by id, call `openCommentForEdit` — is copy-pasted verbatim into both components. Extracting it into the shared `useCommentState` hook (or a small dedicated hook that takes `fileDrafts` and `openCommentForEdit`) would keep this logic OnceAndOnlyOnce and make future changes to the edit flow easier to track.

### Issue 3 of 3
apps/code/src/renderer/features/code-review/components/PendingReviewBar.tsx:563-565
**Drafts cleared before send succeeds**

`clearDrafts` is called before `sendPromptToAgent`, so if the send throws the queued comments are silently lost. The PR description says drafts should clear only on a successful send. Swapping the order aligns implementation with stated intent.

```suggestion
    sendPromptToAgent(taskId, prompt);
    clearDrafts(taskId);
```

Reviews (1): Last reviewed commit: "feat(code-review): batch review comments..." | Re-trigger Greptile

@adboio adboio marked this pull request as draft May 1, 2026 15:19
Closes #1827. Inline review comments now have an "Add to review"
checkbox: when checked, submitting the form queues the comment into a
per-task draft instead of dispatching to the agent. A pinned
PendingReviewBar at the bottom of the review panel lists every queued
draft (file, line range, snippet) with edit / delete affordances and a
single "Send to agent" action that combines all drafts into one prompt
via buildBatchedInlineCommentsPrompt. Drafts also render inline on the
diff at their line range as DraftCommentAnnotation, sharing the same
edit flow as the comment textarea.

Drafts are in-memory per task and clear on successful send, manual
discard, or task unmount. Submitting a one-off comment (checkbox off)
leaves any queued drafts intact. PR comment "Fix with agent" / "Ask
agent" actions are unchanged.

Generated-By: PostHog Code
Task-Id: 53f42d57-7308-48a1-996f-836f1c7536eb
@adboio adboio force-pushed the batch-review-comments-1827 branch from c9d031e to 5943896 Compare May 7, 2026 21:09
Copy link
Copy Markdown
Contributor Author

adboio commented May 7, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@adboio adboio force-pushed the batch-review-comments-1827 branch 2 times, most recently from ed65716 to 2b2e30e Compare May 7, 2026 21:26
@adboio adboio requested a review from a team May 7, 2026 21:27
@adboio adboio marked this pull request as ready for review May 7, 2026 21:29
- Mock @renderer/trpc/client and @features/sessions/service/service in
  ReviewShell.test.tsx so importing ReviewShell (which now transitively
  pulls in sendPromptToAgent → trpcClient) doesn't initialize the IPC
  link at module load time. Fixes the unit-test CI job.
- Use bullets instead of "1.", "2." enumeration in
  buildBatchedInlineCommentsPrompt to match the team rule about avoiding
  numbered lists in agent prompts.
- Send the batched prompt before clearing drafts in PendingReviewBar so
  drafts aren't lost if sendPromptToAgent throws.
- Extract the duplicated handleEditDraft callback in
  InteractiveFileDiff.tsx into a shared useEditDraftHandler hook so the
  edit flow lives in one place.

Generated-By: PostHog Code
Task-Id: 53f42d57-7308-48a1-996f-836f1c7536eb
@adboio adboio force-pushed the batch-review-comments-1827 branch from 2b2e30e to 664fdd5 Compare May 7, 2026 21:29
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 7, 2026

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
apps/code/src/renderer/features/code-review/components/CommentAnnotation.tsx:88-92
The user's explicit opt-out of batching is never persisted. When the user unchecks "Add to review" and sends a comment directly, `setBatchEnabled(taskId, false)` is never called. Because `isBatchEnabled` falls back to `(drafts.length > 0)` when no explicit value is stored, the next comment box will open with the batch checkbox re-checked as long as pending drafts exist — overriding the user's choice every time.

```suggestion
    setBatchEnabled(taskId, false);
    onDismiss();
    sendPromptToAgent(
      taskId,
      buildInlineCommentPrompt(filePath, startLine, endLine, side, text),
    );
```

Reviews (2): Last reviewed commit: "fix(code-review): address PR feedback on..." | Re-trigger Greptile

Copy link
Copy Markdown

@arthurdedeus arthurdedeus left a comment

Choose a reason for hiding this comment

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

lgtm! low-context review, though (codebase-wise)

return `In file <file path="${escapedPath}" />, ${lineRef} (${sideLabel}):\n\n${comment}`;
}

export function buildBatchedInlineCommentsPrompt(
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nice!!

@adboio adboio merged commit 481e499 into main May 8, 2026
16 checks passed
@adboio adboio deleted the batch-review-comments-1827 branch May 8, 2026 15:27
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.

Batch multiple review comments to the agent into a single prompt

2 participants