Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@N2D4
Copy link
Contributor

@N2D4 N2D4 commented Jan 7, 2026

Note

Modernizes pagination API and behavior with clearer cursor semantics and robust coverage.

  • Switches QueryResult.items to include prevCursor/nextCursor and updates slicing to use them in nextOrPrev
  • Refactors ArrayPaginatedList to use before-{n} cursors, sort/filter before slicing, and compute isFirst/isLast against the sorted view
  • Enhances PaginatedList.merge to build JSON array cursors per item, maintain order for next/prev, and validate consistent comparators (adds extra error context)
  • Updates map/flatMap to preserve and propagate item cursors
  • Adds extensive JSDoc to PaginatedList and ArrayPaginatedList for usage and contracts
  • Introduces comprehensive tests covering forward/backward pagination, cursor semantics, filtering/ordering, limit precision, transforms (map/filter/flatMap), merge, and edge cases

Written by Cursor Bugbot for commit 39d7bd9. This will update automatically on new commits. Configure here.

Summary by CodeRabbit

  • New Features

    • Improved pagination with per-item cursor continuity, stricter boundary handling, and precise limit semantics
    • Enhanced support for filtering, ordering, transformations (map/flatMap) and merging multiple paginated lists
  • Tests

    • Extensive test coverage for forward/backward navigation, cursor semantics, filtering, ordering, limit behaviors, merging, transformations, and numerous edge cases

✏️ Tip: You can customize this high-level summary in your review settings.

Copilot AI review requested due to automatic review settings January 7, 2026 20:21
@cmux-agent
Copy link

cmux-agent bot commented Jan 7, 2026

Older cmux preview screenshots (latest comment is below)

Preview Screenshots

Open Workspace (1 hr expiry) Β· Open Dev Browser (1 hr expiry) Β· Open Diff Heatmap

Screenshot capture was skipped.

No UI changes detected - screenshots skipped


Generated by cmux preview system

@vercel
Copy link

vercel bot commented Jan 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
stack-backend Ready Ready Preview, Comment Jan 7, 2026 9:00pm
stack-dashboard Ready Ready Preview, Comment Jan 7, 2026 9:00pm
stack-demo Ready Ready Preview, Comment Jan 7, 2026 9:00pm
stack-docs Ready Ready Preview, Comment Jan 7, 2026 9:00pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 7, 2026

πŸ“ Walkthrough

Walkthrough

This PR replaces a simple cursor model with a new abstract PaginatedList (per-item prevCursor/nextCursor), adds an ArrayPaginatedList concrete implementation, and expands APIs with composition utilities (map, flatMap, filter, addFilter, merge, empty). Extensive tests for pagination flows and edge cases are added.

Changes

Cohort / File(s) Summary
Tests
packages/stack-shared/src/utils/paginated-lists.test.ts
New comprehensive test suite validating forward/backward pagination, per-item prevCursor/nextCursor, filtering, ordering, limit-precision modes, map/flatMap, merge, empty cases, and varied edge cases.
Pagination Core
packages/stack-shared/src/utils/paginated-lists.tsx
Adds abstract PaginatedList<Item, Cursor, Filter, OrderBy> with nextOrPrev, next, prev, map, flatMap, filter, addFilter, merge, empty; changes QueryResult/ImplQueryResult to per-item prevCursor/nextCursor; implements ArrayPaginatedList (cursor format before-{index}), cursor composition for merges, and updated cursor propagation across transforms.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Client as Client Code
    participant PL as PaginatedList (abstract)
    participant Impl as ArrayPaginatedList (concrete)
    participant Filter as Filter/Order Logic

    User->>Client: request page (after/before, limit)
    Client->>PL: next/prev(options)
    PL->>Impl: nextOrPrev(type, options)

    rect rgb(230,245,255)
        note over Impl,Filter: Apply filters & ordering to full dataset
        Impl->>Filter: evaluate items
        Filter-->>Impl: filtered/sorted list
    end

    rect rgb(245,230,255)
        note over Impl: Assign per-item cursors
        Impl->>Impl: compute prevCursor / nextCursor
        Impl->>Impl: slice by limit & precision
    end

    Impl-->>PL: QueryResult{ items[{item,prevCursor,nextCursor}], isFirst,isLast, cursor }
    PL-->>Client: QueryResult to caller

    rect rgb(245,240,230)
        note over Client,PL: Composition flows (map/flatMap/merge)
        Client->>PL: map/filter/merge => new PaginatedList
        Client->>PL: composed.next(options)
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Poem

