[PR #24003] fix: add scroll listener for loading conversation history #30469

Closed
opened 2026-02-21 20:47:33 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/24003

State: closed
Merged: No


Add scroll event listener to trigger loading more historical messages when user scrolls to top in conversation detail view.

Fixes: https://github.com/langgenius/dify/issues/23971

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

This PR fixes an issue where users cannot load more historical messages when scrolling to the top in chatflow conversation detail view. Previously, the InfiniteScroll component was not properly detecting scroll events in inverse mode, causing users to only see the most recent 10 conversation messages.

Problem

  • Users scrolling to the top in conversation detail view could not load more historical messages
  • InfiniteScroll component failed to detect scroll events in inverse mode (inverse={true})
  • Limited visibility of conversation history

Solution

  • Added a scroll event listener to manually detect when user scrolls near the top
  • Triggers fetchData function when scrollTop < 50 to load more historical messages
  • Maintains existing interaction logic and UI design

Screenshots

Before After
image image

Note: Screenshots show the conversation detail view before and after the fix. Users can now scroll to the top to load more historical messages.

Testing

Steps to Test

  1. Open a chatflow application
  2. Navigate to the logs section
  3. Click on a conversation with more than 10 messages
  4. Scroll to the top of the conversation detail view
  5. Verify that more historical messages are automatically loaded

Expected Behavior

  • When scrolling to the top, more historical messages should load automatically
  • Loading should be smooth and not cause duplicate requests
  • The conversation should maintain its scroll position appropriately

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

Additional Notes

  • This is a minimal, focused fix that addresses the core issue without changing the existing UI/UX
  • The solution is backward compatible and doesn't affect other parts of the application
  • Code follows existing patterns and conventions in the codebase
  • No breaking changes introduced
**Original Pull Request:** https://github.com/langgenius/dify/pull/24003 **State:** closed **Merged:** No --- Add scroll event listener to trigger loading more historical messages when user scrolls to top in conversation detail view. Fixes: https://github.com/langgenius/dify/issues/23971 > [!IMPORTANT] > > 1. Make sure you have read our [contribution guidelines](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) > 2. Ensure there is an associated issue and you have been assigned to it > 3. Use the correct syntax to link this PR: `Fixes #<issue number>`. ## Summary This PR fixes an issue where users cannot load more historical messages when scrolling to the top in chatflow conversation detail view. Previously, the InfiniteScroll component was not properly detecting scroll events in inverse mode, causing users to only see the most recent 10 conversation messages. ### Problem - Users scrolling to the top in conversation detail view could not load more historical messages - InfiniteScroll component failed to detect scroll events in inverse mode (`inverse={true}`) - Limited visibility of conversation history ### Solution - Added a scroll event listener to manually detect when user scrolls near the top - Triggers `fetchData` function when `scrollTop < 50` to load more historical messages - Maintains existing interaction logic and UI design ## Screenshots | Before | After | |--------|-------| | <img width="1920" height="935" alt="image" src="https://github.com/user-attachments/assets/7c1db7d1-13b9-45d1-abeb-21b4c0854b4e" />| <img width="1920" height="940" alt="image" src="https://github.com/user-attachments/assets/0ae3ad3c-fd6f-4d06-a418-1f806181ad7d" />| *Note: Screenshots show the conversation detail view before and after the fix. Users can now scroll to the top to load more historical messages.* ## Testing ### Steps to Test 1. Open a chatflow application 2. Navigate to the logs section 3. Click on a conversation with more than 10 messages 4. Scroll to the top of the conversation detail view 5. Verify that more historical messages are automatically loaded ### Expected Behavior - When scrolling to the top, more historical messages should load automatically - Loading should be smooth and not cause duplicate requests - The conversation should maintain its scroll position appropriately ## Checklist - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods ## Additional Notes - This is a minimal, focused fix that addresses the core issue without changing the existing UI/UX - The solution is backward compatible and doesn't affect other parts of the application - Code follows existing patterns and conventions in the codebase - No breaking changes introduced
yindo added the pull-request label 2026-02-21 20:47:33 -05:00
yindo closed this issue 2026-02-21 20:47:33 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#30469