Skip to content

Avoid full-history layout during thread switches - #4537

Merged
ymichael merged 1 commit into
mainfrom
bb/fix-issue-4396-in-bb-thr_z3y7sfycq6
Sep 30, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/fix-issue-4396-in-bb-thr_z3y7sfycq6

Conversation

@ymichael

@ymichael ymichael commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Related to #4396. On a keyed thread remount, the timeline's scroll ref can still be pending when child layout effects run. The virtualizer then falls back to mounting the full loaded history. Expandable panels also synchronously read and write height on mount and on ordinary content rerenders, interleaving layout work across panels.

What changed

Seed the virtualizer with an estimated viewport, keep windowing enabled while the scroll ref is pending, and subscribe when it attaches. Keep the existing fallback for a measured zero-height scrollport. Use shared resize observation for panel mounting and content updates; retain synchronous sizing for expand/collapse transitions.

No SDK/CLI contract, persisted format, server/daemon wire, or protocol version changes. Four files, +129/-33 lines (production code +49/-31). Row-measurement caching and secondary-panel/markdown-preview layout work are outside this change.

How you verified

  • Both new regression tests fail on the original code; 382 relevant timeline, disclosure, and scroll-body tests pass after the fix.
  • pnpm exec turbo run typecheck --filter=@bb/app passes. App lint reports no errors (existing warnings remain).
  • Matched optimized pnpm start:worktree instances: base adbce963ae138ba077afbe011edb414ade4dcf26, exact head 0e0ae963b1ac860611ab157d4e980fb65f7589b6. Served entry assets match their on-disk build hashes. Same deterministic four-thread fixture, 11,568 event rows after normal pruning, with identical event hashes; the measured threads contain 5,747 and 4,612 events.
  • Chrome 154 headless, macOS 26.5.1/M4 Max, 1280×720, no throttling. Eight warm switches per build and panel configuration, alternating build order, observing 900 ms after each click. DOM instrumentation ran separately from timing samples.
Measurement Base Exact head
Median switch blocking, panel closed 68.8 ms 0 ms observed
Median largest frame gap, panel closed 100.0 ms 16.8 ms
Peak mounted timeline rows, two switch directions 105–114 19–21
Peak document DOM elements, same switches 3,384–3,776 1,161–1,355
Median switch blocking, markdown preview open 87.5 ms 7.3 ms
Median largest frame gap, markdown preview open 116.7 ms 33.4 ms

Blocking uses Long Animation Frame blockingDuration; zero means no observed long-frame blocking, not zero CPU or layout work. Distinct row keys mounted across an entire switch were 105/114 on base and 35/35 on head. Both settle at 16 rows with the panel closed. Normal paginated loading remains in place: “full history” here refers to all loaded rows, not every persisted event.

Panel Info/preview switching, tool expansion/collapse, wheel scrolling, and restoration passed on both builds, with approximately 17 ms largest frame gaps for those individual interactions. Restoration preserved the exact row key and viewport offset on each build. No sampled frame had an empty timeline on either build. Screenshots confirm equivalent rendered content and preview behavior, but do not demonstrate a blanking fix.

Control · Exact head (owner-authenticated live review instances).

Limits: synthetic fixture, warm revisits, shared host load, Chromium only; no matched cold-load, Safari/iOS, or reporter-machine measurement. The original 2–9 s delay is not claimed resolved. A browser-daemon restart interrupted one panel run; that run was discarded and rerun completely. Raw scripts, measurements, fixture hash, build/CI records, and screenshots are retained in the owning BB thread's storage with HANDOFF.md.

AGENT GENERATED

@ymichael
ymichael merged commit b4e0a94 into main Sep 30, 2026
20 checks passed
@ymichael
ymichael deleted the bb/fix-issue-4396-in-bb-thr_z3y7sfycq6 branch September 30, 2026 03:42
@SawyerHood SawyerHood mentioned this pull request Sep 30, 2026
2 of 3 tasks
bborn added a commit to bborn/bb that referenced this pull request Oct 12, 2026
Timeline responses over 200 rows were never cached, so long threads were
rebuilt on every request while blocking the event loop. Raise the timeline
cache cap under a total-row budget.

The thread-switch layout changes this commit used to carry are dropped:
upstream get-bb#4537 fixes the same problem in the same files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
bborn added a commit to bborn/bb that referenced this pull request Oct 12, 2026
Timeline responses over 200 rows were never cached, so long threads were
rebuilt on every request while blocking the event loop. Raise the timeline
cache cap under a total-row budget.

The thread-switch layout changes this commit used to carry are dropped:
upstream get-bb#4537 fixes the same problem in the same files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
bborn added a commit to bborn/bb that referenced this pull request Oct 13, 2026
Timeline responses over 200 rows were never cached, so long threads were
rebuilt on every request while blocking the event loop. Raise the timeline
cache cap under a total-row budget.

The thread-switch layout changes this commit used to carry are dropped:
upstream get-bb#4537 fixes the same problem in the same files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
bborn added a commit to bborn/bb that referenced this pull request Oct 14, 2026
Timeline responses over 200 rows were never cached, so long threads were
rebuilt on every request while blocking the event loop. Raise the timeline
cache cap under a total-row budget.

The thread-switch layout changes this commit used to carry are dropped:
upstream get-bb#4537 fixes the same problem in the same files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
bborn added a commit to bborn/bb that referenced this pull request Oct 22, 2026
Timeline responses over 200 rows were never cached, so long threads were
rebuilt on every request while blocking the event loop. Raise the timeline
cache cap under a total-row budget.

The thread-switch layout changes this commit used to carry are dropped:
upstream get-bb#4537 fixes the same problem in the same files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
bborn added a commit to bborn/bb that referenced this pull request Oct 22, 2026
Timeline responses over 200 rows were never cached, so long threads were
rebuilt on every request while blocking the event loop. Raise the timeline
cache cap under a total-row budget.

The thread-switch layout changes this commit used to carry are dropped:
upstream get-bb#4537 fixes the same problem in the same files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
bborn added a commit to bborn/bb that referenced this pull request Oct 23, 2026
Timeline responses over 200 rows were never cached, so long threads were
rebuilt on every request while blocking the event loop. Raise the timeline
cache cap under a total-row budget.

The thread-switch layout changes this commit used to carry are dropped:
upstream get-bb#4537 fixes the same problem in the same files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
bborn added a commit to bborn/bb that referenced this pull request Nov 3, 2026
Timeline responses over 200 rows were never cached, so long threads were
rebuilt on every request while blocking the event loop. Raise the timeline
cache cap under a total-row budget.

The thread-switch layout changes this commit used to carry are dropped:
upstream get-bb#4537 fixes the same problem in the same files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
bborn added a commit to bborn/bb that referenced this pull request Nov 4, 2026
Timeline responses over 200 rows were never cached, so long threads were
rebuilt on every request while blocking the event loop. Raise the timeline
cache cap under a total-row budget.

The thread-switch layout changes this commit used to carry are dropped:
upstream get-bb#4537 fixes the same problem in the same files.

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