GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(context): include diffHunk in PR review comment context by rishavnaskar · Pull Request #1584 · anthropics/claude-code-action

Conversation

@rishavnaskar

@rishavnaskar rishavnaskar commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #855.

Review comments were passed to Claude with only path and line, so the code the comment was actually written against never reached the prompt. diffHunk is available on PullRequestReviewComment in the GraphQL API but wasn't being selected.

Before

  [Comment on src/index.ts:42]: This can overflow

After

  [Comment on src/index.ts:42]: This can overflow
  Diff context:
  ```diff
  @@ -40,3 +40,3 @@
  -const a = 1;
  +const a = 2;

Three changes: select `diffHunk` in the reviews query, add it to `GitHubReviewComment` as optional, and render it under the comment.

Two notes on the implementation:

- The hunk is PR-authored content reaching the prompt, so it goes through `sanitizeContent` the same way the comment body does.
- It's optional and the render is guarded, so comments without a hunk produce byte-identical output to before. All existing `formatReviewComments` tests pass unchanged.

Verified `diffHunk` against the live schema rather than assuming:

gh api graphql -f query='query { __type(name: "PullRequestReviewComment") { fields { name } } }'
→ diffHunk, line, path


### Tests

Two cases added to `test/data-formatter.test.ts`: a comment with a hunk, and one without. On `main` the first fails (`Expected to contain: "Diff context:"`); the second passes both before and after, which is the control showing existing output is unaffected.

bun test 806 pass, 0 fail
bun run typecheck clean
bun run format:check clean

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
rishavnaskar added 2 commits August 3, 2026 02:08
@rishavnaskar
feat(context): include diffHunk in PR review comment context
adde05b
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
@rishavnaskar
test(formatter): cover outdated review comments with an empty diff hunk
8021217
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.
@rishavnaskar

rishavnaskar commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

Verified end to end rather than only in unit tests — ran the modified PR_QUERY against real public PRs and piped the live response through formatReviewComments:

PR review comments populated diffHunk on main on this branch
cli/cli#13988 1 0 1
denoland/deno#36111 3 0 3
anthropics/claude-code-action#1025 1 0 0 (see below)

Real output for cli/cli#13988:

  [Comment on api/client_test.go:193]: Interesting that we didn't have a test for this! 🤔
  Diff context:
```diff
@@ -138,6 +139,100 @@ func TestRESTError(t *testing.T) {
 	}
 }

+func TestRESTWithNextError(t *testing.T) {

That third row turned up an edge case worth pinning: #1025's comment is outdated, and GitHub returns line: null with diffHunk: "" — an empty string, not null. The guard already skips it because "" is falsy, but a later change to diffHunk != null would emit an empty ```diff block. Added a regression test for it in 8021217.

bun test              807 pass, 0 fail
bun run typecheck     clean
bun run format:check  clean
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rishavnaskar

rishavnaskar commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

On the failing checks — they're the credential-gated integration suites, not this change.

They abort before running any code:

Secret source: None
##[error]Environment variable validation failed:
  - Either ANTHROPIC_API_KEY, CLAUDE_CODE_OAUTH_TOKEN, or workload identity federation
    (ANTHROPIC_FEDERATION_RULE_ID and ANTHROPIC_ORGANIZATION_ID) is required

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 — test, typecheck, prettier (and their ci / duplicates), so the full unit suite passes in CI as well as locally.

Happy to rebase or adjust if anything in the diff needs it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ashwin-ant
ashwin-ant approved these changes Aug 14, 2026
View reviewed changes
@ashwin-ant
ashwin-ant merged commit b49813d into anthropics:main Aug 14, 2026
6 of 36 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@rishavnaskar
rishavnaskar deleted the feat/review-comment-diff-hunk branch August 15, 2026 09:38
@github-actions github-actions Bot mentioned this pull request Aug 22, 2026
chore(deps): update anthropics/claude-code-action action to v1.0.194 lacolaco/zenn#403
Merged
1 task
mergify Bot added a commit to ArcadeData/arcadedb that referenced this pull request Aug 23, 2026
@mergify
build(deps): bump the github-actions group with 2 updates [skip ci]
9b7de9d
Bumps the github-actions group with 2 updates: [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) and [anthropics/claude-code-action](https://github.com/anthropics/claude-code-action).
Updates `docker/setup-buildx-action` from 4.2.0 to 4.3.0
Release notes

*Sourced from [docker/setup-buildx-action's releases](https://github.com/docker/setup-buildx-action/releases).*

> v4.3.0
> ------
>
> * Bump `@​docker/actions-toolkit` from 0.92.0 to 0.95.0 in [docker/setup-buildx-action#595](https://redirect.github.com/docker/setup-buildx-action/pull/595)
> * Bump brace-expansion from 1.1.13 to 1.1.18 in [docker/setup-buildx-action#600](https://redirect.github.com/docker/setup-buildx-action/pull/600)
> * Bump js-yaml from 5.2.0 to 5.3.0 in [docker/setup-buildx-action#585](https://redirect.github.com/docker/setup-buildx-action/pull/585)
> * Bump postcss from 8.5.10 to 8.5.25 in [docker/setup-buildx-action#598](https://redirect.github.com/docker/setup-buildx-action/pull/598)
> * Bump undici from 6.27.0 to 6.28.0 in [docker/setup-buildx-action#601](https://redirect.github.com/docker/setup-buildx-action/pull/601)
>
> **Full Changelog**: <docker/setup-buildx-action@v4.2.0...v4.3.0>


Commits

* [`37fe631`](docker/setup-buildx-action@37fe631) Merge pull request [#595](https://redirect.github.com/docker/setup-buildx-action/issues/595) from docker/dependabot/npm\_and\_yarn/docker/actions-to...
* [`b5c4f91`](docker/setup-buildx-action@b5c4f91) [dependabot skip] chore: update generated content
* [`3e93b63`](docker/setup-buildx-action@3e93b63) build(deps): bump `@​docker/actions-toolkit` from 0.92.0 to 0.95.0
* [`e527031`](docker/setup-buildx-action@e527031) Merge pull request [#600](https://redirect.github.com/docker/setup-buildx-action/issues/600) from docker/dependabot/npm\_and\_yarn/brace-expansion-1...
* [`c68814b`](docker/setup-buildx-action@c68814b) [dependabot skip] chore: update generated content
* [`3f891b0`](docker/setup-buildx-action@3f891b0) build(deps): bump brace-expansion from 1.1.13 to 1.1.18
* [`787db26`](docker/setup-buildx-action@787db26) Merge pull request [#585](https://redirect.github.com/docker/setup-buildx-action/issues/585) from docker/dependabot/npm\_and\_yarn/js-yaml-5.2.1
* [`f779368`](docker/setup-buildx-action@f779368) [dependabot skip] chore: update generated content
* [`7d5e604`](docker/setup-buildx-action@7d5e604) build(deps): bump js-yaml from 5.2.0 to 5.3.0
* [`292c2fb`](docker/setup-buildx-action@292c2fb) Merge pull request [#590](https://redirect.github.com/docker/setup-buildx-action/issues/590) from docker/dependabot/github\_actions/actions/setup-n...
* Additional commits viewable in [compare view](docker/setup-buildx-action@bb05f3f...37fe631)
  
Updates `anthropics/claude-code-action` from 1.0.192 to 1.0.198
Release notes

*Sourced from [anthropics/claude-code-action's releases](https://github.com/anthropics/claude-code-action/releases).*

> v1.0.198
> --------
>
> **Full Changelog**: <anthropics/claude-code-action@v1.0.197...v1.0.198>
>
> v1.0.197
> --------
>
> What's Changed
> --------------
>
> * fix: neutralize the checkout credential under actions/checkout v6+ include layout ([#1510](https://redirect.github.com/anthropics/claude-code-action/issues/1510)) by [`@​TemRevil`](https://github.com/TemRevil) in [anthropics/claude-code-action#1526](https://redirect.github.com/anthropics/claude-code-action/pull/1526)
>
> New Contributors
> ----------------
>
> * [`@​TemRevil`](https://github.com/TemRevil) made their first contribution in [anthropics/claude-code-action#1526](https://redirect.github.com/anthropics/claude-code-action/pull/1526)
>
> **Full Changelog**: <anthropics/claude-code-action@v1.0.196...v1.0.197>
>
> v1.0.196
> --------
>
> What's Changed
> --------------
>
> * fix(security): unify secret redaction in public comment outputs by [`@​Juwan-Hwang`](https://github.com/Juwan-Hwang) in [anthropics/claude-code-action#1693](https://redirect.github.com/anthropics/claude-code-action/pull/1693)
> * fix: strip unused ALL\_INPUTS environment variable from Claude subprocess env by [`@​Juwan-Hwang`](https://github.com/Juwan-Hwang) in [anthropics/claude-code-action#1692](https://redirect.github.com/anthropics/claude-code-action/pull/1692)
> * fix(github): match bot actors in comment filters using GraphQL \_\_typename by [`@​Neal006`](https://github.com/Neal006) in [anthropics/claude-code-action#1616](https://redirect.github.com/anthropics/claude-code-action/pull/1616)
>
> New Contributors
> ----------------
>
> * [`@​Juwan-Hwang`](https://github.com/Juwan-Hwang) made their first contribution in [anthropics/claude-code-action#1693](https://redirect.github.com/anthropics/claude-code-action/pull/1693)
>
> **Full Changelog**: <anthropics/claude-code-action@v1.0.195...v1.0.196>
>
> v1.0.195
> --------
>
> **Full Changelog**: <anthropics/claude-code-action@v1.0.194...v1.0.195>
>
> v1.0.194
> --------
>
> What's Changed
> --------------
>
> * Harden delete\_files MCP tool: validate paths within repo root (consistency with commit\_files) by [`@​GabrielOnRails`](https://github.com/GabrielOnRails) in [anthropics/claude-code-action#1636](https://redirect.github.com/anthropics/claude-code-action/pull/1636)
> * Only limit fetch depth when the checkout is already shallow by [`@​winklemad`](https://github.com/winklemad) in [anthropics/claude-code-action#1647](https://redirect.github.com/anthropics/claude-code-action/pull/1647)
> * fix(base-action): add ~/.local/bin to $GITHUB\_PATH after auto-install by [`@​anishesg`](https://github.com/anishesg) in [anthropics/claude-code-action#1643](https://redirect.github.com/anthropics/claude-code-action/pull/1643)
> * feat(context): include diffHunk in PR review comment context by [`@​rishavnaskar`](https://github.com/rishavnaskar) in [anthropics/claude-code-action#1584](https://redirect.github.com/anthropics/claude-code-action/pull/1584)
> * ci: skip Claude-backed test jobs on fork PRs by [`@​ashwin-ant`](https://github.com/ashwin-ant) in [anthropics/claude-code-action#1655](https://redirect.github.com/anthropics/claude-code-action/pull/1655)
> * fix: bump shell-quote to 1.8.4 to remediate CVE-2026-9277 by [`@​doshidhaval`](https://github.com/doshidhaval) in [anthropics/claude-code-action#1557](https://redirect.github.com/anthropics/claude-code-action/pull/1557)
> * fix(images): bound attachment downloads by [`@​abhinavkr26104`](https://github.com/abhinavkr26104) in [anthropics/claude-code-action#1625](https://redirect.github.com/anthropics/claude-code-action/pull/1625)
>
> New Contributors
> ----------------
>
> * [`@​GabrielOnRails`](https://github.com/GabrielOnRails) made their first contribution in [anthropics/claude-code-action#1636](https://redirect.github.com/anthropics/claude-code-action/pull/1636)
> * [`@​winklemad`](https://github.com/winklemad) made their first contribution in [anthropics/claude-code-action#1647](https://redirect.github.com/anthropics/claude-code-action/pull/1647)
> * [`@​doshidhaval`](https://github.com/doshidhaval) made their first contribution in [anthropics/claude-code-action#1557](https://redirect.github.com/anthropics/claude-code-action/pull/1557)
>
> **Full Changelog**: <anthropics/claude-code-action@v1.0.193...v1.0.194>
>
> v1.0.193
> --------
>
> **Full Changelog**: <anthropics/claude-code-action@v1.0.192...v1.0.193>


Commits

* [`3f854a8`](anthropics/claude-code-action@3f854a8) chore: bump Claude Code to 2.1.238 and Agent SDK to 0.3.238
* [`5ee796a`](anthropics/claude-code-action@5ee796a) chore: bump Claude Code to 2.1.237 and Agent SDK to 0.3.237
* [`cff8d3c`](anthropics/claude-code-action@cff8d3c) fix(git-config): neutralize checkout credential in include-based config ([#1526](https://redirect.github.com/anthropics/claude-code-action/issues/1526))
* [`e2a4b76`](anthropics/claude-code-action@e2a4b76) chore: bump Claude Code to 2.1.236 and Agent SDK to 0.3.236
* [`65b50df`](anthropics/claude-code-action@65b50df) fix(github): match bot actors in comment filters using GraphQL \_\_typename ([#1](https://redirect.github.com/anthropics/claude-code-action/issues/1)...
* [`0a80d21`](anthropics/claude-code-action@0a80d21) fix: strip unused ALL\_INPUTS environment variable from Claude subprocess env ...
* [`54eadc2`](anthropics/claude-code-action@54eadc2) fix(security): unify secret redaction in public comment outputs ([#1693](https://redirect.github.com/anthropics/claude-code-action/issues/1693))
* [`d40ddef`](anthropics/claude-code-action@d40ddef) chore: bump Claude Code to 2.1.235 and Agent SDK to 0.3.235
* [`459ad35`](anthropics/claude-code-action@459ad35) chore: bump Claude Code to 2.1.234 and Agent SDK to 0.3.234
* [`d721746`](anthropics/claude-code-action@d721746) fix: bound image attachment downloads ([#1625](https://redirect.github.com/anthropics/claude-code-action/issues/1625))
* Additional commits viewable in [compare view](anthropics/claude-code-action@e63208c...3f854a8)
  
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
  
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot show  ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore  major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself)
- `@dependabot ignore  minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself)
- `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency
- `@dependabot unignore  ` will remove the ignore condition of the specified dependency and ignore conditions
@tks-f tks-f mentioned this pull request Sep 11, 2026
"Prompt is too long": review comment diffHunk (#1584) is added to the prompt with no size limit #1819
Open
@serhiy-bzhezytskyy serhiy-bzhezytskyy mentioned this pull request Sep 11, 2026
fix(formatter): keep only the tail of a review comment's diff hunk #1820
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ashwin-ant ashwin-ant ashwin-ant approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Include diffHunk in PR review comment context

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@rishavnaskar @ashwin-ant
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.