feat(context): include diffHunk in PR review comment context - #1584
feat(context): include diffHunk in PR review comment context#1584rishavnaskar wants to merge 2 commits into
Conversation
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 anthropics#855
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#1025.
|
Verified end to end rather than only in unit tests — ran the modified
Real output for That third row turned up an edge case worth pinning: #1025's comment is outdated, and GitHub returns |
|
On the failing checks — they're the credential-gated integration suites, not this change. They abort before running any code: Fork PRs don't get repository secrets, so these can't pass from a fork. Same pattern on unrelated fork PRs (e.g. #1576): six passing, thirty failing. All six secret-free checks are green here — Happy to rebase or adjust if anything in the diff needs it. |
Fixes #855.
Review comments were passed to Claude with only
pathandline, so the code the comment was actually written against never reached the prompt.diffHunkis available onPullRequestReviewCommentin the GraphQL API but wasn't being selected.Before
After
gh api graphql -f query='query { __type(name: "PullRequestReviewComment") { fields { name } } }'
→ diffHunk, line, path
bun test 806 pass, 0 fail
bun run typecheck clean
bun run format:check clean