fix(kb): added proper pagination for documents in kb#937
fix(kb): added proper pagination for documents in kb#937waleedlatif1 merged 1 commit intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
There was a problem hiding this comment.
Greptile Summary
This PR implements proper server-side pagination for documents in the knowledge base, fixing a performance issue where the frontend was loading all documents (up to 10,000) at once despite the API supporting pagination.
The changes span three key files:
-
use-knowledge.ts: Refactored the hook to use server-side pagination by passing search, limit, and offset parameters directly to the API instead of performing client-side filtering. Removed theMAX_DOCUMENTS_LIMITconstant and simplified the data flow by eliminating client-sideuseMemocalculations. -
store.ts: Updated the caching strategy to match exact request parameters (search, limit, offset) rather than just checking if any cached data exists. This ensures that different pagination requests don't return stale cached results. Also simplified therefreshDocumentsfunction by removing complex document merging logic. -
base.tsx: Removed thedisabled:cursor-not-allowedCSS class from pagination buttons to improve UX during loading states, keeping only thedisabled:opacity-50for visual feedback.
These changes align the frontend implementation with the existing API pagination capabilities, improving performance and scalability for knowledge bases with large document collections by reducing memory usage and network transfer.
PR Description Notes:
- Minor typo: "Preivously" should be "Previously"
Confidence score: 3/5
- This PR addresses a legitimate performance issue but introduces potential regressions in caching behavior and user experience
- Score reflects concerns about cache invalidation strategy and loss of optimistic UI updates in the store refactoring
- Pay close attention to
stores/knowledge/store.tswhere the caching logic changes may cause cache misses and affect document upload UX
3 files reviewed, no comments
Summary
added proper pagination for documents in kb. Preivously the api supported pagination but we loaded all documents in the frontend
Type of Change
Testing
Tested manually.
Checklist
Screenshots/Videos
Screen.Recording.2025-08-11.at.2.09.45.PM.mov