Repository navigation
Conversation
ymichael
added a commit
that referenced
this pull request
Oct 17, 2026
ymichael
force-pushed
the
bb/live-data-stack-14-tasks-thr_jkff7k6wj2
branch
from
October 17, 2026 03:36
9028638 to
e1f9107
Compare
ymichael
changed the base branch from
bb/live-data-stack-3-watching-connect-bb-account-thr_79u87xmcbx
to
bb/live-data-stack-13-docs-thr_eyhy2ce2t5
October 17, 2026 03:37
This was referenced Oct 17, 2026
ymichael
force-pushed
the
bb/live-data-stack-13-docs-thr_eyhy2ce2t5
branch
from
October 17, 2026 04:51
e733966 to
6b98ae1
Compare
ymichael
added a commit
that referenced
this pull request
Oct 17, 2026
ymichael
force-pushed
the
bb/live-data-stack-14-tasks-thr_jkff7k6wj2
branch
from
October 17, 2026 04:51
e1f9107 to
ebc2775
Compare
ymichael
force-pushed
the
bb/live-data-stack-13-docs-thr_eyhy2ce2t5
branch
from
October 17, 2026 05:19
6b98ae1 to
f0fd6d7
Compare
ymichael
added a commit
that referenced
this pull request
Oct 17, 2026
ymichael
force-pushed
the
bb/live-data-stack-14-tasks-thr_jkff7k6wj2
branch
from
October 17, 2026 05:19
ebc2775 to
31e2c28
Compare
ymichael
force-pushed
the
bb/live-data-stack-13-docs-thr_eyhy2ce2t5
branch
from
October 19, 2026 22:21
f0fd6d7 to
7c399df
Compare
ymichael
added a commit
that referenced
this pull request
Oct 19, 2026
ymichael
force-pushed
the
bb/live-data-stack-14-tasks-thr_jkff7k6wj2
branch
from
October 19, 2026 22:21
31e2c28 to
c32e1ca
Compare
ymichael
force-pushed
the
bb/live-data-stack-13-docs-thr_eyhy2ce2t5
branch
from
October 19, 2026 22:49
7c399df to
d13fb8d
Compare
ymichael
added a commit
that referenced
this pull request
Oct 19, 2026
ymichael
force-pushed
the
bb/live-data-stack-14-tasks-thr_jkff7k6wj2
branch
from
October 19, 2026 22:49
c32e1ca to
638a08b
Compare
ymichael
added a commit
that referenced
this pull request
Oct 20, 2026
…mutations (#5640) ## Human comments ## What was wrong **Stack 1 of 14.** Merge order: #5640 → #5658 → #5688 → #5661 → #5669 → #5666 → #5659 → #5660 → #5663 → #5667 → #5668 → #5677 → #5673 → #5670. When a core write changes data that other screens or clients show, someone has to remember to refresh every query that depends on it. Today each write does this by hand: a cache-owner module plus a system change kind (for UI preferences, `ui-preferences-changed`, routed through the realtime registry). Plugins have no equivalent at all, which is #4944. This is step 1 of a stack that replaces #5582. Here, a contract declares what a read depends on and what a write changes, and the client refreshes from those declarations. The plugin hooks in later steps will be thin wrappers over this same core path. ## What changed - **`@bb/domain`:** a new `ContractTagDeclarations` type with `tags(input, output)` and `invalidates(input, output)`. It contains types only. - **`@bb/hono-typed-routes`:** - `defineRoute` accepts these declarations. - After a 2xx JSON response, `typedRoutes` publishes the route's `invalidates` tags through a new `invalidateTags` option. - Registering a route that declares `invalidates` throws if that option is missing. - **Server:** `hub.notifyTags` batches tags within a microtask and sends `{type:"changed", entity:"tags", tags}` to every connected client. This is a new message between the server and the app; the daemon is untouched, so `HOST_DAEMON_PROTOCOL_VERSION` is unchanged. - **New `@bb/query-tags` package:** - Tags are registered on queries through `meta`. - `invalidateTags` refreshes the queries whose data carries a matching tag, within a scope. Core uses `core`. - A read that is in flight restarts only if an overlapping invalidation arrives during it. - `runTaggedMutation` settles only after the affected active reads have re-read. That includes a first load whose tags aren't known yet, which the reference branch got wrong. - **App:** - The realtime cache effects pass `tags` messages to `invalidateTags`, and hold them while the tab is hidden. - A small `route-tags.ts` adapter connects route contracts to these reads and mutations. - **UI preferences, which prove the mechanism:** - The read declares `ui-preferences`, and update and reset invalidate it. - The sync engine saves through `runRouteMutation`. - `ui-preferences-cache-owner.ts`, the `ui-preferences-changed` change kind and its registry entry are deleted. - The sync keeps each acknowledged entry, so a failed re-read neither reverts the preference nor bases the next write on a stale revision. Not in this PR: plugin SDK hooks, plugin RPC, plugin WebSocket targets and the CLI. Those come in later steps of the stack, each with its first caller. ## How you verified - `pnpm exec turbo run build typecheck lint test --filter='...[origin/main]' --continue`: 296/296 tasks passed. - Lint has no errors, and the app's warnings match `origin/main`. - New tests in `@bb/query-tags` cover tag matching, scope isolation, stale inactive queries, in-flight races, and refresh failure and recovery. - The first-load race test fails against the reference implementation. - `@bb/hono-typed-routes` tests: invalidations are published only after 2xx JSON responses, and registration fails without the publisher. - Two isolated browser profiles against a source server: a preference write in one refreshed the footer preferences in the other, and a composer draft survived the refresh. - Two WebSocket clients with no subscriptions both received the `tags` message after an HTTP write. - Sidebar perf, five paired samples per checkout with 3,000 threads, against `origin/main`: | Metric | Main median (range) | Branch median (range) | | --- | ---: | ---: | | Mount, ms | 410 (404–419) | 408 (359–412) | | Pin, ms | 72 (71–73) | 71 (70–73) | | Status patch, ms | 69 (69–71) | 70 (69–73) | | Membership refresh, ms | 103 (103–107) | 107 (103–108) | | Query observers | 13 | 13 | The ranges overlap and the number of query observers is unchanged. These samples were taken before the unused pieces were removed; removing them deleted code paths without changing the read path. Part of #4944 > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code)
ymichael
force-pushed
the
bb/live-data-stack-13-docs-thr_eyhy2ce2t5
branch
from
October 20, 2026 19:47
d13fb8d to
356f6c5
Compare
ymichael
added a commit
that referenced
this pull request
Oct 20, 2026
ymichael
force-pushed
the
bb/live-data-stack-14-tasks-thr_jkff7k6wj2
branch
from
October 20, 2026 19:47
638a08b to
0ebac59
Compare
ymichael
force-pushed
the
bb/live-data-stack-13-docs-thr_eyhy2ce2t5
branch
from
October 20, 2026 21:19
356f6c5 to
02d916d
Compare
ymichael
force-pushed
the
bb/live-data-stack-14-tasks-thr_jkff7k6wj2
branch
from
October 20, 2026 21:19
0ebac59 to
b2b2477
Compare
Collaborator
Author
ymichael
added a commit
that referenced
this pull request
Oct 28, 2026
## Human comments ## What was wrong Tasks kept its views live with its own query layer instead of BB's shared live reads. That layer was a signal scheduler fed by four `useRealtime` channels (`tasks`/`projects`/`comments`/`threads:changed`), per-view patchers, snapshot revision guards, a refresh-generation provider, a hand-written list edit layer and a 60 s pull request poll. The board loaded card metadata with one `listAttachments` call per card plus one `listTaskThreads` call per working task: 427 RPCs for a 400-card project. Every edit triggered 5–6 re-reads, each after the scheduler's 50 ms batching delay. I checked #5670's listed bugs on `main` against a seeded dev instance before porting: | #5670 bug | On `main` | | --- | --- | | Board loads through ~1,000 RPCs | Reproduces: 427 RPCs for 400 cards, 400 of them `listAttachments` | | Several re-reads per edit | Reproduces: 5–6 reads per edit | | Title/description edits don't refresh comments | Not a bug on `main`: activity re-read on every task change, and nothing in it depends on title or description | | Untagged project choices | `listBbProjects` reads core data and refreshes on mount and reconnect, as before | | A `PAR-01` key miss is never refreshed | Does not reproduce: the detail view re-read on any task change. The port keeps this (test below) | ## What changed No Plugin SDK change. Main's keyed reads don't need #5670's "seed cold keyed reads from a list response": the views use plain tagged list reads, so the first paint stays one round trip. - **Contract** (`shared/contract.ts`, `shared/tags.ts`): - Reads declare `tags`. - Three internal reads replace client-side fan-out: - `listAllTasks`: unpaged; replaces the client page loop. - `listTaskCardMeta`: attachment counts and working agents for a project's cards in one read; replaces the per-card calls. - `labelsByProject`: keyed by project, `keyTags`; serves the All tasks list's labels. - **Server** (`api`, `delegate`, `lifecycle`, `attachments`, `cli`): - Every `bb.realtime.publish` becomes `bb.rpc.experimental_invalidate` with the matching tags. - This happens inside the domain handlers that RPC, the CLI and agent tools share, so every write path invalidates exactly once. The contract doesn't also declare `invalidates`: the server would then broadcast twice, and the editing client would re-read twice. - A `whileWatched` producer on `listTaskPullRequests` replaces the frontend 60 s poll. It refreshes a watched task's pull requests every 60 s while its last read had an open or draft PR. - **UI**: - Every view reads through `experimental_useRpcQuery`. List labels for all projects use `experimental_useRpcKeyedQuery`. - List row edits go through `experimental_useRpcMutation` with the shared optimistic cache. The dimmed pending rows come from `pendingInputs`. - The Refresh button uses `experimental_useRpcRefresh`. It spins only for a manual refresh or a reconnect, as before. - **Deleted**: `shell/signal-scheduler.ts`, `shell/refresh.tsx`, `views/list/optimistic.ts`, `views/list/use-task-edits.ts`, the board/list patchers, snapshot revision guards, visibility handling and the detail PR interval. - **Kept**: the localStorage snapshot for folders, projects and the sidebar summary. The shared cache doesn't persist across reloads, and this snapshot is what prevents #1676's reload flash. It is now a plain initial value. - **Docs**: `docs/api_to_audit.md` lists the Tasks producer under watched reads. Behaviour is the same for users. Changes that come from the shared cache: - Returning to a list scope you already opened (for example Active → All) paints its cached rows while it revalidates; `main` showed skeleton rows again. This is the repeat-visit behaviour #1676 asked for. - List rows now refresh after a project prefix rename; on `main` they kept stale keys until the next task change. - Activity no longer re-reads on edits that don't write a comment. - A refused list edit (`ok: false`) shows its toast and re-reads the list to drop the prediction. It no longer rolls back locally first. `sidebarOpenTaskCount` is now a tagged read. Other plugins can read the open-task count live with `experimental_useRpcQuery({ pluginId: "tasks", … })`, which is part of #5720's second ask. ## How you verified - `pnpm exec turbo run typecheck lint test --filter='...[origin/main]' --continue`: - `bb-plugin-tasks`: 398/398. - Lint: 21 warnings, the same count as `main`, none new. - Three failures, all outside Tasks (CI re-runs them): - `@bb/app` `CommandPalette.test.tsx`: a 10 s hook timeout; it passes alone, 71/71. - Two `@bb/server` builtin-plugin hot-reload fixture tests: they time out at load average 24–35. - New `api/live-reads.test.ts` checks that each write invalidates the tags of every read it must refresh and leaves the others alone: - A title edit refreshes that task's detail, both lists and the open count. It doesn't refresh another task, another project, activity or card metadata. - Status changes and comments refresh activity. - A `REV-03` miss resolves when `REV-3` is created. - Prefix renames, moves between projects, uploads, thread attaches, label changes, folders, presets and a CLI edit. - Also tested: `listAllTasks` past one page, and `listTaskCardMeta` contents. - `api.test.ts`: the producer refreshes every 60 s only while the PR is open, and stops when unwatched. - UI tests that pushed realtime events now drive `experimental_invalidateRpc` with the tags the server sends. Tests of the deleted layer were removed: `signal-scheduler`, `optimistic`, `incremental`, the badge coalescing test and the first-connection test (that policy now belongs to core). **Measured on a real dev instance** (`pnpm start:worktree`), same data on both builds: 480 tasks in one project, 50 with attachments, 5 attached threads. Each build ran in the same headless Chromium at 1600×1000. Medians, main → branch: | Load (n=7) | Time to first rows (in-page) | Tasks RPCs | | --- | ---: | ---: | | Board | 364 → 203 ms | 427 → 10 | | Project list | 439 → 378 ms | 29 → 12 | | All tasks | 440 → 406 ms | 32 → 12 | | Task detail | 228 → 227 ms | 29 → 17 | | Edit (n=5) | Visible after | Re-reads | | --- | ---: | ---: | | Board: title edited elsewhere | 77 → 34 ms | 6 → 4 | | Board: drag to another column (optimistic) | 23 → 28 ms | 6 → 4 | | List: title edited elsewhere | 64 → 21 ms | 5 → 5 | | List: priority from the row menu (optimistic) | 125 → 140 ms | 5 → 5 | The two optimistic rows (drag and priority menu) are both immediate on both builds, so their differences are noise. Counting `toLocaleDateString` calls during load showed the list renders its rows fewer times than on `main` (6,370 vs 10,226 calls). No edit triggered a double read. **Driven in the running app on the branch:** - Detail page: - The status change appears in activity, and the badge count follows open/closed changes. - Title rename shows on the list. Comment, sub-task, and attachment upload and removal all update live. - A `bb tasks update` from the CLI updates an open detail view's title and activity live. - Detaching and re-attaching a thread via the CLI removes and restores the board card's working-agent chip live. - Board drag persists. - The Refresh button spins, then clears. - A detail page for an unknown key (`PERF-0481`) resolves once `PERF-481` is created. > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Michael Yong <review@local> 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 tasks plugin kept its views live with its own signal scheduler, cache patchers and snapshot ordering guards. The board loaded through about 1,000 RPCs, and every edit triggered several re-reads. Several refreshes were missing too:
PAR-01was never refreshed whenPAR-1was created.Stack 13 of 13, stacked on #5673. #5640 is merged and #5688 is folded into #5658. Review only this PR's commits. Merge order: #5658 → #5661 → #5669 → #5666 → #5659 → #5660 → #5663 → #5667 → #5668 → #5677 → #5673 → #5670.
What changed
a3b6cd541ePlugin SDK: seeding cold keyed reads.4b71c6dfd8: tasks contracts declare tags,keyTagsandinvalidates, and task membership is seeded.2c99ea120a: task controls write throughexperimental_useRpcMutation.992aca8965: the board and list render membership first, then rows throughexperimental_useRpcKeyedQuery.8a1487142a: detail, activity and embeds stay live through tagged reads. PR refreshes use a watched server producer.431925b1e4: removes the signal scheduler, the patchers and the snapshot ordering guards (−1,197 lines).Behaviour changes:
Optimistic updates and refusals (this PR): list status and detail status both update instantly through the shared optimistic option and roll back on refusal; detail status waited for the server on main. The hand-written list edit layer is replaced. A saved title stays visible until the re-read lands. Tasks mutations that returned
{ok:false}now throwexperimental_PluginRpcRefusal(conflictorinvalid, #5688). A description save drops its pending change only on a refusal, and other errors keep it for retry.aria-busyuntil the save settles or rolls back, driven by the hook'spendingInputs. This is the same pending feedback main shows.How you verified
pnpm exec turbo run build typecheck lint test --filter='...[origin/main]' --continue: 318/318. The Plugin SDK version check passes against step 3.origin/main, median of five samples:Every measured edit re-read exactly one task key. React commit probes confirm that only the edited row re-renders, on both the board and the list.
PAR-01miss recovers afterPAR-1is createdFixes #4944
🤖 Generated with Claude Code