Skip to content

Store each thread once in a keyed store shared with plugin keyed rows - #6002

Merged
ymichael merged 15 commits into
mainfrom
bb/eval-normalized-thread-entities
Oct 22, 2026
Merged

ymichael merged 15 commits into
mainfrom
bb/eval-normalized-thread-entities

Conversation

@ymichael

@ymichael ymichael commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Core kept a separate copy of each thread in every cache that shows it: the thread detail, every list variant, the sidebar, search and the machine preview. Every write had to find and patch each copy by hand (pending-thread-patches, the list and sidebar mappers, snapshot restores, the engine's array rebase). Copies the code missed showed stale state. On main:

  • a list loaded during a failed pin stays pinned;
  • a sidebar refetch during a pending archive brings the thread back.

Core's thread predictions also didn't share plugins' keyed-row path.

Includes #5994 (core pin and unpin on the shared tagged-query predictions). Merge this PR alone and close #5994.

What changed

  • One keyed store in @bb/query-tags (`src/keyed-store.ts):

    • per-client collections of stored rows;
    • ordered prediction layers;
    • the read-start rule;
    • accepted predictions becoming stored values;
    • incremental rebuilds of query views.

    beginOptimisticMutation takes optimisticKeyedUpdate(collection, key, update) next to optimisticQueryUpdate. Core thread predictions and plugin cache.updateKey both go through it, and createTaggedKeyedQueryOwner keeps its rows in the same store.

  • Each thread is stored once. Every list, the sidebar, search and detail keep their exact shapes, now built from those entries, so components don't change. thread-entity-store.ts holds only the thread view configuration: facets, membership, updatedAt merging and sidebar insertion.

  • Every thread writer predicts on the entry:

    • pin, archive, unarchive and delete;
    • rename and metadata, read state;
    • section and parent moves;
    • send status, stop;
    • environment rename, project and section deletion;
    • realtime status.
  • Deleted:

    • pending-thread-patches and thread-archive-cache;
    • the list and sidebar mappers, snapshot and restore, updateCachedThread;
    • optimisticQueriesUpdate, the array rebase, the per-path keyed receipts, infinite receipts and TaggedQueryClient.
  • Bundle: the thread panel query hooks now load with the thread page instead of at boot.

  • Two plugin keyed-row behaviour changes, documented in docs/api_to_audit.md and the query-tags README:

    • a row that loads while a write is pending now shows the prediction, the same rule as plain reads and core threads;
    • an unsubscribed row whose refresh failed is dropped and read fresh on resubscribe, instead of keeping its accepted prediction.

    The plugin SDK surface is unchanged.

Visible changes from main (frame QA at 0 and 400 ms):

  1. Fixed: a list that loads after a failed pin no longer shows the thread pinned.
  2. Fixed: a sidebar refetch during a pending archive no longer brings the thread back.
  3. Undo after archive: the thread reappears when Undo is clicked, instead of after the refetch (about 0.8 s sooner at 400 ms).
  4. Failed unarchive: the thread reappears, then hides again with the error toast (about 0.4 s at 400 ms). Main never shows it.
  5. Failed send: the row shows the working state until the failure toast (about 60 ms at 0 ms, about 430 ms at 400 ms). Main shows nothing.
  6. Failed environment rename at 0 ms: the predicted name can paint for one frame (about 17 ms).

Speed and requests

Requests per action match main. Same headless-Chrome script against start:worktree builds of main (2dc5e37d9e) and this PR on one data dir, 3 pin/unpin cycles each:

Action main this PR
Pin POST + 2 sidebar GETs POST + 2 sidebar GETs
Unpin POST + 2 sidebar GETs POST + 2 sidebar GETs

#5994 had declared tag invalidations on pin and unpin. The server broadcast them and the client re-applied them, which added 2 sidebar reloads per pin. They are removed, together with the thread route tags that only they used. The server and server contract are now identical to main, and there is no schema change.

Script time measured earlier on a VACUUM INTO snapshot of a real bb.db (3,869 threads), at 5 runs, medians, main / this PR at 1×: archive 17.5 / 16.4 ms, move section 18.9 / 21.8 ms, delete 20.3 / 25.0 ms, undo 11.6 / 13.0 ms. Click to paint is unchanged (~46 ms), and cold load and thread switching are at parity.

How you verified

  • pnpm exec turbo run typecheck lint test --filter='...@bb/query-tags': green (app 6,246, plugin SDK 395).
  • Bundle budget: the boot payload is 393.7 KB brotli against the unchanged 394.4 KB budget.
  • @bb/query-tags/testing keyedStoreContract: one six-case table run against core thread lists and against the real plugin hooks (experimental_useRpcKeyedQuery plus experimental_useRpcMutation with updateKey). Breaking the read-start rule fails both.
  • Frame-by-frame QA against main (b143a22): 25 scenarios at 0 and 400 ms, including failures: pin, archive, drag-to-Pinned, status mid-save, every writer above. Everything matches main except the changes listed above.
  • Real plugin caller: push-notifications at 400 ms. Muted shows about 100 ms after the click and holds through acknowledgement, and a forced failure reverts, the same as main.

Net vs #5994: code +2,302 / −2,341; tests and docs +936 / −291.

  • Thread hooks: 358 tests across src/hooks/mutations, cache-owners, queries and realtime effects pass. The stale-read pin test's fake writes now return the server's row, as the real pin route does.
  • After merging current main: pnpm exec turbo run typecheck lint --filter='...[origin/main]' passes (122 tasks), and the @bb/query-tags, plugin SDK and server-contract tests pass. The plugin SDK version check reports the surface unchanged. CI runs the full suite.

AGENT GENERATED

🤖 Generated with Claude Code

ymichael and others added 12 commits October 20, 2026 23:10
Evidence branch for #5658: every core pin and unpin path now uses the
@bb/query-tags prediction layer that the plugin live-data hooks use.

- Predictions survive core's own cache writers: a setQueryData value is
  rebased onto the confirmed data, and the app's TaggedQueryClient runs
  functional updaters on the confirmed data, so rollback removes only the
  prediction.
- structuralSharing calls for an observer's select output no longer
  overwrite the confirmed data.
- Prefix descriptors predict on matching queries that load while a write
  is pending; acknowledged results refine the prediction; infinite queries
  are confirmed by a full reread; caches without a tagged read keep their
  writes and settle to the acknowledged value.
- One thread mutation batcher owns pin, unpin and metadata updates for the
  thread action menu, drag and drop, Move to section and the pin hooks,
  keeping main's per-thread ordering and whole-batch rollback. The
  held-patch pin transactions and the server-result pin write are removed.
- Thread detail, thread lists (including the archived infinite list) and
  sidebar navigation are tagged reads; pin and unpin invalidate their tags.

> AGENT GENERATED

Co-Authored-By: Claude Opus 5.5 <[email protected]>
An acknowledged prediction kept overriding later cache writes until a read
started after the acknowledgement landed, so a dragged thread held the top
of Pinned until the refetch instead of moving to its slot when the pin
order result arrived. A write now folds the acknowledged prediction into
the confirmed data first; the prediction is kept only as a guard reapplied
over reads that started before the acknowledgement.

Add tests for a pin followed by a pin-order write and for concurrent
thread state surviving a successful pin. The pin hooks no longer pass a
no-op invalidate, and writes without predictions no longer subscribe to the
query cache.

> AGENT GENERATED

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Thread detail, lists, archived pages, search, the sidebar and the detail
bootstrap keep their data shapes but are rebuilt from one entity query per
thread. Writes to any view become field-level entity writes. Pin, unpin and
archive predict on the entity only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ted view slots

Status and pending-interaction pushes write the thread entity once, so a
thread hidden by a pending archive still receives them. Views rebuild only
the slots that hold a changed thread.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Read state, rename, section and parent moves, unarchive, delete, stop,
send status, banner cancellation, environment rename and project or section
deletion now predict on the thread entity and roll back by removing the
prediction, instead of snapshotting and restoring every list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…r uses

Removes pending-thread-patches, the list and sidebar mappers, snapshot
restores and the archive cache helpers. In @bb/query-tags, removes
optimisticQueriesUpdate, the array branch of the cache-write rebase and
infinite-query receipts; their tests move to object-shaped values or go.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Queued messages, prompt history, storage, file previews, the timeline hook,
the conversation outline and turn summary details move to
thread-panel-queries.ts. Only lazily loaded routes import them, so they
leave the boot payload (392.5 KB brotli, 1.9 KB under budget).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
At 3,000 threads the map ingests a sidebar in 15-18 ms instead of 23-25 ms,
predicts and rolls back a pin in 0.035 ms instead of 0.78 ms, and predicts on
130 threads at once in under 1 ms instead of about 100 ms. Rows inserted into
a view, such as an unarchived thread in the sidebar, now survive reads that
started before the insertion. With no core writer left on shared arrays,
TaggedQueryClient goes too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael force-pushed the bb/eval-normalized-thread-entities branch from fa38078 to 6fefc43 Compare October 21, 2026 12:58
@ymichael ymichael changed the title Store each thread once and derive thread views from it (evaluation) Store each thread once in a keyed store shared with plugin keyed rows Oct 21, 2026
@ymichael
ymichael marked this pull request as ready for review October 21, 2026 13:06
@ymichael
ymichael changed the base branch from bb/prove-5658-core-mutation-keyed-read-on-the-share-thr_xig942tj2w to main October 21, 2026 23:22
# Conflicts:
#	packages/plugin-sdk/src/internal/rpc-query-host.ts
#	packages/server-contract/src/public-api.ts
@ymichael
ymichael force-pushed the bb/eval-normalized-thread-entities branch from f52c180 to b030b4d Compare October 22, 2026 00:06
ymichael and others added 2 commits October 21, 2026 17:08
Pin and unpin declared tag invalidations that the server broadcast and the
client re-applied, so every pin reloaded the sidebar twice more than main.
The keyed store's prediction already holds the result, and main's settle
and realtime refreshes stay as they were.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 7e2c494 into main Oct 22, 2026
48 checks passed
@ymichael
ymichael deleted the bb/eval-normalized-thread-entities branch October 22, 2026 03:09
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]>
ymichael added a commit that referenced this pull request Nov 18, 2026
## Human comments

## What was wrong

Boot JavaScript grew from 349.6 KB to 419.8 KB brotli between #6076
(dae54bd) and f1c5304, measured per module with the same build.
Most of the growth came from features, but the largest piece was a leak.
#6579 had the sidebar updates badge (`useUpdateInventory`) import
`pluginHasUpdateSurfaces` from `PluginUpdatesCard.tsx`. That one helper
put the plugin-management UI, the shared-ui resource list and
`@radix-ui/react-scroll-area` on boot: 19.7 KB brotli. A second leak
came with #6756: `thread-action-registry` imports `useBbNavigate` from
`plugin-navigation-hooks.ts`, which also defined the plugin-only
file-open hook, so the local open-target hooks loaded before first
paint.

While splitting dialogs I also found a bug in `vite-journey-chunks.ts`.
Vite adds `\0vite/preload-helper.js` to `importedIds` for any module
with a dynamic `import()`, with no matching import declaration in the
code. The counts disagreed, so `moduleEdges` fell back to following
every name of every import. Once `ThreadActionsProvider` gained a split,
that pulled the `@bb/client-core` and `@bb/thread-view` timeline code
into the plugin runtime chunk (PluginFrontend +18.5 KB, NewThreadPage
+15 KB).

Boot brotli growth, #6076 → f1c5304 (per-module attribution, brotli
share of each boot chunk):

| Commit / module cluster | Brotli bytes |
|---|---|
| #6579 Settings → Updates: plugin management UI, shared-ui resource
list, `@radix-ui/react-scroll-area` via `pluginHasUpdateSurfaces` |
+19,727 |
| #7133 dependency update: `react-dom` 19.2.4 → 19.3.1 (+ `react`,
`scheduler`) | +7,329 |
| #6002 keyed thread store: `query-tags` keyed store,
`thread-entity-store`, `thread-panel-queries` | +5,824 |
| #6013 / #6519 core tab and message-metadata registrations through the
plugin collector (`plugin-app-registration-collector`, validators) |
+5,249 |
| #7213 single update button: `@radix-ui/react-hover-card`, badge model
| +3,148 |
| #6756 open-target hooks via `plugin-navigation-hooks` | +2,381 |
| #6763 shared rename path: `inline-rename`, rename dialogs | +1,830 |
| #7176 setup-guide telemetry: `onboarding-model` | +1,733 |
| Radix version bumps (`react-collection` and others, excluding
scroll-area and hover-card) | +~3,900 |
| React Compiler memo caches (Nov 15 budget entry) and other
app/shared-ui feature growth | remainder (~19,000) |
| **Total** | **+70,214** |

Shared packages: `@bb/shared-ui` +15.3 KB (mostly the resource list
above), `@get-bb/plugin-sdk` +5.2 KB (the collector),
`@bb/server-contract` +2.0 KB, `@bb/sdk` +1.2 KB, `@bb/domain` +0.1 KB.
Zod was already on boot at #6076 and is unchanged.

## What changed

- `pluginHasUpdateSurfaces` moved from `PluginUpdatesCard.tsx` to
`plugin-status.ts`. The plugin-management UI now loads with Settings and
Tools (−19.7 KB).
- `usePluginCanOpenFileExternally` moved from
`plugin-navigation-hooks.ts` to a new `plugin-file-open-hooks.ts`, still
re-exported by `plugin-sdk-hooks.ts`. The open-target hooks now load
with the thread and compose pages, which already use them (−2.4 KB).
- An earlier version also set `treeshake.manualPureFunctions: ["z"]` to
drop unused zod schemas (−3.6 KB). It is removed. Rolldown matches that
name in every module, minified dependencies included, and also inside
function bodies. In the built app it deleted sonner's
`setSwiping(true)`/`setSwiping(false)` calls (toasts no longer follow a
swipe on touch screens), cmdk's result-sort call, and two `push` calls
in d3-scale's log ticks.
- The project path, project rename and delete, and thread delete and
archive dialogs load behind `defineSplit` preload-tier wrappers that
mount when opened and stay mounted, following `ApplicationUrlDialog`
(−3.1 KB). Nothing in them is visible at first paint.
- `vite-journey-chunks.ts` ignores the preload helper id. The regression
test fails before the fix and passes after.
- `bundle-budget.json`: `splitBoundaries` boot guards for
`PluginUpdatesCard`, `UpdatePluginDialog`, `useLocalOpenTargets` and the
five dialogs. `@radix-ui/react-scroll-area` is added to
`forbiddenBootPackages`, plus a dated `$comment` entry. Against main's
build, the new budget reports all nine guards.
- Limits are unchanged. Boot now measures 402,655 bytes against 429,151,
which is 6.2% headroom. 10% over the new measurement (442,921) would be
a raise, so lowering the limit would leave less than 10%.

Not reached: 10% headroom needs about 12.3 KB more. The remaining boot
code that isn't first-paint UI is small and spread out. The
command-palette placeholder is kept on boot deliberately so Cmd+K opens
instantly. The updates hover-card body is ~2 KB and splitting it would
risk an empty card on an early hover. The plugin collector (5.2 KB) is
how core registers its own Info tab and message time, per the rule that
core uses the plugin API path. Each of these would cost something
visible or break that rule.

## How you verified

Bundle sizes from real builds of main (3678415, same sizes as
f1c5304) and this branch rebased on main (`.br` files, as
`check-bundle-budget.mjs` counts them):

| Closure | main raw / brotli | branch raw / brotli | brotli Δ |
|---|---|---|---|
| boot | 1,717,479 / 428,928 | 1,597,774 / 402,655 | −26,273 (−6.1%) |
| ThreadPage | 1,909,102 / 504,492 | 1,918,632 / 506,727 | +2,235 |
| NewThreadPage | 1,007,979 / 270,590 | 1,025,094 / 274,769 | +4,179 |
| PluginFrontend | 832,313 / 220,554 | 846,772 / 223,750 | +3,196 |
| boot + ThreadPage | 933,420 | 909,382 | −24,038 |
| boot + NewThreadPage | 699,518 | 677,424 | −22,094 |
| boot + PluginFrontend | 649,482 | 626,405 | −23,077 |

Journey growth is the open-target hooks (~3.9 KB) that those pages use,
plus small dialog dependencies.

First content on a real server (measured with the earlier version that
still had the `z` hint, so about 3.6 KB more JS was removed than now):
one `pnpm start:worktree` server with real data (a real agent thread
plus fixtures). Main's and this branch's builds were served by swapping
`index.html` in `apps/app/dist`, so server and data were identical. Each
run used headless Chrome on a fresh navigation with the HTTP cache
cleared and disabled, 4× CPU throttle, 1.6 Mbps / 150 ms RTT. Median of
6 alternating runs; ranges did not overlap for any metric:

| Page | Metric | main | branch | Δ |
|---|---|---|---|---|
| New thread `/` | FCP | 3,594 ms | 3,430 ms | −164 |
| | composer painted | 6,862 ms | 6,731 ms | −131 |
| Thread `/threads/<id>` | FCP | 3,606 ms | 3,432 ms | −174 |
| | timeline painted | 8,942 ms | 8,756 ms | −187 |
| Plugin page `/plugins/automations/automations` | FCP | 3,572 ms |
3,422 ms | −150 |
| | content painted | 7,496 ms | 7,353 ms | −144 |
| | JS downloaded before content (new / thread / plugin) | 745,687 /
979,589 / 732,738 B | 719,291 / 951,279 / 706,155 B | −26.4 / −28.3 /
−26.6 KB |

Manual checks on the branch build:
- Cold load, sidebar and composer: no console errors.
- Updates badge hover card: lists the provider CLI updates.
- Thread page renders its timeline.
- New thread submitted from the composer.
- Thread delete dialog: confirmed, thread deleted.
- Archive on a parent with a child: dialog shows the child count; both
threads archived.
- "New project" path-entry fallback dialog: path submitted, project
created.
- Settings → Updates and the Plugins page render.
- Project rename and delete dialogs opened through the real
`ProjectActionsProvider` in a throwaway test, because their only menu
sits in a header that the current routes don't render.
- A 409 on `GET /threads/<new>/thread-storage/location` right after
submit also happens on main.

Commands:
- `pnpm exec turbo run typecheck lint --filter=@bb/app`
- `pnpm exec turbo run test --filter=@bb/app -- <63 related test
files>`: 63 passed
- `src/vite-journey-chunks.test.ts`: fails before the fix, passes after
- `node scripts/check-bundle-budget.mjs`: OK
- `oxfmt --check`
- Rebased on main (includes #7736); `pnpm exec turbo run build typecheck
lint --filter=@bb/app` and `check-bundle-budget.mjs` pass, and the 40
app test files that touch the changed providers, dialogs, layout and
hooks pass on the merge.
- The built sonner and cmdk code again contains the swipe setter and
sort calls that the `z` hint had removed.

> AGENT GENERATED

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant