fix: typing in ChatInput no longer causes unnecessary rerenders #136
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.
This PR fixes a major performance issue in the chat UI. Previously, typing in the chat prompt input triggered a rerender of the entire chat message list—, including all message rows on every keystroke.
With a test harness of 1,000 messages and CPU throttled to 4x CPU slowdown, this caused severe UI lag (typing a short phrase could take over 10 seconds to appear).
What Changed:
Chat
component and the message list only rerender on new messages, not on input changes.Impact (with 1,000 messages, 4x CPU slowdown):
"this is me typing"
took over 10 seconds to appearResult:
Closes #128
Note: As a good follow up, implementing #118 will also improve performance.
Screenshots and Videos
Here is the fix in action with 1000 fake bot messages injected and CPU throttling set to 4x slowdown.
Before
CleanShot.2025-07-13.at.09.02.11.mp4
After
CleanShot.2025-07-13.at.09.03.13.mp4