feat: add pagination and sorting to listSessions#331
Open
adwibha wants to merge 2 commits into
Open
Conversation
kalenkevich
approved these changes
May 11, 2026
Author
|
I see |
Add pagination and sorting capabilities to the session listing API. Changes: - ListSessionsRequest now accepts limit, offset, page, and order parameters - ListSessionsResponse now includes page, limit, totalItems, and totalPages - Sorting by updateTime (ascending or descending) with id as tie-breaker - Pagination logic: use limit if provided, fall back to offset-only slicing, or return all - Pagination metadata always included in response for consistency - Database layer counts total items efficiently for offset-only requests - Both DatabaseSessionService and InMemorySessionService implement identically - Added 23 test cases covering pagination edge cases and sorting Closes google#324
b2971e0 to
dcde2db
Compare
Author
|
Hello @kalenkevich, Rebased onto latest Note: |
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.
What this does
Adds pagination and sorting to the
listSessionsfunction, as requested in #324.You can now:
limitandoffset, or usepagefor convenienceAnd it's backward compatible, existing code that doesn't use these features works exactly as before.
How it works
limit, you get paginated results with metadataoffsetalone, it slices from that positionorder, there's no sorting overheadBoth the database and in-memory implementations work the same way.
Link to Issue or Description of Change
1. Link to an existing issue:
Testing Plan
Unit Tests:
Test results: 1306 tests passed (23 new tests added for pagination and sorting)
Manual testing:
Direct service calls work as expected:
Checklist
Additional context
This PR implements the core service layer fully per spec. The HTTP API layer (dev/src/server routes and AdkApiClient) to expose these features is intentionally left as a follow-up to keep this focused.