Shared scroll state support #1322
Open
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.
Added optional singleton mode to
useScrollToBottomhook, allowing scroll state and controls to be shared across multiple components without creating duplicate instances.Why this change:
PromptInputTextareanow actually handles its own damn resize logic #1321Scroll-to-bottombutton position is static and doesn't account for MultimodalInput's config/resize-abilityscroll-to-bottombutton in a separate component (likeMultimodalInput) from where the scrollable container lives (like MessagesContainer), you'd have to re-call the hook, which would create a new instance with its own state. This meant the button wouldn't reflect the actual scroll position.What's new:
ScrollToBottomProvidercontext wrapperuseScrollToBottomnow accepts optionalsingletonboolean parametersingleton=true, hook returns shared instance from providersingleton=false(default), hook works exactly as beforeuseMessageshook now takes the optionalsingletonpropscroll-buttonnow animates as seen in v0.devUsage:
<ScrollToBottomProvider>useScrollToBottom(true)in any child component to access shared stateuseScrollToBottom()continues to work unchangedBenefits:
Example:
This makes it easy to place scroll controls anywhere in the component tree while maintaining a single source of truth for scroll state.
PS: This PR is a supplementary to #1321