Skip to content

fix(dashboard): Hold the reader's place when transcript layout changes - #2511

Merged
BYK merged 2 commits into
mainfrom
fix/dashboard-transcript-scroll-anchor
Nov 2, 2026
Merged

BYK merged 2 commits into
mainfrom
fix/dashboard-transcript-scroll-anchor

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Scrolling up through a Conversation on mobile jumps around. This PR fixes three causes.

Earlier history used a stale snapshot. The transcript saved scrollTop and scrollHeight when the earlier page started to load, and restored from them after the page arrived. On a phone the reader is usually still flinging when the load starts. The restore then threw away every pixel they had scrolled during the fetch. The new e2e journey reproduces this: it fails on main and passes with this change.

Late layout above the reader moved the content. Images, deferred highlighting, and expanding rows above the viewport pushed the visible message down. Chrome's native scroll anchoring hid some of this. Safari has no scroll anchoring, so iOS got the full shift.

Follow mode could pull the reader back down. While the transcript is pinned to the bottom, a live update or a resize could scroll to the bottom again before the reader's first upward scroll event arrived.

What changed:

  • Transcript and event log rows carry a data-scroll-anchor key. The pinning hook remembers the first row that starts inside the viewport, and that row's offset. After any layout change, it moves scrollTop by the distance that row moved. Layout changes include a new history page, a ResizeObserver callback, or a window resize. This replaces the prepend snapshot. A reader at the bottom still stays at the latest message.
  • Transcript content sets overflow-anchor: none, so browser anchoring does not compete with this logic and every browser behaves the same.
  • An upward wheel or touch drag leaves follow mode right away, before the scroll event.

The anchor lookup uses a binary search over rows, so each scroll reads only a few rects.

via @BYK.

--

View Session in Sentry

@vercel

vercel Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 2, 2026 10:41am UTC

Request Review

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

4 screenshot changes — 4 changed · 0 added · 0 removed

Review screenshots in Frameshift

Conversation Detail · Desktop
Conversation Detail · Desktop
Changed
Conversation Event Log · Mobile
Conversation Event Log · Mobile
Changed
Conversation Fork Dialog · Desktop
Conversation Fork Dialog · Desktop
Changed
Conversation Fork Dialog · Mobile
Conversation Fork Dialog · Mobile
Changed

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6ccd857. Configure here.

@BYK
BYK enabled auto-merge (squash) November 2, 2026 10:36
sentry-junior Bot and others added 2 commits November 2, 2026 10:36
Earlier history restored scroll from a snapshot taken when the load
started. On mobile the reader is often still flinging, so the restore
jumped them back. Late layout, such as images and deferred rendering,
also moved the content, and Safari has no native scroll anchoring.

Rows now carry a scroll anchor. After any layout change above the
reader, the scroll position moves by the distance the anchor moved.
Wheel and touch intent leave follow mode before the scroll event, so
a live update cannot pull a reader who starts to scroll up back down.

Co-Authored-By: BYK <[email protected]>

Co-Authored-By: BYK <[email protected]>
… mode

A restore near the bottom sent a scroll event that turned follow mode
back on. Ignore the scroll event that a restore causes.

Listen for wheel and touch on the scroll root, not only on transcript
rows. Compare a touch drag with its highest point, so small steps still
count as a drag down.

Co-Authored-By: BYK <[email protected]>
@sentry-junior
sentry-junior Bot force-pushed the fix/dashboard-transcript-scroll-anchor branch from 3dc1599 to 21b49b6 Compare November 2, 2026 10:41
@BYK
BYK merged commit a1bcaff into main Nov 2, 2026
42 checks passed
@BYK
BYK deleted the fix/dashboard-transcript-scroll-anchor branch November 2, 2026 10:45
BYK added a commit that referenced this pull request Nov 2, 2026
Like Slack, the dashboard now remembers how far each person has read a
Conversation. It opens there and marks the spot with a "New" line.

**Screenshots**

| Desktop | Mobile |
| --- | --- |
| <img alt="Desktop Conversation opened at the New line, with read
messages above it and unread messages below"
src="https://junior-prod.sentry.dev/public/artifacts/1396b8bf-333e-414d-b895-9ef05c8f1545.png"
width="560"> | <img alt="Mobile Conversation opened at the New line,
with the Jump to latest button"
src="https://junior-prod.sentry.dev/public/artifacts/bd8bae1c-dd96-4103-af0c-501d5e747fa4.png"
width="240"> |

<img alt="Settings page with the Open conversations at choice: Where I
left off or Latest message"
src="https://junior-prod.sentry.dev/public/artifacts/9949fd7e-aeac-4aee-b11d-05f55301e17e.png"
width="560">

**Server**
- Adds the `junior_conversation_read_positions` table (migration
`0071`). It keeps one row per user and Conversation.
- Adds `PUT /api/conversations/:id/read-position`. The stored value only
moves forward (`greatest(existing, new)`). It is also capped at the last
event, so devices can report in any order, and a bad client cannot hide
messages that come later.
- The detail response now includes `readPosition` for the signed-in
viewer. Other viewers never see it.

**Dashboard**
- Rows built from stored events now carry `data-transcript-seq`. While
the page is visible, the transcript reports the last row that reached
the viewport, 750 ms after scrolling or layout changes stop. It reports
only forward. A hidden tab and search results do not report. Leaving the
page or hiding the tab sends the pending report at once.
- When a Conversation opens, the page saves the read position from the
first detail. The last unread row comes from the first detail fetched in
that visit, so a cached copy cannot hide messages that arrived while the
reader was away. Rows that were unread then get a "New" separator
(`role="separator"`). Rows that arrive later get no marker, so a reader
who is following live replies does not see one.
- The detail is fetched on each visit. The cached copy shows at once,
and the view moves to the marker when the fetch brings it, unless the
reader already scrolled.
- By default, the transcript opens at the marker with a little context
above it, and "Jump to latest" is shown. If all unread rows fit on
screen, it opens at the bottom as before.
- Settings has a new per-browser choice, "Open conversations at": *Where
I left off* or *Latest message*. The read position itself stays synced
on the server.
- A successful report updates the cached detail, so reopening the
Conversation in the same session uses the new position.
- Mock reporting stores read positions per process, so local QA works.

**Known limits**
- If the saved position comes before the first loaded history page, the
marker shows at the top of the loaded rows. It moves up when older pages
load, and the scroll anchor from #2511 keeps the view steady.
- Other devices get the new position on their next detail fetch. A
transcript that is already open keeps the state from when it opened,
like Slack.

**Validation**
- `read-position`, `detail`, and `archive` integration tests: 10 passed.
- Dashboard unit tests: 48 files, 324 tests passed.
- Dashboard e2e (Chromium): full suite 63 passed. `conversation-send`
"hands web and external messages… without gaps" failed once under
full-suite load, then passed alone and with `--repeat-each 2`.
- New mobile e2e: "opens where the reader left off and reports what they
read" and "opens at new messages after a cached reopen and keeps a quick
exit".
- Typecheck, lint, migration metadata, file length, test architecture,
and dashboard style checks pass.
- WebKit/iOS Safari was not tested in the sandbox.

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:local%3Aweb%3A4352c102f29aab671b5349a8 -->

--

[View Session in
Sentry](https://sentry.sentry.io/explore/conversations/local%3Aweb%3A4352c102f29aab671b5349a8/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <[email protected]>
BYK added a commit that referenced this pull request Nov 3, 2026
…2634)

Scrolling up through a loaded Conversation on a phone still jumps after
#2511.

**Cause.** On narrow screens, transcript rows used `content-visibility:
auto` with a `12rem` size estimate. A row that has not rendered yet has
that estimated size. When the reader scrolls near it, it renders and
gets its real size. Above the reader, each change moves the content, so
the pinning hook corrects `scrollTop` while the reader is still
scrolling. On phones, a scroll write during a touch scroll shows as a
jump.

I measured this in Chromium at the mobile viewport, with 200 events of
mixed length and one wheel scroll up through them:

| | Scroll corrections |
| --- | --- |
| `main` | ~50 (−99 px to +655 px each) |
| This PR | 1 (the earlier page insert) |

**Fix.** Transcript rows lay out at their real size. The scroll anchor
now corrects the position only when the layout really changes above the
reader, such as an earlier page or a late image. The sidebar list keeps
`content-visibility`, because its rows have a fixed height.

The `-mx-2 px-2` on rows kept control outlines inside the paint
containment. Without containment it does nothing, so it is gone.

**Trade-off.** Off-screen rows now cost layout on phones again. #2568
bounds this with a capped window and a virtual list.

The mobile earlier-history journey now scrolls up through the loaded
rows and checks that the transcript makes no scroll corrections. It
fails on `main` with 11 corrections.

Refs #2568

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:local%3Aweb%3A735c6e48f79c0c925da15893 -->

--

[View Session in
Sentry](https://sentry.sentry.io/explore/conversations/local%3Aweb%3A735c6e48f79c0c925da15893/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <[email protected]>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 21b49b67 Deployed Nov 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant