Repository navigation
Conversation
…oke (#1005) Each key typed into an extension's custom panel round-trips to the server in a few ms, but the render it sends back re-renders ChatWindow, and a grouped turn handed MessageView fresh copies of its final message and a fresh written-files list on every render. That defeated MessageView's memo, so every visible answer ran its markdown again per keystroke (and per streamed chunk or notice). The copies and the list are now kept per stored message, so an unchanged transcript re-renders no MessageView: in a dev build with a 400-message session the key-to-paint time went from ~71 ms to ~20 ms, and real answers with code and math save far more. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Typing into an extension's custom panel (a pi-tui
Inputin actx.ui.customoverlay) lagged per keystroke while the composer stayed instant.Measured with a tiny overlay extension on a scratch server and headless Chromium: the server side is fast (key sent → panel update back: 4.5 ms median); the cost was in the browser. Every key re-rendered ChatWindow, and for each grouped turn ChatWindow built fresh copies of the final message (answer part and process part) and a fresh written-files list on every render. That defeated
MessageView's memo, so every visible answer re-ran its markdown pipeline (highlighting, KaTeX) per keystroke, and per streamed chunk or notice too.lib/turn-views.ts(new):getFinalAnswerViews()keeps those copies per stored message in aWeakMap(stored messages are replaced, never mutated);keepWrittenFiles()returns the previous list while the turn wrote the same files.components/ChatWindow.tsxuses them;docs/agents/sessions.mdnote.After the fix an unchanged transcript re-renders no
MessageViewper key; in a dev build with a 400-message session key-to-paint went from ~71 ms to ~20 ms (answers with code and math save more).Tests:
lib/turn-views.test.mjs, a guard incomponents/ChatWindow.process-details.test.mjs.tsc, eslint,npm testpass.Not done: the server still sends two panel updates per key (
requestRender()and after the input handler; pi's TUI coalesces them), and keys go out as parallel requests.Closes #1005
🤖 Generated with Claude Code