feat(server): add forgejo_create_pr_thread_comment for inline review thread replies #4

Merged
lucas merged 1 commit from feat/t-69 into main 2026-10-14 16:26:23 +02:00
Collaborator

Adds forgejo_create_pr_thread_comment { number, comment_id, body }, a mutating Forgejo tool that posts a reply into an existing inline review comment thread. It takes the inline comment id that forgejo_list_pr_comments_and_reviews shows (inline comment 15969 on CHANGELOG.md:60 · review 36), finds that comment across the PR's reviews, and posts through POST /pulls/{n}/reviews/{review_id}/comments. The reply reuses the original comment's path, side, line and extra_lines_count, which is what Forgejo uses to group it into the same thread. This is the only Forgejo API that posts into an existing thread. The web UI's Reply button takes the same server path.

The fetch of each review's inline comments is now a shared helper, fetchInlineComments, used by both the list tool and the new tool. The new tool scans every review that has inline comments, with no 100-review cap. The system-context block and the descriptions of forgejo_post_review, forgejo_create_pr_comment, forgejo_create_issue_comment and forgejo_list_pr_comments_and_reviews now point agents to the new tool for thread replies. The web tool card, its collapsed summary (PR #3 · comment 15969) and the approval dialog show the new tool's arguments. Approval-by-default and Idea-mode blocking come automatically from the mutating flag.

Decisions

  • index.test.ts had two more hard-coded tool counts the plan didn't list (the "all 17 tools" test name and the config-change test's toBe(17)). Both are updated to 18.
  • The CHANGELOG change edits the existing Unreleased "Forgejo integration" entry instead of adding a separate bullet, because that feature hasn't been released yet: the tool count goes to 18, the new tool joins the write list, and the system-context guidance is mentioned. docs/configuration.md is updated the same way.
  • The prs.ts and index.ts header comments already had the wrong tool counts (8 and 16). They are corrected to 10 and 18.

Verification

  • bun test apps/server/src/forgejo apps/server/src/bridge/permission-filter.test.ts: 156 pass, 0 fail. This includes the new buildThreadReplyPayload tests (new side, old side, line-range copy and omission, missing line, missing path) and the updated inventory and permission lists.
  • bun run typecheck (protocol, server, web): exit 0.
  • Smoke run against a local fake Forgejo (Bun.serve) with the real ForgejoClient:
    • The reply to comment 15969 returned posted reply 16000 in the thread of inline comment 15969 (CHANGELOG.md:60) on PR #3.
    • The POST went to /pulls/3/reviews/36/comments with body {"body":"ack","path":"CHANGELOG.md","new_position":60}.
    • The comments of review 35 (zero inline comments) were never requested.
    • Unknown comment_id: 99 returned error: inline comment 99 not found on PR #3. … and made no POST.
    • forgejo_list_pr_comments_and_reviews output is unchanged (inline comment 15969 on CHANGELOG.md:60 · review 36).
  • No live posts were made to the Forgejo instance.
Adds `forgejo_create_pr_thread_comment { number, comment_id, body }`, a mutating Forgejo tool that posts a reply into an existing inline review comment thread. It takes the inline comment id that `forgejo_list_pr_comments_and_reviews` shows (`inline comment 15969 on CHANGELOG.md:60 · review 36`), finds that comment across the PR's reviews, and posts through `POST /pulls/{n}/reviews/{review_id}/comments`. The reply reuses the original comment's path, side, line and `extra_lines_count`, which is what Forgejo uses to group it into the same thread. This is the only Forgejo API that posts into an existing thread. The web UI's Reply button takes the same server path. The fetch of each review's inline comments is now a shared helper, `fetchInlineComments`, used by both the list tool and the new tool. The new tool scans every review that has inline comments, with no 100-review cap. The system-context block and the descriptions of `forgejo_post_review`, `forgejo_create_pr_comment`, `forgejo_create_issue_comment` and `forgejo_list_pr_comments_and_reviews` now point agents to the new tool for thread replies. The web tool card, its collapsed summary (`PR #3 · comment 15969`) and the approval dialog show the new tool's arguments. Approval-by-default and Idea-mode blocking come automatically from the `mutating` flag. ## Decisions - `index.test.ts` had two more hard-coded tool counts the plan didn't list (the "all 17 tools" test name and the config-change test's `toBe(17)`). Both are updated to 18. - The CHANGELOG change edits the existing Unreleased "Forgejo integration" entry instead of adding a separate bullet, because that feature hasn't been released yet: the tool count goes to 18, the new tool joins the write list, and the system-context guidance is mentioned. `docs/configuration.md` is updated the same way. - The `prs.ts` and `index.ts` header comments already had the wrong tool counts (8 and 16). They are corrected to 10 and 18. ## Verification - `bun test apps/server/src/forgejo apps/server/src/bridge/permission-filter.test.ts`: 156 pass, 0 fail. This includes the new `buildThreadReplyPayload` tests (new side, old side, line-range copy and omission, missing line, missing path) and the updated inventory and permission lists. - `bun run typecheck` (protocol, server, web): exit 0. - Smoke run against a local fake Forgejo (`Bun.serve`) with the real `ForgejoClient`: - The reply to comment 15969 returned `posted reply 16000 in the thread of inline comment 15969 (CHANGELOG.md:60) on PR #3`. - The POST went to `/pulls/3/reviews/36/comments` with body `{"body":"ack","path":"CHANGELOG.md","new_position":60}`. - The comments of review 35 (zero inline comments) were never requested. - Unknown `comment_id: 99` returned `error: inline comment 99 not found on PR #3. …` and made no POST. - `forgejo_list_pr_comments_and_reviews` output is unchanged (`inline comment 15969 on CHANGELOG.md:60 · review 36`). - No live posts were made to the Forgejo instance.
Posts a reply into an existing inline review comment thread via
POST /pulls/{n}/reviews/{review}/comments, addressed by the inline comment
id that forgejo_list_pr_comments_and_reviews shows. The tool locates the
comment across the PR's reviews and copies its path, side, line and line
range so Forgejo groups the reply into the same thread.

The system context and the post_review, create_pr_comment,
create_issue_comment and list_pr_comments_and_reviews descriptions point
agents at the new tool for thread replies. Web tool card and approval
dialog render the new tool's arguments.

Co-Authored-By: Claude Opus 5.5 via omp-deck
lucas approved these changes 2026-10-14 16:26:14 +02:00
lucas merged commit 6cc9725478 into main 2026-10-14 16:26:23 +02:00
lucas deleted branch feat/t-69 2026-10-14 16:26:23 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lucas/omp-deck!4
No description provided.