mirror of
https://github.com/open-webui/open-webui.git
synced 2026-03-10 15:54:15 -05:00
[PR #4266] [MERGED] feat: Sidebar infinite scroll (pagination) #8230
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/4266
Author: @thearyadev
Created: 8/1/2024
Status: ✅ Merged
Merged: 8/4/2024
Merged by: @tjbck
Base:
dev-scroll← Head:sidebar-pagination📝 Commits (10+)
4919981add: stores for pagination state519375badd: skip and limit use in queryd119616add: use skip and limit in api call62dc486add: add paginated scroll handler2c4bc7arefactor: uses ofchats.set(...)support pagi sidebar06a6421fix: bool eval order6847c2fMerge branch 'origin/dev' into sidebar-pagination [skip ci]067d76ffix: dynamically determine page sizef9e1a93fix: bug in chat deletion pagination interactcdac0cdrefactor: disable pagination moved to a function📊 Changes
11 files changed (+138 additions, -37 deletions)
View changed files
📝
backend/apps/webui/models/chats.py(+5 -4)📝
backend/apps/webui/routers/chats.py(+1 -1)📝
src/lib/apis/chats/index.ts(+2 -2)📝
src/lib/components/chat/Chat.svelte(+23 -8)📝
src/lib/components/chat/Messages.svelte(+2 -2)📝
src/lib/components/chat/Settings/Chats.svelte(+5 -3)📝
src/lib/components/chat/Tags.svelte(+6 -6)📝
src/lib/components/layout/Sidebar.svelte(+67 -7)📝
src/lib/components/layout/Sidebar/ChatItem.svelte(+16 -4)📝
src/lib/stores/index.ts(+4 -0)📝
src/lib/utils/index.ts(+7 -0)📄 Description
Changelog Entry
Description
This pr adds scroll pagination to the sidebar chat list.
This will improve first-load performance, and increase ui responsiveness in cases where there are many items in the chat history.
#2078
Added
Changed
skipandlimitskipas offset andlimitas limitskipandlimitin the backend are changed to0and-1to ensure that this change does not impact other users of this endpoint, as the frontend api function has been changed to include these default values as well. limit -1 with no offset would work as if those arguments were not passed.chatsstore now use thepageSkipandpageLimitto determine how much of the chat list actually needs to be rehydrated.Additional Information
Math.round(window.innerHeight / 35) + 5where 35 is the approximate height of a single chat in pixels.divis smaller than the viewport height, thedivwill no longer be scrollable, so the user can only see the chats that were loaded already.viewing the chat list filtered by tag, when the user deletes a tag from a chat, the chat list goes back to showing all chats. this doesn't happen inresolved0.3.11I spent an hour trying to fix this with no progress.progress
pageLimitvalues in different network conditions and screen sizesScreenshots and Videos
demo
basic functionality
https://github.com/user-attachments/assets/513b601c-b60c-40e3-94ed-3e18be4a9f44
apply filter loads all chats and disabled pagination
https://github.com/user-attachments/assets/ea5c3586-f9f2-4ac6-9354-2570b0f68b9f
search bar focus disables pagination and loads all chats
https://github.com/user-attachments/assets/39bf4a89-adec-4435-8b34-e0fca388ad46
deleting or archiving a chat only rehydrates up to the current page
https://github.com/user-attachments/assets/35dbac2e-3faa-46b5-b52f-21fc5b477e80
attempt chat list refetch while pagination disabled (fetches all chats)
https://github.com/user-attachments/assets/5d1fd869-00fe-41a8-ac94-d8a41c1d8b03
new chat, title gen, and subsequent messages only rehydrates up to the current page
https://github.com/user-attachments/assets/209b99a0-bb6e-4bbf-9066-c35702bb73b9
determine page size based on
window.innerHeighthttps://github.com/user-attachments/assets/477e3681-5fc7-479c-aecf-b06708e523db
mobile experience
https://github.com/user-attachments/assets/1db0c4b4-94ee-4ba6-a46a-e96ecb204b5f
slow network sim
https://github.com/user-attachments/assets/c34b59af-d8ca-4a9e-9983-42dec3bf5326
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.