πŸ‡ I hopped through lists, cursors in pair,

prev and next, assigned with care.
I map and merge, then filter tooβ€”
Pages forward, pages through.
Small rabbit, big paginate-cheer!

πŸš₯ Pre-merge checks | βœ… 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title "Paginated list tests" is vague and generic, describing only that tests were added without clarifying the scope or the modernization of the pagination API that is the actual main change. Revise the title to reflect the primary change, such as "Modernize pagination API with prevCursor/nextCursor semantics and comprehensive tests" or "Refactor paginated lists with new cursor model and test coverage".
βœ… Passed checks (2 passed)
Check name Status Explanation
Description check βœ… Passed The PR description is well-structured with a comprehensive bullet-point summary of changes, detailed notes on the modernization, and clear explanations of cursor semantics and API updates, exceeding the minimal template requirements.
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • πŸ“ Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive test coverage for the paginated lists utility and refactors cursor semantics from a single itemCursor to separate prevCursor and nextCursor fields. The changes also include extensive documentation improvements and fixes to the pagination logic.

  • Refactored cursor representation: each item now has both prevCursor (position before the item) and nextCursor (position after the item) instead of a single itemCursor
  • Fixed while loop condition in nextOrPrev to properly stop when reaching list boundaries
  • Added comprehensive test suite with 783 lines covering basic pagination, filtering, sorting, cursor semantics, utility methods (map, filter, flatMap, merge), and edge cases

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
packages/stack-shared/src/utils/paginated-lists.tsx Refactored cursor fields from itemCursor to prevCursor/nextCursor, updated ArrayPaginatedList cursor format to before-${number}, fixed pagination loop logic, added extensive JSDoc documentation for all public methods, and removed unused range import
packages/stack-shared/src/utils/paginated-lists.test.ts Added comprehensive test suite covering ArrayPaginatedList functionality, cursor semantics, filtering, ordering, limitPrecision modes, utility methods (map, filter, flatMap, merge), edge cases, and complete pagination walkthroughs

πŸ’‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 7, 2026

Greptile Summary

Added comprehensive test coverage for paginated list utilities and refactored cursor semantics from single itemCursor to separate prevCursor/nextCursor to better represent that cursors point between items rather than at items.

Key changes:

  • Cursor format change: "0" β†’ "before-0" for clarity
  • Cursor semantics: Split itemCursor into prevCursor (before item) and nextCursor (after item)
  • Bug fix: Fixed loop condition in nextOrPrev (line 102) - was || (type === "next" && includesLast) causing infinite loops, now correctly checks && (type !== "next" || !includesLast)
  • Test coverage: Added 783 lines of tests covering pagination, filtering, sorting, merging, and edge cases

Issues found:

  • Critical: ArrayPaginatedList creates cursors before sorting (line 447), meaning pagination through an unsorted array with sorting applied will return wrong items
  • Documentation mismatch: Line 417 claims "re-sorts the entire array" but implementation only sorts the sliced window
  • Test gap: All sorting tests either fetch all items at once or use pre-sorted arrays, missing the critical case of paginating through an unsorted array with sorting

Confidence Score: 2/5

  • This PR has a critical logic bug in ArrayPaginatedList that breaks pagination with sorting
  • The cursor assignment happens before sorting (line 447-450), which breaks pagination when the array isn't pre-sorted. While tests pass, they don't cover this scenario. The loop condition fix (line 102) is correct, but the cursor ordering bug is critical.
  • packages/stack-shared/src/utils/paginated-lists.tsx - ArrayPaginatedList._nextOrPrev method has incorrect cursor assignment order

Important Files Changed

Filename Overview
packages/stack-shared/src/utils/paginated-lists.test.ts New test file with comprehensive coverage of pagination, but missing critical test case for paginating through unsorted arrays with sorting
packages/stack-shared/src/utils/paginated-lists.tsx Changed cursor semantics from itemCursor to prevCursor/nextCursor, fixed loop condition bug, but ArrayPaginatedList implementation has issues with cursor assignment order

Sequence Diagram

sequenceDiagram
    participant Client
    participant PaginatedList
    participant ArrayPaginatedList
    
    Client->>PaginatedList: next({after: "before-0", limit: 2, filter, orderBy})
    PaginatedList->>PaginatedList: nextOrPrev("next", options)
    
    loop while limitRemaining > 0 && !includesLast
        PaginatedList->>ArrayPaginatedList: _nextOrPrev("next", {cursor, limit, filter, orderBy})
        ArrayPaginatedList->>ArrayPaginatedList: Extract cursor position
        ArrayPaginatedList->>ArrayPaginatedList: Calculate new cursor position
        ArrayPaginatedList->>ArrayPaginatedList: Create entries with prevCursor/nextCursor
        ArrayPaginatedList->>ArrayPaginatedList: Slice array window
        ArrayPaginatedList->>ArrayPaginatedList: Filter items
        ArrayPaginatedList->>ArrayPaginatedList: Sort items
        ArrayPaginatedList-->>PaginatedList: {items, isFirst, isLast, cursor}
        PaginatedList->>PaginatedList: Append/prepend to result
        PaginatedList->>PaginatedList: Update limitRemaining
    end
    
    PaginatedList->>PaginatedList: Verify items are sorted
    PaginatedList->>PaginatedList: Trim to exact limit if needed
    PaginatedList-->>Client: {items: [{item, prevCursor, nextCursor}], isFirst, isLast, cursor}
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/stack-shared/src/utils/paginated-lists.test.ts (1)

567-657: Consider adding backward pagination test for merged lists.

All merge tests use forward pagination (next). Given that the merge implementation has separate logic for handling prev direction with reversed iteration and cursor tracking, adding a test for backward pagination through merged lists would improve coverage and confidence.

πŸ§ͺ Suggested test for backward pagination on merged lists
it("should paginate backwards through merged list", async () => {
  const list1 = new ArrayPaginatedList([1, 3, 5, 7, 9]);
  const list2 = new ArrayPaginatedList([2, 4, 6, 8, 10]);

  const merged = PaginatedList.merge(list1, list2);

  const last = await merged.prev({
    before: merged.getLastCursor(),
    limit: 4,
    filter: () => true,
    orderBy: (a, b) => a - b,
    limitPrecision: "exact",
  });

  expect(items(last)).toEqual([7, 8, 9, 10]);

  const middle = await merged.prev({
    before: last.cursor,
    limit: 4,
    filter: () => true,
    orderBy: (a, b) => a - b,
    limitPrecision: "exact",
  });

  expect(items(middle)).toEqual([3, 4, 5, 6]);
});
packages/stack-shared/src/utils/paginated-lists.tsx (1)

336-336: Acceptable use of any for heterogeneous cursor types.

Using any for the cursor type parameter is reasonable here since merged lists may have different cursor types, and the merged cursor is JSON-encoded. Consider adding a brief comment explaining this design choice.

