Skip to content

feat(issue-pr-loop): finish open PRs before starting new issues - #337

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, so open PRs piled up and the chance of conflicts grew.

Change

Ported from thomhurst/TUnit#7423.

  • 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 closed-children parents still are. The held count appears in the idle survey stats.

  • 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 gets a hint to handle the feedback now. Conversation comments do not count (a review with no findings is also a comment).

  • Get-PrActivity reads head commit time and review-thread resolution for all open PRs in one paginated GraphQL query (adding commits to gh pr list --json exceeds GitHub's node limit).

  • scripts/Test-IssuePrLoop.ps1: tests for the feedback detection and the open-PR limit.

  • .agents/skills/issue-pr-loop/SKILL.md: priority items 3 and 6 describe the same rules. (Kept in this PR because this repository does not allow direct pushes to main.)

Validation: pwsh -NoProfile -File scripts/Test-IssuePrLoop.ps1 passes; Get-PrActivity checked against this repository's live open PRs. Script-only change, no hot-path cost.

Add -MaxOpenPrs (default 8): while that many unparked loop PRs are open,
no fresh issue is queued. PRs with unresolved review threads or a
changes-requested review newer than the last push are no longer skipped
for pending checks.
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e56c1b30-8808-4424-b308-55262ae3ecc6
  • 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.

@thomhurst
thomhurst marked this pull request as ready for review November 2, 2026 23:32
@thomhurst
thomhurst merged commit 11f6c12 into main Nov 2, 2026
14 checks passed
@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:33:59.359725Z 8b6ce82 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.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

Review

I found no blocking problems in the script, test or skill changes.

  • Fields and helpers: Test-HasNewFeedback reads author, reviews and comments, and all three are in $prFields. Get-PrActivity uses the existing Invoke-GraphQl helper and its cursor handling.
  • Ranking: a PR with feedback and green checks is no longer rank 0 (the light merge-gate unit). It ranks 2 and gets a full-effort unit, which is the right call.
  • Open-PR limit: parked PRs are excluded from the count. Stranded branches and stale claims are still queued at the limit, as the description says. 0 disables the limit.
  • Tests: they cover thread feedback, a changes-requested review newer than the last push, a loop reply or comment as disposition, stale reviews, comment-only reviews, the limit and 0.
  • Per-message cost: none. This is a script-only change, so the performance rules don't apply. The skill doc is updated in the same PR, which matches the docs rule.

Minor, non-blocking:

  • reviewThreads(first: 100) is not paginated. A PR whose first 100 threads are all resolved but has a later unresolved thread would be missed. That is rare, and it only means the PR waits for checks as before.
  • Get-PrFingerprint doesn't include the unresolved-thread count, so a deferral isn't invalidated by a thread opened on an unchanged head. This is acceptable, because new review activity changes the fingerprint in other ways.

@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: 8b6ce82747

ℹ️ 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".

Comment on lines +294 to +296
if ($comment -and $comment.createdAt -and ([string]$comment.body).Contains($loopMarker)) {
$at = ConvertTo-Instant $comment.createdAt
if ($at -gt $since) { $since = $at }

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 Distinguish disposition comments from other loop comments

When a changes-requested review has no unresolved inline threads, any later comment containing $loopMarker suppresses that feedback, even if the comment does not address it. The draft lifecycle explicitly uses the same marker for Codex review requests and retries, so posting such a request after an outstanding review makes Test-HasNewFeedback return false and excludes the PR while checks remain pending. Advance the disposition timestamp only for an actual response to the feedback, not every loop-authored comment.

AGENTS.md reference: AGENTS.md:L78-L78

Useful? React with 👍 / 👎.

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 when counting unresolved feedback

For a PR with more than 100 review threads, this query examines only the first 100 and never requests subsequent thread pages. If those earlier threads are resolved but a later thread remains open, UnresolvedThreads becomes zero and the pending-check filter skips the PR despite actionable feedback. Paginating the outer PR connection does not paginate each nested thread connection; fetch subsequent thread pages or otherwise ensure the unresolved count covers every thread.

AGENTS.md reference: AGENTS.md:L79-L79

Useful? React with 👍 / 👎.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant