Skip to content

Commit 4d7a9af

Browse files
ymichaelclaude
andauthored
Take the timeline scroll body and composer handle off the boot path (#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]>
1 parent e0c49e2 commit 4d7a9af

25 files changed

Lines changed: 189 additions & 152 deletions

‎apps/app/bundle-budget.json‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,25 @@
197197
"The rail outline moved out of ThreadPage (7.1 KB raw, 1.0 KB brotli), and",
198198
"the ThreadPage limits dropped by that. The shared reveal rule, the lazy",
199199
"helper and the core contribution registrations added 3.9 KB raw and",
200-
"1.2 KB brotli to boot, within its limits, so the boot limits did not change."
200+
"1.2 KB brotli to boot, within its limits, so the boot limits did not change.",
201+
"",
202+
"On 2026-12-01 the boot payload dropped from 428,920 to 419,163 bytes",
203+
"brotli (1,708,056 to 1,668,548 raw). plugin-navigation-hooks read the",
204+
"timeline pane's thread id from timeline-viewport, which also held the",
205+
"scroll source and so put bottom-anchored-scroll-body and",
206+
"scroll-position-keeper on boot; the scroll source moved to",
207+
"timeline-viewport-scroll-source.tsx. The action-context binder built",
208+
"the active composer's plugin handle inside active-composer.ts, and",
209+
"plugin navigation converted initial prompts through",
210+
"plugin-composer-handle.ts, which put the composer handle and its",
211+
"draft actions on boot; each composer now registers its own handle",
212+
"factory from active-composer-handle.ts, and initial prompts convert in",
213+
"initial-prompt-seed.ts through the SDK's composer-draft-transforms.",
214+
"Every page shell uses the scroll body and every page loads the plugin",
215+
"runtime, so the code moved into the shared page chunks: ThreadPage",
216+
"measures 507,873 brotli (+9,362), NewThreadPage 277,858 (+9,632) and",
217+
"PluginFrontend 229,475 (+9,662); boot plus each page is within 0.4 KB",
218+
"of before. The limits stay, leaving 2.3% boot brotli headroom."
201219
],
202220
"maxBootBytes": 1722436,
203221
"maxBootBrotliBytes": 429151,
@@ -347,6 +365,9 @@
347365
"PluginFrontend"
348366
],
349367
"src/views/RootComposeView.tsx": ["boot", "ThreadPage"],
368+
"src/components/ui/bottom-anchored-scroll-body.tsx": ["boot"],
369+
"src/lib/active-composer-handle.ts": ["boot"],
370+
"src/lib/plugin-composer-handle.ts": ["boot"],
350371
"src/core-contributions/components/*": [
351372
"boot",
352373
"ThreadPage",

‎apps/app/src/components/pickers/ModelReasoningPicker.test.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ function ComposerShell({ children }: { children: ReactNode }) {
173173
shell: () => shellRef.current,
174174
surface: null,
175175
host: null,
176+
handle: () => null,
176177
}),
177178
[],
178179
);

‎apps/app/src/components/plugin/PluginNewThreadComposer.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ import { useFixedPanelTabsState } from "@/lib/fixed-panel-tabs";
8686
import { openPluginDetailsInWorkspace } from "./plugin-detail-opener";
8787
import { PluginNewThreadComposer } from "./PluginNewThreadComposer";
8888
import { PluginContext } from "./plugin-context";
89-
import { initialPromptSeedFromComposer } from "@/lib/plugin-composer-handle";
89+
import { initialPromptSeedFromComposer } from "@/lib/initial-prompt-seed";
9090
import { buildPluginEditThreadPrompt } from "@/lib/resource-edit-prompt";
9191

