⚡ Bolt: Throttle chat scroll listener to reduce reflows#86
⚡ Bolt: Throttle chat scroll listener to reduce reflows#86nkissick-del wants to merge 1 commit intomainfrom
Conversation
Throttles the scroll event listener in `useScrollToBottom` to 200ms using lodash's throttle. This prevents excessive layout calculations (checking `scrollTop`, `scrollHeight`) during scrolling, which significantly improves performance when streaming large responses or manually scrolling the chat. Co-authored-by: nkissick-del <236767245+nkissick-del@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: Throttled the scroll event listener in
useScrollToBottomhook usinglodash.throttle(200ms).🎯 Why: The
scrollevent fires very frequently. The handler checkscheckIfUserAtBottomwhich reads layout properties (scrollTop,scrollHeight), forcing a reflow (layout calculation) on every event. This causes performance issues (jank) during streaming or manual scrolling.📊 Impact: Reduces main thread blocking and layout thrashing during scrolling.
🔬 Measurement: Verified using
tscthat the code is type-safe. Manual verification of logic correctness (memoized handler, proper cleanup).PR created automatically by Jules for task 9272284254319496958 started by @nkissick-del
Summary by cubic
Throttled the chat scroll listener in useScrollToBottom to 200ms with lodash.throttle to reduce layout reflows and jank during scrolling and streaming. Memoized the handler and cancel it on cleanup to avoid extra work.
Written for commit dffa3d0. Summary will update on new commits.