Skip to content

[pr-review] Post non-blocking findings inline, collapsed - #206357

Closed
bbayeste wants to merge 6 commits into
mainfrom
pr-review-inline-non-blocking
Closed

bbayeste wants to merge 6 commits into
mainfrom
pr-review-inline-non-blocking

Conversation

@bbayeste

@bbayeste bbayeste commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Non-blocking findings were folded into one collapsed section of the review body. Most findings are non-blocking since #203531, so most of what the review says sat behind one click, away from the code it is about. Nobody could reply to one finding or react to it, so a thumbs-down could not settle it and there was no per-finding signal on non-blocking findings.

post_review.py now posts every finding on its line:

  • A blocking finding is unchanged: marked 🔴 and shown in full.
  • A non-blocking finding is a collapsed block. Its summary is ⚪ and the finding's first sentence, labelled "Non-blocking" unless the sentence already says so. The rest of the message is under it. The "Report this finding" link stays visible below the block.
  • The summary line is part of an HTML block, so markdown there is not rendered. Messages arrive already neutralized, so the summary is unescaped to the text a reader should see and escaped once. Neutralize's \[, \] and \# escapes and bold markers are dropped, and code spans become <code>. The whole summary, label included, is cut at 150 characters at a word, and a cut summary has the full message under it.

The review body says how many findings of each kind are attached to the code. The collapsed body section is kept for findings that cannot go inline: those next to an earlier thread someone replied to, and any GitHub refuses. GitHub refuses every inline comment when it refuses one, so a refused review is retried with only the blocking findings inline before everything falls back to the body. The verdict and the review event are unchanged.

Most findings are now inline, so taking down a superseded review can cost a delete per finding. Those deletes are paced, as backfill's already are.

Test plan: python3 -m unittest discover -s scripts/pr_review -t ., 681 pass. New tests cover the summary on neutralized input (escaped once, no markdown escapes, the label added once, abbreviations, the length cap), the retry with only blocking findings inline, and the paced deletes. The body-only tests (folding, the size cap, fence containment, permalinks) run through the refused-inline fallback and check that the inline attempt was refused first.

Non-blocking findings were folded into one collapsed section of the review
body. Most findings are non-blocking since #203531, so most of what the review
says sat behind one click, away from the code it is about. Nobody could reply
to one finding or react to it, so a thumbs-down could not settle it and there
was no per-finding signal on non-blocking findings.

`post_review.py` now posts every finding on its line. A blocking finding stays
as it was: marked with a red circle and shown in full. A non-blocking one is a
collapsed block whose summary is a grey circle and the finding's first
sentence, labelled "Non-blocking" if the message does not already say so. The
rest of the message and the report link sit under it. The summary is HTML-
escaped, cut at 150 characters (the full message then goes under it), and the
body is contained so an unclosed fence cannot swallow the closing tag.

The review body says how many findings of each kind are attached to the code.
The collapsed body section remains for findings that cannot go inline: those
next to an earlier thread someone replied to, and all of them when GitHub
refuses the inline comments. The verdict, the review event and the fallbacks
are unchanged.

Test plan: `python3 -m unittest discover -s scripts/pr_review -t .`, 675 pass
(6 new). Tests of the body-only behaviour (folding, the size cap, fence
containment, permalinks) now run through the refused-inline fallback.
@bbayeste
bbayeste requested a review from izaitsevfb as a code owner November 23, 2026 23:20
@pytorch-bot

pytorch-bot Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

PR Status: Approved 🚀

Please fix all CI failures and trigger merge by commenting "@pytorchbot merge".

✅ AUTOMATED REVIEW - Ready for human review:

`post_review.py` now posts every finding on its line. Blocking findings appear
in full, non-blocking ones are collapsed under their first sentence, and if
GitHub refuses the inline comments the review is retried with only the blocking
findings inline. The review's recommendation is Approve, and it says every
remaining point is non-blocking.

Findings (7):

[minor] scripts/pr_review/post_review.py:530
Non-blocking (continuing): "collapsed" is wrong for one-sentence findings. Line
388 posts a one-sentence non-blocking finding as an open `<p>`, but the review
body line at 528-530 still says these findings are "attached to the code below,
collapsed", and its count includes the `<p>` ones. The docstrings at lines 24-25
and 365-366 say the same, though only loosely. Suggested fix: drop ", collapsed"
from the body line.

[minor] scripts/pr_review/post_review.py:327
Non-blocking (continuing): the PR description, which becomes the commit message,
is out of date. It says neutralize's escapes "and bold markers are dropped", but
HEAD keeps `**` on purpose (post_review.py:323-327), and the tests confirm this
(test_post_review.py:545-548, 553-556). It also calls every non-blocking finding
"a collapsed block".

