Skip to content

Count only the latest workflow run in GitHub PR check status - #7030

Merged
ymichael merged 2 commits into
mainfrom
bb/fix-pr-status-sync-for-thread-thr-prjzzbmtp2-thr_v9ubgyutfm
Nov 4, 2026
Merged

ymichael merged 2 commits into
mainfrom
bb/fix-pr-status-sync-for-thread-thr-prjzzbmtp2-thr_v9ubgyutfm

Conversation

@ymichael

@ymichael ymichael commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

bb showed PR #7000 as "failing (22 passed, 4 failed)" while GitHub's commit rollup was SUCCESS and the PR was CLEAN. Every workflow had run twice on the head commit, both from pull_request events about a second apart. Concurrency cancelled CI run #20437, and its replacement, #20438, passed. GitHub's rollup only counts the newest run. bb rebuilt the check state from individual check runs and merged duplicates by name only. Four cancelled matrix jobs from the old run never expanded their names (for example Tests (${{ matrix.shard }}, ubuntu-latest, Node 22.x)), so no check in the new run shared their names, and bb counted them as failures. gh pr checks merges by name too and shows the same four failures.

A second path had the same problem. When bb can't resolve the GitHub repository from git remotes, it found the PR with gh pr view. For drafts, closed PRs and failed GraphQL reads, it then used gh's own statusCheckRollup, which has no workflow-run data.

What changed

plugins/github-pr-status/host/git-host.ts:

  • The GraphQL check query now fetches each check run's checkSuite.workflowRun (run number, event, workflow ID). After all check pages are merged, bb drops checks from any run superseded by a newer run of the same workflow and event. Runs for different events, such as push and pull_request, are both kept, so a real failure is not hidden. Status contexts and non-Actions check runs are unchanged.
  • The gh pr view discovery path now asks only for --json url, then reads the PR through the same GraphQL URL read every refresh uses. This now includes drafts and closed PRs. If that read fails, bb reports the PR as unavailable, which keeps any previous snapshot, instead of returning a partial PR. The gh pr view field list, its parser, and the gh-only parsing branches (array reviewRequests, workflowName fallback) are removed.

This is host-local to the plugin. The host/server contract and HOST_DAEMON_PROTOCOL_VERSION are unchanged.

How you verified

  • Added tests:

    • batch tests for a superseded run on one check page and for a newer run on a later page;
    • a discovery-path test for a draft with a superseded run;
    • a GraphQL-shaped normalization test;
    • unavailable cases for invalid or failed GraphQL responses.

    The superseded-run tests failed against the first draft of the fix, because the zod parse clones the check objects and dropped the run tags, so they do catch the bug.

  • pnpm exec turbo run test typecheck lint --filter=bb-plugin-bb--github-pr-status: 174 tests pass, plus typecheck and lint.

  • Read live fix(desktop): allow desktop-launched Computer Use to send Apple Events #7000 with the patched host code: passing, 22/22, ready_to_merge.

  • Ran pnpm start:worktree with a checkout of fix(desktop): allow desktop-launched Computer Use to send Apple Events #7000's branch as a project. bb pull-request show reports checks passing 22/22, CLEAN/MERGEABLE, ready_to_merge. Production bb on the same PR reports failing (22 passed, 4 failed, 26 total), checks_failed.

  • Not exercised live: the discovery path for unresolvable remotes. It is covered by unit tests only.

AGENT GENERATED

🤖 Generated with Claude Code

ymichael and others added 2 commits November 4, 2026 11:11
When a workflow runs twice on the same commit and event (for example a
concurrency-cancelled pull_request run followed by a newer one), GitHub's
rollup only counts the newer run. bb deduped checks by name only, so
cancelled jobs from the old run whose names never appear in the new run
(unexpanded matrix names such as "Tests (${{ matrix.shard }}, ...)")
were counted as failures. PR #7000 showed "4 failed" while GitHub showed
the rollup as SUCCESS.

