Skip to content

Conversation

@redenvci
Copy link

Summary

  • Add offset query parameter to GET /session/:id/message endpoint for efficient pagination
  • Update desktop app's loadMore to use offset-based loading instead of re-fetching all messages
  • Only fetches additional messages needed, then merges them into existing state

Problem

Previously, loading more messages in long sessions required re-fetching all messages from the start with an increased limit. For example, to load 100 more messages when you already have 400, the client would fetch all 500 messages again.

Solution

With the new offset parameter, clients can skip already-loaded messages:

  • Initial load: GET /session/:id/message?limit=400 (400 messages)
  • Load more: GET /session/:id/message?limit=100&offset=400 (only 100 new messages)

This reduces bandwidth and improves performance for long sessions.

Test plan

  • Verify initial message loading still works
  • Verify loading more messages appends correctly
  • Verify complete flag is set when no more messages exist
  • Test with sessions of varying lengths

🤖 Generated with Claude Code

Add offset query parameter to GET /session/:id/message endpoint to enable
efficient pagination of messages. Previously, loading more messages required
re-fetching all messages from the start with an increased limit. With offset,
clients can fetch only the additional messages they need.

Changes:
- Add offset parameter to Session.messages() function
- Add offset query parameter to the session messages route
- Update desktop app's loadMore to use offset-based pagination
- Update server documentation

This improves performance for long sessions by avoiding redundant data transfer
when loading message history.
@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Found 1 potential duplicate PR:

PR #8996: feat(session): add ts_before and breakpoint params to Session.messages API

Why it's related: This PR also addresses message pagination optimization for the Session.messages API endpoint. It adds alternative pagination parameters (ts_before and breakpoint) to handle efficient message loading. Both PRs are solving the same core problem of avoiding re-fetching all messages when loading more data in long sessions, but using different pagination strategies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant