feat: surface inline-comment anchor fields on pr view --reviews (task 0034) #42
Reference in New Issue
Block a user
Delete Branch "task-0034-pr-review-anchor-fields"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Completes both halves of the inline-review round-trip from the
pr-review-commentsspec, as two commits on one branch:.claude/tasks/0034-pr-review-anchor-fields.md— read side.claude/tasks/0035-pr-review-inline-comments.md— write sideRead side (task 0034)
pr view <n> --reviewsnow surfaces each inline review comment's anchor so an agent can answer and reply without a second API call:id— the comment's own id, the handle a reply targets.resolved—yes/no, from whether Gitea populated the comment'sresolver.diff_hunk— structurally trimmed to its@@header line plus its last two lines by default (hunks of three lines or fewer left whole), verbatim under--full. The trim istrimDiffHunkinsrc/diff.ts, distinct from the char-based body truncation.Raw
position/original_positionoffsets stay unsurfaced; the fields ride the existing fetch (no extra API calls).Write side (task 0035)
pr review <n>gains--comments-file <path>, a JSON array of inline comments submitted with the review. Each entry is one of two exclusive shapes (nosidefield anywhere):{ path, line, body }→new_positionon the new side.{ reply_to, body }→ gitea-axi finds the target via the reviews-plus-comments fan-out (no get-comment-by-id endpoint), reconstructs its anchor from the target's owndiff_hunk(anchorFromDiffHunk), and infers old/new side from it, so a same-line post threads with the existing conversation.All entries map onto the review-submission payload's
comments[]— no new HTTP layer. The action flag is still required and top-level--bodycomposes with the batch. An unknownreply_tois aVALIDATION_ERRORraised before the POST; the submitted count rides the action block.Built test-first at the fixture-server CLI seam. Full suite 400 passing, typecheck clean.
Review
/review-uncommittedran on each slice; every Standards and Spec finding was fixed in-branch (extracted the sharedsrc/flag-file.tsreader; tightened--comments-fileshape validation to reject contradictory entries and to refuse a target lacking path/diff_hunk; replaced a fabricated comment-id sentinel with areviewCommentIdguard). No findings remain unaddressed.Risk
prReviewonly additively modified.anchorFromDiffHunkhunk-walk is the one non-trivial spot.`pr review <n>` gains `--comments-file <path>`, a JSON array of inline comments submitted with the review. Each entry is one of two exclusive shapes: a new comment `{ path, line, body }` (mapped to `new_position`, always the new side) or a reply `{ reply_to, body }`. A reply carries no line or side — gitea-axi finds the target via the reviews-plus-comments fan-out (there is no get-comment-by-id endpoint), reconstructs its anchor from the target's own `diff_hunk`, and infers old/new side from it, so a same-line post threads with the existing conversation. All entries map onto the review-submission payload's `comments[]`; no new HTTP layer is added. An unknown `reply_to` is a VALIDATION_ERROR raised before the POST, and the submitted inline-comment count rides the action block. The shared path-resolve-and-read behind --body-file and --comments-file is extracted into src/flag-file.ts.4e9e4cb9d3to662ba82d71