Skip to content

⚡ Bolt: Throttle chat scroll listener to reduce reflows#86

Open
nkissick-del wants to merge 1 commit intomainfrom
bolt-throttle-scroll-9272284254319496958
Open

⚡ Bolt: Throttle chat scroll listener to reduce reflows#86
nkissick-del wants to merge 1 commit intomainfrom
bolt-throttle-scroll-9272284254319496958

Conversation

@nkissick-del
Copy link
Copy Markdown
Owner

@nkissick-del nkissick-del commented Feb 5, 2026

💡 What: Throttled the scroll event listener in useScrollToBottom hook using lodash.throttle (200ms).

🎯 Why: The scroll event fires very frequently. The handler checks checkIfUserAtBottom which 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 tsc that 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.

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

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

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