feat(context): include diffHunk in PR review comment context (#1584)

* feat(context): include diffHunk in PR review comment context

Review comments arrived with only path and line, so the code they were
written against was missing from the prompt. Fetch diffHunk in the PR
GraphQL query and render it under the comment as a diff block.

The hunk is PR-authored content, so it goes through sanitizeContent like
the comment body. Comments without a hunk are unchanged.

Fixes #855

* test(formatter): cover outdated review comments with an empty diff hunk

GitHub returns diffHunk: "" (not null) for comments whose line no longer
exists in the diff, so the render guard has to reject empty strings too.
Found running the real query against anthropics/claude-code-action#1025.
This commit is contained in:
Rishav Naskar
2026-08-14 16:32:44 -07:00
committed by GitHub
parent 9678fce999
commit b49813d0e7
4 changed files with 118 additions and 1 deletions
+1
View File
@@ -22,6 +22,7 @@ export type GitHubComment = {
export type GitHubReviewComment = GitHubComment & {
path: string;
line: number | null;
diffHunk?: string | null;
};
export type GitHubCommit = {