-
Notifications
You must be signed in to change notification settings - Fork 0
feat(state): add encodeCursor/decodeCursor for pagination #71
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-8/types/hash-id
Are you sure you want to change the base?
Conversation
63c1be5 to
53afbd2
Compare
f7beb26 to
501e6c9
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: 53afbd2a01
ℹ️ 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".
53afbd2 to
40d8c28
Compare
40d8c28 to
a527918
Compare
501e6c9 to
538ae91
Compare
Greptile Summary
|
| Filename | Overview |
|---|---|
packages/state/src/index.ts |
Added encodeCursor() and decodeCursor() functions with URL-safe base64 implementation and comprehensive validation |
packages/state/src/__tests__/state.test.ts |
Added complete test coverage for cursor encoding functionality with round-trip and error handling tests |
Confidence score: 5/5
- This PR is safe to merge with minimal risk and follows established patterns
- Score reflects well-tested implementation with comprehensive error handling and adherence to TDD methodology
- No files require special attention as both implementation and tests are thorough and consistent
Sequence Diagram
sequenceDiagram
participant User
participant CLI as "CLI Application"
participant Store as "CursorStore"
participant Encoder as "encodeCursor/decodeCursor"
User->>CLI: "Request paginated data"
CLI->>Store: "createCursor({position: 0})"
Store-->>CLI: "Result<Cursor>"
CLI->>Encoder: "encodeCursor(cursor)"
Encoder-->>CLI: "URL-safe base64 token"
CLI-->>User: "Return data + encoded cursor token"
User->>CLI: "Request next page with cursor token"
CLI->>Encoder: "decodeCursor(token)"
Encoder-->>CLI: "Result<Cursor>"
CLI->>Store: "advanceCursor(cursor, newPosition)"
Store-->>CLI: "New Cursor"
CLI->>Store: "set(advancedCursor)"
CLI->>Encoder: "encodeCursor(advancedCursor)"
Encoder-->>CLI: "New URL-safe base64 token"
CLI-->>User: "Return next page + new cursor token"
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.
2 files reviewed, 2 comments
a527918 to
acafeb4
Compare
538ae91 to
a0c8b3f
Compare
|
Added coverage to reject negative cursor positions when decoding encoded cursors. |
a0c8b3f to
cdebbd0
Compare
acafeb4 to
542dd50
Compare
|
Replaced Buffer-based base64 in cursor encode/decode and tests with TextEncoder + btoa/atob helpers, and kept the negative-position validation in decodeCursor. |
URL-safe base64 encoding (RFC 4648 Section 5) for opaque cursor tokens. Handles encoding/decoding of pagination state for API responses. Closes #47 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
542dd50 to
f814d80
Compare
cdebbd0 to
d8ed1ee
Compare
|
Resolved the Greptile Buffer/base64 feedback (already switched to TextEncoder + btoa/atob) and resubmitted after downstack updates. |

URL-safe base64 encoding (RFC 4648 Section 5) for opaque cursor tokens.
Handles encoding/decoding of pagination state for API responses.
Closes #47
Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com