Skip to content

Add pagination for quote and history lists#73

Merged
DemonGiggle merged 2 commits into
mainfrom
fix-72-list-pagination
May 8, 2026
Merged

Add pagination for quote and history lists#73
DemonGiggle merged 2 commits into
mainfrom
fix-72-list-pagination

Conversation

@DemonGiggle
Copy link
Copy Markdown
Owner

Summary

  • add count and limit/offset pagination for recall history through the store, engine, app, web, and client layers
  • switch TUI quote/history list pages to paged loading with page metadata and left/right page navigation
  • switch the desktop/web frontend quote/history lists to previous/next paging, while preserving full-library quote loading only when a library filter is active
  • add history pagination tests and update TUI expectations for the clarified visible-selection wording

Validation

  • go test ./...
  • npm --prefix frontend run build

Fixes #72

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>
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 thread tui/pages/pagination.go
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
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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>
@DemonGiggle DemonGiggle merged commit 9faf39f into main May 8, 2026
4 checks passed
@DemonGiggle DemonGiggle deleted the fix-72-list-pagination branch May 10, 2026 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Paginate quote and history lists to fix large-dataset performance

1 participant