Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): settle the measured end when a thread first opens #26028

Closeddiddletime(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/26028/headopened View on GitHub

The first-open path treats initialScrollAtEnd as finished positioning and skips correction against measured row heights. When the initial estimate is short, the thread can stop above its real end.

Start the list unpositioned and run measured-end settling on the initial restore, including when the list supplied the initial scroll. A regression that stopped at 2,000 px now reaches the measured 4,200 px end.

Addresses the initial-opening path in #26016. Other intermittent sync-related jumps remain tracked there.

Verified with vp run check:changed, the failing-before restore regression, and an isolated 80-message thread. The images below exercise the same restore helper in a deterministic browser fixture with a 4,760 px measured end. Browser recording.

BeforeAfter
Restore stops at the estimateRestore reaches the measured end

Created with gpt-6-astra-ultrafast in Codex through T3 Code.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. Review in Change Stack →

      No actionable comments were generated in the recent review.

      Recent review info
      Run configuration
      Commits

      Reviewing files that changed from the base of the PR and between dc84b0962efa4f4e05ef392c08986a9cd7c994d1 and 0f0947856ff0ecd9c20683fed8f1c4c71f16ee29.

      Files selected for processing: 3
      • apps/web/src/components/chat/MessagesTimeline.tsx
      • apps/web/src/components/chat/useTimelinePositionRestore.test.ts
      • apps/web/src/components/chat/useTimelinePositionRestore.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

      Walkthrough

      The timeline now initializes without a positioned thread key. When the remembered position is not before the end, restoration settles at the measured end, including when no initial scroll was requested. A test verifies the measured offset after 100 ms.

      Changes: Timeline restoration

      Layer / File(s)Summary
      Initialize and settle the timeline at the end
      apps/web/src/components/chat/MessagesTimeline.tsx, apps/web/src/components/chat/useTimelinePositionRestore.ts, apps/web/src/components/chat/useTimelinePositionRestore.test.ts
      positionedThreadKey now starts as null. End settlement no longer requires an initial scroll operation. The test checks that the list scrolls to the measured end offset after 100 ms.
      Priority: Normal

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Bug fix

      Possibly related issues

      • pingdotgg/t3code#26016 — The issue reports that long threads can open above the latest messages when initial opening skips measured-end settlement. This change adds measured-end settlement for initial opening.
      • pingdotgg/t3code#22111 — The issue reports returning above the newest message after row heights grow. This change adds measured-end settlement for initial and end restoration.
      • pingdotgg/t3code#12372 — The change addresses measured-end restoration for a stranded viewport, but does not change scroll-to-end pill state.

      Suggested reviewers: t3dotgg

      Merge Risk: Minimal · up to 0f094

      The initial-open change has no identified merge-blocking risk; normal checks remain appropriate.

      Pre-merge checks: Passed 4
      Check nameStatusExplanation
      Title checkPassedThe title clearly and concisely describes the primary change: settling the measured end when a thread first opens.
      Description checkPassedThe description explains the problem, change, affected opening path, verification results, regression evidence, screenshots, recording, issue reference, and agent attribution. It does not use the temp…
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Full details: Description check

      Explanation

      The description explains the problem, change, affected opening path, verification results, regression evidence, screenshots, recording, issue reference, and agent attribution. It does not use the template headings or provide explicit maintainer approval, but the content is otherwise mostly complete and focused.

      Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Comment `@coderabbitai help` to get the list of available commands.
    3. juliusmarminge added labelsbugfix

    4. juliusmarminge added labelspr:gate-failed

    5. tanstack-source added labelsbug

    6. Thanks for this. Before a bug fix is taken further, the bug is reproduced on current main, and here it did not appear.

      I tried to reproduce this on main at a61291e3e2 in the web client against a fresh server. I used two long threads. One was built up to about 18,000 px with messages of very different heights: code blocks of 20 to 140 lines, long paragraphs and bullet lists, alongside the agent's replies with code and tables.

      I opened each thread with no saved reading position by reloading the page directly on it, at both desktop and phone widths. I also switched between the threads from the sidebar several times, so they reopened with a saved position at the end. While each one opened, I sampled the scroll position every 50 ms for several seconds. In all twelve openings the view sat exactly at the measured end, with the newest reply visible, and never stopped above it.

      If you have a thread or a set of conditions where it does stop short, such as particular content, a slow connection, or the desktop app, please share them. A recording or the scroll numbers from an affected opening would also help us look at it again.

      Closing this pull request. If it still happens for you, please open an issue with the exact steps, what you see, and the version and platform you are on; a fix is picked up from there.

    7. juliusmarminge closed this

Sign in to join this conversation.