Repository navigation
Give the timeline's reading position one owner so scrolling stops jumping - #5951
Merged
ymichael merged 7 commits intoOct 22, 2026
Merged
Conversation
Window timeline lists on iOS WebKit too. ScrollPositionKeeper (#5879) stays the only scroll writer, and it gains a hold mode for iOS. While a finger is down, momentum is running, or the edge is bouncing, it keeps the correction as a transform on the scroll content. It writes the correction to scrollTop once scrolling has been still for 150 ms. TanStack reads scrollTop plus the held offset, so the window matches what is on screen. Also: - Upgrade @tanstack/react-virtual to 3.14.20 (virtual-core 3.19.5) and drop the virtual-core 3.17.1 patch, which is fixed upstream. - Restore the saved reading row when a detached reader's scrollport changes width (iPad rotation), clamped to the row's new height. - Re-read the live scroll extent before treating a position past the cached extent as a return to the bottom. - While a saved-row restore waits for its row, park at the bottom instead of the scroll root's initial position. That position could keep loading older pages, all the way to the start of the thread. - Document browser scroll ownership in docs/timeline-pagination.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The timeline list sits in an AutoHeightContainer whose explicit height follows its content one ResizeObserver tick late. TimelineWindowedItems snapped it before TanStack's scroll writes, but since #5879 the ScrollPositionKeeper makes those writes and never snapped it. When an older page prepended rows, the keeper's correction was clamped to the old maximum: the reader lost their place and landed on the old bottom. The next scroll event then read that position as a return to the bottom, reattached, and the shell scrolled to the real bottom. The keeper now runs registered scroll extent syncs before any write past the current extent, and TimelineWindowedItems registers the auto-height snap. iOS hold timing is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ScrollPositionKeeper now owns each scroll root's reading position as explicit state: attached to the bottom, or a row key with its offset from the top of the visible viewport. Every layout change is reconciled against that position before paint, from ResizeObservers on the root, its content and each mounted row, and from each windowed list's commit. Targets are computed from the fixed position, never as relative deltas. - A scroll counts as the reader's only during an input session (wheel, touch and momentum, scroll keys, pointer held on the scroller). Any other scroll, such as a clamp, is reconciled back to the position. Attach and detach follow the reader's direction; layout never changes them. - Windowed lists render rows in normal flow between spacers sized from retained measurements, keyed to a row instead of scrollTop, and mount the reading row. A viewport over a spacer renders synchronously. - iOS keeps the transform hold during touch, momentum and bounce. - Thread switches restore the saved row through the same position, and the controller keeps the loaded pages of the eight most recent threads per query client so the row is there on return. Deleted: AutoHeightContainer and its snap plumbing, TanStack in the timeline, CSS bottom scroll anchoring, the shell's intent timers, bottom-restore settle tail, restore attempt loop, width-change restore path, shrink re-attach, content hold timer, and the detail scroller's own stick heuristics and smooth follow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…stable size A message mounted above the viewport by an older-page prepend rendered one frame without its Show more control, and phones then skipped the row under content-visibility with that shorter remembered size. The control arrived from the shared ResizeObserver a frame later, so every forced layout of the skipped row flipped it between the two heights and moved the reader by about 24 px while scrolling. Measuring in the layout effect puts the control in the row's first frame. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
WKWebView can drop a scroll correction that lands as a fling starts and apply it two frames later, which shows the wrong part of a windowed list for those frames. Until that is handled, iOS Safari and the mobile app's WKWebView keep every row mounted, matching main. The position keeper is unchanged; its iOS deferral still covers corrections from older pages and row resizes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ymichael
force-pushed
the
bb/investigate-timeline-windowing-on-ios-thr_tijtmv99as
branch
from
October 22, 2026 14:58
afb5e7c to
529b4a2
Compare
The windowed list renders every row while its scroll root has no usable geometry and windows again once it does, as on main. Saving the reading position now folds in a scroll the reader made whose scroll event has not landed yet, so unmounting right after a wheel keeps the row they scrolled to, while a layout-only change during unmount still keeps the end. Tests pin: no full-history mount while the scroll root is pending, rendering everything without usable geometry, starting at the end when pinned, a nested windowed list mounting above the reader, unmounting during a transient off-bottom layout and before the scroll event lands, and a logarithmic number of row measurements per scroll event. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The send button submits on pointerup and is replaced, so the tap's touchend never reaches the scroller. The keeper kept treating the touch as active and took the app's jump to the end for the reader's gesture, which armed the momentum window. The keyboard closing then clamped scrollTop and the keeper detached the reader at the end, so the reply stopped following. A touch now also ends on the last touch pointer's pointerup, caught on the window in the capture phase. Scrolling to the end ends the input session and resets the touch baseline. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ymichael
deleted the
bb/investigate-timeline-windowing-on-ios-thr_tijtmv99as
branch
October 22, 2026 19:29
ymichael
added a commit
that referenced
this pull request
Oct 23, 2026
… at the end (#6195) ## Human comments ## What was wrong #5951 made `ScrollPositionKeeper` the only owner of the timeline's reading position. In doing so it changed when the timeline counts as following the bottom (attached). Before, any scroll that left the view within 4 px of the end attached it. Since #5951 only a reader scroll down into the end attaches it, or a wheel or End/PageDown while already at the end. Anything else that left the view at the end kept the reader detached: the jump-to-bottom arrow showed even at the very bottom, and new output was not followed. Each case below is a regression from #5951. - **Opening an unread finished thread whose new reply fits on screen.** The NEW-divider reveal goes through `scrollTo`, which always recorded a row anchor. Rows that settled taller a moment later left the view short of the end with the last lines clipped. The anchor was also saved, so the next visit restored to that row. - **Window resizes near the end.** This covers a taller window, a closed side panel, a phone rotated to portrait, and a dismissed keyboard. The viewport grew and the browser clamped to the end, but the keeper kept the anchor. - **Restoring onto the end.** A saved position that restored onto the end stayed detached. - **Touch screens.** On Android and touchscreen Chrome, dragging toward the end while already at the end moves nothing and fires no scroll event. The jump button was the only way back. - **Saving the position.** `savedPosition()` saved a row whenever the reader was detached, even while sitting at the end. Returning after more output landed above it. ## What changed All changes are in `apps/app/src/components/ui/scroll-position-keeper.ts`: - `scrollTo` attaches when it lands at the end, like `revealElement` already does. - A reconcile after a viewport resize (width or height), or one that completes a pending restore, attaches when the reading position's target is at or past the end. - A touch drag of at least 8 px toward the end attaches when the reader is already at the end, like a wheel or PageDown. - `savedPosition()` saves a reader who is at the end as at the bottom. Kept from #5951: a detached reader whose content shrinks onto the end stays detached until they scroll toward it. `docs/timeline-pagination.md` describes the new attach rules and the save rule. Client only: no wire, CLI or plugin API change. ## How you verified - **Tests:** 7 new tests in `scroll-position-keeper.test.ts`. Five fail without the fix: the navigation clamp, viewport growth, a touch drag at the end, saving while at the end, and a restore onto the end. Two guards pass either way: a navigation above the end stays detached, and viewport growth that still leaves the reader's row on screen keeps them on that row. - **Commands:** `pnpm exec turbo run typecheck lint --filter=@bb/app` passes. The keeper, `bottom-anchored-scroll-body` and `TimelineWindowedItems` tests pass (61). - **Production data, headless Chrome at 1500×1040:** I served each build through a proxy in front of a real bb, with mark-read blocked. On a finished thread with only its last reply unread, main opened at the divider detached and settled 43 px short of the end with the last message clipped. This branch stayed at the end, attached, on every run. Unread content longer than a screen still stops at the NEW divider, detached, on both builds. - **Window resize, on a `start:worktree` instance:** I scrolled up 150 px near the end and grew the viewport from 900 to 1200 px. The build before #5951 attaches, main stays detached with the arrow showing, and this branch attaches. - **Sending after scrolling up:** after scrolling up 1,800 px and sending, the view jumps to the end and follows the streamed reply on this branch. - **Not run on a device:** the Android touch-drag fix is covered by its unit test only. Not changed: "Show more" on a long user message while following the bottom now keeps the bottom fixed and grows the message upward. Before #5951 it held the message's top and grew downward. That trade-off is left for a separate decision. > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Merged
ymichael
added a commit
that referenced
this pull request
Oct 24, 2026
## Human comments ## What was wrong `main` has 14 commits since 0.47.0, including #6195, which fixes the timeline staying detached at the bottom (a regression from #5951 that shipped in 0.47.0). `bb-app` and `@bb/desktop` were still at 0.47.0, so the publish and desktop workflows can't ship them. ## What changed - `packages/bb-app/package.json`, `apps/desktop/package.json`: 0.47.0 → 0.47.1 (`node scripts/bump-version.mjs --patch`). - No `CHANGELOG.md` or `RELEASE_META` entry: like earlier fix-only patches, these changes go into the 0.48.0 notes. The release commit sits directly on `b17bfc8fdd` (#6217). Everything below was tested on `22d41249ee`, and the sidebar was tested again on `b17bfc8fdd`. This release includes the daemon protocol bump from #6185 (251 → 252), so enrolled machines will update their daemon. ## How you verified - `node .github/workflows/check-version-lockstep.mjs`: `bb-app=0.47.1 @bb/desktop=0.47.1`. - Typecheck, tests and the `bb-app` tarball smoke run in CI on this PR, instead of locally. - `git diff --check`, and `oxfmt --check` on the changed files: clean. - Manual QA of `22d41249ee` with `pnpm start:worktree` (production bundle) and headless Chrome, on a fresh data dir: - **Timeline (#6195):** a long unread reply stops at NEW, detached. A short unread reply opens at the end with no jump arrow. Scrolling up 150 px and growing the viewport 900 → 1200 attaches. Scrolling up 400 px and growing it stays detached. Sending after scrolling up 1,800 px jumps to the end and follows the streamed Claude Code reply. The view is still at the end after a reload. - **Docs (#6146):** typing in a note while `bb docs pull`/`push` appended a paragraph kept both edits on disk and in the editor. A stale push after a UI edit was refused as a conflict. A new note was renamed from its first line and kept its Markdown after a reload. - **Skills (#6185):** `bb project commands` lists project skills from the documented roots for Claude Code and Codex, with no duplicate names. A Codex `/skill` turn ran the skill. - **Storage & retention (#6190, #6205):** two outside worktrees were listed. Bulk removal removed the clean one, kept its branch, and kept the dirty one. The table fits a 390 px viewport. - **Sidebar multi-select (#6191, #6217), on `b17bfc8fdd`:** with the experiment on, Cmd+Shift-click selected a second thread without navigating ("Actions for 2 threads"). Pressing it again on the same thread deselected it. Shift-click selected a range of 4. Escape cleared the selection. Cmd-click cleared the selection and opened a split. Bulk Pin applied to the two selected threads (checked with `bb thread list`). With the experiment off, Cmd-click opens a split. - **omp (#6186):** the picker labels GPT-5.6 Terra rows `openai` and `openai-codex`. Not exercised: the Ultrafast icon (#6198), because no Codex model on the test account offers Ultrafast. Also not exercised: the Android touch-drag attach, the desktop app, the SDK realtime reconnect (#6183) and retryable host RPCs (#6184). Those last two are covered by unit tests only. > 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
Oct 26, 2026
#6253) ## Human comments ## What was wrong **Scroll-to-bottom button shows while at the bottom.** Collapsing a tool call near the end, while scrolled up a little, clamps the view to the end, but the keeper stayed detached. It attached only through event-specific rules, and #5951 deliberately never attached on a content shrink. On touch the clamp usually falls inside the 3s momentum window after a drag, so that path missed too. Every attach bug since #5951 has had this shape: the view reached the end through a path no rule covered. **Unread threads did not open at NEW.** Where the view landed on open came out of five independent pieces: the read-state snapshot, the loaded rows, the divider's own one-shot scroll, the saved-position restore, and the keeper. Each assumed different timing: - Clicking an unread thread in the sidebar supplied placeholder data to automatic read tracking before the opening snapshot was ready. Marking it read erased the unread cutoff before the divider could capture it. - Reopening a thread first renders a cached copy that still reads as read. When the fresh copy made the thread unread, the divider was treated as a live reply and not revealed. - The first page holds the latest 8 segments on phone and 20 on desktop, and every user-side row starts a segment, including messages from other agents. When the cutoff was older than that page, NEW sat above the oldest loaded row, and then moved as older rows loaded. - The reveal used estimated heights for windowed rows. Rows rendering around it pushed NEW down the screen. - A thread marked unread put NEW above the oldest loaded row, which in paged history is not the thread's start. These predate #5951: the pre-#5951 build fails these cases as well. ## What changed Two structural changes replace the per-case rules. **One attach rule** (`scroll-position-keeper.ts`). A detached view within the 4px threshold of the end attaches, whatever put it there, unless a restore is still waiting for its row. - It attaches at once when the reader's scroll, a navigation, or a completed restore put it there. - It attaches on the next frame when only layout did, so content that shrinks and regrows within a frame does not attach. - This replaces the wheel-down, touch-drag, End/PageDown and resize/restore-at-end rules. The touchmove listener goes too. - Moving up out of the end still detaches, and content changes still never detach. - A view the reader never placed, such as a tool output box that was not streaming when it opened, is attached by layout only when the reader or a navigation brings it to the end, as on main. Otherwise output loading in after the box opens would pull it down. **One landing decision.** - `useThreadUnreadDividerState` takes its snapshot from the first fresh copy of the thread (`hasFreshThread` from `useThreadDetailThread`), never cached or placeholder data. - The same hook owns automatic read tracking and waits until the opening snapshot is ready before marking the thread read. Later refreshes retain that readiness, preserving normal manual-unread behavior. - `TimelineRowsList` decides once, against the loaded rows, whether the cutoff is inside them. If it is not, there is no divider, no automatic paging back, and it stays dropped when the reader pages back by hand. - If it is, the list lands through the keeper's existing restore path, with the divider as the anchor. The divider carries `data-scroll-landmark-id`, which the keeper can now anchor to like a row. The keeper then holds NEW at the top while rows render around it. A reader who already scrolled keeps their position. - Threads marked unread (no read time) get no divider and open like a read thread. The `before-first` placement is removed; `ThreadTimelineUnreadDividerPlacement` is now `{ cutoffAt }`. - Removed: the divider's own scroll effect and retry loop, and `scrollElementIntoViewClampedToMaxScroll` (only the divider used it). `docs/timeline-pagination.md` documents the attach rule and the landing decision. Client only; no wire, CLI or plugin API change. ## How you verified Latest sidebar-opening fix: - Reproduced in the worktree app by clicking an unread thread in the sidebar: NEW was absent and the timeline opened at the bottom. - Extended the existing randomized opening test to include cached sidebar placeholders and the real automatic read-tracking hooks and mutation. The test failed before the fix with “no NEW although the read point is in the first page” and passed after it. - `pnpm exec turbo run test --filter=@bb/app -- src/views/thread-detail/thread-opening.model.test.tsx src/views/thread-detail/useThreadUnreadDividerState.test.ts src/hooks/useThreadReadTracking.integration.test.tsx`: 14 tests passed, including 40 randomized opening sequences. - `pnpm exec turbo run lint typecheck --filter=@bb/app`: passed; lint reports warnings, no errors. `git diff --check` passed. - Rebuilt with `pnpm start:worktree` and repeated the actual sidebar click in Chromium. NEW remained visible after the thread was marked read and landed within 1px of the viewport top. Server and daemon health checks passed. Earlier branch verification (before the sidebar-opening fix): - Keeper tests: - attaches after a persisting shrink; - attaches after a collapse during momentum; - stays detached through a one-frame shrink; - attaches after a viewport grow, a restore landing, or a navigation at the end; - lands on a landmark and holds it at the top while a row above it resizes. - The touch-drag-at-end test was removed with its rule; the one-rule tests cover that case. - Divider tests: - snapshot from the fresh copy after reopening on cached read state; - no reveal for a reply after the thread settled; - a thread marked unread gets no divider; - a cutoff outside the loaded rows is dropped and stays dropped after older rows load. - New randomised test `scroll-position-keeper.model.test.ts`. - What it drives: random sequences of wheel and touch scrolls, row toggles held at the header, streaming, removals, prepends, regroups, one-frame shrinks, viewport resizes, navigations, restores and jumps to the bottom. It runs with and without iOS write deferral, and fires the browser's clamp scroll both before and after the resize callbacks. - What it checks after every step: - attached exactly when the view is at the end; - content changes never detach; - the reading row never moves without the reader, unless the content cannot hold it; - a reader's scroll is never moved. - On main's keeper, 75 of 300 sequences fail with "detached while at the end": 43 triggered by rows removed at the end, 13 by a toggle, and 19 in tool-output-box configuration. - On this keeper, 0 of 5,000 fail. CI runs 200 sequences (about 7s); set `KEEPER_MODEL_SEEDS` for deeper runs. - New randomised opening test `thread-opening.model.test.tsx`. - What it renders: the timeline with the thread view's own loading path. That covers the bootstrap and thread queries (moved into `useThreadDetailThread`, which `ThreadDetailView` now uses), the divider state, the timeline controller, the scroll body and the keeper. - The fake server pages a random history the way the real one does. - Each run picks a fresh open or a return after random time away, a random read state, phone or desktop page size, and a random order for the bootstrap, thread and timeline responses. Sometimes the reader scrolls while they load. - What it checks: NEW sits above the first unread row of the whole history; it is at the top unless the reader scrolled or the view is at the end; it shows whenever the cutoff is inside the first page; otherwise the saved position or the bottom stands. - Coverage over 200 runs: - NEW landed at the top 43 times (16 returns, 22 phone), with the view at the end 53 times; - opened at the bottom 70 times, and at a saved or scrolled spot 25 times; - the reader scrolled while loading 18 times. - Reintroducing each opening bug fails it: - trusting the cached thread copy (NEW left 2513px down after a return); - NEW above the first loaded row; - the one-shot reveal (NEW 156px above the top once real heights replace estimates). - CI runs 40 sequences (about 8s); set `OPENING_MODEL_SEEDS` for more. - `pnpm exec turbo run typecheck lint test --filter=@bb/app`: 647 files, 6312 tests passed. - Real-browser A/B against a live server: headless Chromium; phone runs at 402px with touch emulation. Each build was served through a proxy that rewrote an idle 46-segment thread's read state. "back" means switching to another thread and returning. Where NEW landed, relative to the viewport top ("bottom" = attached at the end with no divider): | Cutoff | Size | main fresh / back | branch fresh / back | Expected | |---|---|---|---|---| | After the last message | desktop | 0 / -231 | 0 / 0 | NEW at top | | After the last message | phone | 0 / -733 | 0 / 0 | NEW at top | | 2 segments back | desktop | 1 / -2627 | 0 / 0 | NEW at top | | 2 segments back | phone | 0 / -4587 | 0 / 0 | NEW at top | | 26 segments back | desktop | -4512 / -15548 | bottom / bottom | bottom | | 26 segments back | phone | -12197 / -10604 | bottom / bottom | bottom | | Marked unread | desktop | -16086 / -15629 | bottom / bottom | bottom | | Marked unread | phone | -14405 / -10604 | bottom / bottom | bottom | - Collapse bug A/B: | Scenario | main | branch | |---|---|---| | Desktop: wheel up 40px, then collapse | at end, detached (button shows) | attached | | Phone: touch drag 60px, then tap to collapse | at end, detached | attached | | Wheel up 200px / drag 250px, then collapse | stays detached, 106 / 157px from end | same, header in the same place | - Guards, identical on main and branch: - wheeling back through history: 24 steps, 0 jumps; - switching away and back restores the same row at the same offset (-358); - a mid-thread toggle keeps the header fixed (443 → 443 → 443); - scrolling up 300px detaches and shows the button, and scrolling back down re-attaches and hides it. > AGENT GENERATED --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
ymichael
added a commit
that referenced
this pull request
Oct 28, 2026
…6434) ## 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 old `bottom-anchored-scroll-body.tsx`). Since #5951, `ScrollPositionKeeper.handleScroll` treats any scroll with no input and no size change as navigation. It handles it exactly like a reader scroll: - it detaches a view at the bottom when it moved up; - it cancels a pending restore; - it sets `userScrolled`, which skips the NEW-divider landing; - it opens a 150 ms input window, so the next few scrolls also count as the reader's. 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`: - A scroll with no input and no size change now counts as layout, and the keeper puts the view back, when the view is attached to the bottom or a restore is waiting for its row. It no longer detaches, cancels the restore, or marks the reader as having scrolled. - A detached view still follows such a scroll as navigation, so find in page keeps working while reading history (`bottom-anchored-scroll-body.test.tsx` already covers that case). - While the desktop window find bar is open, an attached view also follows these scrolls, so find works from the bottom. `WindowFindHost` dispatches `bb:window-find-open` (`apps/app/src/lib/window-find.ts`) when it opens the bar, and the keeper resets when the window regains focus. - Tab counts as input, so moving focus to an offscreen control still navigates. - The scroll-extent floor from #6405 stays. It still keeps a detached reader within a collapse's height of the end in place. The model test fails with "the reading row moved … without the reader" when the floor is removed. `docs/timeline-pagination.md` describes 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`: - an attached view stays at the end on a no-input scroll; - a pending restore survives a no-input scroll; - the find bar lets an attached view follow, and window focus ends that. - Tab: passes on main too, as a guard. - `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: - open and sit idle: 10 runs each; - leave and come back: 10 runs each; - re-insert or replace 25–96 links and code elements mid-run: 12 runs each; - real Maestro swipes, then leave and come back: 2 runs each; - real typing in the composer: 2 runs each. - Results were identical on both builds: - no detach without input, and no run ended away from the bottom; - a swipe up detaches; - a return restores the same row within 10 px; - typing stays attached. 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). > 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
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 3, 2026
## Human comments ## What was wrong `@bb/app` had grown to 657 test files and 6,809 tests. Many tests checked a contract that another test already covered more strongly. Others only exercised wiring, tested a third-party library, or held assertions that could not fail. A few production `export`s and one parameter existed only for these tests. This made the suite slower to run and maintain without catching any extra bugs. ## What changed Test files only, apart from removing test-only exports. Net −1,077 test lines across 58 files (+290 / −1,367), four whole files deleted, and 6,809 → 6,750 tests. Production changes are +8 / −11 across 7 files, with no behaviour change. **Removed** - **Duplicates:** the raw-thread-id title tests that #5261 copied into `ThreadTitleMentions.resources.test.ts` but never removed from the original. Also sibling tests repeating the same setup and assertion, and mocked copies of scenarios that already run through the real code: `composer-submissions`, `app-toast-title-overflow`, OnboardingGate, AddMachineDialog expiry, ToolsView banners, provider-icon, plugin-slots, the cache-owner rename, pin acknowledgement, the CommandPalette settings page, QuestionForm, and the PromptBox/composer-contract rejection. - **Wiring and constant pins:** small helpers tested directly when their only caller is tested (`resolveUrlOpenTarget`, `parseLifecycleError`, `buildAudioInputConstraints`, `resolvePaneArrangementLabel`); realtime registry rows that `satisfies Record<…>` already enforces at typecheck; a snapshot-identity check covered by a stricter structural-sharing test. - **Third-party only:** `src/test/virtualizer-scroll-lifecycle.test.tsx` tested `@tanstack/virtual-core` and guarded a repo patch that #5951 removed. Upstream now cancels the timer itself. - **Vacuous:** a lifecycle-error row varying `hasPath`, which no code reads; BrowserTabDeck rows that pass either way; a FollowUpPromptBox placeholder test whose two placeholders were the same string; a dead `vi.mock` of a module the code under test never imports. - **Test-only production seams:** dropped `export` from `buildAudioInputConstraints`, `buildDevWebSocketUrl`, `resolveUrlOpenTarget`, `parseLifecycleError`, `threadTitleTextSegments` and `resolvePaneArrangementLabel`. Removed `getSecondaryPanelChromeStackClassName`'s `hasGitDiffToolbar` parameter; its only caller passed `false`. **Repaired** (assertions that could not fail) - `plugin-bound-sdk`: the test promised cache updates but only checked call shape. It now asserts that a created section reaches the sidebar cache before `create` resolves. That behaviour (#5045) had no test before. - `split-layout/ops`: `if (root.type === "split")` guards could skip every resize-clamp assertion; they now throw on a non-split root. - `provider-icon`: `toBeDefined()` on a non-optional return replaced with real `ariaLabel` checks. - `use-composers`: the test named "lock or paint" now also exercises `setTextEffect`. - `ThreadMetadataContent`: `path: null` let the "provisioning" test pass without its status check. - Terminal UTF-8 split glyph: this tested the browser's `TextDecoder`. It now writes through `writeTerminalOutput` into a real xterm. - Early `focusEnd`, the voice transition while hidden or under reduced motion, and the model-picker cycle-chord exception could all pass with the guarded code removed. They now fail when it is. - `dev-websocket-url` now goes through `buildBrowserWebSocketUrl`, which also covers the production fallback URL. ## How you verified - **Mutation checks.** Three independent reviewers worked on dedicated worktrees of `main` and of this branch. For every removed or merged test, they wrote the bug it caught as a mutation of the production code. They confirmed the old test fails on `main` and that a remaining test fails on this branch, then restored the source. - About 110 mutations were run. 18 removals turned out to be the only guard on their contract; 16 of those were restored. - The most important restoration: a known raw thread id must display as its title through the synchronous `resolveThreadTitleDisplayText`. The rendered pills hide this bug, but the AppLayout title, archived-threads settings and the parent-thread picker show it. - Other restorations: the Meta+Enter `aria-keyshortcuts` label, QueuedMessagesList open/close reporting and overflow toggling, older touch actions at the former width threshold, the touch-selection menu side (#6567), the terminal-view unmount, the plugin update-action icon, the marketplace icon in AddPluginDialog, the ReuseEnvironmentPicker secondary text, the app chrome row-height token, the focused notification on title Show more, the mapper's unread-error indicator, the `useThreadStorageLocation` fetch, the thread invalidation `maxWait` bounds, and the sidebar info-tab id. - Two gaps were left out on purpose: the `hasPath` lifecycle row (no code reads `hasPath`) and a single `shrink-0` class pin. - Each repaired assertion was shown to fail under a mutation that the old assertion let through. - **Baseline** at 51d8ddc: `pnpm exec turbo run test --filter=@bb/app` ran 6,809 tests, with 6 failures at machine load ~89. All six pass when run alone or at normal load. - **After rebasing onto origin/main:** `pnpm exec turbo run lint typecheck test --filter=@bb/app` gave 0 lint errors, a clean typecheck, and 6,740 of 6,750 tests passing (9 skipped). - The one failure, `CommandPalette` "runs an available shortcut … after closing and restoring focus", timed out opening the palette at load ~79. It failed the same way in the baseline run on `main`. - It passes in five isolated reruns, two of them uncached (`--force`). 🤖 Generated with [Claude Code](https://claude.com/claude-code) > AGENT GENERATED 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
The timeline's scroll position had about ten independent owners, and each one corrected scrollTop on its own:
AutoHeightContainer, which applied its height a frame late;overflow-anchor, which Chrome applies and Safari does not;When two of them disagreed in a frame, the reader saw a jump. Examples:
Attach and detach were inferred from scrollTop, so a layout change could flip them.
What changed
ScrollPositionKeeperis the one owner of the reading position. It stores the position as explicit state: attached to the bottom, or a row key plus its offset from the top of the viewport.AutoHeightContainerand its snap plumbing;docs/timeline-pagination.mddescribes the model.How you verified
Sweep on production data. A read-only snapshot of a production bb database was served through the built app and driven by an automated harness. A per-frame detector measured each visible row's on-screen position, and the harness compared origin/main against this branch.
The breadth pass took every thread longer than one page and ran wheel-up, a medium fling-up, and scroll to top and back, at 1280 px desktop and at phone width.
Curated threads ran the full scenario matrix:
They ran at 1280 and 1600 desktop and at phone width with touch. These threads are clean apart from the residuals below. The detector flagged a few more items, and screencasts of the painted frames show they are not visible movement.
A cell counted only if its input reached the page, scrollTop travelled at least 100 px, and it rendered at 20 fps or more.
Perf, origin/main → this branch. Chrome trace of a long scroll, median of 3 runs. Desktop: 80 wheel steps at 1280 px. Phone: 8 flings at 4× CPU throttle.
iOS (windowing off, as on main), cells with issues:
Send, attached and detached: all attempts are counted.
A streamed reply after the send isn't covered, because the snapshot server has no host.
Commands:
pnpm exec turbo run typecheck lint test --filter=@bb/apppasses (646 files, 6,258 tests). Regression tests cover the windowed list's startup (scroll root pending, no usable geometry, start at the end), unmount saves, nested lists, the anchor loss when windowing activates, the clamp snap, thread-switch restore and spacer coverage, and each fails without its fix.Known residuals:
🤖 Generated with Claude Code