Repository navigation
Declare live-data tags on route contracts and refresh through tagged mutations - #5640
Merged
ymichael merged 1 commit intoOct 20, 2026
Conversation
Publish declared route invalidations through core realtime tags. Track scoped client query tags and await overlapping active reads, including first-load races, before mutations settle. Move UI preferences onto the shared mutation path and retain acknowledged revisions across refresh failures. Keep the surface limited to step-one callers.
This was referenced Oct 16, 2026
ymichael
deleted the
bb/live-data-stack-1-core-contract-tags-tagged-muta-thr_zq74zktcmz
branch
October 20, 2026 18:57
ymichael
pushed a commit
that referenced
this pull request
Oct 20, 2026
#5640 added @bb/query-tags with a typescript-7 (npm:typescript@^7.0.2) dev dependency. #5861 merged first and removed [email protected] from the lockfile when it moved every package to tsrs. The merged lockfile kept the importer entry without a package entry, so pnpm install --frozen-lockfile fails with ERR_PNPM_LOCKFILE_MISSING_DEPENDENCY. Move query-tags to tsrs like every other package.
ymichael
added a commit
to ahmedhesham6/bb
that referenced
this pull request
Oct 20, 2026
get-bb#5640 changed the realtime change-message schema in the plugin SDK bundled types after 0.6.60 was published, so the npm version guard fails. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
added a commit
that referenced
this pull request
Oct 20, 2026
## Human comments ## What was wrong The GitHub PR file diff header highlighted its entire padded row on hover, but only the small expand glyph toggled the diff. Real clicks on the padding, filename text, and addition/deletion counts did nothing. This is the same hit-area mismatch addressed for other rows in #5891. ## What changed Stretch the existing toggle button over the highlighted header using the established positioned pseudo-element pattern. Keep the workspace filename link above that area so its file-opening action remains available. Expose the toggle state with `aria-expanded` and prevent accidental text selection on repeated clicks. Regenerate the lockfile after syncing main to restore the missing TypeScript 7 package entries introduced by #5640. CI previously stopped at frozen dependency installation before running any code checks. Bump the SDK patch version for the same upstream change’s updated bundled contract declarations, as required by the npm version guard. ## How you verified - Reproduced before the change with real Chromium clicks: top/left padding, counts, and filename did nothing; the glyph expanded the diff. - Verified after the change with real clicks on all four padding edges, counts, filename, and glyph for modified, removed, and oversized-diff fixture files. Each expands and collapses; Enter and Space also work. - Confirmed padding clicks on a `pnpm start:worktree` build with local synthetic PR data. - `pnpm exec turbo run typecheck lint test --filter=bb-plugin-github` passed, including all 44 tests. - `pnpm exec turbo run build --filter=bb-plugin-github` passed. - `pnpm install --frozen-lockfile --ignore-scripts` passed after regenerating the lockfile. > AGENT GENERATED
albrand
pushed a commit
to alb-hold/bb
that referenced
this pull request
Oct 24, 2026
Keep writing-assistance in the cache-owner registry while UI preferences moved to live-data tags (get-bb#5640), take the BB_CONNECT_GATE_KEYS_URL row, and keep the native terminal focus tests beside the loading tests.
2 of 13 tasks
ymichael
added a commit
that referenced
this pull request
Oct 28, 2026
…nge (#6466) ## Human comments ## What was wrong Core's query-tag use was left over from the live-data stack (#5640). `route-tags.ts` (`routeTaggedRead` / `routeTaggedPages`) still wrapped `threads.list`, `threads.get` and `sidebarBootstrap`, but those routes have declared no tags since #6002. UI preferences were the only real core tag user: the read declared `ui-preferences`, the two writes declared `invalidates`, and the server sent a `tags` websocket message to every client for them. So core kept a second invalidation mechanism, the `tags` message, `CORE_TAG_SCOPE`, and `tags`/`invalidates` on `defineRoute` for one preference read. Everything else in core refreshes through `changed` messages. ## What changed Core now uses only `changed` messages. Tags are plugin-only. - **UI preferences use a normal system change.** `ui-preferences-changed` is back in `SYSTEM_CHANGE_KINDS`. The update and reset routes send it with `notifySystem` after a successful write, the same point where the route layer used to publish the tags. `realtime-cache-registry.ts` maps it to the ui-preferences query. A failed write invalidates the query through a new `invalidateUiPreferences` in `system-cache-effects.ts`. The sync engine calls `sdk.system.uiPreferences.set` directly. - **Reconnect behaves as on main.** Main refreshed core-tagged queries on reconnect with `applyTags(CORE_TAG_SCOPE, null)`. That is now `ui-preferences-changed`, sent through the same defer-while-hidden path as system messages. It applies on reconnect only, not on the first connect. Thread and sidebar queries use the existing reconnect refresh list, as every other core query does. - **Deleted:** - `route-tags.ts`, and the `queryClient` parameters #6002 added only for it. Thread, palette, sidebar and ui-preferences reads are plain queries again; `sidebar-navigation-query.ts` and `palette-thread-queries.ts` are back to their pre-#6002 text. - The `tags` message: `hub.notifyTags`, its domain schema, the app handler and its tests. - `CORE_TAG_SCOPE`; the query-tags tests use a local scope instead. - `tags`/`invalidates` on core `defineRoute`, with `RouteTagDeclarations`, `RouteTagInput`, `RouteSuccessOutput`, the `invalidateTags` option, the package README, and `hono-typed-routes`' `@bb/domain` dependency. - `UI_PREFERENCES_TAG` and `client-route-descriptors.ts`. That file existed only so the app could import the three ui-preferences routes cheaply; they are back inline in `public-api.ts`. - **`ContractTagDeclarations` moved** from `@bb/domain` into the plugin SDK (`internal/rpc-tags.ts`). Its callers are the SDK, its fake host, and the server's plugin API, which already imports `@get-bb/plugin-sdk/internal/rpc-tags`. #6462's retirement is unchanged: the public `PluginRpcMethodContract` still extends `Omit<ContractTagDeclarations, "invalidates">`, and the runtime still reads `invalidates` for already-built plugins. A new `@ts-expect-error` case in `rpc-contract.test.ts` keeps `invalidates` out of the public type. - **`runTaggedMutation` deleted** from `@bb/query-tags`, along with `TaggedMutationOptions` and its README mention. It had no callers outside the package's own tests. `useTaggedMutation` is now the only mutation entry point, used by core thread writes and plugin RPC mutations. The tests that used the wrapper now drive the hook through a `mutateOnce` test helper (`renderHook` + `mutate`); the helper creates each pending outcome up front, because TanStack starts `mutationFn` a few microtasks after `mutate`. The `core`/`plugin` case pair in `mutation.test.ts` only differed by the wrapper, so it is now one test. - **Plugin tags are unchanged:** the `plugin` message, `experimental_invalidate`, and contract tags. - `docs/api_to_audit.md` no longer says core uses tags for UI preferences or `runRouteMutation`, and #6462's retired-`invalidates` entry no longer says core routes keep `invalidates`. ### Plugin SDK: one added change kind, patch bump to 0.6.96 The SDK's published types copy domain's changed-message schema. Plugins see it through `sdk.subscribe`: the event passed to `system:changed` callbacks is typed from `SYSTEM_CHANGE_KINDS`. This PR therefore: - **Adds `"ui-preferences-changed"` to `system:changed` events.** At runtime, plugins subscribed to `system:changed` get one extra event per preference write. `system:config-changed` is unaffected, since it only fires for `config-changed`. - **Removes the `tags` entry from the copied schema.** No exported type can reach it, but the published `bundled-types` bytes change. `scripts/bump-plugin-sdk.mjs --patch` bumps the SDK from 0.6.95 (#6462) to 0.6.96. Apart from these two changes, moving `ContractTagDeclarations` leaves every public entry the same: only declaration order changed. The internal `rpc-tags` entry now exports the type. **Marketplace plugins that subscribe to `system:changed`.** I scanned the 469 entries in `https://getbb.app/marketplace/v2/marketplace.json`: all 364 git sources (shallow clones of the default branches) and all 14 npm tarballs. Two entries subscribe, and both filter on other kinds, so the new kind is a no-op for them: | Entry | Source | Reacts to | | --- | --- | --- | | `matt-pocock-skills-for-bb` | erikmackinnon/bb-plugin-matt-pocock-skills-for-bb `server/backend.ts` | `plugins-changed` | | `plugin-workshop` | mosmanlaw/plugin-workshop `server/wiring.ts` | `plugins-changed`, `plugin-install-jobs-changed`, `plugin-update-jobs-changed` | Two non-marketplace plugins in the same repos (`brsbl/bb-plugins` open-in-moss, `rebryk/bb-plugins` auto-update) also filter on `plugins-changed`/`plugin-update-jobs-changed`. The other matches were copies of `bb-plugin-sdk.d.ts` and `system:config-changed` listeners. No server/daemon wire change, so `HOST_DAEMON_PROTOCOL_VERSION` is unchanged. Clients parse change kinds leniently, so an older app on a newer server drops the unknown kind. Neither version breaks, but preferences only sync across clients when both sides have this change. ## How you verified - `pnpm exec turbo run typecheck lint test --filter='...[origin/main]' --continue`, rebased on 852d1e8 (before #6462): 254/259 tasks pass, and typecheck and lint pass everywhere. The five failing test tasks are all timing or file-watch tests. The machine's load average was about 40–50 during the run (other worktrees): - Pass alone on this branch: `@bb/app` `FilePreview.test.tsx` (Pierre worker pool) and `bb-plugin-bb--mcp` `cli-runner.test.ts`. - Fail the same way on a clean `origin/main` checkout: `@bb/host-watcher` `workspace-root-ignores.test.ts` (no watch events delivered) and `@bb/desktop` `preload-build.test.ts` (Electron smoke page timeout). - `@bb/server` `builtin-plugins.test.ts`: see the last bullet. - CI is the gate for these. - After rebasing on f67c1e6 (with #6462): `@bb/query-tags` typecheck, lint and test pass (4/4 tasks), and `@get-bb/plugin-sdk` typecheck passes. Not rerun after this rebase: the app, server and full suites, and the browser QA below (it ran on 9c1346d). CI gates this rebase. - New and updated tests: - `realtime-cache-effects.test.ts`: a `ui-preferences-changed` system message refreshes the ui-preferences query, visible or hidden. A reconnect refreshes it; the first connect does not. - `public-ui-preferences.test.ts`: update and reset each send `ui-preferences-changed`; a 409 sends nothing. - **Two clients, in the running app.** Using `start:worktree` builds of this branch and of `origin/main` (9c1346d) on fresh data dirs, with two separate headless browser profiles per build, I removed "Report a bug" from the footer in client A. Client B's footer dropped it about 150 ms later without a reload, on both builds, and it stayed gone after reloading B. - **Requests per action, branch vs main.** Same script on both builds, `/api` requests in a 5 s window after each action, five rounds each: | Action | main (rounds 1–5) | branch (rounds 1–5) | | --- | --- | --- | | Pin | 9, 6, 6, 4, 6 | 6, 6, 6, 6, 6 | | Unpin | 4, 4, 4, 4, 4 | 4, 4, 4, 4, 4 | | Rename | 5, 4, 4, 4, 4 | 5, 4, 4, 4, 4 | | Send + stop | 16, 18, 18, 13, 18 | 15, 18, 19, 18, 18 | Every non-timeline endpoint had the same count on both builds in the settled rounds, for example pin = POST + 2 sidebar GETs + 1 thread GET + hosts + config. The differences are first-visit noise (main round 1 includes the mark-read POST and the extra sidebar fetch it triggers) and timeline GETs during streaming, which vary on both builds (main 4–5, branch 3–6). - **UI preference write.** The writing client sends PUT + 1 GET on this branch, versus PUT + 2 GETs on main. Main re-read once after its local tag invalidation and again for the broadcast `tags` message; the writer now re-reads only on the broadcast. The other client sends 1 GET on both builds. - `test/services/plugins/builtin-plugins.test.ts` ("hot-reloads a source-layout builtin server…") is flaky locally on main too: it failed in 2 of 6 runs on `origin/main`. In the failing runs the file is written 1 ms after the watcher starts, and macOS FSEvents never reports the change. > 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
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 newContractTagDeclarationstype withtags(input, output)andinvalidates(input, output). It contains types only.@bb/hono-typed-routes:defineRouteaccepts these declarations.typedRoutespublishes the route'sinvalidatestags through a newinvalidateTagsoption.invalidatesthrows if that option is missing.hub.notifyTagsbatches 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, soHOST_DAEMON_PROTOCOL_VERSIONis unchanged.@bb/query-tagspackage:meta.invalidateTagsrefreshes the queries whose data carries a matching tag, within a scope. Core usescore.runTaggedMutationsettles 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.tagsmessages toinvalidateTags, and hold them while the tab is hidden.route-tags.tsadapter connects route contracts to these reads and mutations.ui-preferences, and update and reset invalidate it.runRouteMutation.ui-preferences-cache-owner.ts, theui-preferences-changedchange kind and its registry entry are deleted.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.origin/main.@bb/query-tagscover tag matching, scope isolation, stale inactive queries, in-flight races, and refresh failure and recovery.@bb/hono-typed-routestests: invalidations are published only after 2xx JSON responses, and registration fails without the publisher.tagsmessage after an HTTP write.origin/main: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
🤖 Generated with Claude Code