Skip to content

⚡ Bolt: [performance improvement] Optimize React list rendering in ProgressPanel and LogPanel#138

Draft
primoscope wants to merge 1 commit intomainfrom
bolt-optimize-react-list-renders-18023903420292637628
Draft

⚡ Bolt: [performance improvement] Optimize React list rendering in ProgressPanel and LogPanel#138
primoscope wants to merge 1 commit intomainfrom
bolt-optimize-react-list-renders-18023903420292637628

Conversation

@primoscope
Copy link
Copy Markdown
Owner

💡 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 ids for LogMessages 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.

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

💡 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>
@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