Repository navigation
Read GitHub PR branch lookups with a light scan plus the newest PR's details - #8150
Merged
ymichael merged 1 commit intoNov 25, 2026
Conversation
…details A branch lookup listed up to 100 PRs with every detail field, including reviewRequests(first: 100) and statusCheckRollup contexts(first: 100). GitHub prices that at 3 points per environment even when the branch has no PR, so 25 environments cost 75 points per document. On head names shared by many fork PRs (for example `main`), it also timed out after 10 s. The branch scan now asks only for the fields that pick the PR (url, state, head owner) across the same 100 newest PRs, plus full details for the newest PR. When the match is that newest PR, its details are used directly; otherwise the match is read again by URL, as known PRs already are. reviewRequests is read with first: 0 because only totalCount is used. Measured with rateLimit(dryRun: true): a 25-branch document costs 1 point (was 75). Check contexts still page 100 at a time and the review request count still comes from totalCount, so nothing shown in the UI or CLI changes. Fixes #5704 Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
deleted the
bb/5704-host-daemon-pr-status-reads-exhaust-the-git-thr_zectst65km
branch
November 25, 2026 01:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
The GitHub PR Status plugin's branch lookup (
plugins/github-pr-status/host/git-host.ts) asked GitHub for up to 100 PRs on the branch, each with every detail field:reviewRequests(first: 100),commits(last: 1)andstatusCheckRollup.contexts(first: 100). GitHub prices a query by the most it could return, so every lookup cost 3 points even on a branch with no PR, and 25 environments in one document cost 75 points. Repeated across many environments, that used up the 5,000-point hourly GraphQL allowance shared with everyghcall on the machine (#5704; measured by cameronm123 on 0.50.1). The same query also timed out after 10 s on head names shared by many fork PRs (for examplemaininmicrosoft/vscode), so in those cases it never covered 100 PRs.What changed
matchesBranchTargetneeds (url state isCrossRepository headRepositoryOwner). The same repository selection addsnewest: pullRequests(..., first: 1)with full details.reviewRequests(first: 0) { totalCount }: only the count is used.This differs from the issue comment's proposal (
first: 5/10/50). A 5-PR page misses the right PR when newer fork PRs share its head name (onmicrosoft/vscodemainthe matches were at positions 9, 12 and 22). SmallerreviewRequestsorcontextspages save no points, because cost depends only on the number of connection requests.No wire, CLI or protocol changes.
How you verified
Cost, priced with
rateLimit(dryRun: true)on the exact query the plugin sends (captured through aghshim):Latency on real GitHub, median of 5 runs: a branch with a PR takes 847 ms before and 780 ms after. A branch with no PR takes 432 ms before and 516 ms after; I read that as noise and didn't investigate further.
Old vs new code against real GitHub for 9 branch targets (same-repo open, same-repo none, default branch, and 6 fork-owner targets on
microsoft/vscodemain) plus 3 URL reads. Where the old code returned a result, the new code returned the same PR, state, check count and review-request count. The 5 fork-heavy targets the old code timed out on now resolve. Two of them reported a different merge state (BLOCKED, then UNKNOWN) on a later run; GitHub computes merge state lazily.End to end on
pnpm start:worktree:bb pull-request showon a project-checkout environment for Sign other devices in to bb, enforced by a Require sign-in switch #8146's branch found the PR through branch discovery.New tests:
host.test.ts, "finds the branch's PR behind many newer PRs from other forks with the same head name": fails when the scan page is cut to 5.host/batch.test.ts, "reads 25 branch lookups in one document with details for only each branch's newest PR": fails if the detail fields go back into the 100-PR scan.pnpm exec turbo run test typecheck lint --filter=bb-plugin-bb--github-pr-status: 183 passed.Fixes #5704
🤖 Generated with Claude Code