Skip to content

Add in_reply_to field for threading pull review comments via API#36903

Closed
fredriksvan wants to merge 2 commits intogo-gitea:mainfrom
fredriksvan:api-review-comment-reply
Closed

Add in_reply_to field for threading pull review comments via API#36903
fredriksvan wants to merge 2 commits intogo-gitea:mainfrom
fredriksvan:api-review-comment-reply

Conversation

@fredriksvan
Copy link
Copy Markdown

Summary

Currently the API for creating pull request reviews (POST /repos/{owner}/{repo}/pulls/{index}/reviews) does not support threading comments under existing review conversations. The web UI uses replyReviewID in the CreateCodeComment service to thread replies, but the API hardcodes this to 0.

This PR adds an in_reply_to field to CreatePullReviewComment that accepts a pull_request_review_id, allowing API consumers to post threaded replies to existing review conversations.

Changes

  • modules/structs/pull_review.go: Added InReplyTo int64 field to CreatePullReviewComment
  • routers/api/v1/repo/pull_review.go: Separates reply comments (posted immediately via CreateCodeComment with replyReviewID) from pending comments. Reply-only requests return 204 No Content instead of creating empty reviews. Swagger docs updated with 204 response
  • templates/swagger/v1_json.tmpl: Regenerated swagger spec
  • tests/integration/api_pull_review_test.go: Added TestAPIPullReviewCommentReply covering reply-only (204) and mixed reply + pending comment scenarios

Behavior

Request type Result
Reply comments only, no body Reply comments threaded under existing reviews, returns 204
Reply + pending comments + body Replies posted immediately, pending comments + body create a new review, returns 200
Reply comments + APPROVE/REQUEST_CHANGES Replies posted immediately, review event still created
No in_reply_to (existing behavior) Unchanged — all comments are pending review comments

Allow API consumers to thread review comments under existing
review conversations by specifying the review ID (pull_request_review_id)
in the in_reply_to field of CreatePullReviewComment.

Reply comments are posted immediately (not as pending review comments)
using the existing CreateCodeComment service with replyReviewID. When a
request contains only reply comments with no body, the endpoint returns
204 No Content instead of creating a spurious empty review.

Mixed requests (replies + new comments) are supported: replies are
posted immediately while new comments go through the normal pending
review flow.
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 15, 2026
The Review.Comments field is not populated by LoadAttributes.
Use LoadCodeComments which populates Review.CodeComments
(map[path]map[line][]*Comment) to verify the reply was threaded.
@silverwind
Copy link
Copy Markdown
Member

silverwind commented Mar 15, 2026

This is basically a duplicate to #36683, but that PR uses comment_id instead of pull_request_review_id which is better because it matches GitHub's API. I will continue that PR soon, I think this one is obsolete.

@fredriksvan
Copy link
Copy Markdown
Author

Thanks for pointing out #36683 — closing this in favor of that PR. Looking forward to the feature landing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants