Skip to content

Studio: open a long chat at its latest message on Chromium - #17351

Merged
danielhanchen merged 1 commit into
mainfrom
studio-long-chat-open-at-latest
Nov 10, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
studio-long-chat-open-at-latest

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Problem

On Chromium (Chrome, Edge, the Windows app's WebView2), opening a long chat often lands far above its latest message: 4,000 to 23,000 px up, and it stays there. On main, in a Playwright harness with a 200-turn chat, 3 to 6 of 10 fresh loads and 3 to 4 of 10 switches from the sidebar ended up off the bottom; with the CPU throttled 4x, 6 of 18. WebKit was not affected (0 of 60).

Nothing in the page scrolls the thread when it happens (no input, no programmatic scroll). While older messages mount, the autoscroll hook holds the chat at its bottom. Then Chromium moves scrollTop up by about 259 px while scrollHeight reads unchanged at the scroll event: a row that distant-rows.ts (#16986) skips or releases (data-row-distant) at the bottom clamps the scroll position. The hook reads an upward move from the bottom with no height change as the user scrolling up and stops following, and every later batch of mounted messages keeps that offset.

Forcing content-visibility: visible on message rows alone removes it (0 of 8); doing the same for code fences, reasoning or maths, or turning off smooth scroll, scroll anchoring or composer focus does not.

Change

use-intent-aware-autoscroll.tsx only:

  • The hook's MutationObserver also watches data-row-distant; a record for it marks that rows toggled since the last scroll event.
  • An upward move from a pinned bottom counts as a clamp, not the user, when the scroll height changed (as before) or rows toggled since the last scroll event, still only with no scroll key and no held pointer.
  • Wheel and touch still stop following in their own handlers, and PageUp / ArrowUp / Home still count as the user.

Results

Same harness (production build, no input sent, distance from the bottom 5 s after all rows mounted), 200-turn chat, then sidebar switches to a 150-turn chat and back. Main ran twice as an A/A control:

Arm Fresh load of the 200-turn chat Switch to the 150-turn chat Switch back to 200
main 4 of 10 off (8,543 to 23,046 px) 3 of 10 (2,329 to 14,755 px) 4 of 10 (14,401 to 24,547 px)
main again (A/A) 2 of 9 (12,684, 16,824 px) 4 of 9 (6,460 to 14,756 px) 4 of 9 (6,213 to 20,957 px)
this PR 0 of 10 0 of 10 0 of 10

Chromium, 2 rotated rounds of 5 per arm. An earlier run with 10 loads per arm, also on WebKit (Mac UA) and with a 4x CPU throttle, read the same way: main 14 and 10 of 30 off, this PR 0 of 30; throttled main 6 of 18, this PR 0 of 18; WebKit 0 everywhere.

  • A reader who scrolls up (wheel or PageUp) still stays where they left it 5 s later, on Chromium and WebKit, same as main.
  • Long-chat gate passes on this branch.

Tests

  • tests/chat-autoscroll-shrink-intent.test.ts: new test for the row toggle case; tests/desktop-webkit-paths.test.ts updated for the observer signature. The related autoscroll suites (81 tests) pass; tsc --noEmit clean.
  • Not measured: real Safari / Edge / Chrome on macOS and Windows and the desktop apps (Edge and WebView2 share Chromium's behaviour); dragging the scrollbar (a held pointer already keeps the old path).

A distant row (distant-rows.ts) skipped or released while the chat is pinned to its bottom can
move scrollTop up with scrollHeight unchanged by the scroll event. The autoscroll hook read that
as the reader scrolling up and detached, so a 200-turn chat opened up to 23,000 px above its last
message in about half the loads and chat switches. The hook now watches the distant attribute and
treats such a move at a pinned bottom, with no key or pointer behind it, as a clamp.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T04:58:22.676885Z 7b52868 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 7b52868a0d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit c74b6cf into main Nov 10, 2026
@danielhanchen
danielhanchen deleted the studio-long-chat-open-at-latest branch November 10, 2026 06:22
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