Repository navigation
feat(review): post the notes to the pull request on GitHub (ctrl+g), after a summary - #179
Open
backnotprop wants to merge 18 commits into
Open
backnotprop wants to merge 18 commits into
backnotprop wants to merge 18 commits into
Conversation
…rks into the body
# Conflicts: # README.md # crates/plannotator-tui/src/keys.rs # crates/plannotator-tui/src/review/draw.rs # crates/plannotator-tui/src/review/input.rs # crates/plannotator-tui/src/review/mod.rs # crates/plannotator-tui/src/review/overlays.rs
…n GitHub did not clearly refuse it
…lines go as plain comments
…uns off the screen's thread
…trl+g yields to an older config
…and names long notes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tested on real GitHub, in a private scratch repository made for it and deleted after. The real binary, in a private tmux, posted 8 reviews (19 inline comments) to a scratch PR with a real
ghlogin, and each result was checked withgh api .../pulls/N/reviewsand.../comments. GitHub took the payload as built:line,sideandstart_line/start_sidecame back exactly as sent for new lines, removed lines, ranges over changed and context lines, a renamed file (both sides), a deleted file, a new file, single and multi-line suggestions (rendered as applicable suggestions), unicode, markdown, backticks and a 5,171-character note. Also checked for real: the review body (whole-change, file and outside-the-diff notes, with a permalink that resolves at the reviewed commit), a second post skipping posted notes and re-posting edited ones, a post after the PR moved on (GitHub keeps the comments on the reviewed commit and marks them outdated), the outdated body shape after a reload, Approve and Request changes on one's own PR (GitHub's 422 is named, nothing is posted or marked posted), a closed and a merged PR (GitHub takes a Comment review on both), and a lost login (named, nothing lost, Enter again posts once it is back). Not tested for real: a successful Approve or Request changes (one account, so only one's own PR), a permission error, a rate limit, no network, and GitHub Enterprise (--hostname).The real test found three problems, fixed here: a suggestion whose code has a line of three backticks (Markdown) broke out of its
suggestionblock, so GitHub offered a change that drops a line (now fenced past the code's backticks, checked again on GitHub); notes drawn in the diff (the new inline boxes) never said they were posted; and the summary did not say when the PR is closed or merged. The error tests now use GitHub's real words. The later fixes from an independent review (Enter only after the summary is drawn,ghoff the screen's thread with timeouts, "may have been posted" outcomes, length checks, a pinned PR diff context, plain comments for old-line suggestions, posted marks kept when saving fails) were tested with the fakeghand unit tests only, not on real GitHub.What it does
In a pull request review (
plannotator-tui review <PR>),ctrl+gor Post to GitHub… in the Review menu (m) posts the notes to the PR as one GitHub review. This is in addition to sending them to the agent, not instead of it. In any other review, the key and the menu row say that the feature needs a pull request review.A summary always opens first. It shows:
The verdict is Comment by default. Approve and Request changes are explicit choices with
h/l, because the browser app offers them too.Enterposts andEsccancels. There is no way to skip the summary, andEntercounts only once the summary has been drawn with the PR checked: keys typed before it appeared are dropped, so a fastctrl+gEnteror a doubleEnterin the menu posts nothing.Payload (matches the browser's
ReviewSubmissionDialog.tsx)It is one request:
gh api --method POST repos/OWNER/REPO/pulls/N/reviews --input -, with{commit_id, body, event, comments[]}on stdin. Inline comments useline,side, andstart_line/start_side(only for a range), neverposition.LEFTand new lines getRIGHT. A suggestion becomes a```suggestionblock, fenced past any backticks in its code. A suggestion on old lines (browser or Pi) goes as a plain comment with the code quoted, since GitHub cannot apply it; the summary counts those. A browser-written note keeps its conventional-comment prefix.**path:** text;**path (L5-L9, side):**with an "Outdated" label and a "Commented on" code block. This is the browser's withheld/outdated shape.See inline comments.An approval needs no placeholder.Commit and errors
-U3 --inter-hunk-context=0so its hunks are GitHub's whatever the person'sdiff.contextsays. While the summary is open, a read-onlygh pr viewchecks the PR's head. If the PR has moved on, the summary warns about it and points torto reload; it also says when the PR is closed or merged.ghis killed after 20 s (check) or 60 s (post).Enter(for the body, by which kind of notes fill it), andEnterrefuses to post.ghmissing or not logged in;Posted state
A note is "posted" once a post covers it at or after its last edit. This works like deliveries, and it is a separate state from "sent": a note can be both. The state is saved in
review.jsonasposted: [{at, url, commitId, annotationIds}].A later post carries only notes that are new or edited since. Edited notes are posted again as new comments, and the summary says so. After a post, the footer shows the review's link, and the rail and the notes drawn in the diff mark notes
posted. If saving the posted state fails, the marks stay in memory for the session (so it does not post them twice) and the footer says a later session may repeat them. If a bubble's title has no room, its sent/posted marks move into the bubble's body.Key
ctrl+g(post-to-github, rebindable) is free in every code-review context. leaf uses the same key for this.Tests
plannotator-tui-review/src/post/tests.rs) cover: one line, range, both sides, suggestion, file note, whole-change note, outside-diff (quoting, cap, fence, permalink), outdated and off-diff notes, already-posted and edited filtering, the reviewed commit when the PR moved on, empty notes, placeholder per event, the conventional prefix, andgherror classification. A store test covers the posted state across restarts and edits.review/tests/post_flow.rs) use the fakeghfrom the existing PR tests. They cover:Enter;Escposts nothing;commit_idstays on the reviewed commit);Manual run
On real GitHub: see the first paragraph. Before that, I ran the real binary in a private tmux with a scratch
HOMEand data folder, the fakeghand a local bare repository. The summary, the footer after posting, and the rail's posted marks looked right, and the JSON the fakeghreceived was the expected one.Not verified
ghbehaviour on GitHub Enterprise hosts (--hostname);