Skip to content

Conversation

@galligan
Copy link
Contributor

  • Add paginate() 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

Copy link
Contributor Author

galligan commented Jan 23, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a 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".

@greptile-apps
Copy link

greptile-apps bot commented Jan 23, 2026

Greptile Summary

  • Adds pagination helper functions to @outfitter/state package with paginate<T>() for array slicing, cursor persistence functions, and a simplified PaginationStore interface
  • Implements DEFAULT_PAGE_LIMIT constant (25) and singleton pattern for default pagination store to enable cursor persistence across operations
  • Includes comprehensive test coverage following TDD Red phase methodology with 9 test cases covering pagination slicing, edge cases, and cursor persistence

Important Files Changed

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"
Loading

@galligan galligan force-pushed the p3-11/logging/default-patterns branch from c187efe to 3df0449 Compare January 23, 2026 21:27
@galligan galligan force-pushed the p3-12/state/pagination-helpers branch from 49083b5 to 1a27fc3 Compare January 23, 2026 21:27
@galligan
Copy link
Contributor Author

Added pagination tests to ensure non-positive limits fall back to DEFAULT_PAGE_LIMIT and still advance the cursor.

galligan and others added 2 commits January 23, 2026 18:06
- 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>
@galligan galligan force-pushed the p3-12/state/pagination-helpers branch from 1a27fc3 to 6c1bed2 Compare January 23, 2026 23:09
@galligan galligan force-pushed the p3-11/logging/default-patterns branch from 3df0449 to 8166f4f Compare January 23, 2026 23:09
@galligan
Copy link
Contributor Author

Restacked after downstack update (formatRelative test stabilization); no additional changes in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants