Skip to content

⚡ Bolt: [performance improvement] Memoize WebSocket list items to prevent re-renders#122

Draft
primoscope wants to merge 1 commit intomainfrom
bolt-optimize-websocket-lists-12413171551721026586
Draft

⚡ Bolt: [performance improvement] Memoize WebSocket list items to prevent re-renders#122
primoscope wants to merge 1 commit intomainfrom
bolt-optimize-websocket-lists-12413171551721026586

Conversation

@primoscope
Copy link
Copy Markdown
Owner

💡 What: Extracted the inline LogItem and DownloadItem components from LogPanel.tsx and ProgressPanel.tsx respectively, and wrapped them in React.memo(). Also hoisted pure helper functions like getLogColor, formatSpeed, formatETA, and getStatusColor outside of the component bodies. Added inline comments to document the optimizations. Added a critical learning to .jules/bolt.md.

🎯 Why: When building lists that receive high-frequency updates via WebSocket, rendering lists inline with helper functions defined inside the component body creates a massive re-render bottleneck. Because a single WebSocket update updates the entire array state, React was re-rendering all list items instead of just the changed ones, and re-allocating helper functions on every single render cycle.

📊 Impact: Prevents unnecessary re-renders of the entire download/log list when high-frequency WebSocket updates arrive. Only the specific items that change (or new items that are appended) will trigger a render. This greatly reduces CPU overhead and DOM updates on the frontend.

🔬 Measurement: To verify, you can use React Developer Tools Profiler. Start a mock server sending WebSocket events every second and observe the ProgressPanel and LogPanel components. You will see that DownloadItem and LogItem components do not re-render unless their specific download or log props change.


PR created automatically by Jules for task 12413171551721026586 started by @dzp5103

…vent re-renders

Co-authored-by: dzp5103 <214723817+dzp5103@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

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