From 4129f217fa834b13360a506973aa6e1a4d98af4f Mon Sep 17 00:00:00 2001 From: Marcos Date: Tue, 18 Aug 2026 00:54:13 +0000 Subject: [PATCH] fix(post): anchor inline review comments via new_position (Gitea 1.26.x) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Gitea 1.26.x's POST /pulls/{i}/reviews does NOT honor the line/side fields used by newer Gitea — it silently drops them, leaving the comment unpositioned. Gitea then renders a file-level review comment on EVERY diff line of the file, so a 5-finding review on a 25-line diff showed ~125 comment blocks in the Files Changed view (the flood reported on canalhandia PR #2). The 1.26 schema anchors inline review comments with new_position (line in the post-change file) + old_position: 0. f["line"] is already a validated post-change (RIGHT-side) line from split_findings, so it maps directly to new_position. Verified: new_position=98 -> position=98 + populated diff_hunk (positioned, renders on line 98 only); the old line/side form -> position=0, empty diff_hunk (unpositioned). 49 tests pass (no test asserted the POST payload shape). Co-Authored-By: Claude --- pilot/ai_review.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pilot/ai_review.py b/pilot/ai_review.py index 0200f18..0f07535 100644 --- a/pilot/ai_review.py +++ b/pilot/ai_review.py @@ -626,15 +626,20 @@ def post_inline_review( ) -> None: """Post a review with a summary body AND positional inline comments. - Each anchored finding becomes one entry in `comments`: - {path, side:"RIGHT", line, body}. The body carries the ```suggestion - fence when the model produced replacement code. + Each anchored finding becomes one entry in `comments`. Gitea 1.26.x anchors + inline review comments with `new_position` (the line in the POST-change file) + + `old_position: 0` — the `line`/`side` fields used by newer Gitea are NOT + honored here and silently leave the comment unpositioned (Gitea then renders + a file-level comment on EVERY diff line of the file, which is the flood we + hit). `f["line"]` is already a validated post-change (RIGHT-side) line from + `split_findings`, so it maps directly to `new_position`. The body carries the + ```suggestion fence when the model produced replacement code. """ comments = [ { "path": f["path"], - "side": "RIGHT", - "line": f["line"], + "new_position": f["line"], + "old_position": 0, "body": inline_comment_body(f), } for f in anchored