Skip to content

Add review comment commands - #1163

Merged
abhinav merged 11 commits into
mainfrom
branch-comment-commands
Sep 6, 2026
Merged

Add review comment commands#1163
abhinav merged 11 commits into
mainfrom
branch-comment-commands

Conversation

@ed-irl

@ed-irl ed-irl commented May 14, 2026

Copy link
Copy Markdown
Collaborator

Add gs review commands for posting and managing review feedback.

The command group lists remote review threads, posts immediate comments, stages and edits local comments, submits staged comments as one review, edits remote comments, and resolves or unresolves threads.

Staged comments persist by branch until submission. Commands use the optional ReviewRepository interfaces, recover forge-owned opaque identifiers from ListReviewThreads, and check new comment coordinates against reviewdiff.Patch before submission.

@ed-irl
ed-irl force-pushed the branch-comment-commands branch from 75c2b68 to bed2fb1 Compare June 2, 2026 18:58
@ed-irl
ed-irl force-pushed the branch-comment-commands branch from bed2fb1 to 55e79ed Compare June 2, 2026 20:17
@ed-irl
ed-irl force-pushed the branch-comment-commands branch from c1b7235 to 631867a Compare June 2, 2026 22:33
@ed-irl
ed-irl force-pushed the branch-comment-commands branch from cc6ba9a to a4057f6 Compare June 8, 2026 10:18
@ed-irl
ed-irl force-pushed the branch-comment-commands branch from fa75bd3 to b8b5295 Compare June 12, 2026 20:07
@ed-irl
ed-irl force-pushed the branch-comment-commands branch from b8b5295 to 6f87470 Compare June 13, 2026 13:39
@ed-irl
ed-irl force-pushed the branch-comment-commands branch from 6f87470 to f6588c8 Compare June 15, 2026 09:52
@ed-irl ed-irl changed the title branch comment: add CLI commands for managing review comments worktree: Add worktree management commands and per-worktree trunks Jun 19, 2026
@ed-irl
ed-irl force-pushed the branch-comment-commands branch from 7170265 to f86efce Compare June 19, 2026 01:03
@ed-irl
ed-irl force-pushed the branch-comment-commands branch from f86efce to 112367a Compare June 24, 2026 01:32
abhinav added a commit that referenced this pull request Aug 30, 2026
ShamHub review threads record the change head in
`ReviewThread.CommitHash`. When that revision differs from the current
head, compare the two revisions and mark a right-side thread outdated
only when the later patch deletes a line in its inclusive range.

Insertions alone do not stale an anchor. File-level and left-side
threads retain their stored state because their recorded coordinates do
not identify a comparable source range. Explicitly seeded outdated state
still takes precedence, and diff or parsing failures propagate to the
caller.

This builds on the review patch queries from #1162. The user-facing
staleness script is included with the commands in #1163.

---------

Co-authored-by: Abhinav Gupta <mail@abhinavg.net>
Base automatically changed from branch-comment-stale to main August 30, 2026 17:53
@abhinav
abhinav force-pushed the branch-comment-commands branch 3 times, most recently from 8b8bb59 to 31f7350 Compare August 30, 2026 22:25
@abhinav abhinav changed the title branch comment: Add review comment commands Add review comment commands Aug 30, 2026
@abhinav
abhinav force-pushed the branch-comment-commands branch from b2ea4cb to 7e2fa8c Compare September 1, 2026 00:43
ed-irl and others added 11 commits September 5, 2026 17:11
Store single-line review comments by branch so branch comment commands can assemble, edit, and submit a review across invocations. Local integer IDs address drafts before the forge assigns review thread and comment IDs.

The persisted shape intentionally retains the original single-line anchor contract. File-level and line-range staging remain a separate design decision.
Add `gs branch comment` for posting and managing review feedback.
The command group can list remote threads,
stage and batch comments into a review,
reply to or edit comments,
and resolve threads.

Forge IDs are opaque values rather than strings.
Recover IDs from `ReviewRepository.ListReviewThreads`
before reply, edit, or resolution operations.
Exercise `gs branch comment` workflows against ShamHub.
The scripts keep command parsing, staged state, diff mapping,
and forge operations inside one end-to-end boundary.

They cover immediate and staged submission,
listing and JSON output,
staged editing,
and review-thread discovery.
Exercise the user-visible outdated status after a later ShamHub revision deletes one anchored line while preserving another. Cover both the human-readable list and extension-facing JSON output.
Branch comment locations are coordinates in the selected branch postimage.
Check single-line anchors against `reviewdiff.Patch` before submission, retain
the requested path and line, and submit them on the right side of the review
diff.

This removes the working-tree mapping and textual side conversion from
immediate and staged submission. Staged state remains single-line; file and
range staging are deferred to their own contract.
Move review-comment management from gs branch comment to the top-level gs
review namespace. Comments and replies now default to local drafts and use
--no-draft for immediate posting. Publish sends drafts as one review, while
list, edit, resolve, and reopen expose the remaining workflows with numeric
draft references.

Keep the draft default fixed and retain the existing ID lifecycle. Persistent
allocation, deletion, configurable defaults, and staged file or range anchors
remain separate review units.
`gs branch comment add` now accepts a file,
an inclusive `file:start-end` range,
or `--pr` for an unanchored review body.
Single-line `file:line` anchors remain supported.

`--pr` uses `SubmitReviewRequest.Body`.
Because `ListReviewThreads` does not return review bodies,
PR-level comments do not appear in `gs branch comment list`.
Accept immediate review comments anchored to a whole file, one line, or an
inclusive line range. Parse those forms into a typed review-thread range and
check the complete anchor against the selected branch patch before
submission.

Drop `--pr` because review bodies are not returned by `ListReviewThreads` and
overlap ordinary change comments. Staged comments retain their existing
single-line syntax until their persistence and lifetime contracts are
decided.
`gs branch comment list --json` now includes `scope`, `side`,
`range`, `commitSHA`, `resolved`, and `stale`
for editor integrations.

Resolution and staleness are omitted
when a forge returns `nil` for unsupported state.
The existing `status` field remains for compatibility.
Compare complete deterministic JSON records for inclusive ranges and
file-level threads instead of matching fragments of serialized output. A
focused conversion test also preserves omission of resolution, staleness,
commit, and timestamp fields when the forge does not expose them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants