Skip to content

fix(web): show a new session's first prompt; cheaper streaming render - #154

Merged
sanchitrk merged 2 commits into
canaryfrom
claude/streaming-render-perf
Nov 11, 2026
Merged

sanchitrk merged 2 commits into
canaryfrom
claude/streaming-render-perf

Conversation

@sanchitrk

@sanchitrk sanchitrk commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Fix

A new session's first prompt stayed hidden (data-prompt-pending). The transcript's callback ref captured the composer inset, so React detached and re-attached the list whenever the composer was measured. LegendList reported the anchored prompt ready in that gap, the follow hook found no list, marked the prompt positioned without scrolling, and never revealed it. The follow ref now goes straight to the list, and --composer-height is set through the list's style prop.

Performance (prompt → rendered reply)

  • Finished replies keep their blocks. The reply no longer collapses into one block on finish, which re-parsed and re-highlighted everything in one frame.
  • Finished code highlights once. An LRU of Shiki lines (500 entries) survives list remounts and thread switches.
  • Streaming code highlights incrementally. Completed lines keep their nodes; only new text is tokenized, resuming from Shiki's grammar state. Output matches a full highlight once the fence finishes.
  • Thinking summary scans only up to its first paragraph.
  • Draft checkpoints are not stored in the event log (published ephemeral); settled messages still are.

Verified in the Electron app (Kimi K3 via GitHub Copilot)

  • First prompt and follow-ups render; the composer mask still uses the measured height.
  • A finished reply keeps its first block's DOM node.
  • After a thread switch, finished code comes back highlighted from the cache.
  • During a 30 s reply, no draft message rows are stored; only the final message.
  • Highlight time while a ~145-line block streams: about 1.1 s with full re-highlight vs. about 90 ms with incremental (two runs each), with no long tasks either way.

vp check, vp run typecheck and vp run knip:check pass.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

sanchitrk and others added 2 commits November 11, 2026 18:56
The transcript's callback ref captured the composer inset, so React
detached and re-attached the list whenever the composer was measured.
LegendList reported the anchor ready in that gap, the follow hook found
no list, marked the prompt positioned without scrolling, and the turn
stayed hidden. Pass the follow ref straight through and set
--composer-height with the list's style prop instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Replies render block by block after they finish too, so the end of a
  stream no longer re-parses and re-highlights the whole reply.
- Finished code highlights once, from an LRU, across remounts and
  thread switches.
- A streaming code fence highlights incrementally: completed lines keep
  their nodes and only new text is tokenized from the saved grammar
  state (about 12x less highlight time on a 120-line block).
- The thinking summary scans only up to its first paragraph.
- Draft message checkpoints are published without being stored in the
  event log; only settled messages are kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sanchitrk
sanchitrk merged commit 34351ed into canary Nov 11, 2026
1 check passed
@sanchitrk
sanchitrk deleted the claude/streaming-render-perf branch November 11, 2026 13:27
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