⚡ Bolt: [performance improvement] Add React.memo for high-frequency WebSocket list rendering#131
⚡ Bolt: [performance improvement] Add React.memo for high-frequency WebSocket list rendering#131primoscope wants to merge 1 commit intomainfrom
Conversation
Added React.memo wrapper components for DownloadItem and LogItem to prevent expensive array map re-renders on high-frequency WebSocket state updates. 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:
Added
React.memotoDownloadItem(with a custom primitive property equality check) inProgressPanel.tsx, andLogIteminLogPanel.tsx. Assigned a stable, unique ID to incoming logs instead of relying on array indices.🎯 Why:
The
ProgressPanelandLogPanelcomponents render lists of items. Both lists are updated very frequently via WebSockets.Because the parent components re-create the entire array objects immutably, all items in the list re-render on every single WebSocket message, even if only one download changed or only one log was appended. This causes significant CPU usage and jank, especially for many active downloads or long log outputs (which maxes at 1000). Array indices as keys on logs also forced complete re-renders when the array shifted.
📊 Impact:
Massively reduces re-renders of unchanged list items. For example, if there are 100 log items and 1 is added, the existing 100 will no longer re-render. If there are 10 active downloads and 1 progresses, the other 9 will not re-render. This drastically improves React rendering performance during high-frequency WebSocket updates and ensures UI stability.
🔬 Measurement:
Verified locally using Playwright integration tests mapping against a mock FastAPI backend. High-frequency simulated WebSocket payload ticks confirmed no regressions and functional state tracking. The TS compilation (
pnpm run build) continues to pass successfully.PR created automatically by Jules for task 10593381347885775425 started by @dzp5103