Skip to content

Restore #7028 and #7030, which #7011 reverted - #7052

Merged
ymichael merged 2 commits into
mainfrom
bb/restore-7028-7030
Nov 4, 2026
Merged

ymichael merged 2 commits into
mainfrom
bb/restore-7028-7030

Conversation

@ymichael

@ymichael ymichael commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

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.

What users got back after #7011:

What changed

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

ymichael and others added 2 commits November 4, 2026 13:06
## 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 #7000 with the patched host code: `passing`, 22/22,
`ready_to_merge`.
- Ran `pnpm start:worktree` with a checkout of #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](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
(cherry picked from commit b0e91c3)
…rns (#7028)

Two separate causes produced noisy child → parent completion notices.

1. **Notices piled up while the parent was blocked.** A child's turn-end
notice only coalesced into a queued row that was still inside its 2 s
scheduled window
([`getPendingCoalescedQueuedThreadMessage`](https://github.com/get-bb/bb/blob/4f973b851a/packages/db/src/data/queued-thread-messages.ts#L885-L906)
required `state = 'scheduled'` and `send_at > now`). Once that row moved
to `waiting` (pending question, starting turn, offline host), every
later outcome created another row. On 2026-11-03 a parent blocked on an
AskUserQuestion from 22:23 to 04:31 received ten separate "completed"
notices from one child, all steered in within two seconds of the answer.
The same pile-up existed before #6728 (pairs from one child appear in
the event log since September); this is the first time a parent stayed
blocked long enough for it to reach ten.
2. **`/compact` turns were reported as completions.** A `/compact` on a
child runs as its own turn whose only root item is the context
compaction. Its turn end notified the parent with "No final output was
recorded." just before the queued message behind it started the real
work. All 7 "No final output" child notices since #6821 were these
turns. Before #6821 the same turn re-sent the previous turn's output.

| Area | Change |
|---|---|
| `packages/db` `getPendingCoalescedQueuedThreadMessage` /
`updateCoalescedQueuedThreadMessageInTransaction` | Match any
undelivered coalesced row (`queued`, `scheduled`, `waiting`). Only a row
still inside its time window has `send_at` pushed back; a waiting row
keeps its wait. |
| `apps/server` `postCoalescedSystemNotice`, child notifications |
Return the row as stored; arm the dispatch timer only for a scheduled
row. |
| `packages/db` `isStoredTurnContextCompactionOnly` | New: true when a
turn's completed root items are all `contextCompaction`. |
| `apps/server/src/internal/events.ts` | A completed child turn that
only compacted context does not notify the parent. A turn that compacts
and then answers still does. |
| `bb guide threads` | `--parent-notifications` text says
compaction-only turns are not reported. |

No daemon wire change, so `HOST_DAEMON_PROTOCOL_VERSION` is unchanged.
No schema change.

- `apps/server/test/threads/system-notice-dispatch.test.ts`: "merge
later outcomes into a row still waiting on the parent" (parent on a
pending question, two outcomes from one child plus one from another →
one waiting row, latest status per child). Fails on main, passes here.
It replaces "start a new row once the earlier window has expired", which
pinned the pile-up.
- `apps/server/test/threads/child-completion-turn-output.test.ts`: "does
not notify the parent for a turn that only compacted context"
(compaction-only turn → no notice; compaction + answer → notice with the
answer). Fails without the `events.ts` change. The existing turn-scoping
test now records the parent's latest notice per child turn, because its
harness parent never accepts a turn and the old assertion counted the
pile-up.
- `pnpm exec turbo run typecheck lint --filter=@bb/server
--filter=@bb/db` passes.
- `pnpm exec turbo run test --filter=@bb/server --filter=@bb/db`: 3857
passed / 1 skipped, and 653 passed. One run hit a 40 s timeout in
`builtin-plugins.test.ts` under load ~14; that file passes on its own
(27/27).
- Live QA against a `pnpm start:worktree` server: to follow in a
comment.

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

> AGENT GENERATED

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 920804a)
@ymichael
ymichael merged commit 82e14ef into main Nov 4, 2026
51 checks passed
@ymichael
ymichael deleted the bb/restore-7028-7030 branch November 4, 2026 21:15
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