Skip to content

[Fix] Stale PR clock resets on bot activity so stale PRs never close - #2077

Merged
edelauna merged 2 commits into
mainfrom
fix/stale-pr-author-clock-2076-3g42lod72wfj6
Oct 17, 2026
Merged

edelauna merged 2 commits into
mainfrom
fix/stale-pr-author-clock-2076-3g42lod72wfj6

Conversation

@ghost

@ghost ghost commented Oct 17, 2026

Copy link
Copy Markdown

​Created by Roomote. Follow up by mentioning @roomote, in the web UI, or in Discord.

Related GitHub Issue

Closes: #2076

Description

actions/stale uses the PR updated_at field as its inactivity clock. The label-pr-review-state.yml workflow updates PRs many times per day (review-status comments, awaiting-author and has-conflicts label flips). Each update resets updated_at, so actions/stale removed 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-PR reconcile job. 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 latest ready_for_review event. Opening the PR counts as author activity. Bot comments and label changes never move the clock. The step then applies the thresholds from stale.yml: stale-inactive after 60 days, stale-awaiting-author after 14 days with the awaiting-author label, 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 removes stale-inactive and stale-awaiting-author when the author clock is inside the window. The exempt labels do-not-close, pinned, and work-in-progress never close and get stale labels cleared. Read-only fork pull_request_review runs write nothing, matching the existing review-state step.
  • .github/workflows/stale.yml: both actions/stale jobs now run with debug-only: true, so the new step can be validated (for example with workflow_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 existing pr-review-state-workflow.test.ts pattern. Covered cases: close despite hourly bot activity, mark stale once, clear on author activity, exempt PRs never close, both awaiting-author thresholds, ready_for_review and author reviews reset the clock, maintainer commits do not, read-only fork runs write nothing, closed PRs are skipped.
  • src/vitest.workflow.config.ts runs 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.mjs lists 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 test from the repository root — full suite passes (10941 tests).
  • pnpm --dir src run check-types — passes.
  • ESLint on all touched files — passes with no new suppressions.
  • Reviewers can repeat the workflow tests with pnpm --dir src run test:workflow. After merge, the issue suggests testing policy C with workflow_dispatch on a known-stale PR while stale.yml stays in debug-only mode.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I reviewed my own code with care.
  • Writing Style: The PR title and description use Simplified Technical English (ASD-STE100): short sentences, plain words, active voice, one idea per sentence, no contractions.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Visual Snapshot (UI changes only): If a user would notice this change at a glance (layout, theme tokens, brand elements, empty/error states), I added or updated a *.visual.tsx snapshot in webview-ui/. See webview-ui/AGENTS.md → "When a UI change needs a snapshot".
  • Documentation Impact: I checked if my changes need documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I read and agree to the Contributor Guidelines.

Visual Snapshots

No UI changes. This PR changes CI workflow automation only.

Videos (interaction / animation only)

No interaction or animation changes.

Documentation Updates

  • No documentation updates are required. (Stale-PR behavior is CI automation and is not documented in the docs repository.)

Additional Notes

stale.yml stays in place with debug-only: true as a safety net. A follow-up PR can remove it once the new step is proven on live data.

Get in Touch

Discord: 0x7777777_

@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one): 1
  • coderabbit-review-active

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository: Zoo-Code-Org/Zoo-Code/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 8d1bbba1-f155-49bc-8f82-6b24a8c67595

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Review status

This 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. community-approved is managed the same way — do not add or remove it manually. It signals a fresh community code approval for the current head as an advisory priority only; maintainer review is still required.

@codecov

codecov Bot commented Oct 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@edelauna
edelauna marked this pull request as ready for review October 17, 2026 19:47
@edelauna
edelauna enabled auto-merge October 17, 2026 20:01
@edelauna
edelauna added this pull request to the merge queue Oct 17, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 17, 2026
@edelauna
edelauna added this pull request to the merge queue Oct 17, 2026
Merged via the queue into main with commit f707b6d Oct 17, 2026
25 checks passed
@edelauna
edelauna deleted the fix/stale-pr-author-clock-2076-3g42lod72wfj6 branch October 17, 2026 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stale PR clock resets on bot activity and never closes

2 participants