#7750 · Warm timeline remount investigation
Trusted main base: 39ad460629bb3d0997b9ba6d9fb27bc272a60d8f
Verdict: NOT REPRODUCED · Root-cause confidence: low · reproduction label: no-repro
1. TL;DR
The report describes expensive warm thread navigation dominated by style recalculation. A real-browser reproduction was attempted twice, but this host has no Chrome/Chromium, so no browser trace or millisecond measurement was obtained. A smaller diagnostic using the actual timeline and scroll components ran in two clean trusted checkouts and confirmed that remounting repeats geometry and table-related style reads even with the same row objects. It also found that 150- and 300-row histories both mount only 17 top-level timeline rows in this fixture. These findings identify reachable profiling targets, not proof of the reported latency, a whole-timeline style invalidation, or a safe performance fix.
2. Claims vs findings
| Claim to test | Status | Evidence |
|---|---|---|
| Warm navigation costs roughly 200 ms and style recalculation dominates. | Unverified | No Chromium engine was available. JSDOM has no rendering engine and does not report RecalcStyleDuration. |
| The relevant work belongs to core rather than third-party plugins. | Partly investigated | The core-only fixture repeats geometry requests, but it is not a with/without-plugin browser comparison. |
| A warm switch avoids geometry/style work because rows are already cached. | Repeated requests verified | The same row array and objects were remounted four times per history size, with identical API counts in both checkouts. |
| The entire long timeline is rebuilt or restyled. | Not established | Only 17 top-level rows mount for both 150 and 300 input rows. This says nothing about browser invalidation scope outside the mounted DOM. |
| Minified geometry and height functions explain the slow switch. | Unverified attribution | No matching release bundle or source map was executed. No offsetHeight read occurred in this probe; that hotspot is not reproduced. |
| The new-thread page has the same expensive behavior. | Unverified | The diagnostic does not open the compose route. |
3. Environment
- Linux x86_64; Node v22.19.0; pnpm 9.15.0; Vitest 4.1.12; React 19.3.1; JSDOM with the repository's synthetic flow-layout helper.
- Two fresh temporary checkouts at
39ad460629bb3d0997b9ba6d9fb27bc272a60d8f, referred to as CHECKOUT_1 and CHECKOUT_2 in sanitized logs. No existing user runtime data was read. - No app server, provider, database, or network-listening test port was started. The BB Browser Automation local/headless backend was requested; both attempts failed before opening a browser.
- The full monorepo build initially failed because a plugin needed the unbuilt SDK runtime. Building the existing SDK through Turbo resolved this for the relevant app build; app builds succeeded in both checkouts. No dependency was added.
- A later fetch found main at
3c8f94a21da24d8c1351e8f19558670b0b1e6d03; the intervening setup-guide change was not a timeline fix. Executed evidence remains pinned to the recorded base.
4. Minimal reproduction
This is a limited diagnostic, not a failing latency regression. The investigator-authored patch extends the repository's existing real-component mount test. Key changes model the page lifetime found in source; they do not execute a sidebar click, full ThreadScreen, or product navigation.
git clone https://github.com/get-bb/bb.git bb-7750-first cd bb-7750-first git checkout --detach 39ad460629bb3d0997b9ba6d9fb27bc272a60d8f pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build --filter=@get-bb/plugin-sdk pnpm exec turbo run build --filter=@bb/app cp /tmp/7750-test.tsx apps/app/src/components/thread/timeline/ThreadTimelineRows.mount-layout-reads.test.tsx pnpm exec turbo run test --filter=@bb/app -- src/components/thread/timeline/ThreadTimelineRows.mount-layout-reads.test.tsx --silent=false git diff --check
Before running these commands, expand the full diagnostic test below and save its complete contents as /tmp/7750-test.tsx. The copy step replaces only the existing test file, not production code. Expected: changing the keyed page remounts the timeline, the last row stays available, and existing scroll/stream layout-read invariants continue passing. Actual, in each checkout:
Test Files 1 passed (1) Tests 5 passed (5) 12 measurement records; both runs identical.
| Input rows | Mounted, commit / settled | getBoundingClientRect | clientHeight | scrollHeight | getComputedStyle |
|---|---|---|---|---|---|
| 12 | 12 / 12 | 7 | 12 | 12 | 52 |
| 150 | 17 / 17 | 17 | 13 | 13 | 78 |
| 300 | 17 / 17 | 17 | 13 | 13 | 78 |
Each row represents every one of four key changes for that size. Counts cover the remount and three synthetic frames. scrollTop was 7 and clientWidth was 4 on each remount. These are API requests, not layout or style recalculation counts. The test provides no elapsed browser-CPU measurement.
{
"count": 300,
"timelineKey": "second",
"committedRows": 17,
"settledRows": 17,
"counts": {
"scrollTop": 7,
"getBoundingClientRect": 17,
"clientHeight": 13,
"scrollHeight": 13,
"clientWidth": 4,
"getComputedStyle": 78
}
}
Browser setup actual result (repeated twice):
{
"ok": false,
"error": {
"code": "command_failed",
"message": "Install Chrome/Chromium on this host or link its executable at the plugin data runtime/chrome path."
}
}
No screenshot is presented: this is a timing investigation, not a demonstrated visual defect, and no browser launched.
The complete repeatable test is included inline. Raw logs and the diagnostic patch remain in the investigator's local evidence directory, not this public repository.
Full executed diagnostic test
// @vitest-environment jsdom
import { act, cleanup, render } from "@testing-library/react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { MemoryRouter } from "react-router-dom";
import { afterEach, describe, expect, it } from "vitest";
import type { TimelineRow } from "@bb/server-contract";
import { BottomAnchoredScrollBody } from "@/components/ui/bottom-anchored-scroll-body";
import { installFakeFlowLayout } from "@/test/fake-flow-layout";
import { conversationRow, toolRow } from "@/test/fixtures/thread-timeline-rows";
import { ThreadTimelineRows } from "./ThreadTimelineRows";
const VIEWPORT_HEIGHT = 600;
const ROW_HEIGHT = 140;
const LAYOUT_GETTERS = [
[Element.prototype, "scrollTop"],
[Element.prototype, "scrollLeft"],
[Element.prototype, "scrollHeight"],
[Element.prototype, "scrollWidth"],
[Element.prototype, "clientHeight"],
[Element.prototype, "clientWidth"],
[Element.prototype, "clientTop"],
[Element.prototype, "clientLeft"],
[HTMLElement.prototype, "offsetHeight"],
[HTMLElement.prototype, "offsetWidth"],
[HTMLElement.prototype, "offsetTop"],
[HTMLElement.prototype, "offsetLeft"],
] as const;
const LAYOUT_METHODS = [
[Element.prototype, "getBoundingClientRect"],
[Element.prototype, "getClientRects"],
] as const;
const restores: (() => void)[] = [];
afterEach(() => {
cleanup();
for (const restore of restores.splice(0).reverse()) restore();
document.body.replaceChildren();
});
function recordLayoutReads() {
const reads: string[] = [];
const stacks = new Set<string>();
let recording = false;
const note = (name: string) => {
if (recording) {
reads.push(name);
stacks.add(
`${name}\n${new Error().stack?.split("\n").slice(3, 7).join("\n")}`,
);
}
};
for (const [prototype, name] of LAYOUT_GETTERS) {
const descriptor = Object.getOwnPropertyDescriptor(prototype, name);
const get = descriptor?.get;
if (descriptor === undefined || get === undefined) continue;
Object.defineProperty(prototype, name, {
...descriptor,
get(this: Element) {
note(name);
return get.call(this);
},
});
restores.push(() => Object.defineProperty(prototype, name, descriptor));
}
for (const [prototype, name] of LAYOUT_METHODS) {
const original = prototype[name];
Object.defineProperty(prototype, name, {
configurable: true,
writable: true,
value(this: Element) {
note(name);
return Reflect.apply(original, this, []);
},
});
restores.push(() =>
Object.defineProperty(prototype, name, {
configurable: true,
writable: true,
value: original,
}),
);
}
const originalGetComputedStyle = window.getComputedStyle;
window.getComputedStyle = (...args) => {
note("getComputedStyle");
return originalGetComputedStyle(...args);
};
restores.push(() => {
window.getComputedStyle = originalGetComputedStyle;
});
return {
stacks: () => [...stacks],
during(run: () => void): string[] {
reads.length = 0;
stacks.clear();
recording = true;
try {
run();
} finally {
recording = false;
}
return [...reads];
},
};
}
function historyRows(count: number, firstSeq = 1): TimelineRow[] {
return Array.from({ length: count }, (_, offset): TimelineRow => {
const seq = firstSeq + offset;
if (seq % 3 === 0) {
return toolRow({
id: `row-${seq}`,
seq,
toolArgs: { path: `src/file-${seq}.ts`, limit: 200, offset: seq },
toolName: "Read",
turnId: `turn-${seq}`,
});
}
return conversationRow({
id: `row-${seq}`,
role: seq % 3 === 1 ? "user" : "assistant",
seq,
text:
seq % 3 === 1
? `Question ${seq}\n\n${"A line of the question.\n\n".repeat(24)}`
: `Answer ${seq}\n\n| a | b |\n| - | - |\n| ${seq} | two |\n\n\`\`\`ts\nconst value = ${seq};\n\`\`\``,
turnId: `turn-${seq}`,
});
});
}
function setup(rows: TimelineRow[]) {
const layout = installFakeFlowLayout({
heightOf: (element) =>
element.hasAttribute("data-timeline-row-id") &&
element.parentElement?.hasAttribute("data-timeline-items") === true
? ROW_HEIGHT
: null,
scrollElement: () =>
document.querySelector<HTMLElement>("[data-page-scroll-viewport]"),
viewportHeight: VIEWPORT_HEIGHT,
});
restores.push(layout.restore);
const recorder = recordLayoutReads();
const queryClient = new QueryClient();
const tree = (timelineRows: TimelineRow[], timelineKey = "initial") => (
<QueryClientProvider client={queryClient}>
<MemoryRouter>
<BottomAnchoredScrollBody
key={timelineKey}
footer={null}
maxWidthClassName="max-w-3xl"
>
<ThreadTimelineRows
timelineRows={timelineRows}
threadRuntimeDisplayStatus="idle"
/>
</BottomAnchoredScrollBody>
</MemoryRouter>
</QueryClientProvider>
);
const view = render(tree(rows));
for (let frame = 0; frame < 3; frame += 1) act(() => layout.frame());
const mounted = () =>
[
...document.querySelectorAll<HTMLElement>(
"[data-timeline-items] > [data-timeline-row-id]",
),
].map((row) => row.dataset.timelineRowId ?? "");
return {
layout,
mounted,
recorder,
rerender: (timelineRows: TimelineRow[], timelineKey?: string) =>
view.rerender(tree(timelineRows, timelineKey)),
};
}
describe("timeline rows mounting", () => {
it.each([12, 150, 300])(
"records warm remount layout requests for %i rows",
(count) => {
const rows = historyRows(count);
const harness = setup(rows);
for (const timelineKey of ["second", "first", "second", "first"]) {
let committed: string[] = [];
const reads = harness.recorder.during(() => {
act(() => harness.rerender(rows, timelineKey));
committed = harness.mounted();
for (let frame = 0; frame < 3; frame += 1)
act(() => harness.layout.frame());
});
const counts = Object.fromEntries(
[...new Set(reads)].map((name) => [
name,
reads.filter((read) => read === name).length,
]),
);
console.log(
JSON.stringify({
count,
timelineKey,
committedRows: committed.length,
settledRows: harness.mounted().length,
counts,
}),
);
if (count === 300 && timelineKey === "second")
console.log(JSON.stringify({ stacks: harness.recorder.stacks() }));
expect(harness.mounted()).toContain(`row-${count}`);
}
},
);
it("reads no layout while a scroll mounts new rows, and covers the viewport by the next paint", () => {
const harness = setup(historyRows(150));
expect(harness.mounted()).not.toContain("row-1");
act(() => harness.layout.userScrollTo(0));
expect(harness.mounted()).not.toContain("row-4");
const reads = harness.recorder.during(() =>
act(() => harness.layout.runFrameCallbacks()),
);
act(() => harness.layout.flushResizeObservers());
expect(harness.mounted()).toEqual(
expect.arrayContaining(["row-1", "row-2", "row-3", "row-4"]),
);
expect(reads).toEqual([]);
});
it("reads no layout while a streamed row mounts at the end", () => {
const rows = historyRows(150);
const harness = setup(rows);
const grown = [...rows, ...historyRows(1, 151)];
const reads = harness.recorder.during(() =>
act(() => harness.rerender(grown)),
);
expect(harness.mounted()).toContain("row-151");
expect(reads).toEqual([]);
});
});
5. Root cause: known lifetime, unresolved latency
Page lifetime restarts when thread identity changes
ThreadScreen keys the page shell by thread identity. React therefore recreates its subtree when switching thread IDs. Reusing timeline query data does not preserve the component instances or their observers across that key change. The probe models this lifetime one layer below PageShell.
switch (presentation.kind) {
case "page":
return (
<div
data-thread-window=""
className="flex h-full min-h-0 min-w-0 flex-col overflow-clip"
>
<PageShell
key={thread.id}
scrollBehavior="bottom-anchor"
scrollAnchorThreadId={thread.id}
scrollContentInsetEndPx={contextCardInset}
Scroll/window geometry reads remain reachable on remount
Recorded stacks point to connect → syncFloor / reconcile, naturalFloorHeight, and syncWindow viewport/container rectangles. Resize-observer settlement also invokes reconciliation. Geometry reads are real core requests, but whether a given read forces expensive browser work depends on preceding invalidations, which this test cannot observe.
const scrollElement = positionKeeper.getScrollElement();
if (container === null || scrollElement === null) return;
const viewportHeight =
positionKeeper.getViewportHeight() || scrollElement.clientHeight;
if (viewportHeight <= 0) return;
const model = renderedModel();
const localTop =
scrollElement.getBoundingClientRect().top -
container.getBoundingClientRect().top;
const visible = visibleRange(model, localTop, viewportHeight);
Table ancestor discovery accounts for the observed style requests
The getComputedStyle stacks point to readMarkdownTableGeometry and findHorizontalClipAncestor. The fixture includes Markdown tables. JSDOM does not load the application's normal CSS layout, so clipping-ancestor discovery and its counter totals are not a quantitative proxy for the browser. The nullish-assignment cache can also repeat a no-ancestor search in this synthetic environment. No claim is made that these style requests cause 78 separate browser recalculations.
function findHorizontalClipAncestor(element: HTMLElement): HTMLElement | null {
let current: HTMLElement | null = element;
while (current && current !== document.body) {
if (
HORIZONTAL_CLIP_OVERFLOW_VALUES.has(getComputedStyle(current).overflowX)
) {
return current;
}
current = current.parentElement;
}
return null;
The existing shared resize dispatcher already batches reads before writes. A blanket claim that these observer callbacks are unbatched is not supported. Both existing tests asserting no synchronous layout reads while mounting additional rows during scroll or streaming passed. The root cause of the reported latency is still unknown.
6. Proposed next experiment and fix decision
Capture a real-browser trace of warm sidebar switches on trusted main, then identify read-after-write invalidation stacks before changing scroll anchoring, observer batching, or view lifetime. Use two synthetic long threads in a fresh isolated app, warm them, alternate actual sidebar clicks, and capture Performance.getMetrics plus a timeline trace. Distinguish total CPU from longest task, and separate initial mount, ResizeObserver delivery, table measurement, composer sizing, and table-of-contents work. Compare with and without third-party frontend assets only after verifying the browser page and cached histories are equivalent.
No production fix or pull request is safe here: the reported browser defect has not been reproduced and there is no focused pre-fix failing regression test for its latency. Removing geometry reads speculatively could break initial positioning, restored anchors, or viewport coverage. The diagnostic passes on unchanged production code and must not be presented as proof of a performance repair. No branch, commit, or PR was created in the target repository.
7. Verification
The same agent repeated the diagnostic in a second clean clone, detached at the same trusted commit. Before applying only the diagnostic patch, git status was clean. A separate frozen install and relevant SDK/app builds succeeded. The exact Turbo test command above ran live, not from the test cache; it passed all five tests. All twelve count records matched CHECKOUT_1 exactly. A second BB Browser Automation launch failed for the same missing-browser prerequisite.
The final verdict is deliberately NOT REPRODUCED, not partial confirmation: observing ordinary geometry requests alone does not reproduce excessive style-recalculation time. This is a repeated check by the same agent, not independent verification. The report limits its claim accordingly. git diff --check passed in both source checkouts. No production files changed, both failed browser sessions are closed, and no test listeners or data directories were created.
8. PR and related context
The issue timeline and open-PR search returned no linked open PR at investigation time. No linked PR code was checked out or run. Nearby repository issues #7693 and #7694 concern unchanged-row update work; that is distinct from this keyed-remount probe and no shared cause is asserted.
9. Appendix
Both runs produced twelve records, four for each history size. All twelve record objects were equal between checkouts, including the first/second key sequence and committed/settled row counts. First run: five tests passed in 18.51 seconds; second run: five tests passed in 18.95 seconds. These durations include test imports and JSDOM work and are not application navigation timings.
getBoundingClientRect ScrollPositionKeeper.naturalFloorHeight (scroll-position-keeper.ts:996) ScrollPositionKeeper.syncFloor (scroll-position-keeper.ts:1006) ScrollPositionKeeper.connect (scroll-position-keeper.ts:328) getBoundingClientRect Object.onPositionChange (TimelineWindowedItems.tsx:537 and :538) ScrollPositionKeeper.notifyLists (scroll-position-keeper.ts:1049) getComputedStyle findHorizontalClipAncestor (markdown-preview.tsx:1645) readMarkdownTableGeometry (markdown-preview.tsx:1555) Object.read (markdown-preview.tsx:1576 and :1594)
Boundary note: issue text and GitHub metadata were used as untrusted claims only. No issue-supplied script, patch, URL, branch, or executable was run. Only trusted main source and the investigator-authored diagnostic were executed; no external issue links were fetched. No credentials or user runtime data are included.
> AGENT GENERATED