Files
Ivan Zaitsev 89a8b1cfba [hardened PR review] Declutter replaced reviews: fold, delete unreplied comments, link nearby threads (#201479)
minimizing obsolete automatic reviews did not hide their review comments, meaning the identical comments from different review iterations could pile up on the same line.
this PR deletes obsolete comments (that don't have maintainer replies), and also edits the obsolete review to wrap them in `<details>` so they render better on mobile (which doesn't currently support minimization).

---

✴️ iz2: On PRs with many re-reviews (e.g. #201405: 24 automated reviews, 67 open inline threads), minimizing a replaced review hides only its body. Its inline comments stay listed on the Files tab and in GitHub Mobile, because `GITHUB_TOKEN` can't resolve threads here.

When a newer automated review replaces an earlier one, this change:
- folds the earlier review's body into a collapsed `<details>` section (the marker stays the first line; no cross-links)
- deletes its inline comments that nobody replied to or reacted to. A comment is deleted only if its review thread, read by GraphQL cursor, holds that one comment. Answered comments and their replies stay.
- posts a new blocking finding within 3 lines of an earlier comment someone replied to in the review body, with a link to that thread, instead of opening another inline thread. The match is by position only, so the link text says only that the thread is nearby.

Reviews hidden by earlier runs get the same fold and delete from a backfill. The backfill runs after any clean-verdict dismissal and is capped at 50 writes, 1 second apart, and 90 seconds per run, so a PR like #201405 is cleaned over a few runs. A change request that may still stand is never folded or emptied.

Known limits:
- A reply that isn't visible yet, because it was posted after the threads were read or is still pending in someone's unsubmitted review, does not protect its root comment. The API shows neither, so a maintainer who is mid-reply when a new push is reviewed can lose the comment they were answering.
- Throttled deletes on the takedown path, before a clean verdict's dismissal, are not time-bounded.

Test plan: `python3 -m unittest discover -s scripts/pr_review -t .` passes all 472 tests, including new cases for overlapping runs, reply, reaction and thread-count protection, retraction, and the backfill's budget, pacing, clock and change-request gate.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/201479
Approved by: https://github.com/huydhn, https://github.com/albanD
2026-10-22 00:32:15 +00:00
..