feat: add pr review-thread command for managing review threads #12482
+875
−0
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.
Summary
This PR adds a new
gh pr review-threadcommand to manage pull request review threads via the GitHub GraphQL API.Implements three subcommands:
list- List all review threads for a PR with optional--unresolvedfilterresolve- Mark a review thread as resolvedunresolve- Mark a review thread as unresolvedMotivation
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
pkg/cmd/pr/reviewthread/with command structure following existing patterns (similar topkg/cmd/label/)resolveReviewThreadandunresolveReviewThreadListReviewThreadsto list threads with filtering supportFiles added:
pkg/cmd/pr/reviewthread/reviewthread.go- Main command coordinatorpkg/cmd/pr/reviewthread/resolve.go- Resolve thread implementationpkg/cmd/pr/reviewthread/unresolve.go- Unresolve thread implementationpkg/cmd/pr/reviewthread/list.go- List threads with filtering*_test.gofor each commandFile modified:
pkg/cmd/pr/pr.go- Added review-thread command integrationUsage Examples
Test Coverage
All commands have comprehensive test coverage:
reviewthread_test.go- Tests command structure and subcommand registrationresolve_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.544sTested Locally
Built and tested locally with
make build: