fix: paginate knowledge base dashboard lists#9055
Conversation
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- Switching
DocumentsTab.vuetov-data-table-serverkeeps thesearchprop butloadDocumentsdoesn’t sendsearchQueryto the backend, so the search now only applies to the current page instead of the full result set—consider either wiring the search term into the API call or reverting to client-side filtering semantics explicitly. - In
knowledge_base_service.list_kbs, you callkb_manager.list_kbs()to get all KBs and then slice in Python; if the underlying manager can support pagination, consider pushing thepage/page_sizedown to avoid loading the full list in memory for large deployments.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Switching `DocumentsTab.vue` to `v-data-table-server` keeps the `search` prop but `loadDocuments` doesn’t send `searchQuery` to the backend, so the search now only applies to the current page instead of the full result set—consider either wiring the search term into the API call or reverting to client-side filtering semantics explicitly.
- In `knowledge_base_service.list_kbs`, you call `kb_manager.list_kbs()` to get all KBs and then slice in Python; if the underlying manager can support pagination, consider pushing the `page`/`page_size` down to avoid loading the full list in memory for large deployments.
## Individual Comments
### Comment 1
<location path="dashboard/src/views/knowledge-base/components/DocumentsTab.vue" line_range="14-15" />
<code_context>
<!-- 文档列表 -->
<v-card variant="outlined">
- <v-data-table :headers="headers" :items="documents" :loading="loading" :search="searchQuery" :items-per-page="10">
+ <v-data-table-server :headers="headers" :items="documents" :loading="loading" :search="searchQuery"
+ :items-per-page="pageSize" :page="page" :items-length="total"
+ @update:page="onPageChange" @update:items-per-page="onItemsPerPageChange">
<template #item.doc_name="{ item }">
</code_context>
<issue_to_address>
**issue (bug_risk):** Using `v-data-table-server` with the `search` prop likely disables the existing client-side search behavior.
With `v-data-table-server`, filtering is expected to be done on the server, so the `search` prop is typically ignored. Here `searchQuery` is still passed to the component, but `loadDocuments` never sends it to `knowledgeApi.documents`, so search will likely stop working. Either pass `searchQuery` to the API and reload on search changes, or revert to `v-data-table` if you need client-side filtering.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Code Review
This pull request implements server-side pagination for both the knowledge base list and the documents list. It updates the backend services to calculate pagination slices and return total counts, and modifies the frontend Vue components to use pagination controls and v-data-table-server. Feedback points out that switching to v-data-table-server in DocumentsTab.vue breaks the search functionality because the backend list_documents API does not support search, and search query changes are not properly handled via events. Additionally, in knowledge_base_service.py, negative or zero values for page or page_size could lead to incorrect slicing, so slicing indices should be guarded using max(1, ...).
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Fixes the native knowledge base dashboard only showing the first page/default subset of knowledge bases and documents.
Modifications / 改动点
Added paginated loading for the native knowledge base list, including total count handling and page fallback after deletion.
Switched the knowledge base document table to server-side pagination so all documents can be navigated.
Returned
totalfrom knowledge base and document list service responses while preserving the existingitems/page/page_sizeshape.This is NOT a breaking change. / 这不是一个破坏性变更。
Screenshots or Test Results / 运行截图或测试结果
Results:
Checklist / 检查清单
😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
/ 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。
👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
/ 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。
🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in
requirements.txtandpyproject.toml./ 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到
requirements.txt和pyproject.toml文件相应位置。😮 My changes do not introduce malicious code.
/ 我的更改没有引入恶意代码。
Summary by Sourcery
Add proper server-side pagination for the knowledge base dashboard lists so all knowledge bases and documents can be browsed reliably.
New Features:
Bug Fixes:
Enhancements: