cmux-next: a new chat follows its reply past one screen (cx-ubd1y)

Merged
TE
25d ago
+188-2

In a new chat, a reply that grows past one screen is now followed to its latest line, and so is every turn after it. Before this, the view stayed on the first turn while the reply streamed below it.

Found in dogfood run 5 on the newest nightly (cx-ubd1y). Lighthouse-story test:

  • A 2000-word reply streamed entirely below the view.
  • After four more prompts, the view still showed the first answer.

Cause

VirtualTranscript lays a new chat out on estimated row heights first.

  1. That first pass can overshoot the viewport, so the transcript opens at the latest row (offset 12).
  2. Measurement then shrinks the transcript back to fit, and the browser clamps the offset to 0.
  3. The branch that keeps the view at the latest row required a nonzero offset, so once the reply overflowed nothing moved it.
  4. The next commit recorded the view as scrolled up, so it stayed there for the rest of the chat.

The fix keeps that branch at offset 0 too. Anchoring a row while the reader is scrolled up still needs a nonzero offset, as before.

Test

webviews/test/transcript-follow.test.ts runs in real Chromium. It mounts the transcript with the pane's stylesheets, streams a reply past the viewport, then sends a new turn.

  • Red on the base: the latest row's text ends 1503 px below the view.
  • Green: it ends inside the view.

Also passing locally:

  • the transcript and find tests (jump to latest, viewport resize, hidden follow, scroll restore, long chat updates, range copy, minimap, turn keys, chat find, diff find, popup escape, suggestion lists, edited side);
  • test/ui-rules.test.ts;
  • bun run check.

Changelog

  • Fixed: A new chat's transcript keeps up with a reply that grows past one screen, and with the turns after it.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Fixes a new chat's transcript so it follows a reply once it streams past one screen, and keeps following every turn after it. Before this, the view stayed on the first turn while the reply grew below it.

The follow branch in VirtualTranscript now also works at scroll offset 0: a new chat's first layout pass overshoots the viewport on estimated heights, settles back to fit, and the browser clamps the offset to 0. Previously that offset was recorded as scrolled up, so nothing moved the view once the reply overflowed.

Testing

  • Adds a real-Chromium test that mounts the transcript with the pane's stylesheets, streams a reply past the viewport, and verifies the latest line ends inside the view.
  • Covers the next user turn sent after the reply comes into view as well.