Skip to content

Restore lost scroll regression tests and fix two bugs they found - #6437

Merged
ymichael merged 1 commit into
mainfrom
bb/restore-lost-scroll-tests-thr_zb7zgnd6bb
Oct 28, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/restore-lost-scroll-tests-thr_zb7zgnd6bb

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

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:

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 Keep an attached timeline at the end through scrolls with no input #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

#5951 and earlier rewrites deleted about 200 scroll-related regression
tests. An audit marked each one not about scrolling, covered by a current
test, obsolete, or a gap. The gaps were rewritten against the current keeper,
gated (each kept test fails under a mutation that reintroduces its bug), and
moved into their owner test files.

Two restored tests failed on main:
- A scroll with no input on a detached view, such as find in page, was undone
  when a re-render reconciled before its scroll event arrived. apply() now
  takes such a scroll as navigation, except a clamp onto the end of shrunken
  content, which stays layout.
- When a hidden pane regained height, windowed spacers kept estimated heights
  instead of the heights measured while every row was mounted, so the scroll
  extent jumped later. The window state now refreshes them on that change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ymichael
ymichael merged commit 24847ae into main Oct 28, 2026
51 checks passed
@ymichael
ymichael deleted the bb/restore-lost-scroll-tests-thr_zb7zgnd6bb branch October 28, 2026 16:55
ymichael added a commit that referenced this pull request Oct 28, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ymichael ymichael mentioned this pull request Oct 28, 2026
ymichael added a commit that referenced this pull request Oct 28, 2026
## Human comments

## What was wrong

`main` has 134 commits since 0.47.0, and 0.47.1 shipped without notes.
`bb-app` and `@bb/desktop` were still at 0.47.1, so the publish and
desktop workflows can't ship them.

## What changed

- `packages/bb-app/package.json`, `apps/desktop/package.json`: 0.47.1 →
0.48.0 (`node scripts/bump-version.mjs --minor`).
- `CHANGELOG.md`: the 0.48.0 section, written as a quality and
performance release and covering everything since 0.47.0, including
0.47.1. Sections: Reliability, Performance, Usability, New experiments
(early adopter set only), Other improvements, Bug fixes, Plugins, and
Thanks (7 external contributors). The only numbers in it are
deterministic payload and memory figures; single-machine measurements
were left out.
- `changelog-metadata.ts`: the 0.48.0 `RELEASE_META` entry (October 28,
2026, "Faster loading, lighter live updates, and a long list of fixes").

The release commits sit directly on `24847ae036`, the current `main`
(including #6437, whose two scroll fixes are in Bug fixes).

## How you verified

- `node .github/workflows/check-version-lockstep.mjs`: `bb-app=0.48.0
@bb/desktop=0.48.0`.
- On `f8c0701e94` (before rebasing onto #6437; CI covers the rebased
branch): `pnpm exec turbo run typecheck test --filter=@bb/app
--filter=@bb/config --filter=@bb/server --filter=bb-app`: 16 of 17 tasks
passed. `@bb/server` had 3 timeouts in
`test/services/plugins/builtin-plugins.test.ts` under load; that file
passes 28/28 when run alone.
- `pnpm exec turbo run smoke:tarball --filter=bb-app --force`: 62/62
tasks passed.
- `apps/app` `changelog-preview.test.ts`: 7/7 passed. Prettier check on
`CHANGELOG.md` and `changelog-metadata.ts` and `git diff --check`:
clean.

> AGENT GENERATED

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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