-
Notifications
You must be signed in to change notification settings - Fork 733
Fix scroll auto-jump and message visibility issues #308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe ChatInterface.jsx component updates visibleMessageCount handling: it increases when older messages are prepended during pagination, initializes to at least 100 on session load, resets to 100 on session clear, and skips auto-scroll while older-message pagination is in progress. Changes
Sequence Diagram(s)(omitted — changes are localized state/UX adjustments without multi-component sequential flow) Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/components/ChatInterface.jsx`:
- Around line 4064-4067: The auto-scroll guard can be bypassed because
isLoadingMoreRef.current is reset synchronously in loadOlderMessages' finally
block; change the finally block so it defers clearing isLoadingMoreRef.current
to the next tick (e.g., wrap the assignment in setTimeout(() => {
isLoadingMoreRef.current = false; }, 0)) so the effect that checks
isLoadingMoreRef during the pending render still sees it as true and auto-scroll
is correctly skipped. Update only loadOlderMessages' finally cleanup and keep
the existing guard that checks isLoadingMoreRef.current in the scrolling effect.
Fixes two related scroll issues: 1. Auto-scroll jumping to bottom when loading older messages 2. Limited message visibility (only 100 messages visible despite loading more) Root causes: 1. Auto-scroll useEffect triggered on chatMessages.length change, even during pagination loading 2. visibleMessageCount stayed at 100 regardless of how many messages were actually loaded Changes: - Skip auto-scroll when isLoadingMoreRef.current is true (pagination in progress) - Initialize visibleMessageCount to match actual loaded message count on session load - Increase visibleMessageCount when pagination loads more messages - Reset visibleMessageCount to 100 when clearing session Impact: - Users can now scroll up to view history without being auto-jumped to bottom - All loaded messages are visible (not limited to first 100) - Pagination works seamlessly with visibility system
5a1b39f to
2da8c96
Compare
Description
Fixes two related scroll issues that impacted user experience when viewing message history.
Issues Fixed
1. Auto-scroll jumping to bottom when loading older messages
Problem: When scrolling up to view previous messages, the UI would automatically jump back to the bottom.
Root cause: The auto-scroll useEffect (line 4055) triggered on every
chatMessages.lengthchange, including when pagination loaded older messages. It didn't check if the length change was due to pagination.Fix: Added check for
isLoadingMoreRef.currentto skip auto-scroll during pagination loading.2. Limited message visibility (only 100 messages visible)
Problem: Even though pagination loaded 260+ messages, only the last 100 were visible. Users couldn't scroll to see the loaded history.
Root cause:
visibleMessageCountwas initialized to 100 and never updated when:Fix:
visibleMessageCounttoMath.max(100, messages.length)on session loadvisibleMessageCountby the number of messages loaded during paginationChanges
ChatInterface.jsx
Testing
✅ Tested: Can scroll up to view history without auto-jump to bottom
✅ Tested: All loaded messages are now visible (not limited to 100)
✅ Tested: Pagination works seamlessly with the visibility system
Impact
Summary by CodeRabbit
Bug Fixes
Improvements
✏️ Tip: You can customize this high-level summary in your review settings.