⚡ Bolt: [performance improvement] Optimize Progress and Log Panel re-renders#125
⚡ Bolt: [performance improvement] Optimize Progress and Log Panel re-renders#125primoscope wants to merge 1 commit intomainfrom
Conversation
…nent re-renders - Refactored `ProgressPanel.tsx` to memoize individual download items (`DownloadItem`). - Implemented a custom equality function for `React.memo` in `DownloadItem` to accurately compare primitive progress values instead of object references, preventing unnecessary re-renders when polling replaces the entire `downloads` array. - Refactored `LogPanel.tsx` to memoize individual log lines (`LogItem`). - Added a client-side generated unique `id` to `LogMessage` objects when they are received via WebSocket, enabling stable React keys and preventing full-list re-renders when the logs array is sliced. - Moved pure helper functions (`formatSpeed`, `formatETA`, `getStatusColor`, `getLogColor`) outside of component bodies to avoid recreation on every render. - Added explanatory comments for the optimizations. 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: Implemented
React.memowith custom equality checks and stable keys to prevent unnecessary re-renders in theProgressPanelandLogPanelcomponents. Pure helper functions were also extracted out of component bodies.🎯 Why: The
downloadsandlogsarrays are updated very frequently via WebSocket and polling. Previously, appending a single log or updating a single download's progress would force every single item in those lists to re-render, causing unnecessary CPU work and potential UI stutter.📊 Impact: Drastically reduces React render cycle cost for high-frequency updates. Only the specific
DownloadItemorLogItemthat receives new data will re-render, reducing main-thread blocking during intense downloading.🔬 Measurement: Verify by starting a download or triggering logs, and using React Developer Tools Profiler with "Highlight updates when components render" enabled to observe that only updated rows re-render.
PR created automatically by Jules for task 15880277296549731960 started by @dzp5103