Skip to content

Conversation

@c-julin
Copy link
Contributor

@c-julin c-julin commented Jan 12, 2026

Summary

Implements unlimited pagination for Kafka message browsing, allowing users to navigate through arbitrarily large topics without loading all messages into memory.

Changes

Backend

  • Add stateless page token system using base64-encoded cursors
  • Implement round-robin message distribution across partitions
  • Add pagination fields to ListMessages proto (next_page_token)
  • Integration tests for multi-page scenarios

Frontend

  • Add "Load More" button for paginated message loading
  • Auto-load next page when scrolling to bottom (if no filters/limits)
  • Display loading state and message counts
  • Reset pagination when changing filters or page size

Key Features

  • Stateless pagination (no server-side state)
  • Consistent round-robin distribution ensures fair partition representation
  • Handles dynamic watermark changes between pages
  • Backward compatible with existing single-page mode

Add PageToken struct with encode/decode, validation, and cursor management for multi-partition offset tracking. Supports both ascending and descending order pagination.
Add page_token, page_size, next_page_token, and has_more fields to support cursor-based pagination in ListMessages API.
- Add PageToken and PageSize to ListMessagesRequest
- Pass next_page_token and has_more in completion message
- Validate pagination mode (maxResults=-1) and reject filters
- Add calculateConsumeRequestsWithPageToken with round-robin message distribution
- Support both ascending and descending order pagination
- Reverse messages per-partition for descending order
- Fix offset boundary check (inclusive EndOffset)
- Track finished partitions to prevent over-consumption
- Test first page and multi-page pagination
- Verify descending order within partitions
- Test filter rejection with pagination mode
- Verify legacy mode compatibility
- Add pageToken/nextPageToken to message search state
- Auto-load next page when user reaches last loaded page
- Reset pagination when navigating back to page 1
- Disable sorting in unlimited mode (maxResults=-1)
- Hide unlimited option in Latest/Live mode
- Auto-reset to 50 when switching to Latest/Live from unlimited
…eter

Remove hasMore as an explicit parameter from IListMessagesProgress.OnComplete().
The hasMore field is now automatically derived from whether nextPageToken is empty.

This simplifies the interface by removing redundant state - the information about
whether more pages exist is already encoded in the presence/absence of nextPageToken.

Changes:
- Remove hasMore parameter from OnComplete() interface (4 params -> 3 params)
- Derive HasMore automatically: HasMore = nextPageToken != ""
- Update all call sites to pass 3 parameters instead of 4
- Update integration tests to check nextPageToken instead of hasMore
- Update mocks to match new 3-parameter signature

The protobuf has_more field is still populated for wire compatibility, but is no
longer passed as a separate parameter through the application layers.
- Fix mock expectations in integration tests to use 3 parameters
- Remove HasMore field from stream completion message struct
- Fix page token test to handle unordered partition iteration
@github-actions
Copy link
Contributor

github-actions bot commented Jan 12, 2026

The latest Buf updates on your PR. Results from workflow Buf CI / validate (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedJan 14, 2026, 2:36 PM

Frontend fixes:
- Fix stale closure race condition in auto-load effect by capturing
  messageSearch reference and validating before state update
- Add proper cleanup for loadMore operations on component unmount
- Fix circular effect dependency in page reset by using ref instead
  of state in dependency array
- Add retry limit (max 3 attempts) for loadMore failures to prevent
  infinite retry loops on network errors
- Track mounted state to prevent state updates on unmounted component

Backend fix:
- Change pagination logging from INFO to DEBUG level to reduce
  log verbosity in production
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