Skip to content

Conversation

@ry2009
Copy link
Contributor

@ry2009 ry2009 commented Jan 2, 2026

  • Adds cursor pagination for session messages: GET /session/:sessionID/message?limit=…&before=… and sets Link:
    …; rel="next" when older pages exist.
    • TUI loads older messages when you scroll near the top (shows “Loading more…”), preserving scroll position.
    • Removes the hard 100 message trimming so loaded history doesn’t get dropped.
    • Regenerated SDK/OpenAPI (packages/sdk/*) and added a unit test packages/opencode/test/session/messages-
      pagination.test.ts.
    • Note: not true virtualization yet (we still render all loaded messages).

@ry2009
Copy link
Contributor Author

ry2009 commented Jan 2, 2026

maybe a separate pr ab implementing real windowing for true virtualization

CasualDeveloper added a commit to CasualDeveloper/opencode that referenced this pull request Jan 14, 2026
Implements Issue anomalyco#6548: Cursor-based pagination to support long session
histories without performance degradation.

This builds on the approach from PR anomalyco#6656 by @ry2009, addressing the
feedback from that review and adding additional features.

Backend:
- Add `before` and `after` cursor support to Session.messages and API
- Add Binary.lowerBound to util for efficient cursor lookup on ULIDs
- Use Promise.allSettled for graceful handling of deleted messages
- Add LRU cache for Storage.list (100 entries, 30s TTL) with invalidation
- Return RFC 5005 compliant Link headers (rel="prev"/rel="next")
- Return 400 when both cursors specified (mutual exclusion)
- Validate cursors via Zod schema with graceful fallback

TUI:
- Track message_page state with hasOlder/hasNewer flags
- Implement loadOlder/loadNewer with scroll position restoration
- Memory-bound to 500 messages with 50-message eviction chunks
- Skip live SSE inserts when detached from head (hasNewer=true)
- Add error state handling for failed pagination requests

Improvements over PR anomalyco#6656:
- Bi-directional pagination (before + after cursors)
- Proper parseLinkHeader utility with comprehensive tests
- Memory bounding to prevent unbounded growth
- LRU caching to reduce Storage.list calls
- Error state feedback instead of silent failures
- RFC 5005 compliant Link header semantics

Other fixes:
- Add cache invalidation to import command

Tests:
- messages-pagination.test.ts: cursor, boundary, deletion tests (5 tests)
- session-messages.test.ts: API validation, Link header tests (4 tests)
- cache.test.ts: LRU eviction, TTL, invalidation tests (7 tests)
- parse-link-header.test.ts: RFC 8288 parser tests (9 tests)

Closes anomalyco#6548
CasualDeveloper added a commit to CasualDeveloper/opencode that referenced this pull request Jan 14, 2026
Implements Issue anomalyco#6548: Cursor-based pagination to support long session
histories without performance degradation.

This builds on the approach from PR anomalyco#6656 by @ry2009, addressing the
feedback from that review and adding additional features.

Backend:
- Add `before` and `after` cursor support to Session.messages and API
- Add Binary.lowerBound to util for efficient cursor lookup on ULIDs
- Use Promise.allSettled for graceful handling of deleted messages
- Add LRU cache for Storage.list (100 entries, 30s TTL) with invalidation
- Return RFC 5005 compliant Link headers (rel="prev"/rel="next")
- Return 400 when both cursors specified (mutual exclusion)
- Validate cursors via Zod schema with graceful fallback

TUI:
- Track message_page state with hasOlder/hasNewer flags
- Implement loadOlder/loadNewer with scroll position restoration
- Memory-bound to 500 messages with 50-message eviction chunks
- Skip live SSE inserts when detached from head (hasNewer=true)
- Add error state handling for failed pagination requests

Improvements over PR anomalyco#6656:
- Bi-directional pagination (before + after cursors)
- Proper parseLinkHeader utility with comprehensive tests
- Memory bounding to prevent unbounded growth
- LRU caching to reduce Storage.list calls
- Error state feedback instead of silent failures
- RFC 5005 compliant Link header semantics

Other fixes:
- Add cache invalidation to import command

Tests:
- messages-pagination.test.ts: cursor, boundary, deletion tests (5 tests)
- session-messages.test.ts: API validation, Link header tests (4 tests)
- cache.test.ts: LRU eviction, TTL, invalidation tests (7 tests)
- parse-link-header.test.ts: RFC 8288 parser tests (9 tests)

Closes anomalyco#6548
CasualDeveloper added a commit to CasualDeveloper/opencode that referenced this pull request Jan 14, 2026
Implements Issue anomalyco#6548: Cursor-based pagination to support long session
histories without performance degradation.

This builds on the approach from PR anomalyco#6656 by @ry2009, addressing the
feedback from that review and adding additional features.

Backend:
- Add `before` and `after` cursor support to Session.messages and API
- Add Binary.lowerBound to util for efficient cursor lookup on ULIDs
- Use Promise.allSettled for graceful handling of deleted messages
- Add LRU cache for Storage.list (100 entries, 30s TTL) with invalidation
- Return RFC 5005 compliant Link headers (rel="prev"/rel="next")
- Return 400 when both cursors specified (mutual exclusion)
- Validate cursors via Zod schema with graceful fallback

TUI:
- Track message_page state with hasOlder/hasNewer flags
- Implement loadOlder/loadNewer with scroll position restoration
- Memory-bound to 500 messages with 50-message eviction chunks
- Skip live SSE inserts when detached from head (hasNewer=true)
- Add error state handling for failed pagination requests

Improvements over PR anomalyco#6656:
- Bi-directional pagination (before + after cursors)
- Proper parseLinkHeader utility with comprehensive tests
- Memory bounding to prevent unbounded growth
- LRU caching to reduce Storage.list calls
- Error state feedback instead of silent failures
- RFC 5005 compliant Link header semantics

Other fixes:
- Add cache invalidation to import command

Tests:
- messages-pagination.test.ts: cursor, boundary, deletion tests (5 tests)
- session-messages.test.ts: API validation, Link header tests (4 tests)
- cache.test.ts: LRU eviction, TTL, invalidation tests (7 tests)
- parse-link-header.test.ts: RFC 8288 parser tests (9 tests)

Closes anomalyco#6548
CasualDeveloper added a commit to CasualDeveloper/opencode that referenced this pull request Jan 14, 2026
Implements Issue anomalyco#6548: Cursor-based pagination to support long session histories without performance degradation.

This builds on the approach from PR anomalyco#6656 by @ry2009, addressing the feedback from that review and adding additional features.

Backend:
- Add `before` and `after` cursor support to Session.messages and API
- Add Binary.lowerBound to util for efficient cursor lookup on ULIDs
- Use Promise.allSettled for graceful handling of deleted messages
- Add LRU cache for Storage.list (100 entries, 30s TTL) with invalidation
- Return RFC 5005 compliant Link headers (rel="prev"/rel="next")
- Return 400 when both cursors specified (mutual exclusion)
- Validate cursors via Zod schema with graceful fallback

TUI:
- Track message_page state with hasOlder/hasNewer flags
- Implement loadOlder/loadNewer with scroll position restoration
- Memory-bound to 500 messages with 50-message eviction chunks
- Skip live SSE inserts when detached from head (hasNewer=true)
- Add error state handling for failed pagination requests

Improvements over PR anomalyco#6656:
- Bi-directional pagination (before + after cursors)
- Proper parseLinkHeader utility with comprehensive tests
- Memory bounding to prevent unbounded growth
- LRU caching to reduce Storage.list calls
- Error state feedback instead of silent failures
- RFC 5005 compliant Link header semantics

Other fixes:
- Add cache invalidation to import command

Tests:
- messages-pagination.test.ts: cursor, boundary, deletion tests (5 tests)
- session-messages.test.ts: API validation, Link header tests (4 tests)
- cache.test.ts: LRU eviction, TTL, invalidation tests (7 tests)
- parse-link-header.test.ts: RFC 8288 parser tests (9 tests)

Closes anomalyco#6548
CasualDeveloper added a commit to CasualDeveloper/opencode that referenced this pull request Jan 14, 2026
Implements Issue anomalyco#6548: Cursor-based pagination to support long session histories without performance degradation.

This supersedes PR anomalyco#6656 by @ry2009, addressing the feedback from that review and adding additional features.

Backend:
- Add `before` and `after` cursor support to Session.messages and API
- Add Binary.lowerBound to util for efficient cursor lookup on ULIDs
- Use Promise.allSettled for graceful handling of deleted messages
- Return RFC 5005 compliant Link headers (rel="prev"/rel="next")
- Return 400 when both cursors specified (mutual exclusion)
- Validate cursors via Zod schema with graceful fallback

TUI:
- Track message_page state with hasOlder/hasNewer flags
- Implement loadOlder/loadNewer with scroll position restoration
- Memory-bound to 500 messages with 50-message eviction chunks
- Skip live SSE inserts when detached from head (hasNewer=true)
- Add error state handling for failed pagination requests

Improvements over PR anomalyco#6656:
- Bi-directional pagination (before + after cursors)
- Proper parseLinkHeader utility with comprehensive tests
- Memory bounding to prevent unbounded growth
- Error state feedback instead of silent failures
- RFC 5005 compliant Link header semantics

Tests:
- messages-pagination.test.ts: cursor, boundary, deletion tests (5 tests)
- session-messages.test.ts: API validation, Link header tests (4 tests)
- parse-link-header.test.ts: RFC 8288 parser tests (9 tests)

Closes anomalyco#6548
CasualDeveloper added a commit to CasualDeveloper/opencode that referenced this pull request Jan 14, 2026
Implements Issue anomalyco#6548: Cursor-based pagination to support long session histories without performance degradation.

This supersedes PR anomalyco#6656 by @ry2009, addressing the feedback from that review and adding additional features.

Backend:
- Add `before` and `after` cursor support to Session.messages and API
- Add Binary.lowerBound to util for efficient cursor lookup on ULIDs
- Use Promise.allSettled for graceful handling of deleted messages
- Return RFC 5005 compliant Link headers (rel="prev"/rel="next")
- Return 400 when both cursors specified (mutual exclusion)
- Validate cursors via Zod schema with graceful fallback

TUI:
- Track message_page state with hasOlder/hasNewer flags
- Implement loadOlder/loadNewer with scroll position restoration
- Memory-bound to 500 messages with 50-message eviction chunks
- Skip live SSE inserts when detached from head (hasNewer=true)
- Add error state handling for failed pagination requests

Improvements over PR anomalyco#6656:
- Bi-directional pagination (before + after cursors)
- Proper parseLinkHeader utility with comprehensive tests
- Memory bounding to prevent unbounded growth
- Error state feedback instead of silent failures
- RFC 5005 compliant Link header semantics

Tests:
- messages-pagination.test.ts: cursor, boundary, deletion tests (5 tests)
- session-messages.test.ts: API validation, Link header tests (4 tests)
- parse-link-header.test.ts: RFC 8288 parser tests (9 tests)

Closes anomalyco#6548
CasualDeveloper added a commit to CasualDeveloper/opencode that referenced this pull request Jan 15, 2026
Implements Issue anomalyco#6548: Cursor-based pagination to support long session histories without performance degradation.

This supersedes PR anomalyco#6656 by @ry2009, addressing the feedback from that review and adding additional features.

Backend:
- Add `before` and `after` cursor support to Session.messages and API
- Add Binary.lowerBound to util for efficient cursor lookup on ULIDs
- Use Promise.allSettled for graceful handling of deleted messages
- Return RFC 5005 compliant Link headers (rel="prev"/rel="next")
- Return 400 when both cursors specified (mutual exclusion)
- Validate cursors via Zod schema with graceful fallback

TUI:
- Track message_page state with hasOlder/hasNewer flags
- Implement loadOlder/loadNewer with scroll position restoration
- Memory-bound to 500 messages with 50-message eviction chunks
- Skip live SSE inserts when detached from head (hasNewer=true)
- Add error state handling for failed pagination requests

Improvements over PR anomalyco#6656:
- Bi-directional pagination (before + after cursors)
- Proper parseLinkHeader utility with comprehensive tests
- Memory bounding to prevent unbounded growth
- Error state feedback instead of silent failures
- RFC 5005 compliant Link header semantics

Tests:
- messages-pagination.test.ts: cursor, boundary, deletion tests (5 tests)
- session-messages.test.ts: API validation, Link header tests (4 tests)
- parse-link-header.test.ts: RFC 8288 parser tests (9 tests)

Closes anomalyco#6548
CasualDeveloper added a commit to CasualDeveloper/opencode that referenced this pull request Jan 15, 2026
Implements Issue anomalyco#6548: Cursor-based pagination to support long session histories without performance degradation.

This supersedes PR anomalyco#6656 by @ry2009, addressing the feedback from that review and adding additional features.

Backend:
- Add `before` and `after` cursor support to Session.messages and API
- Add Binary.lowerBound to util for efficient cursor lookup on ULIDs
- Use Promise.allSettled for graceful handling of deleted messages
- Return RFC 5005 compliant Link headers (rel="prev"/rel="next")
- Return 400 when both cursors specified (mutual exclusion)
- Validate cursors via Zod schema with graceful fallback

TUI:
- Track message_page state with hasOlder/hasNewer flags
- Implement loadOlder/loadNewer with scroll position restoration
- Memory-bound to 500 messages with 50-message eviction chunks
- Skip live SSE inserts when detached from head (hasNewer=true)
- Add error state handling for failed pagination requests

Improvements over PR anomalyco#6656:
- Bi-directional pagination (before + after cursors)
- Proper parseLinkHeader utility with comprehensive tests
- Memory bounding to prevent unbounded growth
- Error state feedback instead of silent failures
- RFC 5005 compliant Link header semantics

Tests:
- messages-pagination.test.ts: cursor, boundary, deletion tests (5 tests)
- session-messages.test.ts: API validation, Link header tests (4 tests)
- parse-link-header.test.ts: RFC 8288 parser tests (9 tests)

Closes anomalyco#6548
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.

1 participant