Skip to content

Cursor pagination — Phase 1: backward-compatible compat layer #441

Description

@lucy-meachem

Goal

Add cursor-based pagination support (x-has-more / x-next-cursor response headers) to the SDK's central pagination plumbing, backward-compatibly alongside the existing offset/x-total-count pagination. Ships first, before any backend change — it alters no endpoint behaviour.

Scope (Phase 1)

Core plumbing only — the three central pagination files plus a bulk helper:

  • ConnectionparseResponse reads x-has-more / x-next-cursor and wraps the body as { list, hasMore, nextCursor } when present (offset x-total-count path unchanged).
  • Paginated — add optional nextCursor + hasMore; hasNextPage() prefers hasMore over the endReached heuristic.
  • List.getNextPaginated — thread cursor (from previous.nextCursor) into the callback; derive endReached from hasMore when provided.
  • List.getAllPaginated — new loop helper that follows cursors until hasMore is false (for bulk fetchers in Phase 2).
  • Full test + build gate: npx jest, npx tsc -p . --noEmit, npm run lint.

All additive: responses without cursor headers behave exactly as today, so this is safe to release before the backend moves.

Confirmed decisions

  • Cursor sent back as the cursor query param.
  • Coexistence: SDK handles both offset and cursor responses.
  • Forward-only (no prev/jump-to-page).
  • No sort param on cursor endpoints (fixed server-side).

Not in this phase

Endpoint call-site migration → Phase 2 (#442).

References

  • Design: docs/superpowers/specs/2026-07-02-cursor-pagination-design.md
  • Plan (Tasks 1–4, 7): docs/superpowers/plans/2026-07-02-cursor-pagination.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions