Skip to content

Preserve thread scroll position when older rows load - #1975

Merged
ymichael merged 1 commit into
mainfrom
bb/investigate-localhost-refresh-issue-thr_5ne6vjr4e3
Aug 19, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/investigate-localhost-refresh-issue-thr_5ne6vjr4e3

Conversation

@ymichael

@ymichael ymichael commented Aug 19, 2026 •

Copy link
Copy Markdown
Collaborator

What was wrong

When an older timeline page was prepended, BottomAnchoredScrollBody tried to restore the captured viewport in its layout effect while AutoHeightContainer still exposed the previous wrapper height. The later ResizeObserver height update happened after that compensation opportunity, so Chromium clamped the scroll position to the old maximum and left the viewport on an older message as the full prepended height appeared.

What changed

The timeline height snap revision now includes the leading row identity. A paginated prepend therefore snap-syncs AutoHeightContainer during the same commit, before the parent scroll body's layout effect measures the added height. Streaming growth and the existing completed-turn topology revision remain unchanged. A focused regression test covers a leading-row prepend while the latest completed turn stays constant.

No wire, daemon protocol, CLI, or configuration changes.

Before and after

Before After
Before: loading older rows moves the viewport After: loading older rows preserves the viewport

How you verified

  • The new regression test fails on the previous code (200px remained stale instead of snap-syncing to 400px) and passes with this change.
  • Reproduced against a worktree-local SQLite copy of the affected 9,753-event thread, without navigating to or mutating the production thread.
    • Before: six prepended rows changed scrollTop from 553 to 1,353 and replaced the visible row.
    • After: scrollTop compensates from 553 to 2,923 while the same visible row remains at exactly -426px.
  • pnpm exec turbo run test --filter=@bb/app --force: 410 files passed, 3,138 tests passed, 3 skipped.
  • Focused scroll/height suite: 5 files passed, 28 tests passed.
  • pnpm exec turbo run typecheck --filter=@bb/app.
  • pnpm exec turbo run lint --filter=@bb/app (0 errors; existing warnings only).
  • Manual Chromium before/after recording on the isolated worktree dev app.

Fixes: no linked issue.

AGENT GENERATED: by GPT-5.6 Codex

@bb-slop-cop

bb-slop-cop Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

🚨 SLOP COP 🚨 · review

I am SlopCop. I am reviewing this pull request for security, code quality, performance, architecture, and product behavior.

@bb-slop-cop bb-slop-cop Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 SLOP COP 🚨 · review

Plain English summary: This change keeps the current message in place when bb loads older thread history. It updates the timeline height before scroll restoration.

I found no blocking issue and no changed line that needs an inline comment.

  • Security: The key contains only row identifiers and sequence values. It does not expose message content or private paths.
  • Code quality: The change uses the existing height revision contract. The focused test covers the new height update.
  • Performance: Each leading-row change adds one synchronous height read. It does not add an observer or a repeated measurement loop.
  • Architecture: The existing parts keep clear roles. The code search found no duplicate implementation or useful refactor for this change.
  • Tests: Eight focused tests passed. The app type check passed. All GitHub checks passed at this SHA.
  • Product test: I did not run the browser test. Parallel test tasks overloaded the review host and made timed results invalid.

A future test can assert the final scroll position through the full scroll container. I do not require that test for this change.

The GPT-5.6 review gate returned APPROVE.

@ymichael
ymichael merged commit 4792abf into main Aug 19, 2026
12 checks passed
@ymichael
ymichael deleted the bb/investigate-localhost-refresh-issue-thr_5ne6vjr4e3 branch August 19, 2026 23:59
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