Repository navigation
Make the GitHub plugin an inbox: next steps, split view, agents, merge and snooze - #1
Closed
alexandre-vl wants to merge 9 commits into
Closed
alexandre-vl wants to merge 9 commits into
alexandre-vl wants to merge 9 commits into
Conversation
The list query now also reads, for open pull requests, the draft state, head and base branches, mergeability, review decision and requested reviewers, merge-queue state and check counts by state, and the server derives each pull request's next step with core's attention order. The Pull requests tab groups rows into Your move, Ready to merge, Needs fixing, In progress, Waiting for review, Open and Drafts, with one status glyph and the reason on a second line. `bb github prs` prints the same next step, and `--json` adds `nextStep` and a `pr` status object.
2 tasks done
The status pill in the pull request detail is now a menu: Draft, Open (ready for review) and Closed, each offered only when GitHub's viewerCanUpdate, viewerCanClose and viewerCanReopen allow it. A closed draft reopens as a draft. Closing takes a second press, the pill spins and keeps focus while GitHub answers, the success toast offers Undo when undoing restores the exact state, and a failure says why and reloads. `bb github pr-state <repo> <number> --state open|draft|closed` runs the same gh commands through the new setPullState path. The diff stat uses core's diff tokens and DiffSizeBar blocks, splits the change into code, tests, docs and generated files on hover and above the file list, and scrolls to the files. The head branch is a copy chip.
The plugin now carries the whole v3 prototype (v3, v3.1 and v3.2) on top of the grouped inbox and the status menu. - Inbox: Inbox, Mine, All, Merged and Issues views; j/k, Enter, x and single-key actions; filter qualifiers as removable chips; display options; row menus for status, snooze, agents, branch and GitHub; multi-select with a bulk bar; Merge all and Fix all with agents per group, each summed up in one toast. - Split view: the list beside the pull request from 60rem. The detail says what the pull request needs next (ready, failing checks, conflicts, an agent at work or asking a question) and acts on it: merge dialog, agent sheet with presets on core's composer, re-run failed checks, and answers to the agent in place. - Detail tabs: Activity with replies to GitHub, Files in reading order with core's diff colours, and Checks with their logs. - Snooze until checks change, a new push, a reply, tomorrow or next week. - Home page section, thread header chip, thread-row status, palette commands and the panel badge share the inbox's wording. - Skeletons fade in; when GitHub is unreachable the last sync stays on screen with a banner. - Server: agentPrompt, linkThread, listFollows, mergePull, repoSettings, rerunFailedChecks, setFollow, snoozePull, startAgent and unsnoozePull RPCs, and `bb github merge|rerun|snooze|unsnooze|agent|follow`. Fixes found while capturing the screenshots: the home page says what a waiting agent asks, like the inbox; a restored filter no longer takes focus and covers the list with suggestions; the detail reloads once a merge settles instead of offering Merge until the next sync; the phone header drops a separator that started a line.
Two rounds of critics (UX hierarchy, mobile, scope, bugs, QA, code review) drove this pass. The plugin stays a GitHub tool: agent features that were not there before the port are cut, and every surface follows one rule set. - Merge: one path, the mergePull RPC with --match-head-commit. The merge dialog is gone; the card's split button, the row's Merge… step, `m` and the phone drawer share one method menu, default method first, anchored inside the card. Merge… shows wherever `m` works; when checks or reviews may still block the merge it opens the pull request and asks GitHub there, and says why when GitHub refuses. Delete the branch is off by default and a branch a bb worktree holds is kept. - Cut: bulk selection, Merge all, Fix all, display options, peek, the thread header chip, thread-row statuses, follows, the startAgent and startWork RPCs and the annotation fields. - Hierarchy: one filled GitHub action per card, Start an agent… last and absent while checks run; issues put assignees, labels and status before the agent; the row reason drops "Waiting for GitHub"; group shortcuts by where they work; drop the header shortcuts button. - Phone: long-press drawers titled with the pull request, 40 px touch targets, a merge drawer, rows that clamp to two lines. - State: one shared store per resource, so each signal loads each list once and a stale response cannot overwrite a fresh one; status changes on pull requests and issues show at once, with Undo, until GitHub reports them; the status pill keeps focus while a change runs. - Keyboard and focus: focus follows j/k in split view, menus opened with m/z/s land on their first item and return focus to the row, Enter in the new issue title moves to the description, comment and issue drafts survive navigation. - Viewer: the server keeps the last GitHub login, and the panel says it can't tell which pull requests are yours instead of "Nothing needs you".
Follow-ups from the QA pass on the reworked plugin: - j/k in split view moves exactly one pull request per press, even while the route is still catching up with the previous press. - j/k with focus inside the detail moves focus to the new row instead of dropping it. - Closing the agent sheet opened from a row returns focus to that row. - The status pill offers Reopen right after Close (and Close right after Reopen) before GitHub reports the new state. - Merging from the card keeps focus on the card, removing the last filter chip focuses the first row, and a merged row leaving the list hands focus to the row that takes its place.
The detail showed one fixed card skeleton while the pull request loaded, so the tabs below it jumped when the real card arrived: 34 px on desktop and up to 122 px on a phone, where actions stack. The skeleton now takes the row's status, the viewer, the agent and the repository's write access. It draws one row per failing check, the checks bar, the action buttons the card will show and the agent line, with phone line heights. The card also drops its empty action row, which added a 12 px gap.
When the viewer's review was requested, the next-step card became the review card and a failing CI run showed only as "· 1 check failing" in grey, and the row said nothing about it. The same held for a pull request with conflicts. The review and conflicts cards now list the failing checks with their logs, like the failing-checks card, and the loading skeleton draws those rows too. Rows and the home section add "Checks failing" in red after the reason when another reason leads; the reason truncates first, so the note stays visible on a phone. Rows keep no count, since the list and the detail count checks differently.
Port get-bb#5901 to the Files tab's rows: the toggle stretches over the header with a positioned pseudo-element, the file link stays above it, and repeated clicks no longer select text.
Owner
Author
|
Closing: superseded by get-bb#6037 (branch
|
alexandre-vl
pushed a commit
that referenced
this pull request
Oct 30, 2026
## Human comments ## What was wrong Several cache owners wrote a server reply or the thread-detail bootstrap straight into the React Query cache with `setQueryData` while a fetch of the same key could still be in flight. React Query writes fetch results without checking whether they're older than what's cached (query-core `query.ts`), so the older fetch landed last and put stale data back. Effects included: an environment or host status that stayed stale after opening a thread, a plugin settings form resetting its draft to the old value, a cancelled plugin install flipping back to running, new plugin update jobs dropping out of the list, an `idle` app update phase switching off the progress poll, and the AI service selection flickering back. These are items #2–get-bb#10 from the direct cache write audit (@thread:thr_fjr5x8dzaz). #1 (thread tabs) is fixed separately in get-bb#6611. ## What changed Two fixes, depending on whether the data has a version field: - **Environment and Host keep the newer copy by `updatedAt`** (#2, #3, get-bb#10). The bootstrap ingest (`thread-detail-cache-owner.ts`), the rename reply (`applyEnvironmentUpdateResult`), and the `useEnvironment`/`useHosts` fetches all compare `updatedAt`. The fetch-side check is what catches a fetch that started before the write and lands after it. To make it testable, those fetches now live in `environmentQueryOptions` and `hostsQueryOptions`. Host `status` comes from live daemon sessions and a disconnect doesn't change `updatedAt`, so on a tie the cached copy wins over the bootstrap. The bootstrap only fills an empty cache or replaces strictly older data. Rename replies and fetch results still win ties. - **`setQueryDataOverInFlightFetch`** (`cache-effect-utils.ts`) for data with no version (#4–#9): it writes the value, and if a fetch of the key is in flight it cancels that fetch (the cache keeps the written value) and refetches. With nothing in flight it's a plain write. Used by `applyPluginSettingsView`, `applyPluginInstallJob`, `applyPluginUpdateJob`, `hydrateAppUpdateStatus`, `hydrateSystemVersionCache` and `writeCachedAiServices`, so every caller gets the fix. Where the audit suggested an unconditional cancel-write-invalidate (#7) or a cancel before the write (#8, #9), this helper refetches only when a fetch was actually in flight. That avoids an extra request on every write. Forced version and app-update checks update the server's cache, so the trailing unforced refetch returns the forced result. No wire, CLI or plugin API changes. Not covered here: audit items get-bb#11 (plugin safe mode) and get-bb#12 (prompt history), both low risk. Also not covered: a lint rule restricting direct `setQueryData` calls to the helper, which would stop new call sites from bringing the race back. ## How you verified - New tests use real `QueryClient`/`QueryObserver` instances: start a fetch that resolves late with older data, do the write, let the fetch land, then check that the newer value survives (and, for the helper, that the trailing refetch runs). - `thread-detail-cache-owner.test.ts` (new): late environment and host-list fetches after a bootstrap, an older bootstrap over a newer cache, and the equal-`updatedAt` host status case. - `environment-workspace-cache-owner.test.ts`: a late environment fetch after a rename, and an older rename reply over a newer cache. - `in-flight-fetch-writes.test.ts` (new): one row per cache-owner write for #4–#9, plus helper tests for the no-fetch case (no extra request) and a fetch of an unobserved query. - With each source change reverted, every race test failed on the stale data and passed once the fix was restored. - `pnpm exec turbo run typecheck lint test --filter=@bb/app`: passed (647 files, 6515 tests; 0 lint errors, no new warnings). After rebasing onto `0472409243` I re-ran the three changed test files (21 tests passed). 🤖 Generated with [Claude Code](https://claude.com/claude-code) > AGENT GENERATED --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
alexandre-vl
pushed a commit
that referenced
this pull request
Nov 6, 2026
…ately, and read shared refs once per repo (get-bb#7082) ## Human comments ## What was wrong Every watched environment ran its own full `git for-each-ref refs/heads refs/remotes` whenever any ref in the repository was written, and fingerprinted the whole listing (`packages/host-workspace/src/git.ts`, `apps/host-daemon/src/watch-manager.ts`). On `~/Projects/bb` (4,474 local branches, 2,672 remote refs) that listing is about 1 MB and takes about 200–300 ms. Because the fingerprint covered every ref, any ref write in the repository changed every watched environment's fingerprint, whether it was a commit in one worktree, a new thread's branch or a `fetch --prune`. Each environment then emitted `git-refs-changed`, which refetches git status, files and the branch list in the git plugin and makes the PR plugin run `inspectRefs`. This is finding #1 ("Ref watch fan-out") of the Nov 4 hot-path overreach audit. ## What changed - **One listing per repository.** `WatchManager.readSharedGitRefs` keeps one pending listing per common git dir. Requests join it until the read starts, after a 25 ms join window. A ref change that arrives after a read has started gets a fresh read, so no environment acts on a listing taken before its own event. The listing runs from the worktree that started it. If it rejects (for example, that worktree was removed), each joined environment retries with its own read instead of failing with it. - **`git-refs-changed` now means "a ref this environment uses moved".** `SharedGitRefsSnapshot.fingerprintFor({ branchName, mergeBaseBranch })` covers only the oids of: - the HEAD branch, plus its `%(upstream)` and `%(push)` refs - every remote-tracking ref named after the branch (`refs/remotes/*/<branch>`). bb creates worktrees with `--no-track`, and a plain `git push fork <branch>` leaves both `%(upstream)` and `%(push)` empty, so a push to a fork remote still refreshes PR status. - the default branch, local and `origin/` - `origin/HEAD` and its target - the environment's merge-base branch (`refs/heads/<base>` and `refs/remotes/<base>`). The server resolves it per watched environment with the rule the git plugin reads status with (`mergeBaseBranch ?? baseBranch ?? defaultBranch`, `resolveEnvironmentMergeBaseBranch`) and sends it as `mergeBaseBranch` on each `watch-set.replace` workspace target. That covers envs started from a non-default branch and a base picked from any surface (Diff tab, Info tab, context banner), all of which persist through the git plugin's `setMergeBase`. A merge-base change already emits `metadata-changed`, so the server re-sends the target; the daemon updates the running watch in place (no re-provision) and rereads its refs, so the env refreshes once against the new base. - **New `git-branches-changed` environment change kind.** `SharedGitRefsSnapshot.branchNamesFingerprint` hashes the repository's branch-name set. When it changes, the daemon emits `git-branches-changed` instead of `git-refs-changed`. Each consumer handles it as follows: - **git plugin** (`plugins/git/server/invalidation.ts`): invalidates only the branch list (`refs:` tag, the `branches` RPC). It keeps the status/files caches and does not bump the refs generation. `refsChanged` is now set per change kind rather than inferred from the refs tag, so a batch that mixes the new kind with `work-status-changed` doesn't bump refs either. - **github-pr-status**: `environmentChangeEffect` returns `null`, so the kind is ignored; PR status doesn't depend on other branches existing. Added to its mapping table test. - **App cache registry** (`realtime-cache-registry.ts`): `dirty: []`, the same as `git-refs-changed`. Neither is in the app's watched-kinds list or the server's watch-target kinds. - **Server** (`notifyDaemonEnvironmentChange`): forwards the new kind unchanged. The existing internal test now covers it. - **Supporting changes.** `inspectGitRepository` already read `--git-common-dir`; it now returns it, and `HostWorkspace` exposes it as `gitCommonDir`. The listing format drops `%(refname:short)` (local names are now sliced from `refs/heads/`) and adds `%(upstream)` and `%(push)`. **Why the bumps are needed** - **`HOST_DAEMON_PROTOCOL_VERSION` 262 → 263:** `git-branches-changed` is a new value in the daemon's `environment-change` WebSocket message (`hostDaemonEnvironmentChangeSchema`). A 262 server would reject it, and a 262 daemon would keep emitting `git-refs-changed` for branch-name changes. The same bump covers the new required `mergeBaseBranch` field on `watch-set.replace` workspace targets. - **`@get-bb/plugin-sdk` 0.6.125 → 0.6.126** (`scripts/bump-plugin-sdk.mjs --patch`): the new kind widens the `changes` union of the SDK's `environment:changed` event (`ENVIRONMENT_CHANGE_KINDS` → `ChangedMessage`), which changes the published bundled types. **No visible behaviour change.** Every env still refreshes when its own branch, upstream, push target, default branch or merge base moves, and its branch list refreshes when a branch is created or deleted. The branch list is not ordered by commit, so moves of unrelated branches can't change it. ## How you verified **Real data, main vs branch.** I wrote a harness outside the checkout. It runs the real `WatchManager` with the subprocess parcel watcher on 20 real `~/Projects/bb` worktrees, with a `git` PATH shim that logs every spawn. It then writes a probe branch (`refs/heads/bench-refwatch-probe`) in the real repo: create, 5 moves, delete. Before and after each step it diffs every other ref, so writes by other agents can be attributed. To show what each env refetches, it maps the kinds each env emitted through that checkout's own git-plugin `tagsForEnvironmentChanges` and github-pr-status `environmentChangeEffect`. For the main run, every non-test file in this PR is checked out from origin/main. Probe branch **create and delete**, 20 watched worktrees, final run (load 5–10): | | main | branch | |---|---|---| | `for-each-ref` spawns | 20 (15.2 s / 19.5 s summed) | 1 (0.20 s / 0.24 s) | | envs emitting `git-refs-changed` | 20 | 0 | | envs emitting `git-branches-changed` | — | 20 | | git plugin refetch per env | status + files + branch list, caches cleared | branch list only, caches kept | | PR plugin per env | `invalidate` (`inspectRefs` → `upstream` host call) | none | One env on the branch also had an unrelated `work-status-changed` during the delete step (its own files changed), and refetched status and files for that. Probe branch **moves**: main spawned 20 `for-each-ref` per move and all 20 envs emitted `git-refs-changed` (more when other agents' writes overlapped). The branch spawned 1 per move and 0 envs emitted anything. Earlier runs across load 5–45 gave the same counts: - moves reached 0 envs whenever nothing else moved (16 of 16 such steps) - 1 env when a watched worktree switched its own HEAD branch mid-step (verified in its reflog) - `for-each-ref` at watch startup: main 20–28, branch 11–17, because provisioning is serial so only part of it joins How often name changes happen on `~/Projects/bb`. These now trigger only a branch-list refetch instead of a full refresh of every env: - Live 29-minute sample: 18 ref-write bursts, 7 of which changed the name set (2 local creates, 5 remote creates, 2 remote prunes). - Reflogs, last 7 days: about 105 ref creations a day against 253 moves. That is a lower bound, since deleted refs lose their reflogs. Costs: - A single listing with the new format, 15 interleaved runs: median 259 ms and 0.90 MB, against 286 ms and 1.09 MB for the old format. - `%(push)` adds about 18 ms (190 ms against 172 ms at low load). - Each env now keeps a short fingerprint string instead of a ~1 MB copy of the listing. **Tests** - `packages/host-workspace/test/host-workspace.test.ts`, for both files and reftable: - creating a branch changes `branchNamesFingerprint` but not the `main` env's fingerprint. - moving an unrelated branch leaves the `main` env's fingerprint unchanged. - moving the env's own branch, its upstream, its `refs/remotes/fork/<branch>` (no config), a renamed `%(push)` destination, or the default branch changes it. - with an env on `main`, moving its merge base changes the fingerprint for a local base (`feature`) and a remote one (`fork/feature`). This fails if the merge base is left out of the watched set. - `apps/host-daemon/src/watch-manager.test.ts`: - a branch-name change emits only `git-branches-changed`, and an own-ref move emits only `git-refs-changed`. - an env reports its merge base moving and the other env doesn't. Changing a merge base through `watch-set.replace` keeps the watch running (no re-provision), refreshes that env once, and later base moves reach it. This fails without the in-place update. - two worktrees of one repo share one read, and only the one whose refs moved reports. - a change that arrives while a shared read is running starts a fresh read. This test fails if a started read can be joined. - when the shared read rejects, joined envs fall back to their own read. This test fails without the fallback. - `plugins/git/server/invalidation.test.ts`: `git-branches-changed` → refs tag only, caches kept, no refs-generation bump, also when mixed with `work-status-changed`. - `plugins/github-pr-status/server.test.ts`: `git-branches-changed` → no effect. - `packages/host-daemon-contract/test/contract.test.ts`: protocol 263 (262 no longer compatible), and the new kind parses in `environment-change`. - `apps/server/test/internal/internal-environment-change.test.ts`: the server forwards the new kind to clients. - `apps/server/test/app/watch-interests.test.ts`: workspace targets carry the resolved merge base (`null`, then `baseBranch`, then a `setMergeBase`-style override, then back to `baseBranch` when cleared), re-sent on each `metadata-changed`. - **Live check on a `pnpm start:worktree` dev server** with a scratch repo and 4 worktree threads, watching the client WebSocket's environment events: - moving `origin/feature/beta`: only the env started from `feature/beta` gets `git-refs-changed` (before this commit, none did). - setting Worktree A's merge base to `origin/feature/alpha`: A gets `metadata-changed` + `git-refs-changed`, and its watch isn't restarted. Moving `origin/feature/alpha` afterwards reaches A only. - after clearing A's merge base, moving `feature/alpha` again reaches no env. - Commands: - `pnpm exec turbo run typecheck` for `@bb/host-daemon-contract`, `@bb/host-workspace`, `@bb/host-daemon`, `@bb/server`, `@bb/app`, `bb-environment-provider-host` and the git and github-pr-status plugins: all pass. - Targeted `vitest run` for those packages: all pass. CI runs the full suites. > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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 plugin's Pull requests tab is a table that lists every open pull request as
openwith aReviewbutton. The list query reads onlynumber title state author labels assignees url body updatedAt, so a draft, a failing check, a conflict and a green pull request look the same until each one is opened. Doing anything about a pull request (merge it, re-run its checks, mark it ready, put it aside) means leaving for GitHub. get-bb#5867 has the numbers and the v3 design this PR implements.The first port of that design (55db5ae) was then reviewed by eight independent agent threads in two rounds (UX hierarchy, mobile, scope, bugs, interaction QA, code). They found:
--match-head-commit. The method list flashed every method before the repository's settings loaded. The row menu, the card andmdisagreed on whether a pull request could be merged. The merge menu opened outside the card.m/zfocused "Back";viewercall showed "Nothing needs you" over waiting pull requests;What changed
The clean upstream pull request is get-bb#6037: these nine commits squashed into one, on current
main.Nine commits on
main. The first three are unchanged:fa35bc6 reworks the port into a simpler GitHub tool.
mergePullRPC with--match-head-commit, and the merge dialog is gone.mand the phone drawer share one method menu (components/merge.tsx). The default method is listed first, and the menu opens from the chevron, inside the card.mworks. When checks or reviews may still block the merge, it opens the pull request and asks GitHub there, using fresh data. If GitHub refuses, it says why.startAgent,agentPrompt,setFollow,listFollows,startWorkandstartReviewRPCs.j/kin split view.m,zandsland on their first item and give focus back to the row.fb5eab1 fixes what the QA thread's last pass found on fa35bc6. It changes focus and menu choices only, so the screenshots below still match.
j/kin split view moves one pull request per press, even while the route is still catching up with the previous press. fa35bc6's focus fix had brought back a dropped-press bug from the first round.j/kwith focus inside the detail moves focus to the new row instead of dropping it.6dcaa48 fixes Q03, the last open finding from that pass: the tabs jumped when the card loaded.
text-pretty. Otherwise loaded cards are unchanged.a0435c3 keeps failing checks visible when another reason leads.
0e717bd carries get-bb#5901 to the Files tab: the whole file header toggles the diff. bd48728 updates the README.
Left as they are, on purpose:
j/kyet, and one shared row component is still to come;bb githubhas no commands for issue status, assignees, comments or creation, a gap that already exists onmain;How you verified
pnpm exec turbo run typecheck test lint --filter=bb-plugin-github:Tests 148 passed (148);Found 0 warnings and 0 errors.jin split view while the route catches up (it fails without fb5eab1);expected to have a length of 2 but got +0).node scripts/check-plugin-forks.mjs plugins/github:1 forkable plugin(s) passed.j/k).jpresses 20 ms apart in split view move six rows;Status: Closed;data-changedsignal, Guard managed jobs against default-server CLI writes get-bb/bb#5839 leaves and focus is on Keep the macOS window chrome aligned at every zoom level get-bb/bb#5830;tablist tops seen: 640 (jump 0px).Hover Merge, Squash merge, then a review request:
On a phone: long press, Merge…, Squash merge:
Loading a pull request on a phone, skeleton then card. The "Description" heading shows how far the page moves:
Failing checks when your review leads: