Skip to content

Publish GitHub PR status changes to every open view - #6351

Merged
ymichael merged 1 commit into
mainfrom
bb/investigate-stale-github-pr-status-thr_gva967bmbe
Oct 27, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/investigate-stale-github-pr-status-thr_gva967bmbe

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

An open thread view could show a stale PR status indefinitely. In plugins/github-pr-status/store.ts, when a client read was the first to fetch a changed PR, publishChanges skipped invalidating that environment, on the assumption that the reader is the only viewer. Readers were tracked by environment ID, not by client, so every other open view of the same thread was never told. The store then recorded the new row in served, so later polls saw no change and never published either. The view stayed wrong until it remounted (switching threads does refetch) or reloaded.

Any plugin RPC without a plugin token is a client caller, so bb thread show and bb pull-request show count as viewer reads. Agents and manager threads that run them froze open views of the threads they inspected. Core's implementation before #6125 (pull-request-watch.ts) published every change to every watcher. The exemption arrived with the move into the plugin and was kept in #6143.

What changed

  • store.ts: removed the reader exemption (loadingReaders, the readers parameter of load, and the per-environment check in publishChanges). Every change now invalidates every watched environment that shows it. The client that triggered the fetch refetches once more, and that read is served from the 10 s cache without calling gh.
  • No wire, CLI, SDK or doc changes. The README's "publishes only changed rows" still holds.

How you verified

  • New store.test.ts case: a viewer read that finds a change must publish to the environment's watchers. It fails on main (expected "vi.fn()" to be called once with arguments: [ [ 'a' ] ]) and passes with the change.
  • pnpm exec turbo run test typecheck lint --filter=bb-plugin-bb--github-pr-status: 158 tests passed, typecheck and lint clean.
  • End to end on an isolated pnpm start:worktree instance. A fake gh served GraphQL PR reads from a state file, and headless pages ran against a real thread:
    • Two pages on one thread. I flipped the PR to passing and reloaded only page B. On main, B showed "Ready to merge" and A stayed on "Checks failing" for more than 6 minutes, including after the scheduled poll fetched the new state. With this change, A updated within 6 s, with one gh call.
    • One open page plus bb thread show in the CLI. On main, the CLI printed passing and the page stayed failing 30 s later. With this change, it updated within 3 s.
    • Switching threads away and back refetches and shows the new status, so a view is stuck only while it stays open.
  • On the live server, with the thread open, polling (every 5 minutes when quiet, a 30 s follow-up after a push) and push detection (refresh 13 s after a simulated push) both fired on schedule, so neither is part of this bug.

🤖 Generated with Claude Code

AGENT GENERATED

When a client read was the first to see a changed pull request, the store
returned the new row to that read and skipped invalidating the same
environment for everyone else, then marked the row as served. Other open
views of that thread stayed stale until they remounted, and later polls
saw no change. Any read without a plugin token counts as a client read,
so `bb thread show` and `bb pull-request show` froze open views too.

Publish every change to every watcher, as core did before the plugin.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 5b5b7f4 into main Oct 27, 2026
48 checks passed
@ymichael
ymichael deleted the bb/investigate-stale-github-pr-status-thr_gva967bmbe branch October 27, 2026 03:05
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