Skip to content

Conversation

@musonza
Copy link
Owner

@musonza musonza commented Jan 4, 2026

Summary

  • Adds cursor-based pagination as an alternative to offset-based pagination for message retrieval
  • Cursor pagination prevents duplicate messages when new messages arrive between page loads
  • Maintains backwards compatibility by adding a new endpoint rather than modifying the existing one

New Endpoint

GET /conversations/{id}/messages-cursor

Parameters:

  • participant_id (required)
  • participant_type (required)
  • perPage (optional, default: 25)
  • sorting (optional: asc/desc)
  • cursor (optional - from previous response)

Programmatic Usage

Chat::conversation($conversation)
    ->setParticipant($user)
    ->setCursorPaginationParams(['perPage' => 25, 'cursor' => $nextCursor])
    ->getMessagesWithCursor();

Test plan

  • Basic cursor pagination returns correct response structure
  • Navigation through multiple pages using cursor works correctly
  • Descending sort order works as expected
  • Required parameter validation works

Closes #324

@musonza musonza self-assigned this Jan 4, 2026
Cursor pagination is more suitable for real-time chat applications as it
avoids duplicate messages when new messages arrive between page loads.

This adds a new endpoint alongside the existing offset-based pagination
to maintain backwards compatibility.

New endpoint: GET /conversations/{id}/messages-cursor

Closes #324
@musonza musonza force-pushed the feature/cursor-pagination branch from ca23378 to 1423e46 Compare January 4, 2026 21:21
@musonza musonza merged commit 74b1dde into master Jan 4, 2026
10 checks passed
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.

Current message pagination approach is not well-suited to a realtime chat application

2 participants