Skip to content

Conversation

@pierluigilenoci
Copy link

@pierluigilenoci pierluigilenoci commented Jan 16, 2026

Summary

This PR adds a new gh pr review-thread command to manage pull request review threads via the GitHub GraphQL API.

Implements three subcommands:

  • list - List all review threads for a PR with optional --unresolved filter
  • resolve - Mark a review thread as resolved
  • unresolve - Mark a review thread as unresolved

Motivation

Closes #12419

Currently, there's no way to resolve or unresolve PR review threads from the CLI. This forces users to switch to the web UI to manage conversation threads, breaking their terminal workflow.

Implementation Details

  • Added new package pkg/cmd/pr/reviewthread/ with command structure following existing patterns (similar to pkg/cmd/label/)
  • Uses GraphQL mutations: resolveReviewThread and unresolveReviewThread
  • Uses GraphQL query ListReviewThreads to list threads with filtering support
  • Integrated into main PR command structure under "Targeted commands" group
  • Includes comprehensive test coverage (11 tests) for all commands and subcommands

Files added:

  • pkg/cmd/pr/reviewthread/reviewthread.go - Main command coordinator
  • pkg/cmd/pr/reviewthread/resolve.go - Resolve thread implementation
  • pkg/cmd/pr/reviewthread/unresolve.go - Unresolve thread implementation
  • pkg/cmd/pr/reviewthread/list.go - List threads with filtering
  • Corresponding test files: *_test.go for each command

File modified:

  • pkg/cmd/pr/pr.go - Added review-thread command integration

Usage Examples

# List all review threads for current PR
gh pr review-thread list

# List all review threads for PR #123
gh pr review-thread list 123

# List unresolved threads for PR #123
gh pr review-thread list 123 --unresolved

# Resolve a thread (get thread ID from list command)
gh pr review-thread resolve MDEyOlB1bGxSZXF1ZXN0UmV2aWV3VGhyZWFk...

# Unresolve a thread
gh pr review-thread unresolve MDEyOlB1bGxSZXF1ZXN0UmV2aWV3VGhyZWFk...

Test Coverage

All commands have comprehensive test coverage:

  • reviewthread_test.go - Tests command structure and subcommand registration
  • resolve_test.go - Tests resolve command (3 tests)
  • unresolve_test.go - Tests unresolve command (3 tests)
  • list_test.go - Tests list command with filtering (4 tests)

Total: 11 tests, all passing.

$ go test ./pkg/cmd/pr/reviewthread/... -v
=== RUN   TestList
--- PASS: TestList (0.00s)
=== RUN   TestList_unresolvedOnly
--- PASS: TestList_unresolvedOnly (0.00s)
=== RUN   TestList_noThreads
--- PASS: TestList_noThreads (0.00s)
=== RUN   TestList_noUnresolvedThreads
--- PASS: TestList_noUnresolvedThreads (0.00s)
=== RUN   TestResolveNoArgs
--- PASS: TestResolveNoArgs (0.00s)
=== RUN   TestResolve
--- PASS: TestResolve (0.00s)
=== RUN   TestResolve_apiError
--- PASS: TestResolve_apiError (0.00s)
=== RUN   TestNewCmdReviewThread
--- PASS: TestNewCmdReviewThread (0.00s)
=== RUN   TestUnresolveNoArgs
--- PASS: TestUnresolveNoArgs (0.00s)
=== RUN   TestUnresolve
--- PASS: TestUnresolve (0.00s)
=== RUN   TestUnresolve_apiError
--- PASS: TestUnresolve_apiError (0.00s)
PASS
ok      github.com/cli/cli/v2/pkg/cmd/pr/reviewthread   0.544s

Tested Locally

Built and tested locally with make build:

$ ./bin/gh pr review-thread --help
Manage pull request review threads.

Review threads are created when comments are left on specific lines of code
during a pull request review. These threads can be resolved or unresolved to
track which feedback has been addressed.

USAGE
  gh pr review-thread <command> [flags]

AVAILABLE COMMANDS
  list:          List review threads for a pull request
  resolve:       Resolve a review thread
  unresolve:     Unresolve a review thread

@pierluigilenoci pierluigilenoci requested a review from a team as a code owner January 16, 2026 21:54
@cliAutomation cliAutomation added the external pull request originating outside of the CLI core team label Jan 16, 2026
@github-actions
Copy link

Thank you for your pull request! 🎉

This PR appears to fix the following issues that are not labeled with help wanted Contributions welcome :

As outlined in our Contributing Guidelines, we expect that PRs are only created for issues that have been labeled help wanted.

While we appreciate your initiative, please note that:

  • PRs for non-help wanted issues may not be reviewed immediately as they might not align with our current priorities
  • The issue might already be assigned to a team member or planned for a specific release
  • We may need to close this PR. For example, if it conflicts with ongoing work or architectural decisions

What happens next:

  • Our team will review this PR and the associated issues
  • We may add the help wanted label to the issues, if appropriate, and review this pull request
  • In some cases, we may need to close the PR. For example, if it doesn't fit our current roadmap

Thank you for your understanding and contribution to the project! 🙏

This comment was automatically generated by cliAutomation.

@pierluigilenoci pierluigilenoci force-pushed the feature/review-thread-management branch from 201accf to 3140e90 Compare January 16, 2026 22:08
Implements resolve, unresolve, and list subcommands for managing
PR review thread conversations via GraphQL API.

- resolve: Mark a review thread as resolved
- unresolve: Mark a review thread as unresolved
- list: List all review threads for a PR with optional --unresolved filter

Fixes cli#12419

Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com>
@pierluigilenoci pierluigilenoci force-pushed the feature/review-thread-management branch from 3140e90 to 4d53972 Compare January 16, 2026 22:21
@pierluigilenoci pierluigilenoci changed the title Add pr review-thread command for managing review threads feat: add pr review-thread command for managing review threads Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external pull request originating outside of the CLI core team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add gh support to resolve/unresolve PR review threads

2 participants