Skip to content

perf(ui): a long transcript keeps only the turns near the view, so reading it back to its start no longer fills a phone's memory - #802

Merged
Michael McQuade (giraffesyo) merged 1 commit into
canaryfrom
perf/transcript-keeps-what-is-near
Nov 17, 2026
Merged

Michael McQuade (giraffesyo) merged 1 commit into
canaryfrom
perf/transcript-keeps-what-is-near

Conversation

@giraffesyo

@giraffesyo Michael McQuade (giraffesyo) commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Summary

The message list draws the end of a long conversation and the turns before it as the reader scrolls up (#795), but it never lets go of a turn once drawn. Reading a long agent session back to its first turn draws all of it again, and on a phone that is more memory than the tab that #795 kept from closing.

The list now keeps a window of whole turns around the view, in both directions:

  • Within two screens of either edge of the window, it draws about 100 more parts there.
  • Turns more than four screens from the view are let go of, above and below. What the reader is looking at stays where it is.
  • Once the end has been let go of, new turns, the reply being written and the queue wait below until the reader comes back. Jump to latest brings them back to the end and follows it from there, and reaching the foot of a window that stops short of the end isn't taken for reaching the end.
  • A turn the reader is editing, selecting text in, or reached with the keyboard is kept.
  • What the reader opened in a turn, such as a tool's output, a thought, a folded run or a long reply, is open again when the turn is drawn again. Expand-all and a new conversation start afresh.
  • Turns drawn again appear at once rather than entering as new ones.

The long agent session story scrolled to its first turn and back, before on the left and after on the right, each with a counter of the elements its transcript holds. Before keeps every turn it passed; after lets go of the turns it left behind:

long-session.mp4

It looks as it did, at desktop and phone width:

Long agent session at desktop width

Long agent session at phone width

whole still draws every message, which SessionView's find uses. A follow-up moves find off it.

Testing

  • ChatMessageList.window.test.tsx covers the window: letting go of turns far above and far below without moving the view, drawing them again on the way back without animating them, holding new turns and the streaming reply while short of the end, jumping back to the end from far above it, not taking the window's foot for the end, keeping an edited or selected turn, and starting the memory of opened blocks afresh on an expand-all change or a cleared conversation. AgentMessageParts.test.tsx covers a tool's output and a thought opening again when drawn again. Each test fails with the code it covers broken.

  • Measured in a host app's production build, against an agent session of 100 turns with 4,000 tool calls and 800 edits, before and after, alternating between them:

    Long agent session: 100 turns, 4,000 tool calls, 800 edits Before After
    Elements in the transcript, scrolling to the first turn and back 2,243 rising to 106,958, all kept 1,582–3,265
    WebKit at phone size, page memory: opened 386–389 MB 379–385 MB
    … at the first turn 1,070–1,128 MB 538–681 MB
    … back at the end 1,085–1,161 MB 630–713 MB
    Chromium at the first turn, after garbage collection 192,593 DOM nodes, 86 MB heap 4,923 DOM nodes, 32 MB heap
    Opening the session, median of 6 1,420 ms 1,391 ms
    Switching to it from a short session, median of 6 122 ms 122 ms

    Before is this branch's base built from source the same way, so the two differ only by this change. Three rounds each for memory; the line at the top of the view never moved by more than 2px in either.

    Measured again after release on the published packages, 0.145.1 against 0.146.1, which the host styles from their compiled files (the source builds above lacked some of the package's classes): at the first turn 1,066–1,257 MB against 487–509 MB on a phone, back at the end 1,099–1,365 MB against 530–629 MB, and 192,453 against 4,783 DOM nodes in Chromium. Both load 1,869 KB up front, and opening the session took a median of 1,100 ms against 1,084 ms.

  • Letting go of turns above only once scrolling paused was tried and dropped: during a fling the list then held as much as before.

Checklist

  • make check passes: its TypeScript half (lint-js, test-js, verify-build); no Go changed
  • A new or changed shared message is in every language in problem/messages/ (none)
  • No code, rule or param was renamed (they are API contract)

…ading it back to its start no longer fills a phone's memory

The message list drew a long conversation's end and the turns before it as the
reader scrolled up, but never let go of a turn once drawn. Reading back to the
first turn of a long agent session drew it whole, and a phone's browser closes
the tab long before that.

The list now keeps a window of whole turns around the view in both directions:

- Within two screens of either edge it draws about 100 more parts there.
- Turns more than four screens from the view are let go of, above and below,
  and what the reader is looking at stays where it is.
- Once the end has been let go of, new turns, the reply being written and
  the queue wait below until the reader comes back; the jump control brings
  them back to the end and follows it.
- A turn the reader is editing, selecting text in or reached with the
  keyboard is kept.
- What the reader opened in a turn (a tool's output, a thought, a folded run,
  a long reply) is open again when the turn is drawn again. Expand-all and a
  new conversation start afresh.
- Turns drawn again appear at once rather than entering as new ones.
@giraffesyo
Michael McQuade (giraffesyo) merged commit 90a1f5a into canary Nov 17, 2026
12 of 13 checks passed
@giraffesyo
Michael McQuade (giraffesyo) deleted the perf/transcript-keeps-what-is-near branch November 17, 2026 15:15
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