feat(code-review): batch review comments into a single agent prompt#1965
feat(code-review): batch review comments into a single agent prompt#1965
Conversation
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
|
| const draftAnnotations = useMemo(() => { | ||
| const drafts = editSeed | ||
| ? fileDrafts.filter((d) => d.id !== editSeed.draftId) | ||
| : fileDrafts; | ||
| return buildDraftAnnotations(drafts); | ||
| }, [fileDrafts, editSeed]); | ||
| const annotations = useMemo(() => { | ||
| const all = [...prAnnotations]; | ||
| const all = [...prAnnotations, ...draftAnnotations]; | ||
| if (commentAnnotation) all.push(commentAnnotation); | ||
| return all; | ||
| }, [prAnnotations, commentAnnotation]); | ||
| }, [prAnnotations, draftAnnotations, commentAnnotation]); | ||
|
|
||
| const renderAnnotation = useCallback( | ||
| (annotation: DiffLineAnnotation<AnnotationMetadata>) => | ||
| renderSharedAnnotation( | ||
| annotation, | ||
| renderSharedAnnotation(annotation, { |
There was a problem hiding this comment.
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.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/src/renderer/features/code-review/components/InteractiveFileDiff.tsx
Line: 375-389
Comment:
**`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.
How can I resolve this? If you propose a fix, please make it concise.- 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
Summary
Closes #1827. Lets reviewers queue multiple inline review comments and send them to the agent as one combined prompt instead of one prompt per comment.
PendingReviewBarpinned to the bottom of the review panel lists every queued draft (file, line range, snippet) with edit / delete buttons, click-to-scroll on the file path, and a single Send to agent action that combines all drafts viabuildBatchedInlineCommentsPrompt.DraftCommentAnnotation, sharing the comment textarea for edit.Test plan