Skip to content

Add resolve/unresolve review comment API endpoints#36441

Merged
wxiaoguang merged 7 commits intogo-gitea:mainfrom
bircni:feature/review-comment-api
Feb 1, 2026
Merged

Add resolve/unresolve review comment API endpoints#36441
wxiaoguang merged 7 commits intogo-gitea:mainfrom
bircni:feature/review-comment-api

Conversation

@bircni
Copy link
Copy Markdown
Member

@bircni bircni commented Jan 23, 2026

Summary

I added API endpoints to resolve and unresolve pull request review comments.
This mirrors the UI conversation resolve behavior and returns the updated PullReviewComment with resolver information.

Usage

New endpoints:

  • POST /repos/{owner}/{repo}/pulls/{index}/comments/{id}/resolve
  • POST /repos/{owner}/{repo}/pulls/{index}/comments/{id}/unresolve

Example:

curl -X POST -H "Authorization: token $TOKEN" -H "Accept: application/json" http://localhost:3000/api/v1/repos/OWNER/REPO/pulls/PR_INDEX/comments/COMMENT_ID/resolve

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jan 23, 2026
@github-actions github-actions bot added modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code labels Jan 23, 2026
@bircni bircni force-pushed the feature/review-comment-api branch from 58a4c69 to a928f12 Compare January 23, 2026 23:08
@silverwind silverwind added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Jan 24, 2026
@silverwind silverwind requested a review from Copilot January 24, 2026 02:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds API endpoints to resolve and unresolve pull request review comments, providing programmatic access to functionality that previously existed only in the UI.

Changes:

  • Added POST endpoints /repos/{owner}/{repo}/pulls/{index}/comments/{id}/resolve and /repos/{owner}/{repo}/pulls/{index}/comments/{id}/unresolve
  • Refactored ToPullReviewCommentList to extract a new ToPullReviewComment function for converting single comments
  • Updated Swagger documentation to reflect the new API endpoints

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
routers/api/v1/api.go Registers the new resolve/unresolve routes with appropriate middleware for authentication and archive checks
routers/api/v1/repo/pull_review.go Implements the handler functions with permission checks, validation, and response formatting
services/convert/pull_review.go Refactors comment conversion logic to support both list and single comment conversion
templates/swagger/v1_json.tmpl Adds OpenAPI/Swagger documentation for the new endpoints

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lunny
Copy link
Copy Markdown
Member

lunny commented Jan 24, 2026

It's better to add some tests

@bircni bircni force-pushed the feature/review-comment-api branch 2 times, most recently from 4f90506 to 5bff286 Compare January 24, 2026 20:00
@bircni
Copy link
Copy Markdown
Member Author

bircni commented Jan 24, 2026

@lunny added some tests 😄

@lunny lunny added this to the 1.26.0 milestone Jan 25, 2026
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jan 25, 2026
@bircni bircni requested a review from wxiaoguang January 25, 2026 09:58
Comment on lines +1363 to +1364
m.Post("/comments/{id}/resolve", reqToken(), mustNotBeArchived, repo.ResolvePullReviewComment)
m.Post("/comments/{id}/unresolve", reqToken(), mustNotBeArchived, repo.UnresolvePullReviewComment)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't need issue index, see the /issues/comments/{id}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it better go under /pulls/reviews as only review comments can be marked resolved?

Copy link
Copy Markdown
Member

@lafriks lafriks Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While it could be not very useful to provide review id in url but there is already /pulls/review/{id}/comments endpoint that can be base for this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue endpoints have already deprecated the unnecessary index

