⚡ Bolt: optimize chat message re-renders#99
Conversation
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- Memoize MessageBubble and ThinkingIndicator components - Optimize props to localize re-renders to affected items only - Reduce ReactMarkdown re-rendering overhead during streaming and copy actions
…lity - Memoize MessageBubble and ThinkingIndicator components - Optimize props to localize re-renders to affected items - Extract message actions into sub-components (EditAction, CopyAction) - Integrate HeroUI components for message actions - Use descriptive prop names (isGenerating) and remove unnecessary comments
- Refactor MessageBubble to use data-role attributes - Use Tailwind data- modifiers for conditional alignment and styling - Improve code cleanliness by removing ternary operators in className strings - Maintain performance optimizations (memoization and localized props)
83751b6 to
977eb32
Compare
💡 What: Optimized the Chat component by memoizing message bubbles and the thinking indicator. Refactored props to use booleans (
isCopied,isTyping) instead of passing parent state identifiers.🎯 Why: Previously, every message in the chat would re-render whenever a new message was being streamed or when any message was copied. This was due to the entire message list receiving updated parent state props. Since
MessageBubbleusesReactMarkdown, these redundant re-renders were computationally expensive.📊 Impact: Reduces re-renders from$O(N)$ to $O(1)$ during streaming and clipboard actions, significantly improving UI responsiveness and reducing CPU usage in long conversations.
🔬 Measurement: Can be verified using React DevTools Profiler by observing that only the active/copied message bubbles highlight during updates.
PR created automatically by Jules for task 10170850428801528950 started by @amrabed