docs/design/web-shell-stream-render-performance.md
Thinking and assistant deltas currently wake the transcript on every animation
frame. Each accepted snapshot runs transcript projection and downstream list
work, while the growing Markdown document is parsed again at every streaming
flush. Although ChatEditor is memoized, this main-thread work still competes
with editor input and becomes increasingly expensive as the active response
grows.
The transcript projector is linear, but browser profiling with 50,000 retained
messages attributes only 2.5% of sampled time to projection. The dominant
104 ms long task spends 52.1 ms in applyTurnCollapse; repeated full-history
derivation in MessageList also includes final-answer collection, agent
grouping, pinning, and display-index generation.
After the tail-only path, two CPU samples reduced applyTurnCollapse from
467.8 ms total self time to 26.7–51.5 ms, final-answer collection from 247.2 ms
to 11.4–26.9 ms, grouping from 54 ms to 2.4–7.6 ms, and display-index
generation from 67.5 ms to 3.7–12 ms. The mock SSE disconnected after replay
in that rerun, so these samples establish hotspot reduction but are not used as
end-to-end completion or long-task acceptance evidence.
Markdown has the opposite shape: every streamed append changes the complete source string and reparses the complete growing document. Throttling bounds how often that happens but not the cost of each parse.
WeakMap, allowing the
existing row comparator's JSON cache to avoid reserializing unchanged
historical tool output.MessageList derivations under the same narrow condition,
replacing only the rendered tail row. Any earlier block change, terminal
transition, tool/background update, usage change, translation change, or
view-option change takes the existing full calculation path.npm run test:e2e:perf --workspace=@qwen-code/web-shell deterministically
replays 5,000 historical turns, streams 400 Markdown-heavy chunks while
typing, verifies the final output and composer contents, and records input
latency and browser long-task metrics in the Playwright report.