Repository navigation
Merge and other PR actions act on the PR URL bb already found - #7070
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… views read Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
force-pushed
the
bb/pr-merge-re-discovers-the-pr-thr_2di5n4tdqh
branch
from
November 5, 2026 06:25
6b58336 to
4a188a9
Compare
ymichael
added a commit
that referenced
this pull request
Nov 5, 2026
) ## Human comments ## What was wrong [Windows CI](https://github.com/get-bb/bb/actions/runs/42103646525/job/127512847896) timed out after 5,058ms in the host test that runs ready, draft, and merge. Those are three independent commands, but their sequential child-process launches shared one five-second test deadline. The test was added in #7070 after the repository-template improvements in #7049. It does not test a state transition between actions: the fake GitHub CLI only records each invocation and returns success. ## What changed Make the host-boundary check table-driven, with one case for each action. Every case keeps its own real tracked-fork repository and fake-gh child process, checks successful completion, and asserts the exact checked PR URL and command flags. All three actions and all prior assertions remain covered. Each case uses the existing five-second deadline. This is a test-only reliability change. It does not change production behavior, retries, timeouts, CI shards, or cache handling. The extra private fixture copies cost about 0.74 seconds in a local alternating comparison (median combined action-test duration: 0.40s before, 1.14s after); this is not a CI speedup claim. ## How you verified - Full package: `pnpm exec turbo run test lint typecheck --filter=bb-plugin-bb--github-pr-status` — all 180 tests, lint, and typecheck passed. - Controlled process-start delay: temporarily added 1.8 seconds to each fake-gh action child. The original combined test failed at its existing five-second deadline; all three new host cases passed at the same deadline. The delay was removed. - Coverage controls: independently changed the host handler to forward a wrong URL for ready, draft, then merge. Each mutation failed the original test and its corresponding new case. Restored the production file byte-for-byte. - Fresh CI executions at this head: [Windows](https://github.com/get-bb/bb/actions/runs/42108415313/job/127529530828) and [Linux](https://github.com/get-bb/bb/actions/runs/42108415313/job/127529531423) each passed all 180 package tests; both were test cache misses. The local delay experiment is a controlled reproduction, not a claim to reproduce Windows scheduling. - Formatter, `git diff --check`, code-review guidance, and test audit completed; independent root-agent review found no issues. > AGENT GENERATED
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
Merge, Mark ready and Convert to draft did two lookups to find a pull request bb already had. First,
requireActionTargetalways ran an uncached branch discovery (loadPullRequest(env, null, true): git config reads, then a GraphQL search by head branch). Thenactrangh pr mergewith no selector, after reading the branch config again. With no selector, gh resolves the PR from the branch itself: five more git processes (remote -v, twoconfig --get-regexp,symbolic-ref,rev-parse @{push}) and its own GraphQL search by branch. Each git process is slow in~/Projects/bb(about 4.5k branches, a 10k-line.git/config). This is finding #13 in the Nov 4 hot-path audit ("Merge: precheck by URL and pass it to gh").What changed
Only
plugins/github-pr-status. This is rebased on #7071, which madeviewstakeknown: { url, branchName }and return the workspace'srefs.server.ts: the action precheck passes the PR URL the store already holds asknown. It still bypasses caches, so state and mergeability are checked fresh. The precheck now getsrefsback from its ownviewsresult. It then rediscovers by branch when the PR has merged or closed, or when itsheadRefNameisn'trefs.branchNamefrom that same read. A stale stored URL is therefore never acted on. For example, after a branch switch, a refused Mark ready updates the plugin's branch map without touching the stored URL, and the next Merge would otherwise act on the old branch's PR. A fork PR whose upstream branch has a different name never matches the local branch, so it always rediscovers. That costs main's lookup plus one URL read, and still acts on the right PR. With no stored URL, the precheck discovers by branch, as before.actreceives the URL of the PR that passed the precheck.contract.ts/host.ts/host/git-host.ts:acttakes a requiredurland runsgh pr merge|ready <url> …. The host no longer reads the current branch or the upstream config for actions.runPullRequestActionForCurrentBranchbecomesrunPullRequestAction.HOST_DAEMON_PROTOCOL_VERSIONbump and no plugin SDK change.actis this plugin's own host contract, and the server ships the host artifact for each plugin generation.How you verified
Real data: the
~/Projects/bbworktree for this PR's own branch (open PR #7070), measured on origin/main after #7071 against this branch. The plugin's real host entry ran underexperimental_createHostEntryHarness, making the sameviews→actcalls the server makes for a merge. Aghshim onPATHrewrotegh pr merge|ready <args>intogh pr view <same selector> --json <the fields gh pr merge fetches>. That exercises gh's PR finder without merging. The merge mutation itself is the same on both sides and is not in these numbers. Three interleaved rounds of 15 per side ran at load average 8–11.Per-round total p50, main → branch: 1552 → 1242, 1466 → 1170, 1424 → 1188 ms.
What remains is GitHub latency: one GraphQL read for the precheck plus gh's own read before the mutation.
Tests:
pnpm exec turbo run test typecheck lint --filter=bb-plugin-bb--github-pr-statuspasses (179 tests). New server tests use a fake host that applies the realviewsrule: URL read only whenknown.branchNamematches the workspace branch.knownset to the stored URL and branch, and passes that URL toact.gh pr ready|merge <url>args, including from a fork-tracking workspace.🤖 Generated with Claude Code