[minor] scripts/pr_review/post_review.py:358
Non-blocking (continuing): a long first token can empty the summary. In
`summary_line` (351-361), the first token can be 136 or more characters with no
spaces, such as a long dotted name or a code span, and `_BLOB` doesn't reject
these. The cut at `MAX_HEADLINE - 1` then lands inside that token and
`_LAST_WORD` removes all of it. What remains is `"Non-blocking: "`, which isn't
empty, so the `or kept` fallback never fires and the summary reads `
Non-blocking:`. The effect is cosmetic, since the full message is still under
`<details>`. Suggested fix: drop the partial word only when what remains is
longer than the label.

[minor] scripts/pr_review/post_review.py:332
Non-blocking (continuing): the cut-at-word logic is duplicated. `_LAST_WORD`
(post_review.py:332) is identical to `extract_verdict._PARTIAL_TOKEN`
(extract_verdict.py:184) but lacks its comment on the anchoring. The guard at
post_review.py:356-358 repeats the one in extract_verdict.py around lines
476-478. A shared public `cut_at_word(text, limit)` would keep the copies from
drifting apart.

[minor] scripts/pr_review/post_review.py:373
Non-blocking (new): a finding that drew only a reaction gets a duplicate thread
on the next round. `delete_unreplied` keeps any earlier inline comment that has
a reaction (1064, 1076, via `reacted()` at 1002-1004). But `note_discussions`
(766) only links a new finding to a comment someone replied to, using
`replies_seen`, which is built from `in_reply_to_id`. So if an author reacts
without replying and the next review re-raises the finding as "continuing", a
new inline comment is posted on the same line and the reacted one stays visible.
GITHUB_TOKEN can't resolve threads (823-825), and minimizing hides only the
review. Each such round adds a thread. Blocking findings already had this gap,
but this PR makes it common because non-blocking findings are the majority and
the kind that carries over between rounds. Suggested fix: have
`note_discussions` treat reacted comments like replied ones.

[minor] scripts/pr_review/post_review.py:364
Non-blocking, low confidence (continuing): re-reviews may hit `truncated` more
often. Non-blocking findings used to sit in the latest review body, which
`fetch_pr_comments.py` keeps in its "answered" tier. Each one is now a separate
inline item, and one with no reply or reaction falls into the tier that is
dropped first when the item cap is reached.

(1 more not shown, see the review run)

Reviewed commit: af578b0

Review run

