Repository navigation
[Fix] Stale PR clock resets on bot activity so stale PRs never close - #2077
Conversation
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one): 1
Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Review statusThis PR was opened by an automated account. A human maintainer must verify the change intent, provenance, and validation before merging. Current step: Mark the PR ready. Required CI must pass before CodeRabbit starts. Review-state labels are managed by this workflow; do not edit them manually. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Related GitHub Issue
Closes: #2076
Description
actions/staleuses the PRupdated_atfield as its inactivity clock. Thelabel-pr-review-state.ymlworkflow updates PRs many times per day (review-status comments,awaiting-authorandhas-conflictslabel flips). Each update resetsupdated_at, soactions/staleremoved the stale label on every run and stale PRs never closed (see PR #28 in the issue).This PR implements policy C from the issue: the review workflow owns the clock, and only author activity resets it.
Changes:
.github/workflows/label-pr-review-state.yml: adds one step, "Reconcile stale PR clock", to the per-PRreconcilejob. The step computes the last author activity for the PR: the latest commit by the author, the latest comment or review by the author, and the latestready_for_reviewevent. Opening the PR counts as author activity. Bot comments and label changes never move the clock. The step then applies the thresholds fromstale.yml:stale-inactiveafter 60 days,stale-awaiting-authorafter 14 days with theawaiting-authorlabel, and close after 7 more days. The close decision reads the author clock, not the label age, so a PR with new author activity never closes in the same run. The step removesstale-inactiveandstale-awaiting-authorwhen the author clock is inside the window. The exempt labelsdo-not-close,pinned, andwork-in-progressnever close and get stale labels cleared. Read-only forkpull_request_reviewruns write nothing, matching the existing review-state step..github/workflows/stale.yml: bothactions/stalejobs now run withdebug-only: true, so the new step can be validated (for example withworkflow_dispatch) before this workflow is removed.src/services/__tests__/stale-pr-clock-workflow.test.ts: new unit tests. They execute the embedded workflow step against mocked GitHub API responses, following the existingpr-review-state-workflow.test.tspattern. Covered cases: close despite hourly bot activity, mark stale once, clear on author activity, exempt PRs never close, bothawaiting-authorthresholds,ready_for_reviewand author reviews reset the clock, maintainer commits do not, read-only fork runs write nothing, closed PRs are skipped.src/vitest.workflow.config.tsruns the new test file in the dedicated non-Turbo workflow lane; the unit and services lanes exclude it, same as the existing workflow test.src/eslint.config.mjslists the new file next to the existing exception for tests that read root-level config.Test Procedure
pnpm --dir src run test:workflow— 218 tests pass, including the 12 new stale-clock tests.pnpm testfrom the repository root — full suite passes (10941 tests).pnpm --dir src run check-types— passes.pnpm --dir src run test:workflow. After merge, the issue suggests testing policy C withworkflow_dispatchon a known-stale PR whilestale.ymlstays indebug-onlymode.Pre-Submission Checklist
*.visual.tsxsnapshot inwebview-ui/. Seewebview-ui/AGENTS.md→ "When a UI change needs a snapshot".Visual Snapshots
No UI changes. This PR changes CI workflow automation only.
Videos (interaction / animation only)
No interaction or animation changes.
Documentation Updates
Additional Notes
stale.ymlstays in place withdebug-only: trueas a safety net. A follow-up PR can remove it once the new step is proven on live data.Get in Touch
Discord: 0x7777777_