⚡ Bolt: [performance improvement] Add React.memo to prevent unnecessary re-renders in WebSocket panels#124
Conversation
…ry re-renders in ProgressPanel and LogPanel
* Extracts individual log/download rendering logic into memoized components (DownloadItem, LogItem)
* Wraps high-frequency updated arrays using useMemo
* Moves static helper functions outside the component bodies to prevent recreation on re-render
Co-authored-by: dzp5103 <214723817+dzp5103@users.noreply.github.com>
|
👋 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. |
💡 What: Extracted individual rows in
ProgressPanelandLogPanelintoReact.memocomponents (DownloadItemandLogItem), relocated static helper functions outside the render body, and wrapped filtering operations inuseMemo.🎯 Why: The application receives high-frequency updates via WebSockets for download progress and log streaming. Previously, pushing a single new progress update or log line triggered a complete re-render of the entire list (O(n) complexity), causing UI stuttering and unneeded CPU load.
📊 Impact: Reduces React rendering time for these panels from O(n) to O(1) per WebSocket update. Only the specific item that changed (or was appended) will render, while the rest are skipped via memoization.
🔬 Measurement: Verify the improvement by starting a large download that emits frequent progress updates and logs. Using the React DevTools Profiler, observe that when a WS message arrives, only the corresponding
DownloadItemor the appendedLogItemrenders, instead of the entire list.PR created automatically by Jules for task 1780541894330660461 started by @dzp5103