Repository navigation
Take core off query tags: UI preferences refresh through a system change - #6466
Merged
Merged
Conversation
Core now refreshes only through changed messages; tags are plugin-only. UI preferences use the ui-preferences-changed system change, published by the update and reset routes and handled in the realtime cache registry. The route-tags wrapper, the tags websocket message, CORE_TAG_SCOPE, and tags/invalidates on defineRoute are deleted. ContractTagDeclarations moves into the plugin SDK; invalidates stays out of the public RPC contract type. runTaggedMutation is deleted and its tests drive useTaggedMutation. The added change kind appears in the SDK's system:changed event type, so the plugin SDK is bumped to 0.6.96. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
force-pushed
the
bb/take-core-off-tags-thr_cmtzgs6ymh
branch
from
October 28, 2026 19:20
14b9d16 to
fe14e70
Compare
mistakeknot
added a commit
to mistakeknot/aleph
that referenced
this pull request
Nov 3, 2026
Sync upstream bb through get-bb#6466 (remove query tags)
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
Core's query-tag use was left over from the live-data stack (#5640).
route-tags.ts(routeTaggedRead/routeTaggedPages) still wrappedthreads.list,threads.getandsidebarBootstrap, but those routes have declared no tags since #6002. UI preferences were the only real core tag user: the read declaredui-preferences, the two writes declaredinvalidates, and the server sent atagswebsocket message to every client for them. So core kept a second invalidation mechanism, thetagsmessage,CORE_TAG_SCOPE, andtags/invalidatesondefineRoutefor one preference read. Everything else in core refreshes throughchangedmessages.What changed
Core now uses only
changedmessages. Tags are plugin-only.ui-preferences-changedis back inSYSTEM_CHANGE_KINDS. The update and reset routes send it withnotifySystemafter a successful write, the same point where the route layer used to publish the tags.realtime-cache-registry.tsmaps it to the ui-preferences query. A failed write invalidates the query through a newinvalidateUiPreferencesinsystem-cache-effects.ts. The sync engine callssdk.system.uiPreferences.setdirectly.applyTags(CORE_TAG_SCOPE, null). That is nowui-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.route-tags.ts, and thequeryClientparameters Store each thread once in a keyed store shared with plugin keyed rows #6002 added only for it. Thread, palette, sidebar and ui-preferences reads are plain queries again;sidebar-navigation-query.tsandpalette-thread-queries.tsare back to their pre-Store each thread once in a keyed store shared with plugin keyed rows #6002 text.tagsmessage:hub.notifyTags, its domain schema, the app handler and its tests.CORE_TAG_SCOPE; the query-tags tests use a local scope instead.tags/invalidateson coredefineRoute, withRouteTagDeclarations,RouteTagInput,RouteSuccessOutput, theinvalidateTagsoption, the package README, andhono-typed-routes'@bb/domaindependency.UI_PREFERENCES_TAGandclient-route-descriptors.ts. That file existed only so the app could import the three ui-preferences routes cheaply; they are back inline inpublic-api.ts.ContractTagDeclarationsmoved from@bb/domaininto 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. Retire invalidates on plugin RPC contracts #6462's retirement is unchanged: the publicPluginRpcMethodContractstill extendsOmit<ContractTagDeclarations, "invalidates">, and the runtime still readsinvalidatesfor already-built plugins. A new@ts-expect-errorcase inrpc-contract.test.tskeepsinvalidatesout of the public type.runTaggedMutationdeleted from@bb/query-tags, along withTaggedMutationOptionsand its README mention. It had no callers outside the package's own tests.useTaggedMutationis 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 amutateOncetest helper (renderHook+mutate); the helper creates each pending outcome up front, because TanStack startsmutationFna few microtasks aftermutate. Thecore/plugincase pair inmutation.test.tsonly differed by the wrapper, so it is now one test.pluginmessage,experimental_invalidate, and contract tags.docs/api_to_audit.mdno longer says core uses tags for UI preferences orrunRouteMutation, and Retire invalidates on plugin RPC contracts #6462's retired-invalidatesentry no longer says core routes keepinvalidates.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 tosystem:changedcallbacks is typed fromSYSTEM_CHANGE_KINDS. This PR therefore:"ui-preferences-changed"tosystem:changedevents. At runtime, plugins subscribed tosystem:changedget one extra event per preference write.system:config-changedis unaffected, since it only fires forconfig-changed.tagsentry from the copied schema. No exported type can reach it, but the publishedbundled-typesbytes change.scripts/bump-plugin-sdk.mjs --patchbumps the SDK from 0.6.95 (#6462) to 0.6.96. Apart from these two changes, movingContractTagDeclarationsleaves every public entry the same: only declaration order changed. The internalrpc-tagsentry now exports the type.Marketplace plugins that subscribe to
system:changed. I scanned the 469 entries inhttps://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:matt-pocock-skills-for-bbserver/backend.tsplugins-changedplugin-workshopserver/wiring.tsplugins-changed,plugin-install-jobs-changed,plugin-update-jobs-changedTwo non-marketplace plugins in the same repos (
brsbl/bb-pluginsopen-in-moss,rebryk/bb-pluginsauto-update) also filter onplugins-changed/plugin-update-jobs-changed. The other matches were copies ofbb-plugin-sdk.d.tsandsystem:config-changedlisteners.No server/daemon wire change, so
HOST_DAEMON_PROTOCOL_VERSIONis 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 Retire invalidates on plugin RPC contracts #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):@bb/appFilePreview.test.tsx(Pierre worker pool) andbb-plugin-bb--mcpcli-runner.test.ts.origin/maincheckout:@bb/host-watcherworkspace-root-ignores.test.ts(no watch events delivered) and@bb/desktoppreload-build.test.ts(Electron smoke page timeout).@bb/serverbuiltin-plugins.test.ts: see the last bullet.After rebasing on f67c1e6 (with Retire invalidates on plugin RPC contracts #6462):
@bb/query-tagstypecheck, lint and test pass (4/4 tasks), and@get-bb/plugin-sdktypecheck 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: aui-preferences-changedsystem 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 sendui-preferences-changed; a 409 sends nothing.Two clients, in the running app. Using
start:worktreebuilds of this branch and oforigin/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,
/apirequests in a 5 s window after each action, five rounds each: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
tagsmessage; 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 onorigin/main. In the failing runs the file is written 1 ms after the watcher starts, and macOS FSEvents never reports the change.🤖 Generated with Claude Code