🐛 Report a bad review

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/206357

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit af578b0 with merge base 7f632bb (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot Bot added the topic: not user facing topic category label Nov 23, 2026
@github-actions github-actions Bot added bot-triaged This is a label only to be used by the auto triage bot triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels Nov 23, 2026
@pytorch-bot pytorch-bot Bot added the in progress PR is being worked on by the author, until the automated review accepts it label Nov 23, 2026
lintrunner's formatter wrapped five lines of the new tests, and the URL link
check fetched their placeholder URLs. Mark those with `# @lint-ignore`, as the
other tests do.
github-actions[bot]

This comment was marked as outdated.

@albanD albanD left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Do fix the escape flagged by the bot before mergin!

…e on refusal

- Messages reach `comment_body` neutralized, so already HTML-escaped. The
  summary escaped them again and showed `&lt;` as `&amp;lt;`. It now unescapes
  to the text a reader should see and escapes once.
- The summary line is part of an HTML block, so markdown on it is not
  rendered. It drops neutralize's `\[`, `\]` and `\#` escapes and bold markers,
  and turns code spans into `<code>`.
- The 150-character cap covers the whole summary, label included, and cuts at
  a word.
- The label is added only when "non-blocking" is nowhere in the sentence, and a
  sentence ends only before a capital, so "e.g. `x`" does not end one.
- GitHub refuses every inline comment when it refuses one. On a refusal, the
  review is now posted with only the blocking findings inline before falling
  back to the body.
- Taking down a superseded review paces its deletes, as backfill does: most
  findings are inline now, so a review can cost a delete per finding.
- Tests: the summary is checked on neutralized input, the long-headline test
  checks the summary itself, and the fallback tests check that an inline
  attempt was refused first.

Test plan: `python3 -m unittest discover -s scripts/pr_review -t .`, 681 pass.
github-actions[bot]

This comment was marked as outdated.

@github-actions
github-actions Bot dismissed their stale review November 24, 2026 16:37

Withdrawn: the automated review of 2d4ce44 found nothing blocking.

github-actions[bot]

This comment was marked as outdated.

- `neutralize` leaves `@**user**` and `#**12**` alone, since no letter or digit
  follows the `@` or `#`. Stripping `**` from the summary turned them into a
  live mention and a live cross-reference. The summary no longer strips `**`;
  it only drops neutralize's own escapes, which keeps every defused mention and
  reference defused. A test covers both.
- The label counts only at the start of the sentence or as "(non-blocking)" or
  "non-blocking:", so a sentence about a non-blocking copy still gets it.
- The cut drops a split word only when it split one, and uses a local regex
  instead of `extract_verdict`'s private `_PARTIAL_TOKEN`.
- A one-sentence finding is a single line, with no empty block to open.
- A successful blocking-only retry says that the non-blocking findings went to
  the body. `with_removed`'s docstring says what the retry changes.
- `take_down` reads `BACKFILL_PAUSE` when called, so tests can zero it, and the
  comment says what is paced.
- Tests: two body-only tests run through the refused-inline fallback, the fence
  test checks that no fence survives, and the cut tests cut mid-word and on a
  space.

Test plan: `python3 -m unittest discover -s scripts/pr_review -t .`, 684 pass.
github-actions[bot]

This comment was marked as outdated.

@github-actions
github-actions Bot dismissed their stale review November 25, 2026 04:30

Withdrawn: the automated review of e716882 found nothing blocking.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review of af578b0: nothing blocking; ready for human review.

post_review.py now posts every finding on its line. Blocking findings appear in full, non-blocking ones are collapsed under their first sentence, and if GitHub refuses the inline comments the review is retried with only the blocking findings inline. The review's recommendation is Approve, and it says every remaining point is non-blocking.

⚪ 7 non-blocking findings

"below, collapsed.",

Non-blocking (continuing): "collapsed" is wrong for one-sentence findings. Line 388 posts a one-sentence non-blocking finding as an open &lt;p&gt;, but the review body line at 528-530 still says these findings are "attached to the code below, collapsed", and its count includes the &lt;p&gt; ones. The docstrings at lines 24-25 and 365-366 say the same, though only loosely. Suggested fix: drop ", collapsed" from the body line.


_MD_ESCAPE = re.compile(r"\\([\[\]#])")

Non-blocking (continuing): the PR description, which becomes the commit message, is out of date. It says neutralize's escapes "and bold markers are dropped", but HEAD keeps ** on purpose (post_review.py:323-327), and the tests confirm this (test_post_review.py:545-548, 553-556). It also calls every non-blocking finding "a collapsed block".


kept = _LAST_WORD.sub("", kept) or kept

Non-blocking (continuing): a long first token can empty the summary. In summary_line (351-361), the first token can be 136 or more characters with no spaces, such as a long dotted name or a code span, and _BLOB doesn't reject these. The cut at MAX_HEADLINE - 1 then lands inside that token and _LAST_WORD removes all of it. What remains is "Non-blocking: ", which isn't empty, so the or kept fallback never fires and the summary reads Non-blocking:. The effect is cosmetic, since the full message is still under &lt;details&gt;. Suggested fix: drop the partial word only when what remains is longer than the label.


_LAST_WORD = re.compile(r"(?<!\S)\S+\Z")

Non-blocking (continuing): the cut-at-word logic is duplicated. _LAST_WORD (post_review.py:332) is identical to extract_verdict._PARTIAL_TOKEN (extract_verdict.py:184) but lacks its comment on the anchoring. The guard at post_review.py:356-358 repeats the one in extract_verdict.py around lines 476-478. A shared public cut_at_word(text, limit) would keep the copies from drifting apart.


head, rest = split_headline(finding["message"])

Non-blocking (new): a finding that drew only a reaction gets a duplicate thread on the next round. delete_unreplied keeps any earlier inline comment that has a reaction (1064, 1076, via reacted() at 1002-1004). But note_discussions (766) only links a new finding to a comment someone replied to, using replies_seen, which is built from in_reply_to_id. So if an author reacts without replying and the next review re-raises the finding as "continuing", a new inline comment is posted on the same line and the reacted one stays visible. GITHUB_TOKEN can't resolve threads (823-825), and minimizing hides only the review. Each such round adds a thread. Blocking findings already had this gap, but this PR makes it common because non-blocking findings are the majority and the kind that carries over between rounds. Suggested fix: have note_discussions treat reacted comments like replied ones.


def comment_body(finding: dict, report: str = "", blocking: bool = True) -> str:

Non-blocking, low confidence (continuing): re-reviews may hit truncated more often. Non-blocking findings used to sit in the latest review body, which fetch_pr_comments.py keeps in its "answered" tier. Each one is now a separate inline item, and one with no reply or reaction falls into the tier that is dropped first when the item cap is reached.


fold(gh, pr, review, reason)

Non-blocking (continuing): take_down paces only its deletes. Line 828 calls fold(gh, pr, review, reason) with no budget, although fold accepts budget=. Only delete_unreplied gets a Budget(pause=BACKFILL_PAUSE), at line 831. hide_earlier calls take_down once per review, so the minimize at line 840 and the next review's fold PUT run back to back. _backfill (around line 1122) shares one Budget across its folds and deletes, and doing the same in take_down would pace all these writes. The impact is small.

This review is AI-generated and advisory. Each new automated review replaces the previous one. Report a bad review

@bbayeste

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added ciflow/trunk Trigger trunk jobs on your pull request ready for review Automated review passed, ready for a final review by a maintainer. and removed in progress PR is being worked on by the author, until the automated review accepts it labels Nov 25, 2026
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot-triaged This is a label only to be used by the auto triage bot ciflow/trunk Trigger trunk jobs on your pull request Merged ready for review Automated review passed, ready for a final review by a maintainer. topic: not user facing topic category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants