Repository navigation
Win back 26 KB of boot JavaScript without raising the budget - #7744
Merged
Merged
Conversation
The sidebar updates badge imported one helper from PluginUpdatesCard, which put the plugin management UI, the shared-ui resource list and Radix scroll area on the boot path. The helper now lives in plugin-status.ts. The plugin file-open hook leaves plugin-navigation-hooks.ts so thread actions no longer pull the local open-target hooks onto boot. Zod's z calls are marked pure so unused top-level schemas drop out, and five action dialogs load behind preload-tier splits that mount when opened. vite-journey-chunks.ts ignored names for any module with a dynamic import, because Vite adds its preload helper to importedIds without a matching import declaration. Such modules followed every export of every import, which pulled the thread timeline into the plugin runtime chunk once ThreadActionsProvider gained a split. Boot: 428,928 -> 398,930 bytes brotli. Split guards cover what moved. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Rolldown applies manualPureFunctions by name to every module, so it also removed calls to unrelated functions and variables named z in minified dependencies: sonner's swipe state setter, cmdk's result sort, and d3-scale log tick pushes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
force-pushed
the
bb/win-back-boot-bundle-headroom-thr_5vzp9ch95x
branch
from
November 18, 2026 04:02
8a54a39 to
4e6a8a1
Compare
ymichael
added a commit
that referenced
this pull request
Dec 1, 2026
…8507) ## Human comments ## What was wrong Boot JavaScript grew from 393.2 KB to 418.9 KB brotli between #7744 (Nov 18) and main, leaving 0.2 KB under the 419.1 KB limit. Two of the largest steps were static edges from the boot path into page-only code: - #8089: `plugin-navigation-hooks` imports `useTimelinePaneThreadId` from `timeline-viewport.tsx`, which also defined `TimelineViewportScrollSource`. That put `bottom-anchored-scroll-body` and `scroll-position-keeper` on boot. - #7960: `active-composer.ts` built the active composer's plugin handle itself, so the action-context binder (on boot) pulled in `plugin-composer-handle`, the SDK's `composer-handle` and `composer-draft-actions`, `plugin-composer-host` and `composer-editor-registry`. #8050 added a second path to the same modules: plugin navigation converts `initialPrompt` parts through `plugin-composer-handle.ts`. #7962's boot growth (~1 KB brotli) is the exclusive-pick logic the sidebar thread list and navigation need before they paint, so it stays. ## What changed - `TimelineViewportScrollSource` moved to `apps/app/src/lib/timeline-viewport-scroll-source.tsx`; `timeline-viewport.tsx` exports `useTimelineViewportStore` for it. - `ActiveComposerCandidate` gained `handle(pluginId)`. `composer-root` registers a factory built by the new `active-composer-handle.ts`, and `getActiveComposerHandle` calls it, so `active-composer.ts` no longer imports the handle code. `experimental_useActiveComposer` uses the same builder. - `initialPromptSeedFromComposer` and `mentionText` moved to `apps/app/src/lib/initial-prompt-seed.ts`. It imports `composerDraftFromInsertParts` from a new SDK internal subpath, `@get-bb/plugin-sdk/internal/composer-draft-transforms`, where that function now lives. A re-export through `internal/composer-handle` still kept the whole module on boot. - Plugin SDK 0.6.216 for the new subpath. - `bundle-budget.json`: `splitBoundaries` boot guards for `bottom-anchored-scroll-body.tsx`, `active-composer-handle.ts` and `plugin-composer-handle.ts`, plus a dated `$comment` entry. Limits unchanged. ## How you verified Real builds of main (e0c49e2) and this branch, brotli bytes from the `.br` files `check-bundle-budget.mjs` counts: | Closure | main | branch | Δ | |---|---|---|---| | boot | 428,920 | 419,163 | −9,757 | | ThreadPage | 498,511 | 507,873 | +9,362 | | NewThreadPage | 268,226 | 277,858 | +9,632 | | PluginFrontend | 219,813 | 229,475 | +9,662 | | boot + each page | | | −95 to −395 | Raw boot: 1,708,056 → 1,668,548. Every page shell uses the scroll body (`page-shell.tsx`) and every page loads the plugin runtime that needs the composer handle, so the code moved into the shared page chunks. The shell's critical path shrinks, the total before page content is unchanged, and boot is back to 2.3% headroom. I didn't measure paint timings. - Negative control: re-adding the `timeline-viewport` → scroll-body import and a `plugin-navigation-hooks` → `plugin-composer-handle` import fails the check with both new guards, and boot returns to 418.6 KB. - `pnpm exec turbo run test --filter=@bb/app --filter=@get-bb/plugin-sdk`: 709 + 47 test files pass. - `pnpm exec turbo run typecheck lint --filter=@bb/app --filter=@get-bb/plugin-sdk`, `node apps/app/scripts/check-bundle-budget.mjs`, `oxfmt --check`. - Live `pnpm start:worktree` with a real Claude Code thread, driven in headless Chrome: no console errors, scroll-to-latest works, the outline rail's active tick follows scrolling, and typing in the composer works. > 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
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) importpluginHasUpdateSurfacesfromPluginUpdatesCard.tsx. That one helper put the plugin-management UI, the shared-ui resource list and@radix-ui/react-scroll-areaon boot: 19.7 KB brotli. A second leak came with #6756:thread-action-registryimportsuseBbNavigatefromplugin-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.jstoimportedIdsfor any module with a dynamicimport(), with no matching import declaration in the code. The counts disagreed, somoduleEdgesfell back to following every name of every import. OnceThreadActionsProvidergained a split, that pulled the@bb/client-coreand@bb/thread-viewtimeline 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):
@radix-ui/react-scroll-areaviapluginHasUpdateSurfacesreact-dom19.2.4 → 19.3.1 (+react,scheduler)query-tagskeyed store,thread-entity-store,thread-panel-queriesplugin-app-registration-collector, validators)@radix-ui/react-hover-card, badge modelplugin-navigation-hooksinline-rename, rename dialogsonboarding-modelreact-collectionand others, excluding scroll-area and hover-card)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
pluginHasUpdateSurfacesmoved fromPluginUpdatesCard.tsxtoplugin-status.ts. The plugin-management UI now loads with Settings and Tools (−19.7 KB).usePluginCanOpenFileExternallymoved fromplugin-navigation-hooks.tsto a newplugin-file-open-hooks.ts, still re-exported byplugin-sdk-hooks.ts. The open-target hooks now load with the thread and compose pages, which already use them (−2.4 KB).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'ssetSwiping(true)/setSwiping(false)calls (toasts no longer follow a swipe on touch screens), cmdk's result-sort call, and twopushcalls in d3-scale's log ticks.defineSplitpreload-tier wrappers that mount when opened and stay mounted, followingApplicationUrlDialog(−3.1 KB). Nothing in them is visible at first paint.vite-journey-chunks.tsignores the preload helper id. The regression test fails before the fix and passes after.bundle-budget.json:splitBoundariesboot guards forPluginUpdatesCard,UpdatePluginDialog,useLocalOpenTargetsand the five dialogs.@radix-ui/react-scroll-areais added toforbiddenBootPackages, plus a dated$commententry. Against main's build, the new budget reports all nine guards.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 (
.brfiles, ascheck-bundle-budget.mjscounts them):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
zhint, so about 3.6 KB more JS was removed than now): onepnpm start:worktreeserver with real data (a real agent thread plus fixtures). Main's and this branch's builds were served by swappingindex.htmlinapps/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://threads/<id>/plugins/automations/automationsManual checks on the branch build:
ProjectActionsProviderin a throwaway test, because their only menu sits in a header that the current routes don't render.GET /threads/<new>/thread-storage/locationright after submit also happens on main.Commands:
pnpm exec turbo run typecheck lint --filter=@bb/apppnpm exec turbo run test --filter=@bb/app -- <63 related test files>: 63 passedsrc/vite-journey-chunks.test.ts: fails before the fix, passes afternode scripts/check-bundle-budget.mjs: OKoxfmt --checkpnpm exec turbo run build typecheck lint --filter=@bb/appandcheck-bundle-budget.mjspass, and the 40 app test files that touch the changed providers, dialogs, layout and hooks pass on the merge.zhint had removed.🤖 Generated with Claude Code