fix(github): reply in the triggering review thread#37574
Open
chAwater wants to merge 1 commit into
Open
Conversation
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?
(This verification was done with the help of opencode)
Verified end-to-end with a real GitHub PR: the handler's built-in mock-event mode (github run --event ) feeds a webhook payload into the exact code path that runs in GitHub Actions, with the fixed code running locally. All replies were real API calls — no mocking of the GitHub API.
On a closed PR: replies triggered from a top-level review comment, a reply inside a thread, and a file-level comment ("Add comment on file") all land inside the review thread with the correct
in_reply_to_id, while regular timeline comments still post as top-level. The fallback path is preserved, so a failed reply degrades to the old behavior instead of losing the response.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