-
Notifications
You must be signed in to change notification settings - Fork 22
feat: cursor-based pagination for messages API #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
MichaelSun48
merged 9 commits into
scaleapi:main
from
gabrycina:feature/cursor-pagination-messages
Dec 9, 2025
Merged
feat: cursor-based pagination for messages API #92
MichaelSun48
merged 9 commits into
scaleapi:main
from
gabrycina:feature/cursor-pagination-messages
Dec 9, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BREAKING CHANGE: /messages endpoint now returns PaginatedMessagesResponse
instead of raw array.
Backend:
- Add cursor/direction params to /messages endpoint
- Return {data, next_cursor, has_more} response format
- Add pagination.py with encode/decode cursor utilities
- Add find_by_field_with_cursor to MongoDB adapter
Frontend:
- Replace useTaskMessages with useInfiniteTaskMessages hook
- Implement infinite scroll with IntersectionObserver
- Add scroll position preservation when loading older messages
- Fix Thinking indicator to hide when streaming starts
- Remove deprecated custom-subscribe-task-state.tsx
Backwards-compatible change: - Original GET /messages endpoint unchanged (returns list[TaskMessage]) - New GET /messages/paginated endpoint with cursor pagination (returns PaginatedMessagesResponse) This allows existing SDK users to continue using the API without updates.
smoreinis
reviewed
Dec 8, 2025
smoreinis
approved these changes
Dec 8, 2025
Collaborator
smoreinis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Backend changes LG (just one minor question)
Collaborator
|
also, looks like the Agentex UI lint & typecheck is failing |
- MongoDB cursor uses compound (created_at, _id) comparison to handle timestamp ties - UI hooks use listPaginated() instead of list() for paginated endpoints
- Rename PaginatedMessagesResponse -> MessageListPaginatedResponse - Add null coalescing for optional fields (next_cursor, has_more)
SDK now includes listPaginated() and MessageListPaginatedResponse
Frontend changes moved to feature/cursor-pagination-messages-ui branch. This PR now contains only backend changes for /messages/paginated endpoint.
MichaelSun48
approved these changes
Dec 9, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Implements cursor-based pagination for the
/messagesendpoint to enable infinite scroll in the UI.Breaking Change
GET /messagesnow returnsPaginatedMessagesResponseinstead of raw array:{ "data": [...], "next_cursor": "...", "has_more": true }Backend Changes
cursoranddirectionquery params to/messages{data, next_cursor, has_more}response formatpagination.pywith cursor encode/decode utilitiesfind_by_field_with_cursor()to MongoDB adapterFrontend Changes
useTaskMessageswithuseInfiniteTaskMessageshookcustom-subscribe-task-state.tsxRelated PRs
Suggested Deployment Order