Read each check run's workflow run and drop checks from runs superseded
by a newer run of the same workflow and event, across all check pages.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
When bb cannot resolve the GitHub repository from git remotes, it found the
PR with gh pr view and used gh's own statusCheckRollup for drafts, closed
PRs and failed GraphQL reads. That output has no workflow run data, so
checks from superseded workflow runs were still counted.

Use gh pr view only to find the PR URL and read the PR through the same
GraphQL read every refresh uses. A failed read now reports unavailable,
which keeps any previous snapshot, instead of returning a partial PR.
Remove the gh pr view field list and parser that only this path used.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit b0e91c3 into main Nov 4, 2026
48 checks passed
@ymichael
ymichael deleted the bb/fix-pr-status-sync-for-thread-thr-prjzzbmtp2-thr_v9ubgyutfm branch November 4, 2026 19:18
ymichael added a commit that referenced this pull request Nov 4, 2026
## Human comments

## What was wrong

#7011 (updateWhenIdle settings) reverted two PRs that had merged about
30 minutes before its commit was created: #7028 (merge child notices
while the parent is blocked, skip `/compact` turns) and #7030 (count
only the latest workflow run in GitHub PR check status). Its body
mentions neither, so it looks accidental.

- #7011 is a single commit, `6b17f1bc04`, whose parent is #7028's merge
commit `920804af63`. Even so, the commit's own diff rewrites 11 files to
their earlier content:
- In #7028's 9 files it is an exact inverse of #7028, apart from four
exports #7011 added to `packages/db/src/data/index.ts`.
- #7030's 3 files in `plugins/github-pr-status/host/` went back to their
pre-#7030 content.
- That pattern fits a branch whose files came from an older checkout and
were committed onto a newer base.
- CI stayed green because each revert also removed the matching tests.
- No other PR was affected. Every file the commit touched was compared
with its earlier versions on main; only these two PRs match.

What users got back after #7011:
- **#7028:** a parent blocked on a question, a starting turn or an
offline host collects a separate notice for every child update again (on
Nov 3 one parent got ten from one child). `/compact` turns on a child
send the parent "No final output was recorded."
- **#7030:** bb shows green PRs as failing ("22 passed, 4 failed") when
GitHub cancelled a duplicate CI run.

## What changed

- Cherry-picks `b0e91c38f8` (#7030) and `920804af63` (#7028) onto
current main with `-x`. #7030 applies unchanged.
- #7028 conflicted only in `coalesced-system-notices.ts`, because #7029
(merged after #7011) added withdrawing a pending notice there. The
result is #7028's version with #7029's withdraw path kept: the pending
lookup has no `now` and a merge writes `windowEndsAt`. This is the
combination #7029 was tested with before #7011 landed.
`child-thread-notifications.ts` resolved to main's existing version,
which already guards on a scheduled row.
- Restores the #7029 test that depends on #7028: an ownership change
undone after its 2 s window but before delivery is withdrawn. Its test
helper comes back with it.
- `internal/events.ts` and `db/data/events.ts` merged cleanly with the
later #7031 and #7033 changes.
- No daemon wire, CLI, config or plugin SDK surface change;
`check-plugin-sdk-version` reports the surface unchanged.

## How you verified

- With main's current code and the restored tests, 7 tests fail. With
this branch they pass:
- `thread-ownership-notices`: "withdraw a move undone after its window
but before delivery"
- `system-notice-dispatch`: "merge later outcomes into a row still
waiting on the parent"
- `child-completion-turn-output`: "does not notify the parent for a turn
that only compacted context"
- `github-pr-status` `git-host` / `batch`: superseded workflow runs,
including on a later checks page and for drafts found through `gh pr
view`
- Server: ownership notices, notice dispatch, child completion output,
notice kinds, child outcomes, parenting, plugin events, queue updates,
sidebar status and child notifications all pass (112 tests).
- `turbo run test` for the GitHub PR Status plugin, `@bb/db` and
`@bb/templates` passes (10/10 tasks). `turbo run typecheck` for server,
db, app and the plugin passes (10/10 tasks).

> AGENT GENERATED

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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