9292
function PanedRootComposeView() {

‎apps/app/src/components/plugin/PluginNewThreadComposer.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
import { PluginContext } from "@/components/plugin/plugin-context";
1212
import { useQuickCreateProjectController } from "@/hooks/useQuickCreateProject";
1313
import { useRootComposeProjectId } from "@/lib/root-compose-selection";
14-
import { initialPromptSeedFromComposer } from "@/lib/plugin-composer-handle";
14+
import { initialPromptSeedFromComposer } from "@/lib/initial-prompt-seed";
1515
import type { InitialPromptSeed } from "@/components/promptbox/mentions/initial-prompt-draft";
1616

1717
function pluginInitialPromptSeed(

‎apps/app/src/components/plugin/PluginThreadRail.test.tsx‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@ import {
3232
markPluginFrontendsSettled,
3333
resetPluginFrontendBootStateForTest,
3434
} from "@/lib/plugin-frontend-boot-state";
35-
import {
36-
TimelineViewportProvider,
37-
TimelineViewportScrollSource,
38-
} from "@/lib/timeline-viewport";
35+
import { TimelineViewportProvider } from "@/lib/timeline-viewport";
36+
import { TimelineViewportScrollSource } from "@/lib/timeline-viewport-scroll-source";
3937
import { makePluginRegistrationSet } from "@/test/fixtures/plugins";
4038
import {
4139
makeThreadResponse,
@@ -103,7 +101,6 @@ class ResizeObserverMock implements ResizeObserver {
103101
disconnect: ResizeObserver["disconnect"] = vi.fn();
104102
}
105103

106-
107104
for (const { component } of collectCoreContributionSlots(
108105
coreThreadOutline,
109106
"threadRailOutlines",

‎apps/app/src/components/promptbox/composer-root.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
isActiveComposerShell,
2222
registerActiveComposerCandidate,
2323
} from "@/lib/active-composer";
24+
import { activeComposerHandle } from "@/lib/active-composer-handle";
2425
import { useAppNavigationSurfaceId } from "@/lib/app-navigation-host";
2526
import type { PluginComposerHost } from "@/components/plugin/plugin-composer-host";
2627
import { observeSharedResize } from "@bb/shared-ui/lib/shared-resize-observer";
@@ -189,6 +190,7 @@ export function ComposerRoot({
189190
shell: () => rootRef.current?.closest(APP_COMPOSER_SELECTOR) ?? null,
190191
surface,
191192
host: composerHost,
193+
handle: (pluginId) => activeComposerHandle(pluginId, composerHost),
192194
}),
193195
[composerHost, rootRef, surface],
194196
);

‎apps/app/src/components/tools/SkillsLibrary.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
} from "@tanstack/react-query";
1515
import { PERSONAL_PROJECT_ID } from "@bb/domain";
1616
import { buildSkillEditThreadPrompt } from "@/lib/resource-edit-prompt";
17-
import { initialPromptSeedFromComposer } from "@/lib/plugin-composer-handle";
17+
import { initialPromptSeedFromComposer } from "@/lib/initial-prompt-seed";
1818
import type { EditableSkillScope, SkillSummary } from "@bb/server-contract";
1919
import { ResourceListState } from "@bb/shared-ui/resource-list";
2020
import {
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import type { PluginComposerApi } from "@get-bb/plugin-sdk";
2+
import {
3+
createComposerHandleBinding,
4+
type ComposerHandleBinding,
5+
} from "@get-bb/plugin-sdk/internal/composer-handle";
6+
import type { PluginComposerHost } from "@/components/plugin/plugin-composer-host";
7+
import { detachedComposerController } from "@/lib/plugin-composer-handle";
8+
9+
const activeComposerBindings = new Map<
10+
string,
11+
{ key: string; binding: ComposerHandleBinding }
12+
>();
13+
14+
export function activeComposerHandle(
15+
pluginId: string,
16+
host: PluginComposerHost | null,
17+
): PluginComposerApi | null {
18+
if (host === null) return null;
19+
const controller = detachedComposerController(pluginId, host, "The active");
20+
const existing = activeComposerBindings.get(pluginId);
21+
if (existing?.key === host.textEffectKey) {
22+
existing.binding.update(controller);
23+
return existing.binding.handle;
24+
}
25+
const binding = createComposerHandleBinding(host.textEffectKey, controller);
26+
activeComposerBindings.set(pluginId, { key: host.textEffectKey, binding });
27+
return binding.handle;
28+
}

‎apps/app/src/lib/active-composer.ts‎

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
import type { PluginComposerApi } from "@get-bb/plugin-sdk";
2-
import {
3-
createComposerHandleBinding,
4-
type ComposerHandleBinding,
5-
} from "@get-bb/plugin-sdk/internal/composer-handle";
62
import type { PluginComposerHost } from "@/components/plugin/plugin-composer-host";
73
import {
84
getFocusedAppNavigationSurfaceId,
95
subscribeFocusedAppNavigationSurface,
106
type AppNavigationSurfaceId,
117
} from "@/lib/app-navigation-host";
12-
import { detachedComposerController } from "@/lib/plugin-composer-handle";
138

149
export const APP_COMPOSER_SELECTOR = "[data-app-composer]";
1510
const APP_SHELL_ATTRIBUTE = "data-app-shell";
@@ -18,6 +13,7 @@ export interface ActiveComposerCandidate {
1813
shell: () => Element | null;
1914
surface: AppNavigationSurfaceId | null;
2015
host: PluginComposerHost | null;
16+
handle: (pluginId: string) => PluginComposerApi | null;
2117
}
2218

2319
const candidates = new Set<ActiveComposerCandidate>();
@@ -159,33 +155,8 @@ export function composerHoldsCaret(
159155
return shell !== null && shell === caretShellAt(focus);
160156
}
161157

162-
const activeComposerBindings = new Map<
163-
string,
164-
{ key: string; binding: ComposerHandleBinding }
165-
>();
166-
167-
export function activeComposerHandle(
168-
pluginId: string,
169-
host: PluginComposerHost | null,
170-
): PluginComposerApi | null {
171-
if (host === null) return null;
172-
const controller = detachedComposerController(
173-
pluginId,
174-
host,
175-
"The active",
176-
);
177-
const existing = activeComposerBindings.get(pluginId);
178-
if (existing?.key === host.textEffectKey) {
179-
existing.binding.update(controller);
180-
return existing.binding.handle;
181-
}
182-
const binding = createComposerHandleBinding(host.textEffectKey, controller);
183-
activeComposerBindings.set(pluginId, { key: host.textEffectKey, binding });
184-
return binding.handle;
185-
}
186-
187158
export function getActiveComposerHandle(
188159
pluginId: string,
189160
): PluginComposerApi | null {
190-
return activeComposerHandle(pluginId, getActiveComposer()?.host ?? null);
161+
return getActiveComposer()?.handle(pluginId) ?? null;
191162
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import type { ComposerInsertPart, ComposerMention } from "@get-bb/plugin-sdk";
2+
import { composerDraftFromInsertParts } from "@get-bb/plugin-sdk/internal/composer-draft-transforms";
3+
import {
4+
promptMentionResourceFromComposerMention,
5+
promptTextMentionFromComposerMention,
6+
serializedTextForPromptMentionResource,
7+
} from "@bb/client-core";
8+
import type { InitialPromptSeed } from "@/components/promptbox/mentions/initial-prompt-draft";
9+
10+
export function mentionText(mention: ComposerMention): string {
11+
return serializedTextForPromptMentionResource(
12+
promptMentionResourceFromComposerMention(mention),
13+
);
14+
}
15+
16+
export function initialPromptSeedFromComposer(
17+
initialPrompt: string | readonly ComposerInsertPart[],
18+
pluginId: string | null,
19+
): InitialPromptSeed {
20+
if (typeof initialPrompt === "string") return initialPrompt;
21+
const draft = composerDraftFromInsertParts(initialPrompt, {
22+
pluginId,
23+
mentionText,
24+
});
25+
return {
26+
text: draft.text,
27+
mentions: draft.mentions.map(promptTextMentionFromComposerMention),
28+
};
29+
}

0 commit comments

Comments
 (0)