πŸ“ Suggested comment
   static merge<
     Item,
     Filter extends unknown,
     OrderBy extends unknown,
   >(
+    // Cursor type is `any` because merged lists may have different cursor types;
+    // the merged cursor is a JSON-encoded array of individual list cursors
     ...lists: PaginatedList<Item, any, Filter, OrderBy>[]
   ): PaginatedList<Item, string, Filter, OrderBy> {
πŸ“œ Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 7a39d7c and 0634e8f.

πŸ“’ Files selected for processing (2)
  • packages/stack-shared/src/utils/paginated-lists.test.ts
  • packages/stack-shared/src/utils/paginated-lists.tsx
🧰 Additional context used
πŸ““ Path-based instructions (6)
**/*.{tsx,ts,jsx,js}

πŸ“„ CodeRabbit inference engine (AGENTS.md)

For blocking alerts and errors, never use toast; instead, use alerts as toasts are easily missed by the user

Files:

  • packages/stack-shared/src/utils/paginated-lists.test.ts
  • packages/stack-shared/src/utils/paginated-lists.tsx
**/*.{test,spec}.{ts,tsx,js,jsx}

πŸ“„ CodeRabbit inference engine (AGENTS.md)

When writing tests, prefer .toMatchInlineSnapshot() over other selectors if possible; check snapshot-serializer.ts to understand how snapshots are formatted and how non-deterministic values are handled

Files:

  • packages/stack-shared/src/utils/paginated-lists.test.ts
**/*.{tsx,ts}

πŸ“„ CodeRabbit inference engine (AGENTS.md)

NEVER use Next.js dynamic functions if avoidable; prefer using client components instead to keep pages static (e.g., use usePathname instead of await params)

Files:

  • packages/stack-shared/src/utils/paginated-lists.test.ts
  • packages/stack-shared/src/utils/paginated-lists.tsx
**/*.{ts,tsx,js,jsx}

πŸ“„ CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js,jsx}: NEVER try-catch-all, NEVER void a promise, and NEVER use .catch(console.error) or similar; use loading indicators instead; if asynchronous handling is necessary, use runAsynchronously or runAsynchronouslyWithAlert instead
Use ES6 maps instead of records wherever possible

Files:

  • packages/stack-shared/src/utils/paginated-lists.test.ts
  • packages/stack-shared/src/utils/paginated-lists.tsx
**/*.{ts,tsx}

πŸ“„ CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Code defensively; prefer ?? throwErr(...) over non-null assertions with good error messages explicitly stating violated assumptions
Avoid the any type; when necessary, leave a comment explaining why it's used, why the type system fails, and how errors would be caught at compile-, test-, or runtime

Files:

  • packages/stack-shared/src/utils/paginated-lists.test.ts
  • packages/stack-shared/src/utils/paginated-lists.tsx
**/*.{tsx,css}

πŸ“„ CodeRabbit inference engine (AGENTS.md)

**/*.{tsx,css}: Keep hover/click animations snappy and fast; don't delay actions with pre-transitions (e.g., no fade-in on button hover) as it makes UI feel sluggish; instead apply transitions after the action like smooth fade-out when hover ends
When creating hover transitions, avoid hover-enter transitions and use only hover-exit transitions (e.g., transition-colors hover:transition-none)

Files:

  • packages/stack-shared/src/utils/paginated-lists.tsx
🧠 Learnings (1)
πŸ“š Learning: 2026-01-07T00:55:19.856Z
Learnt from: CR
Repo: stack-auth/stack-auth PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T00:55:19.856Z
Learning: Applies to **/e2e/**/*.{test,spec}.{ts,tsx,js,jsx} : ALWAYS add new E2E tests when changing the API or SDK interface; err on the side of creating too many tests due to the critical nature of the authentication industry

Applied to files:

  • packages/stack-shared/src/utils/paginated-lists.test.ts
🧬 Code graph analysis (2)
packages/stack-shared/src/utils/paginated-lists.test.ts (3)
apps/e2e/tests/helpers.ts (1)
  • it (12-12)
packages/stack-shared/src/utils/paginated-lists.tsx (1)
  • ArrayPaginatedList (433-458)
packages/stack-shared/src/utils/strings.tsx (1)
  • stringCompare (61-65)
packages/stack-shared/src/utils/paginated-lists.tsx (1)
packages/stack-shared/src/utils/errors.tsx (1)
  • StackAssertionError (69-85)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (16)
  • GitHub Check: Vercel Agent Review
  • GitHub Check: CodeQL analysis (javascript-typescript)
  • GitHub Check: Agent
  • GitHub Check: Cursor Bugbot
  • GitHub Check: build (22.x)
  • GitHub Check: lint_and_build (latest)
  • GitHub Check: all-good
  • GitHub Check: restart-dev-and-test-with-custom-base-port
  • GitHub Check: check_prisma_migrations (22.x)
  • GitHub Check: docker
  • GitHub Check: setup-tests-with-custom-base-port
  • GitHub Check: E2E Tests (Node 22.x, Freestyle prod)
  • GitHub Check: E2E Tests (Node 22.x, Freestyle mock)
  • GitHub Check: setup-tests
  • GitHub Check: build (22.x)
  • GitHub Check: restart-dev-and-test