// EditIssueCommentDeprecated modify a comment of an issue
func EditIssueCommentDeprecated(ctx *context.APIContext) {
	// swagger:operation PATCH /repos/{owner}/{repo}/issues/{index}/comments/{id} issue issueEditCommentDeprecated

@bircni bircni force-pushed the feature/review-comment-api branch from 56c2c02 to d10ac57 Compare January 25, 2026 15:42
@wxiaoguang wxiaoguang marked this pull request as draft January 26, 2026 01:24
@wxiaoguang wxiaoguang force-pushed the feature/review-comment-api branch from b80f4ff to fa2da7b Compare January 26, 2026 01:43
@delvh delvh changed the title feat(api): add resolve/unresolve review comment endpoints Add resolve/unresolve review comment API endpoints Jan 26, 2026
Copy link
Copy Markdown
Member

@delvh delvh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming sounds fine, especially as GitHub does not seem to support any such route in their API, so we can't look at it.

@bircni
Copy link
Copy Markdown
Member Author

bircni commented Jan 26, 2026

@delvh @wxiaoguang i renamed all occurences of pull review to pull request review

@wxiaoguang
Copy link
Copy Markdown
Contributor

ping @lafriks

@wxiaoguang
Copy link
Copy Markdown
Contributor

ping @lafriks

ping @lafriks

@wxiaoguang
Copy link
Copy Markdown
Contributor

ping @lafriks

ping @lafriks

ping @lafriks

@bircni
Copy link
Copy Markdown
Member Author

bircni commented Jan 30, 2026

@lafriks whats the final decision? Can you unblock it?

@bircni
Copy link
Copy Markdown
Member Author

bircni commented Feb 1, 2026

@lafriks ping

@lafriks
Copy link
Copy Markdown
Member

lafriks commented Feb 1, 2026

I still believe that the same item's endpoints should be grouped together. Currently we have /pulls/review/{id}/comments endpoint to create review comments, I don't thing it's a good place to have other review related comments endpoints in other place now also.

What other @go-gitea/maintainers think?

@wxiaoguang
Copy link
Copy Markdown
Contributor

wxiaoguang commented Feb 1, 2026

I still believe that the same item's endpoints should be grouped together. Currently we have /pulls/review/{id}/comments endpoint to create review comments, I don't thing it's a good place to have other review related comments endpoints in other place now also.

Then you need to answer 2 questions before just saying "believe that the same item's endpoints should be grouped together":

  1. How does the review/{id} id help in real world? Show a real case that the {id} is useful.
  2. Why other "comments" APIs deprecated issues/{index}? Add resolve/unresolve review comment API endpoints #36441 (comment)

@lafriks
Copy link
Copy Markdown
Member

lafriks commented Feb 1, 2026

I don't believe it's the best design but as issue comments follow the same pattern I won't block

@lafriks lafriks dismissed their stale review February 1, 2026 11:40

I'm ok that it follows general pattern as with issue comments

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged labels Feb 1, 2026
@wxiaoguang
Copy link
Copy Markdown
Contributor

I don't believe it's the best design but as issue comments follow the same pattern I won't block

Still don't understand why you "don't believe it's the best design" since the questions are still not answered.

@wxiaoguang wxiaoguang marked this pull request as ready for review February 1, 2026 11:58
@wxiaoguang wxiaoguang enabled auto-merge (squash) February 1, 2026 11:59
@wxiaoguang wxiaoguang merged commit c2dea22 into go-gitea:main Feb 1, 2026
24 checks passed
@bircni bircni deleted the feature/review-comment-api branch February 1, 2026 15:03
@silverwind
Copy link
Copy Markdown
Member

Something seems wrong with this merge, other PRs show unrelated error:

https://github.com/go-gitea/gitea/actions/runs/21568528769/job/62143809600?pr=36457

Error: tests/integration/api_pull_review_test.go:384:145: not enough arguments in call to pull_service.CreateCodeComment
	have ("context".Context, *"code.gitea.io/gitea/models/user".User, *"code.gitea.io/gitea/modules/git".Repository, *"code.gitea.io/gitea/models/issues".Issue, number, string, string, bool, number, string, nil)
	want ("context".Context, *"code.gitea.io/gitea/models/user".User, *"code.gitea.io/gitea/modules/git".Repository, *"code.gitea.io/gitea/models/issues".Issue, int64, int64, int64, string, string, bool, int64, string, []string)
make[1]: *** [/home/runner/work/gitea/gitea/Makefile:636: integrations.pgsql.test] Error 1

@silverwind
Copy link
Copy Markdown
Member

Actually no, it's just a bug in #36457.

zjjhot added a commit to zjjhot/gitea that referenced this pull request Feb 2, 2026
* giteaofficial/main: (26 commits)
  [skip ci] Updated translations via Crowdin
  Remove and forbid `@ts-expect-error` (go-gitea#36513)
  Add resolve/unresolve review comment API endpoints (go-gitea#36441)
  Fix incorrect vendored detections (go-gitea#36508)
  Bump alpine to 3.23, add platforms to `docker-dryrun` (go-gitea#36379)
  Unify repo names in system notices (go-gitea#36491)
  Allow scroll propagation outside code editor (go-gitea#36502)
  Refactor ActionsTaskID (go-gitea#36503)
  Update JS deps, remove `knip`, misc tweaks (go-gitea#36499)
  [skip ci] Updated translations via Crowdin
  Fix editorconfig not respected in PR Conversation view (go-gitea#36492)
  Add FOLDER_ICON_THEME configuration option (go-gitea#36496)
  Don't create self-references in merged PRs (go-gitea#36490)
  Use reserved .test TLD for unit tests (go-gitea#36498)
  Fix bug when list pull request commits (go-gitea#36485)
  Update some go dependencies (go-gitea#36489)
  chore: add comments for "api/healthz", clean up test env (go-gitea#36481)
  [SECURITY] Toolchain Update to Go 1.25.6 (go-gitea#36480)
  [skip ci] Updated translations via Crowdin
  Render merged pull request title as such in dashboard feed (go-gitea#36479)
  ...
silverwind added a commit to silverwind/gitea that referenced this pull request Feb 4, 2026
* origin/main: (1246 commits)
  fix(packages/container): data race when uploading container blobs concurrently (go-gitea#36524)
  [skip ci] Updated translations via Crowdin
  Remove and forbid `@ts-expect-error` (go-gitea#36513)
  Add resolve/unresolve review comment API endpoints (go-gitea#36441)
  Fix incorrect vendored detections (go-gitea#36508)
  Bump alpine to 3.23, add platforms to `docker-dryrun` (go-gitea#36379)
  Unify repo names in system notices (go-gitea#36491)
  Allow scroll propagation outside code editor (go-gitea#36502)
  Refactor ActionsTaskID (go-gitea#36503)
  Update JS deps, remove `knip`, misc tweaks (go-gitea#36499)
  [skip ci] Updated translations via Crowdin
  Fix editorconfig not respected in PR Conversation view (go-gitea#36492)
  Add FOLDER_ICON_THEME configuration option (go-gitea#36496)
  Don't create self-references in merged PRs (go-gitea#36490)
  Use reserved .test TLD for unit tests (go-gitea#36498)
  Fix bug when list pull request commits (go-gitea#36485)
  Update some go dependencies (go-gitea#36489)
  chore: add comments for "api/healthz", clean up test env (go-gitea#36481)
  [SECURITY] Toolchain Update to Go 1.25.6 (go-gitea#36480)
  [skip ci] Updated translations via Crowdin
  ...

# Conflicts:
#	modules/templates/helper.go
#	options/locale/locale_en-US.ini
#	routers/web/repo/cherry_pick.go
#	routers/web/repo/editor.go
#	routers/web/repo/patch.go
#	templates/repo/editor/edit.tmpl
#	web_src/js/features/codeeditor.ts
@bircni bircni mentioned this pull request Mar 22, 2026
lunny pushed a commit that referenced this pull request Mar 22, 2026
I'd like to apply as a maintainer.

Thanks to @TheFox0x7 for the suggestion.

Merged PRs:
- #36441
- #36571
- #36603
- #36768
- #36776
- #36783
- #36876
- #36883
- #36924

Ongoing work:
- #36514
- #36752
- #36912
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code type/feature Completely new functionality. Can only be merged if feature freeze is not active.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants