Repository navigation
Conversation
ymichael
force-pushed
the
bb/thread-action-registry-step-2-notification-level-thr_zcdeqftdp5
branch
3 times, most recently
from
October 9, 2026 07:49
8742f56 to
a2830f4
Compare
Base automatically changed from
bb/thread-action-registry-v1-thr_dessxnxvus
to
main
October 9, 2026 17:42
ymichael
force-pushed
the
bb/thread-action-registry-step-2-notification-level-thr_zcdeqftdp5
branch
2 times, most recently
from
October 9, 2026 18:31
0db6776 to
df01415
Compare
A plugin that keeps per-thread state in thread plugin metadata could only
read it one thread at a time, so a menu that shows that state for the rows
on screen needed one request per row. Push notifications' per-thread levels
need exactly that read.
`POST /threads/plugin-metadata` with `{ pluginId, threadIds }` (1–200 ids)
returns `{ threadId, metadata }` for each requested thread holding that
plugin's namespace, archived and deleted threads included, in one
`WHERE plugin_id = ? AND thread_id IN (...)` query on the table's primary
key. Corrupt namespaces are omitted and logged without their content.
The core SDK exposes it as `threads.experimental_listPluginMetadata({
pluginId, threadIds })`. The plugin-bound SDKs (backend `bb.sdk`, the app's
`useSdk()`, and the fake host) take no `pluginId` and always read the
caller's own namespace. Documented in docs/api_to_audit.md and the Plugin
Guide's thread plugin metadata surface.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A registration with per-thread state had no way to know which threads a
surface shows, so it could only load state for every thread or fetch per
row. `experimental_useThreadActions` is already the one subscription every
surface makes per thread (sidebar rows, the open thread's header, open
menus), so the registry now reference-counts the ids those calls name.
`useData` receives `{ threadIds }`: the union of subscribed ids, sorted and
deduplicated, published at most once per animation frame with a 100 ms
timeout fallback for hidden tabs. The ids live in their own store that only
the collectors read, so scrolling re-renders one collector per
registration, not the rows. Registrations without per-thread state ignore
the input; bb's own hooks take no arguments.
The registration docs describe the pattern for per-thread data until an
attributes layer lands: an id-keyed cache, one batched fetch for the ids
not cached yet, realtime updates per id.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A direct load of a settings route keeps the app sidebar body mounted but hidden. `SidebarWindowedItems` treated a zero-height scroll container as "realize every row", and pinned threads render outside the windowing, so every thread row mounted behind the settings page (225 rows on the QA instance) and each one subscribed to the thread action registry. Rows are now realized only when the scroll container has height: a zero-height container realizes nothing, and the IntersectionObserver realizes the visible rows once a resize gives it height. Environments without IntersectionObserver keep promote-all. The pinned tree waits for `useSidebarListShown`, which follows the scroll container's height with a ResizeObserver. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`PluginSettingDescriptor` select settings can declare `experimental_optionLabels`, a record from option value to label. The settings form shows the label in the picker and as the current value; stored values, defaults, `settings.get()` and `bb plugin config set` keep the option values. A label for a value that is not an option is refused at define time. First consumer: push notifications' level settings. Re-derived from 2f9fc5d886. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Users asked to mute specific threads, to quiet child threads under a coordinator, and to hear about pending interactions without a push for every finished turn (#1446, Discord 2026-09-29). The plugin had only server-wide channel toggles. A thread's level is `all`, `input-only` or `muted`. Defaults fill gaps and ancestors cap: a thread uses its own level, else the `childLevel` setting if it has a parent (default `input-only`, which matches today's rule that child threads never push a finished turn), else `defaultLevel` (default `all`). The result is capped by every ancestor's own level, so muting a coordinator mutes its whole subtree, a worker set to `all` beats the child default, and a parent set to `all` never makes an unset worker louder. Thread plugin metadata stores only the inputs, `{ own, ancestorCap }` (the quietest own level among all ancestors), and the key is removed when a thread holds neither. Setting a level pushes the new cap down the subtree, and `thread.created` copies the parent's cap. One pure resolver serves the sender, the CLI and the app, so changing a default never rewrites rows. Every write is published on the `threadNotifications` realtime channel. The app registers one `experimental_threadAction` in `THREAD_ACTION_GROUPS.settings`. Its `useData` keeps an id-keyed cache, fetches only the `threadIds` it has not loaded through `threadNotifications.list` (batches of up to 200, archived threads included, so an unarchived thread shows its level without a reload), applies channel updates per id, and refetches after a realtime reconnect. `item` resolves the level and hint and `run` calls `threadNotifications.set`. The sidebar benchmark mounts the registration and checks that no id is fetched twice. `bb push-notifications thread <thread> [--level inherit|all|input-only|muted]` shows or sets a level from the CLI, and `status` shows both defaults. Re-derived from b237c68fb8, 2f9fc5d886, 2b482e6462 and 8dffcd7402: the per-row metadata fetch, and `threadNotifications.get` are gone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… option labels
push-notifications needs `useData({ threadIds })`,
`threads.experimental_listPluginMetadata`, and `experimental_optionLabels`,
so its `engines.bbPluginSdk` floor moves to 0.6.36.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…le-thread reads The plugin-bound experimental_listPluginMetadata always forced the caller's own namespace, while getPluginMetadata and updatePluginMetadata default pluginId and accept another plugin's id. All three now share that rule. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A reconnect refetched only the threads on screen and kept every other cached level. When an off-screen thread came back into view, the fetch skipped ids already in the cache, so a level changed or cleared during the disconnect stayed stale until a reload. A reconnect now drops cached levels for threads not on screen, so they load fresh when shown again. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Notifications submenu repeated its trigger as a heading and put a
same-size hint ("Default (All activity)") directly above a "Default"
choice, so the hint read as a fifth option and the entry itself never
said what the level was.
Thread actions gain `detail`, a muted second line under the label (it
follows the label in a quick-action tooltip). Desktop submenus no
longer draw `choices.heading`, since their trigger names them; the drawer
step and quick-action popover still title themselves with it. `hint`
is now a footnote below the choices.
Notifications shows the effective level as its detail with a per-level
icon (declared `push-notifications/ringing` and `push-notifications/off`
manifest icons, built-in BellDot for needs-input-only), labels the
inherit choice with the level it falls back to ("Default (Needs input
only)"), and keeps a footnote only when a parent or ancestor limits it.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Each thread stored a copy of its quietest ancestor's level, kept in sync only when a level was set or a child was created. Nesting a thread under a new parent, or archiving a parent (which releases its unarchived children), left that copy stale, so a moved worker kept its old coordinator's mute. Core gains threads.experimental_listAncestors (POST /threads/ancestors): each requested thread's ancestor ids from the parent up, in one recursive query on the primary key. Push-notifications now stores only a thread's own level and resolves the limit from the current ancestors and their levels on every read, for the menu, the CLI and the sender. The cap push-down, the thread.created copy and the stored "inherit" rows are gone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
force-pushed
the
bb/thread-action-registry-step-2-notification-level-thr_zcdeqftdp5
branch
from
October 9, 2026 19:33
5fce07e to
24b4a5d
Compare
ymichael
deleted the
bb/thread-action-registry-step-2-notification-level-thr_zcdeqftdp5
branch
October 9, 2026 19:57
This was referenced Oct 9, 2026
2 of 13 tasks
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
Push notifications had only server-wide channel toggles. Users could not mute one thread, quiet the workers under a coordinator, or keep approvals while skipping finished-turn pushes (#1446, Discord 2026-09-29). This is step 2 of the thread action registry plan, following #5243 (merged): the first plugin registration in
experimental_threadAction. A per-thread setting also exposed a gap in step 1's API. A registration had no way to know which threads are on screen, and core had no way to read one plugin's metadata for many threads in one request. Without those, a plugin either loads every thread or fetches per row.What changed
Ten commits; the first four change core or the thread list and can be reviewed on their own, and the last four are review follow-ups (items 7–10).
POST /threads/plugin-metadatatakes{ pluginId, threadIds }(1–200 ids). It runs oneWHERE plugin_id = ? AND thread_id IN (…)query on the table's primary key, so no new index or migration. Archived and deleted threads are included, and corrupt namespaces are omitted and logged. The core SDK exposes it asthreads.experimental_listPluginMetadata({ pluginId, threadIds }). The plugin-bound SDKs (backendbb.sdk, appuseSdk(), fake host) defaultpluginIdto the caller and accept another plugin's id, likegetPluginMetadataandupdatePluginMetadata. The route trustspluginId, like the existing single-thread metadata routes, because app requests carry no plugin identity. That is listed as an audit item for all three routes.useData({ threadIds })(core). The registry reference-counts the thread ids named byexperimental_useThreadActionscallers: sidebar rows on screen, the open thread's header, and open menus. It publishes them sorted and deduplicated, once the set has been quiet for 32 ms (at most 100 ms after the first change), so rows that mount a frame apart during a scroll step arrive in one change. A surface counts only while visible:AppSidebarwraps the thread list inThreadActionSurfaceVisibility, visible when the app body is shown and the sidebar (or compact drawer) is open. A hidden sidebar on a settings route therefore contributes no ids, even if a plugin list mounts rows. The ids live in their own store that only the collectors read, so scrolling re-renders one collector per registration, not the rows. bb's ownuseDatahooks take no arguments and are unaffected. The registration docs make this the recommended pattern for per-thread data until an attributes layer lands.SidebarWindowedItemstreated a zero-height scroll container as "realize every row", and pinned threads render outside the windowing. So a direct load of a settings route mounted every row behind the hidden sidebar. A zero-height container now realizes nothing, and the IntersectionObserver realizes visible rows once a resize gives it height. Environments without IntersectionObserver keep promote-all. The pinned tree waits foruseSidebarListShown, which follows the container's height with a ResizeObserver.PluginSettingDescriptorselect settings can declareexperimental_optionLabels(value → label). The settings form shows the label in the picker and as the current value, while stored values, defaults,settings.get()andbb plugin config setkeep the option values. A label for a value that is not an option is refused at define time. The level selects use it: All activity, Needs input only, Muted, Same as default.all,input-onlyormuted. Defaults fill gaps and ancestors cap. A thread uses its own level, elsechildLevelif it has a parent (defaultinput-only, which matches today's rule that child threads never push a finished turn), elsedefaultLevel(defaultall). Every ancestor's own level caps the result: muting a coordinator mutes its whole subtree, a worker set toallbeats the child default, and a parent set toallnever makes an unset worker louder. Thread plugin metadata stores only a thread's own level,{ own }, and only when one is set; the limit from ancestors is worked out on every read from the current tree (item 10). The CLI says "limited by parent" when that ancestor is the direct parent and "limited by an ancestor" otherwise. One pure resolver serves the sender, the CLI and the app, so changing a default rewrites nothing. The registration sits inTHREAD_ACTION_GROUPS.settings; itsuseDatakeeps an id-keyed cache and fetches only uncachedthreadIdsthroughthreadNotifications.list(200-id batches). It applies thethreadNotificationsrealtime channel per id. After a reconnect it refetches the threads on screen and drops cached levels for the rest, so they load fresh when shown again.itemresolves the level (shown as described in item 9), andruncallsthreadNotifications.set. Nothing is fetched per row. CLI:bb push-notifications thread <thread> [--level inherit|all|input-only|muted] [--json], andstatusshows both defaults.engines.bbPluginSdkfloor raised to match.pluginId, like the single-thread reads, instead of always forcing the caller's namespace.detail, a muted second line under the label; a quick-action button's tooltip shows "Label: detail". Desktop submenus no longer drawchoices.heading, because the trigger names them; the phone drawer step and the quick-action popover still use it as their title.choices.hintis now a footnote below the choices, after a separator. Notifications setsdetailto the effective level and switches its icon per level: two SVGs declared in the plugin manifest,push-notifications/ringingandpush-notifications/off, plus the built-inBellDotfor Needs input only. The Default choice names its fallback ("Default (Needs input only)"), and the footnote appears only when a parent or ancestor limits the level ("Limited by a parent thread" / "Limited by an ancestor thread").threads.experimental_listAncestors(POST /threads/ancestors, 1–200 ids): each thread's ancestor ids from the parent up, in one recursive query on the primary key. Push-notifications reads the ancestors and then everyone's own level in one batched metadata call, for the menu, the CLI and the sender. The cap push-down, thethread.createdcopy and storedinheritrows are gone. Open menus are not refreshed when an ancestor's level changes; only the written thread is published.No server/daemon wire changes. Docs:
docs/api_to_audit.md(new read entry; slot entry updated withthreadIdsand the Notifications registration),docs/configuration.md,docs/multiple-devices.md, thebb guidecustomization template, the plugin-authoring references, the plugin overview, and the Plugin Guide surfaces.Changes from the source commits (b237c68fb8, 2f9fc5d886, 2b482e6462, 8dffcd7402):
threadNotifications.getare gone.How you verified
allbeats aninput-onlychild default;allleaves an unset worker atinput-only;alland its worker;all.POST /threads/ancestorsagainst a real database: ancestor order, one entry per id, unknown ids dropped, 400 for 0 or 201 ids, and both move paths (PATCH /threads/:idnesting and the child release when a parent is archived);childLevelunder a muted default.useDatagets the union of subscribed ids and drops released ones;threadNotifications.listcall. Thread-list windowing tests cover zero height realizing nothing, then realizing on resize plus intersection.pluginId.pnpm exec turbo run typecheck lint test --filter=@bb/app --filter=@get-bb/plugin-sdk --filter=./plugins/thread-list --filter=./plugins/plugin-api-docs --filter=@bb/server --filter=./plugins/push-notifications --filter=@bb/db --filter=@bb/sdk --filter=@bb/server-contractpasses: app 5580, server 3399, lint 0 errors.turbo run typecheck --filter='...[ea9cd4061f]'(89 packages) and every plugin's tests (46 tasks) pass. The SDK version guard passes.detail, the icon, the Default label and the footnote for a muted thread, a child limited by its parent, a grandchild limited by an ancestor, a child on the child default, and a top-level thread on the global default. Push-notifications tests (41), thread-list row tests (107), and appThreadActionsMenutests (42) pass; app/plugin lint has 0 errors; the SDK version guard passes. On astart:worktreeinstance I took screenshots of the desktop row menu (on Default, child on Default, set to All activity under a muted parent, muted, Needs input only) and the 390 px phone drawer. A level set from the CLI updated the open menu live.@bb/apptypecheck fails only inlazySecondaryPanelComponents.tsx, which comes from main (Convert large text pastes into ordinary attachments #5098) and which this branch doesn't touch.Request counts on a
start:worktreeinstance with 240 threads (headless Chrome 1400×900, countingthreadNotifications.listrequests and their id counts):/settings/(34 rows)Sidebar benchmark (
BB_SIDEBAR_BENCH=1, 3,000 threads, 81 rendered rows, median of 8 alternating runs in the same tree). The baseline column is this branch with the push-notifications registration unmounted. Core collectors and thread-list's Move are mounted in both. The machine was noisy, so individual runs spread widely.threadNotifications.listcalls / ids requestedThe benchmark ran before the resolver and label changes; neither changes what renders or how often. The single extra observer is the plugin's settings query. The first cut cost about 30 ms per status patch: every fetched batch replaced the cache, even when no requested thread had a level, which re-evaluated every row. The cache now changes only when a batch returns a stored level.
🤖 Generated with Claude Code