fj pr comment is write-once: no edit/delete, no --edit-last/--create-if-none, unlike fj issue #120
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Observation
fj prcan add a comment to a pull request but cannot edit or delete one, and offers no idempotent-upsert flag.fj issuedoes all three. The PR comment surface is write-once.fj pr's verb set (src/cli/pr.rs:27-66) has exactly one comment verb:CommentArgs(src/cli/pr.rs:234) carries onlynumber+body; the handler (src/cli/pr.rs:592) only posts. There is noEditComment/DeleteCommentin the enum, and no--edit-last/--create-if-none.The issue side already has the full set (
src/cli/issue.rs:40-44):backed by
src/cli/issue_comment.rs(comment/edit_comment/delete_comment).The decisive part: the write endpoints already exist and already work for PRs. In Forgejo a pull request is an issue, and comment mutation goes through the shared
/repos/{owner}/{repo}/issues/comments/{id}path. The helpersapi::issue::edit_comment(src/api/issue.rs:216) andapi::issue::delete_comment(src/api/issue.rs:232) take a barecomment_idand are not issue-specific at all. Sofj pr comment edit/deletecould call the exact functionsfj issue comment edit/deletealready call. The gap is purely a missing CLI verb on the PR side.Why it matters
The canonical agent/CI pattern is a single maintained status comment: a bot posts "build running...", then edits that same comment to "build green ✓" on completion, rather than spamming a new comment per run.
gh pr comment --edit-last --create-if-none --body ...is the standard idempotent primitive for exactly this, andgh issue/pr comment --delete-lastcleans up.With
fjtoday:fj pr commentedit verb at all), so it either spams new comments or drops tofj apiwith a hand-managed comment id.--edit-last/--create-if-none, so a script must firstissue view --comments --json, grep for its own marker, extract the id, and branch on whether it exists. That read-modify-write dance is precisely what--edit-last/--create-if-nonecollapse into one call.This is jarring next to the existing surface:
fj pr reviewandfj pr request-reviewsit right besidefj pr comment, so a user reasonably expectsfj pr comment editto exist and only discovers otherwise mid-script.Possible directions (sketches)
fj pr commentsubverbs (or sibling commands)edit <comment-id>anddelete <comment-id>that call the already-presentapi::issue::edit_comment/delete_comment(src/api/issue.rs:216-232). No new API code; mirrorsrc/cli/issue_comment.rsverbatim. Comment ids come fromfj pr view --comments --json.--edit-lastand--create-if-noneto bothfj issue commentandfj pr comment: list the authenticated user's comments on the target, pick the most recent authored one, and edit it (or create when none exists). This is the gh-parity idempotency flag and the highest-leverage piece for bots.fj comment add/edit/delete <number>working for both issues and PRs (same endpoints) would close the asymmetry in one place.Converted to backlog item rasterstate/fj#131 (p2, size M).