Skip to content

Keep outline jumps on target with timeline windowing - #4217

Merged
ymichael merged 2 commits into
mainfrom
bb/fix-outline-jumping-in-timeline-windowing-thr_vxftsyhutj
Sep 23, 2026
Merged

ymichael merged 2 commits into
mainfrom
bb/fix-outline-jumping-in-timeline-windowing-thr_vxftsyhutj

Conversation

@ymichael

@ymichael ymichael commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

With the Timeline windowing experiment enabled, clicking a conversation-outline entry often failed to land on the message. Two independent causes:

  1. Loaded-but-unmounted targets were treated as not loaded. The outline calls onNavigateToRow(id) so the virtualizer adds the destination to alwaysMountedKeys, then immediately searches the DOM for [data-timeline-row-id] — synchronously, before React renders the forced row. The row was never found, so the jump either gave up (no older pages) or fell into the pagination loop and loaded an older page it didn't need.
  2. The virtualizer reverted jumps into freshly paginated content. TanStack Virtual caches scrollOffset and only refreshes it from scroll events, which the browser delivers asynchronously. After scrollIntoView, a row resized in the same frame (common right after older pages load); resizeItem → applyScrollAdjustment then called scrollTo(staleOffset + delta), pulling the viewport back to roughly where it started. Instrumented live: scrollIntoView put the target at offset 0, and the next write was scrollTo({top: 31880}) from applyScrollAdjustment.

What changed

  • apps/app/src/components/thread/toc/ThreadTableOfContents.tsx: when the destination is already in the loaded timelineRows, wait up to the existing TOC_JUMP_RENDER_FRAMES budget for it to render before falling back to older-page pagination. The per-page wait reuses the same helper.
  • apps/app/src/components/ui/bottom-anchored-scroll-body.tsx: scrollElementIntoView dispatches a synchronous scroll event on the scroll area when scrollIntoView moved it, so scroll observers (the virtualizer's cached offset in particular) see the new position before any same-frame resize adjustment.

App-only; no wire changes.

How you verified

  • Regression tests, each failing on main and passing with the fix:
    • ThreadTableOfContents.test.tsx — waits for a loaded but unmounted message to render instead of paginating
    • bottom-anchored-scroll-body.scroll-preservation.test.tsx — notifies scroll listeners synchronously when revealing a row moves the viewport
  • pnpm exec turbo run test typecheck lint --filter=@bb/app — 5054 tests passed; lint has only pre-existing warnings.
  • Live app via pnpm start:worktree on a seeded 8,624-event thread (206 user messages, windowing on, 1,500-event pages). Fresh load per case, one outline click, target offset sampled every frame for 5s:
Case main (2d5d5e3) This PR
Loaded but unmounted (user-seed:7836) unneeded older-page fetch on click; one run ended −4,586px lands at 14ms, no jump-driven fetch, holds at 0
One older page (user-seed:7542) lands lands, holds at 0
Five older pages (user-seed:4327) ends −27,083px away lands at ~500ms, holds at 0
Ten older pages (user-seed:141) ends −54,003px away lands at ~1s, holds at 0

The PR column was consistent across two full runs.

Fixes: N/A — reported directly; no issue filed.

AGENT GENERATED

🤖 Generated with Claude Code

ymichael and others added 2 commits September 23, 2026 13:56
With timeline windowing enabled, clicking a conversation outline entry
for a loaded but unmounted row asked the timeline to mount it and then
searched the DOM synchronously, before React rendered it. The jump was a
no-op when no older pages existed, and otherwise loaded an unneeded older
page before scrolling.

The outline now waits up to the existing render-frame budget for a loaded
row to appear before falling back to older-page pagination.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The timeline virtualizer caches its scroll offset from scroll events. When a
row resized in the same frame as the outline jump, its scroll adjustment used
the pre-jump offset and pulled the viewport back to where it started.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael ymichael changed the title Wait for windowed outline targets to render before paginating Keep outline jumps on target with timeline windowing Sep 23, 2026
@ymichael
ymichael merged commit bb34cef into main Sep 23, 2026
18 checks passed
@ymichael
ymichael deleted the bb/fix-outline-jumping-in-timeline-windowing-thr_vxftsyhutj branch September 23, 2026 21:13
ymichael added a commit that referenced this pull request Sep 23, 2026
## Human comments

## What was wrong

Timeline row windowing (#2011) only ran when the `timelineWindowing`
experiment was turned on, and it was off by default. So long timelines
and large expanded details still mounted every row. The known
outline-jump bug with windowing on was fixed by #4217, which is already
on `main` (bb34cef), so nothing else was holding back the rollout.

## What changed

- **App:** `ThreadTimelineSurface` no longer reads the experiment from
system config. I removed the `timelineWindowingEnabled` prop and context
from `ThreadTimelineRows` and the `enabled` prop from
`TimelineWindowedItemsLoader`/`TimelineWindowedItems`. Windowing still
falls back to fully mounted rows below the per-list thresholds (60/40
top-level, 20 nested) or when there is no usable scroll root. Outline
and search navigation targets now always stay mounted.
- **Experiment key:** removed `timelineWindowing` from `@bb/domain`
experiments, the Settings → Experiments toggle, and the test fixtures.
Legacy stored rows are ignored, as before.
- **Docs:** `docs/configuration.md`, the bb-guide customization
template, and the bb-cli `app-settings.md` reference now describe
windowing as standard behavior. The verify-bb settings recipe lists the
remaining experiments.
- **Plugin SDK:** bumped to `0.5.20`, because the experiment keys are
part of its bundled declarations. Same as #2772 and #3424.
- No host-daemon wire changes.

## How you verified

- I deleted the tests for the experiment-off path. The remaining
windowing tests now run without a flag.
- `pnpm exec turbo run typecheck lint test --filter=@bb/app
--filter=@bb/server --filter=@bb/desktop --filter=@bb/cli
--filter=@bb/db --filter=@bb/domain --filter=@bb/plugin-api-map
--filter=@bb/templates` passed (25/25 tasks; app 557 files, server 299
files). Lint shows only pre-existing warnings.
- `node .github/workflows/check-plugin-sdk-version.mjs` passed.

Related: #2011 (added the experiment), #4217 (outline-jump fix under
windowing, merged).

> 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