Skip to content

fix(watch-pr): keep stack parents beyond the first 300 open PRs - #854

Open
rudycelekli wants to merge 1 commit into
cursor:mainfrom
rudycelekli:fix/watch-pr-open-pr-limit-20261024b
Open

rudycelekli wants to merge 1 commit into
cursor:mainfrom
rudycelekli:fix/watch-pr-open-pr-limit-20261024b

Conversation

@rudycelekli

@rudycelekli rudycelekli commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Stack discovery in watch-pr reads the repository's open pull requests with gh pr list --limit 300 and builds the stack from that list. gh returns the newest PRs first, so once a repository has more than 300 open PRs, the oldest ones are left out. Those are usually the bottom of a stack, since the base PR is opened first. When the parent is missing, orderStack starts the stack at the watched PR and doesn't mention the cut. Stack mode can then report the stack clear while the unseen base PR still has failing checks or unresolved threads. Queued mode can report COMPLETE after the top PR merges into a base branch that hasn't reached trunk. This repository has about 270 open PRs right now, so it is close to the limit.

The fix keeps the same gh pr list query but stops treating a full page as complete. If gh returns exactly as many rows as the limit asked for, the reader asks again with double the limit, and repeats until the result comes back shorter than the limit. Repositories under 300 open PRs still make the same single call as before. Larger repositories get the whole open list, so the parent walk in orderStack can reach the real bottom of the stack. Parsing and the fork-head handling are unchanged.

The new open-pulls.test.ts puts a fake gh on PATH that behaves like the real one: newest first, cut off at --limit. It serves 400 open PRs, and the watched PR's base is the oldest one. On main, discoverStack returns only the watched PR and the test fails. With the fix it returns the parent and then the watched PR. The existing watch-pr github, cli and policy tests still pass, the regenerated harness tree passes --check, and validate-plugins passes.

Made with Cursor


Note

Medium Risk
Changes how open PRs are fetched for stack discovery; large repos may trigger multiple gh calls, but behavior for small repos is unchanged and fixes incorrect completion signaling.

Reviewed by Cursor Bugbot for commit 54eac27. Bugbot is set up for automated code reviews on this repo. Configure here.

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