πŸ”‡ Additional comments (7)
packages/stack-shared/src/utils/paginated-lists.test.ts (3)

1-9: LGTM on imports and helper setup.

The items helper function cleanly extracts item values from paginated results, improving test readability.


11-96: Solid coverage of forward pagination scenarios.

Tests correctly verify boundary flags (isFirst/isLast), cursor continuation, and edge cases (empty array, limit 0).


734-782: Excellent integration tests for complete traversal.

These walkthrough tests validate that repeated pagination calls correctly collect all items in both forward and backward directions, providing confidence in the cursor continuation logic.

packages/stack-shared/src/utils/paginated-lists.tsx (4)

32-76: Well-documented API with clear examples.

The JSDoc comments effectively explain the cursor-based pagination model, including the stability guarantee that cursors remain valid even when filters change.


96-141: Robust implementation with sort validation.

The sort order assertion (lines 119-127) is a good defensive measure that catches implementation bugs early. The loop correctly handles the different limitPrecision modes.


396-408: Empty list implementation is correct.

The any types for filter/orderBy are acceptable here since an empty list never processes any items. The implementation correctly returns isFirst: true, isLast: true for all queries.


433-458: Clear implementation with appropriate performance caveat.

The documentation correctly notes that this implementation re-filters and re-sorts on each query, making it suitable only for small datasets. The cursor stability (tied to original array indices) correctly implements the documented contract.

@cmux-agent
Copy link

cmux-agent bot commented Jan 7, 2026

Preview Screenshots

Open Diff Heatmap

⏳ Preview screenshots are being captured...

Workspace and dev browser links will appear here once the preview environment is ready.


Generated by cmux preview system

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/stack-shared/src/utils/paginated-lists.tsx (1)

403-415: Consider using generic type parameters instead of any.

The empty() factory uses any for Filter and OrderBy types. While this works functionally since the empty list never uses these values, using proper generics would improve type safety.

