Repository navigation
Keep an attached timeline at the end through scrolls with no input - #6434
Merged
Merged
Conversation
Since #5951 the keeper treated any scroll with no input and no size change as navigation and followed it, so a stray native scroll detached a view at the bottom, cancelled a pending restore, and skipped the NEW landing. #6405 removed the two known sources; this removes the class. A view attached to the bottom, or waiting on a restore, now reconciles such a scroll back like layout. Detached views still follow it, so find in page keeps working while reading history. The desktop window find bar dispatches bb:window-find-open, and until the window regains focus an attached view follows find too. Tab counts as input, so focus moving to an offscreen control still navigates. The scroll extent floor stays: it keeps a detached reader near the end from being moved by a one-task collapse, which the model test catches without it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ymichael
deleted the
bb/fix-scrolling-logic-regressions-thr_zb7zgnd6bb
branch
October 28, 2026 05:42
ymichael
added a commit
that referenced
this pull request
Oct 28, 2026
## Human comments ## What was wrong #5951 rewrote timeline scroll ownership, and it and earlier rewrites deleted many regression tests that previous scroll-bug fixes had added. I listed the tests added by the 50 commits that changed the scroll code since May and checked which still exist on main: 200 of the missing ones were scroll-related. Restoring the uncovered ones against the current keeper found two live bugs: - **Find in page undone (L007).** On a scrolled-up timeline, a scroll with no input (find in page, a focus jump) was written back when a reconcile ran before its scroll event. `ScrollPositionKeeper.apply()` only took in an unexplained scroll during an input session, and `TimelineWindowedItems` reconciles in a layout effect after every commit. So any re-render in that frame, typically while a thread streams, undid the jump. In headless Chrome on a streaming thread, 1 of 5 such jumps snapped back. This contradicted the documented rule that a detached view follows navigation. - **Scroll height jump after a hidden pane appears (L034).** While a scroll root has no height, every row mounts and is measured. When it regained height, windowing resumed with the spacers from the window state captured at mount, so the spacers used estimates. The extent was wrong (20,762 px vs 28,322 px in the test) until the window keys next changed. ## What changed - `scroll-position-keeper.ts`: `apply()` now treats an unexplained scroll outside an input session as navigation, for views that follow navigation (detached, or the desktop find bar open). It takes the position from the screen, marks the reader as having scrolled, and drops any pending restore. A clamp onto the end of shrunken content stays layout. - `TimelineWindowedItems.tsx`: when the scroll root goes from no height to having one, the window state refreshes its heights from the retained measurements (`knownHeights`, shared with the existing window update). - **Restored tests.** Each was gated with the test-audit rules, and every one kept fails under a mutation that reintroduces its bug: - `scroll-position-keeper.test.ts`: 11 tests, plus 1 folded into an existing test. - `bottom-anchored-scroll-body.test.tsx`: 6. - `TimelineWindowedItems.test.tsx`: 4, two of them folded in. - `ThreadTimelineRows.system-summary.test.tsx`: 1, the streaming detail scroller. - `thread-opening.model.test.tsx`: 1, a live reply adding NEW above an attached view. - **Dropped:** restored tests that duplicated current coverage, that no mutation could make fail, or that asserted implementation (class names, listener counts). - `test/fake-flow-layout.ts`: `flushResizeObservers` reports the scroll element's own size, so viewport shrinks reach the keeper. - `docs/timeline-pagination.md`: reconciliation step 1 and the hidden-pane windowing rule. Audit totals for the 200 lost tests: - 94 not about scrolling; - 37 covered by a current test, each cited by exact title; - 28 obsolete; - 36 gaps, which became the restored tests; - 5 failed on main: L007 and L034 above, plus three left as they are: - L030: a header scroll-to-top whose first smooth frame lands within 4 px of the end re-attaches; - L049 and L078: scroll handlers read `scrollHeight` and `clientHeight` on each scroll event, which #5951 introduced on purpose. Client only; no wire, CLI or plugin API change. ## How you verified - The L007 tests fail on the pre-fix keeper (`f8c0701e94`) and pass here. So does L034 against the pre-fix `TimelineWindowedItems`. - Each kept test was run against its listed mutation, and the production code was restored byte for byte afterwards. - `pnpm exec turbo run typecheck lint test --filter=@bb/app`: passes (643 files, 6,369 tests; lint has 0 errors). - **Before this change, headless Chrome comparisons of pre-merge main against #6434** gave identical results on real long threads. They covered: - open, then 45 wheel steps up through older pages with no jumps; - leave and return to the same row; - window resize near the end; - PageUp/End; - table-of-contents reveal; - phone swipe, drawer close and header scroll-to-top; - NEW landing at the top on desktop and phone. > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
ymichael
added a commit
that referenced
this pull request
Nov 2, 2026
…ead (#6832) ## Human comments ## What was wrong The timeline's scroll keeper tells the reader's scrolls apart from layout shifts by listening for `wheel`, touch, pointer and key input on the timeline. An iframe in the timeline (inline-vis, docs embeds, PDF previews) receives its own wheel events, so when the browser chains a scroll from the frame to the timeline, the timeline scrolls with no input it can see. While attached to the bottom, `handleScroll` treated that as an unexplained displacement and wrote the scroll back to the end, so small trackpad scrolls over the last preview could not leave the bottom. Investigation: https://get-bb.github.io/reports/issues/6740.html ## What changed `apps/app/src/components/ui/scroll-position-keeper.ts`: `followsUnexplainedScroll()` also follows a scroll without visible input while an iframe in the timeline matches `:hover`, like it already does while the window find bar is open. Hover is read when the scroll arrives instead of being tracked from pointer events, so a frame that is removed or re-rendered under a resting pointer leaves no stale state. The rest of #6434's rule is unchanged: with no hovered frame, an attached view still snaps back. This takes the issue's "more general option" rather than its proposed postMessage wheel bridge in inline-vis, so it covers every embedded frame (inline-vis, docs embeds, PDF previews) and needs no cooperation from the frame. It does not cover touch scrolling over a frame, browser find on the web, or VoiceOver, which #6434 already listed as pulled back at the bottom. ## How you verified - New keeper tests: an unexplained scroll while a frame is hovered is followed (fails without the fix); a hovered frame that leaves the timeline does not keep following scrolls. All keeper tests pass (`pnpm exec turbo run test --filter=@bb/app -- src/components/ui/scroll-position-keeper.test.ts src/components/ui/scroll-position-keeper.model.test.ts`). - Headless Chrome on the report's source harness, programmatic 300px scroll with no input: pointer over text snaps back; pointer over the iframe follows; pointer moved back to text snaps back again. - `pnpm exec turbo run typecheck lint --filter=@bb/app`: no errors. - Real app (`pnpm start:worktree`, Claude Code thread whose last message is a 1600px inline-vis), headless Chrome, 30 wheel steps of `deltaY: -8` with the pointer over the iframe from the bottom: before 1514 → 1514 (stuck), after 1514 → 1274. - Source harness from the investigation report (real keeper + inline-vis `frameDocument`): before 1800 → 1800, after 1800 → 1560, matching scrolling over host text. Not verified: touch scrolling over an iframe on iOS/Android, which may have the same gap since touch events inside the frame also never reach the timeline. Fixes #6740 > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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
#5951 changed what a scroll with no input means. Before, such a scroll could never detach the timeline from the bottom (
if (!hasRecentUserScrollIntent()) return;in the oldbottom-anchored-scroll-body.tsx). Since #5951,ScrollPositionKeeper.handleScrolltreats any scroll with no input and no size change as navigation. It handles it exactly like a reader scroll:userScrolled, which skips the NEW-divider landing;iOS WebKit makes such scrolls on its own. The Discord reports ("jumps up 225 pixels after a few idle seconds", "coming back to a thread it lands randomly up") came from two of them. #6405 removed both triggers: a collapse and regrow within one frame, and markdown links being recreated. The rule stayed, though, so any stray scroll we haven't found still detaches the view.
What changed
apps/app/src/components/ui/scroll-position-keeper.ts:bottom-anchored-scroll-body.test.tsxalready covers that case).WindowFindHostdispatchesbb:window-find-open(apps/app/src/lib/window-find.ts) when it opens the bar, and the keeper resets when the window regains focus.docs/timeline-pagination.mddescribes the rule, the find-bar signal and Tab.Trade-off: browser find on the web (no signal) and VoiceOver scrolling are pulled back while the view sits at the very bottom, as before #5951.
Client only; no wire, CLI or plugin API change.
How you verified
New tests. 4 of them fail on main's keeper:
scroll-position-keeper.test.ts:scroll-position-keeper.model.test.ts: a new random step fires a scroll with no input. On main it fails with "a content change detached the reader".The model test passes 2,000 sequences (
KEEPER_MODEL_SEEDS=2000).pnpm exec turbo run typecheck lint test --filter=@bb/app: passes (643 files, 6,347 tests; lint has 0 errors).iOS 26.5 Simulator Safari, main vs this branch, alternating runs against real long threads through a proxy that blocks mark-read and sends:
Results were identical on both builds:
Current main does not reproduce a stray scroll on iOS in these flows. This change guards against new sources rather than fixing a visible bug on main.
Not checked: VoiceOver, and the desktop find bar in Electron (covered by a unit test only).
🤖 Generated with Claude Code