Add pagination for quote and history lists#73
Merged
Conversation
Expose paged quote and recall history access through the app, web, MCP, TUI, and frontend layers. Update the TUI and desktop/web UI to show page metadata and use left/right for result paging while keeping pgup/pgdn for scrolling. Preserve full-library loading only when quote filtering is active, and cover the new history count and pagination paths with tests. Fixes #72 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Code Review
This pull request implements pagination for recall history and quotes across the database, engine, API, and user interfaces (TUI and frontend). It introduces new methods for counting records and fetching specific pages using limit and offset parameters. Feedback was provided to refactor the clampPageOffset helper function in the TUI to improve code clarity and maintainability by reusing existing pagination logic.
Comment on lines
+10
to
+22
| func clampPageOffset(totalCount int64, pageSize, offset int) int { | ||
| if totalCount <= 0 || pageSize <= 0 { | ||
| return 0 | ||
| } | ||
| if offset < 0 { | ||
| offset = 0 | ||
| } | ||
| maxOffset := int((totalCount - 1) / int64(pageSize) * int64(pageSize)) | ||
| if offset > maxOffset { | ||
| return maxOffset | ||
| } | ||
| return offset | ||
| } |
There was a problem hiding this comment.
The calculation for maxOffset is a bit dense. Reusing the logic from the totalPages function can make this function's intent clearer and improve maintainability.
func clampPageOffset(totalCount int64, pageSize, offset int) int {
if totalCount <= 0 || pageSize <= 0 {
return 0
}
if offset < 0 {
offset = 0
}
// Reuse logic from totalPages for clarity.
numPages := int((totalCount + int64(pageSize) - 1) / int64(pageSize))
maxOffset := (numPages - 1) * pageSize
if offset > maxOffset {
return maxOffset
}
return offset
}Normalize count responses in the frontend so both the desktop runtime
(raw numeric counts) and the web bridge ({count}) drive paging state
correctly.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Validation
Fixes #72