Fix auto-scroll failing when components are dynamically added to chat #7820
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes the auto-scroll issue where the chat would fail to stay anchored to the bottom when components dynamically appear in the chat (e.g., tool outputs, inline elements).
Changes
Problem Solved
Previously, the auto-scroll only observed immediate children of the chat container. When components like tool outputs or other inline elements were dynamically added, they weren't being observed by the ResizeObserver, so their height changes didn't trigger the auto-scroll behavior. This fix ensures all dynamically added elements are observed, maintaining the anchor-to-bottom behavior even when complex components pop into the chat.
Summary by cubic
Keep the chat anchored to the bottom when dynamic components (tool outputs, inline elements) are added.