πŸ’‘ Suggested improvement
-  static empty() {
-    class EmptyPaginatedList extends PaginatedList<never, "first" | "last", any, any> {
+  static empty<Filter = unknown, OrderBy = unknown>(): PaginatedList<never, "first" | "last", Filter, OrderBy> {
+    class EmptyPaginatedList extends PaginatedList<never, "first" | "last", Filter, OrderBy> {
πŸ“œ Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 0634e8f and 39d7bd9.

πŸ“’ Files selected for processing (2)
  • packages/stack-shared/src/utils/paginated-lists.test.ts
  • packages/stack-shared/src/utils/paginated-lists.tsx
🧰 Additional context used
πŸ““ Path-based instructions (6)
**/*.{tsx,ts,jsx,js}

πŸ“„ CodeRabbit inference engine (AGENTS.md)

For blocking alerts and errors, never use toast; instead, use alerts as toasts are easily missed by the user

Files:

  • packages/stack-shared/src/utils/paginated-lists.test.ts
  • packages/stack-shared/src/utils/paginated-lists.tsx
**/*.{test,spec}.{ts,tsx,js,jsx}

πŸ“„ CodeRabbit inference engine (AGENTS.md)

When writing tests, prefer .toMatchInlineSnapshot() over other selectors if possible; check snapshot-serializer.ts to understand how snapshots are formatted and how non-deterministic values are handled

Files:

  • packages/stack-shared/src/utils/paginated-lists.test.ts
**/*.{tsx,ts}

πŸ“„ CodeRabbit inference engine (AGENTS.md)

NEVER use Next.js dynamic functions if avoidable; prefer using client components instead to keep pages static (e.g., use usePathname instead of await params)

Files:

  • packages/stack-shared/src/utils/paginated-lists.test.ts
  • packages/stack-shared/src/utils/paginated-lists.tsx
**/*.{ts,tsx,js,jsx}

πŸ“„ CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js,jsx}: NEVER try-catch-all, NEVER void a promise, and NEVER use .catch(console.error) or similar; use loading indicators instead; if asynchronous handling is necessary, use runAsynchronously or runAsynchronouslyWithAlert instead
Use ES6 maps instead of records wherever possible

Files:

  • packages/stack-shared/src/utils/paginated-lists.test.ts
  • packages/stack-shared/src/utils/paginated-lists.tsx
**/*.{ts,tsx}

πŸ“„ CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Code defensively; prefer ?? throwErr(...) over non-null assertions with good error messages explicitly stating violated assumptions
Avoid the any type; when necessary, leave a comment explaining why it's used, why the type system fails, and how errors would be caught at compile-, test-, or runtime

Files:

  • packages/stack-shared/src/utils/paginated-lists.test.ts
  • packages/stack-shared/src/utils/paginated-lists.tsx
**/*.{tsx,css}

πŸ“„ CodeRabbit inference engine (AGENTS.md)

**/*.{tsx,css}: Keep hover/click animations snappy and fast; don't delay actions with pre-transitions (e.g., no fade-in on button hover) as it makes UI feel sluggish; instead apply transitions after the action like smooth fade-out when hover ends
When creating hover transitions, avoid hover-enter transitions and use only hover-exit transitions (e.g., transition-colors hover:transition-none)

Files:

  • packages/stack-shared/src/utils/paginated-lists.tsx
🧠 Learnings (1)
πŸ“š Learning: 2026-01-07T00:55:19.856Z
Learnt from: CR
Repo: stack-auth/stack-auth PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-07T00:55:19.856Z
Learning: Applies to **/e2e/**/*.{test,spec}.{ts,tsx,js,jsx} : ALWAYS add new E2E tests when changing the API or SDK interface; err on the side of creating too many tests due to the critical nature of the authentication industry

Applied to files:

  • packages/stack-shared/src/utils/paginated-lists.test.ts
🧬 Code graph analysis (1)
packages/stack-shared/src/utils/paginated-lists.tsx (1)
packages/stack-shared/src/utils/errors.tsx (1)
  • StackAssertionError (69-85)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: Vercel Agent Review
  • GitHub Check: Cursor Bugbot
  • GitHub Check: docker
  • GitHub Check: all-good
  • GitHub Check: setup-tests-with-custom-base-port
  • GitHub Check: build (22.x)
  • GitHub Check: check_prisma_migrations (22.x)
  • GitHub Check: setup-tests
  • GitHub Check: build (22.x)
  • GitHub Check: E2E Tests (Node 22.x, Freestyle mock)
  • GitHub Check: lint_and_build (latest)
  • GitHub Check: E2E Tests (Node 22.x, Freestyle prod)
  • GitHub Check: restart-dev-and-test
  • GitHub Check: restart-dev-and-test-with-custom-base-port
πŸ”‡ Additional comments (8)
packages/stack-shared/src/utils/paginated-lists.tsx (3)

32-53: LGTM!

The documentation is comprehensive with clear examples demonstrating usage patterns for cursor-based pagination.


96-141: LGTM!

The nextOrPrev implementation correctly handles:

  • Loop termination based on limit and boundary conditions
  • Result sorting validation
  • Proper cursor advancement when trimming for exact/at-most precision

181-222: LGTM!

The flatMap implementation correctly passes the full item entry (including cursor metadata) to the mapper and propagates the new cursor structure.

packages/stack-shared/src/utils/paginated-lists.test.ts (5)

11-96: LGTM!

Comprehensive test coverage for basic forward pagination including edge cases (empty array, zero limit).


98-145: LGTM!

Backward pagination tests properly verify cursor chaining and boundary flags.


147-221: LGTM!

Thorough testing of the per-item prevCursor/nextCursor semantics including cursor chaining in both directions.


707-814: LGTM!

Excellent coverage of merge backward pagination including:

  • Single backward page (lines 707-737)
  • Complete backward walkthrough (lines 739-764)
  • Forward/backward consistency verification (lines 766-814)

These tests validate the fixes to merge backward pagination logic.


1-9: LGTM!

Well-structured test file with comprehensive coverage. The helper function items() at line 9 cleanly extracts item values from paginated results, reducing test verbosity.

@N2D4 N2D4 merged commit dc93c70 into dev Jan 7, 2026
21 of 24 checks passed
@N2D4 N2D4 deleted the paginated-list-tests branch January 7, 2026 21:13
@coderabbitai coderabbitai bot mentioned this pull request Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants