-
Notifications
You must be signed in to change notification settings - Fork 0
fix: pre-fetch review comments and allow astral.sh in responder #186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+111
−3
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| --- | ||
| steps: | ||
| - name: Fetch PR review comments | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| PR_NUMBER: ${{ inputs.pr_number }} | ||
| run: | | ||
| mkdir -p /tmp/gh-aw/review-data | ||
|
|
||
| OWNER="${GITHUB_REPOSITORY_OWNER}" | ||
| REPO="${GITHUB_REPOSITORY#*/}" | ||
|
|
||
| echo "Fetching review comments for PR #${PR_NUMBER}..." | ||
|
|
||
| # Fetch review comment threads via GraphQL (includes resolution status) | ||
| gh api graphql -f query=' | ||
| query($owner: String!, $repo: String!, $pr: Int!) { | ||
| repository(owner: $owner, name: $repo) { | ||
| pullRequest(number: $pr) { | ||
| title | ||
| body | ||
| reviewThreads(first: 100) { | ||
| nodes { | ||
| id | ||
| isResolved | ||
| isOutdated | ||
| comments(first: 100) { | ||
| nodes { | ||
| id | ||
| databaseId | ||
| body | ||
| path | ||
| line | ||
| author { login } | ||
| createdAt | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }' -f owner="$OWNER" -f repo="$REPO" -F pr="$PR_NUMBER" \ | ||
| > /tmp/gh-aw/review-data/threads.json | ||
|
|
||
| # Extract unresolved threads for easy agent consumption | ||
| if ! jq '[.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved == false) | .comments = .comments.nodes]' \ | ||
| /tmp/gh-aw/review-data/threads.json \ | ||
| > /tmp/gh-aw/review-data/unresolved-threads.json; then | ||
| echo "Error: Failed to extract unresolved review threads from GraphQL response" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| UNRESOLVED=$(jq 'length' /tmp/gh-aw/review-data/unresolved-threads.json) | ||
| echo "Found ${UNRESOLVED} unresolved thread(s)" | ||
| echo "Data saved to /tmp/gh-aw/review-data/" | ||
| --- | ||
|
|
||
| <!-- | ||
| ## Fetch PR Review Comments | ||
|
|
||
| Shared component that pre-fetches PR review comment threads before the agent runs. | ||
| The agent reads `/tmp/gh-aw/review-data/unresolved-threads.json` instead of using MCP tools. | ||
|
|
||
| ### Why | ||
|
|
||
| The GitHub MCP `pull_request_read` tool intermittently returns empty arrays `[]` inside | ||
| the gh-aw agent sandbox. This has been observed consistently in our repo — the tool | ||
| never reliably returns review comment data. Pre-fetching via `gh api` in a workflow step | ||
| (which has GITHUB_TOKEN) bypasses the MCP entirely. | ||
|
|
||
| ### Output Files | ||
|
|
||
| - `/tmp/gh-aw/review-data/threads.json` — Full GraphQL response with all review threads | ||
| - `/tmp/gh-aw/review-data/unresolved-threads.json` — Filtered to unresolved threads only | ||
|
|
||
| ### Usage | ||
|
|
||
| Import in your workflow: | ||
|
|
||
| ```yaml | ||
| imports: | ||
| - shared/fetch-review-comments.md | ||
| ``` | ||
|
|
||
| Then tell the agent to read the pre-fetched data: | ||
|
|
||
| ```markdown | ||
| Read the unresolved review threads from `/tmp/gh-aw/review-data/unresolved-threads.json`. | ||
| ``` | ||
| --> |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.