fix(github): reply in the triggering review thread#37574
Open
chAwater wants to merge 1 commit into
Open
Conversation
6 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue for this PR
Closes #37560
Type of change
What does this PR do?
When opencode is triggered from an inline review comment (
pull_request_review_commentevent), the reply is posted to the PR conversation as a top-level comment instead of the review thread it was asked in.the
createComment()always callsissues.createCommentopencode/packages/opencode/src/cli/cmd/github.handler.ts
Lines 1264 to 1273 in 45cd8d7
which should be
pulls.createReplyForReviewCommentfor review comment,like the
addReaction, using thereactions.createForPullRequestReviewCommentopencode/packages/opencode/src/cli/cmd/github.handler.ts
Lines 1178 to 1189 in 45cd8d7
And I also add a try-catch block to prevent failure (such as no permission or the comment being deleted) and fall back to old behavior.
the
comment.in_reply_to_idis the root of the thread, also refer to #26689, but I think its on the wrong fileHow did you verify your code works?
(The verification was done with the help of opencode)
Ran the fixed code locally via the handler's built-in mock-event mode:
opencode github run --event <json>, which feeds a webhook payload into the exact code path that runs in GitHub Actions.USE_GITHUB_TOKEN=true GITHUB_TOKEN=$(gh auth token) MODEL=<provider/model> GITHUB_RUN_ID=0 SHARE=false bun run --conditions=browser packages/opencode/src/index.ts github run --event "$(cat event.json)"All comments were created by real GitHub API calls on a real PR (throwaway repo) — no mocking of the GitHub API.
gh api repos/<owner>/<repo>/pulls/comments/<comment_id> | jq '{eventName:"pull_request_review_comment", actor:"<you>", repo:{owner:"<owner>",repo:"<repo>"}, payload:{comment:(. + {body:"/oc <prompt>"}), pull_request:{number:<PR>, title:"test"}}}' > event.jsonTest on a closed PR
BTW: I found an unrelated bug on the reaction emoji with
use_github_tokenduring the verification, maybe I will report it later 😄Screenshots / recordings
None
Checklist