Skip to content

fix(issue-pr-loop): finish open PRs before starting new issues - #7327

Merged
thomhurst merged 1 commit into
mainfrom
loop-wip-limit
Nov 2, 2026
Merged

thomhurst merged 1 commit into
mainfrom
loop-wip-limit

Conversation

@thomhurst

Copy link
Copy Markdown
Owner

Problem

Loop workers skipped every PR whose checks were still running and started new issues instead. Open PRs piled up, and each one in flight raises the chance of conflicts.

Change

scripts/Start-IssuePrLoop.ps1:

  • New -MaxOpenPrs (default 8, 0 = no limit). While that many of the loop's open PRs lack needs-human/on-hold, no fresh issue is queued. Stranded branches, stale in-progress claims, and parents with all sub-issues closed still are. The skipped count shows in survey stats as "held by the open-PR limit".
  • Test-HasNewFeedback: a PR with unresolved review threads, or an outside CHANGES_REQUESTED review newer than both the head commit and the loop's last reply, is no longer skipped for pending checks. It ranks with failed-CI PRs, is not a light unit, and its hint says to handle the feedback without waiting for checks. Conversation comments do not count, since a review with no findings is also a comment.
  • Get-PrActivity: one paginated GraphQL query for each open PR's head commit time and unresolved thread count. (gh pr list --json commits exceeds GitHub's GraphQL node limit.)

scripts/Test-IssuePrLoop.ps1 covers feedback detection and the open-PR limit, including new issue fixtures. The matching SKILL.md priority-list change was pushed to main separately.

Ported from thomhurst/TUnit#7423.

Validation

  • pwsh -NoProfile -File scripts/Test-IssuePrLoop.ps1 passes.
  • Get-PrActivity was run live against this repository and returned head commit times and thread counts for all open PRs.

Handle undispositioned review feedback while checks still run, and queue
no new issue while -MaxOpenPrs (default 8) unparked loop PRs are open.

Ported from thomhurst/TUnit#7423.
@coderabbitai

coderabbitai Bot commented Nov 2, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • 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

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@greptile-apps

greptile-apps Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The changes affect which work the issue-PR loop queues.

The PR appears safe to merge, with two non-blocking gaps that can delay review feedback.

Findings

  1. P2 Later review threads are missed ▶
  2. P2 Reopened threads stay deferred ▶

Summary

Adds MaxOpenPrs to hold fresh issues while enough unparked PRs remain open. It also makes unresolved threads and recent changes-requested reviews actionable during running checks.

  • The loop picks up new review feedback before checks finish.
  • The loop pauses new issues at its open-PR limit.

Author thomhurst explicitly keeps existing-work exceptions eligible at the limit and defines review freshness relative to the loop's last reply; these choices were not reported as defects.

Reviews (1) · Last reviewed commit: "fix(issue-pr-loop): finish open PRs befo..." · Reviewed by Greptile

function Get-PrActivity {
$query = 'query($owner: String!, $name: String!, $cursor: String) { repository(owner: $owner, name: $name) { ' +
'pullRequests(states: OPEN, first: 100, after: $cursor) { pageInfo { hasNextPage endCursor } ' +
'nodes { number commits(last: 1) { nodes { commit { committedDate } } } reviewThreads(first: 100) { nodes { isResolved } } } } } }'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Later review threads are missed

Get-PrActivity reads only the first 100 review threads on each PR. If those are resolved but a later thread from a COMMENTED review is unresolved, Test-HasNewFeedback returns false. The loop then skips the PR while checks run, despite its unanswered feedback. Paginate the thread connection before deciding there is no feedback, and test an unresolved thread beyond the first page.

else { '' }
# A green, clean PR usually needs only the merge gate or a disposition reply.
New-Candidate 'pr' ([int]$pr.number) $rank (Get-PrFingerprint $pr) ($rank -eq 0)
New-Candidate 'pr' ([int]$pr.number) $rank (Get-PrFingerprint $pr) ($rank -eq 0) $hint

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Reopened threads stay deferred

The new feedback signal does not reach the saved fingerprint. If a reviewer reopens a resolved thread on a PR already deferred for running checks, the head, checks, review submittedAt, and conversation comments can all remain unchanged. Get-Candidates includes the PR, but Select-Item still drops it through Test-Deferred. Include thread activity in both survey and post-unit fingerprints so fresh feedback wakes the PR without waiting for checks or expiry.

@thomhurst
thomhurst marked this pull request as ready for review November 2, 2026 23:33
@thomhurst
thomhurst merged commit 22f8977 into main Nov 2, 2026
17 of 18 checks passed
@thomhurst
thomhurst deleted the loop-wip-limit branch November 2, 2026 23:33
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T23:35:29.426303Z 05288db Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 05288db7e8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

function Get-PrActivity {
$query = 'query($owner: String!, $name: String!, $cursor: String) { repository(owner: $owner, name: $name) { ' +
'pullRequests(states: OPEN, first: 100, after: $cursor) { pageInfo { hasNextPage endCursor } ' +
'nodes { number commits(last: 1) { nodes { commit { committedDate } } } reviewThreads(first: 100) { nodes { isResolved } } } } } }'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Paginate review threads before counting unresolved feedback

For a PR with more than 100 review threads, this query only examines the first 100, even though the outer PR connection is paginated. If those threads are resolved but a later thread remains open, Test-HasNewFeedback returns false and Get-Candidates skips the PR while checks run, or incorrectly assigns it light merge-gate effort once checks pass. Fetch subsequent thread pages before concluding that no unresolved feedback exists, as scripts/Assert-PrGreen.ps1 already does. This also preserves the repository's requirement to handle reopened and undispositioned threads.

AGENTS.md reference: AGENTS.md:L54-L54

Useful? React with 👍 / 👎.

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.

1 participant