⚡ Bolt: [performance improvement] Optimize React list rendering in ProgressPanel and LogPanel#138
Conversation
💡 What: - Extracted list items in `ProgressPanel` and `LogPanel` into `React.memo` components (`DownloadItem` and `LogItem`). - Moved static format helpers (`formatSpeed`, `formatETA`, `getStatusColor`, `getLogColor`) outside the component bodies. - Generated client-side stable `id`s for `LogMessage`s to use as React keys instead of array indices. - Added custom equality function to `DownloadItem`'s `React.memo` to compare primitive output fields. 🎯 Why: - During high-frequency WebSocket updates (logs arriving every few milliseconds), appending items to a state array triggered an `O(N)` re-render for every existing item in the list. This caused significant UI lag as the download progressed and logs accumulated. 📊 Impact: - Transforms rendering complexity from `O(N)` to `O(1)` per new message. Existing items in the list no longer re-render unnecessarily when a new item is appended. 🔬 Measurement: - Start a large download. - Open React DevTools Profiler. - Observe that as logs and progress updates fly in, only the new rows and the specific progress rows being updated flash/re-render, instead of the entire list container and every child element. 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:
ProgressPanelandLogPanelintoReact.memocomponents (DownloadItemandLogItem).formatSpeed,formatETA,getStatusColor,getLogColor) outside the component bodies.ids forLogMessages to use as React keys instead of array indices.DownloadItem'sReact.memoto compare primitive output fields.🎯 Why:
O(N)re-render for every existing item in the list. This caused significant UI lag as the download progressed and logs accumulated.📊 Impact:
O(N)toO(1)per new message. Existing items in the list no longer re-render unnecessarily when a new item is appended.🔬 Measurement:
PR created automatically by Jules for task 18023903420292637628 started by @dzp5103