-
Notifications
You must be signed in to change notification settings - Fork 0
feat(state): add pagination helpers #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: p3-11/logging/default-patterns
Are you sure you want to change the base?
feat(state): add pagination helpers #74
Conversation
ad3fdae to
ce86912
Compare
a6e86d0 to
6614501
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6614501a22
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
6614501 to
61b42a2
Compare
1578d94 to
c187efe
Compare
61b42a2 to
49083b5
Compare
Greptile Summary
|
| Filename | Overview |
|---|---|
| packages/state/src/index.ts | Added complete pagination helpers API including paginate(), loadCursor(), saveCursor(), and PaginationStore interface |
| packages/state/src/tests/state.test.ts | Added comprehensive test suite with 9 test cases covering all pagination helper functions and edge cases |
Confidence score: 5/5
- This PR is extremely safe to merge with minimal risk as it only adds new functionality without modifying existing APIs
- Score reflects comprehensive test coverage following TDD methodology, well-documented functions, and proper integration with existing cursor infrastructure
- No files require special attention as the implementation follows established patterns and includes thorough testing
Sequence Diagram
sequenceDiagram
participant User
participant API as "API/Controller"
participant Store as "PaginationStore"
participant Paginate as "paginate()"
User->>API: "Request paginated data"
API->>Store: "loadCursor(id)"
Store-->>API: "Return cursor | null"
alt cursor exists
API->>Paginate: "paginate(items, cursor)"
Paginate-->>API: "Return {page, nextCursor}"
else no cursor
API->>API: "createCursor({position: 0})"
API->>Paginate: "paginate(items, newCursor)"
Paginate-->>API: "Return {page, nextCursor}"
end
opt nextCursor exists
API->>Store: "saveCursor(nextCursor)"
end
API-->>User: "Return page data + cursor token"
c187efe to
3df0449
Compare
49083b5 to
1a27fc3
Compare
|
Added pagination tests to ensure non-positive limits fall back to DEFAULT_PAGE_LIMIT and still advance the cursor. |
- Add paginate<T>() for slicing arrays with cursor-based pagination - Add loadCursor() and saveCursor() for cursor persistence - Add PaginationStore interface and createPaginationStore() factory - Add getDefaultPaginationStore() singleton accessor - Add DEFAULT_PAGE_LIMIT constant (25) Fixes #49, #50 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1a27fc3 to
6c1bed2
Compare
3df0449 to
8166f4f
Compare
|
Restacked after downstack update (formatRelative test stabilization); no additional changes in this PR. |

Fixes #49, #50
Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com