feat(session): bi-directional cursor-based pagination (#6548)#8535
feat(session): bi-directional cursor-based pagination (#6548)#8535CasualDeveloper wants to merge 7 commits intoanomalyco:devfrom
Conversation
|
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate FoundPR #6656: "session: paginate message loading"
This is not a duplicate in the traditional sense—it's a more complete implementation that builds upon and replaces the earlier approach. |
|
@rekram1-node hi Aiden, would appreciate your feedback on how I implemented pagination, per your suggestion! :) |
|
Glad I could help kickstart this, I have been a little busy to continue my OSS journey right now. I haven't personally looked through the code in depth (just did a skim) but 1k line changes seems like a lot for one PR (might be better to split it if you can) but once again maybe the code is super clean and simple -- I just haven't sifted through deeply lol. Great work & good luck closing this! |
4f57718 to
afe9c53
Compare
4bd8bf6 to
34eea60
Compare
Adds session_list_limit config option to limit sessions displayed in the session list dialog (default: 150). Limit only applies when not searching; search uses server-side limit of 30. Remove message_limit as it conflicts with cursor-based pagination (anomalyco#8535) and is now redundant.
Phase 4-6: Complete auto-scroll implementation - Add KV signal for runtime toggle (persists across sessions) - Add historyConfig memo with default values - Implement loadOlder() function: * Checks both KV toggle and config.enabled * Triggers when scroll position <= load_threshold pixels from top * Uses existing loadConversationHistory() with ts_before API - Implement updateVisibleMessageViews() for batch tracking: * Updates lastViewed timestamp for all visible messages * Called on scroll events for efficient viewport detection - Add scroll event handlers: * onMouseScroll: triggers auto-load and view tracking * onKeyDown: triggers auto-load on up/pageup/home keys - Add command menu toggle option: * Dynamic title based on current state * Starts/stops cleanup worker on toggle * Uses KV system as designed - Add lifecycle management: * createEffect monitors config and KV toggle * Starts worker when both enabled and session active * onCleanup ensures worker stops on unmount - Import onCleanup from solid-js Complete feature implementation: ~190 lines vs PR anomalyco#8535's ~400 lines
34eea60 to
2c70c15
Compare
Adds session_list_limit config option to limit sessions displayed in the session list dialog (default: 150). Limit only applies when not searching; search uses server-side limit of 30. Remove message_limit as it conflicts with cursor-based pagination (anomalyco#8535) and is now redundant.
2c70c15 to
adec748
Compare
Adds session_list_limit config option to limit sessions displayed in the session list dialog (default: 150). Limit only applies when not searching; search uses server-side limit of 30. Remove message_limit as it conflicts with cursor-based pagination (anomalyco#8535) and is now redundant.
adec748 to
01e84ef
Compare
01e84ef to
ea25515
Compare
Adds session_list_limit config option to limit sessions displayed in the session list dialog (default: 150). Limit only applies when not searching; search uses server-side limit of 30. Remove message_limit as it conflicts with cursor-based pagination (anomalyco#8535) and is now redundant.
Adds session_list_limit config option to limit sessions displayed in the session list dialog (default: 150). Limit only applies when not searching; search uses server-side limit of 30. Remove message_limit as it conflicts with cursor-based pagination (anomalyco#8535) and is now redundant.
5067f2a to
5f6351c
Compare
bd214cc to
a7d1cc1
Compare
00637c0 to
71e0ba2
Compare
f1ae801 to
08fa7f7
Compare
0649e5f to
feb0c78
Compare
…oundary hints - Fix '[object Object]' error display: extract message from non-Error thrown objects - Fix PgUp/PgDn/line/half-page scroll not triggering page loads at boundaries - Make '(scroll up/down for more)' hints only show near page boundaries - Add missing Binary.lowerBound helper that PR anomalyco#8535 referenced but didn't include
|
@CasualDeveloper Confirmed it's working. PR submitted to your PR/fork. CasualDeveloper#1 |
Add a lower-bound binary search helper used by cursor pagination to locate insertion and boundary indexes efficiently.
Teach session message listing to handle before/after cursors with stable ordering so pagination windows can be traversed in both directions.
Expose before/after pagination params in the session messages route and update OpenAPI so clients can request paged message windows.
Introduce session pagination state management, bounded in-memory windows, and link-header parsing utilities to support incremental loading in the TUI.
Connect scroll commands and boundary loading in the session view, add edge-aware hint visibility, and harden pagination error and revert-marker handling for navigation jumps.
Add regression coverage for session/api pagination, Link header parsing, and TUI pagination helper flows including edge-state updates after boundary loads.
feb0c78 to
49838f6
Compare
|
Quick update: I integrated and validated the feedback from @NamedIdentity repro report, then rebased/cleaned branch history and force-pushed the final state (head Integrated fixes:
Validation on this branch:
|
|
I pulled your latest update. Tested and it works. One small issue with keybinds found by Claude Opus 4.6 during merging and checks which it decided it needed to fix. Details below:
|
|
@NamedIdentity Thanks again for checking this. I re-verified directly on the current PR head
For additional context: this PR does not modify I also reran typecheck on this head ( Could you confirm your local checkout is at |

Problem
Session message pagination lacked robust cursor-based navigation and reliable boundary behavior in the TUI, making long sessions harder to traverse and risking unbounded in-memory growth.
Solution
before/after/oldest) in session + API layers with RFC 8288 Link headers and regenerated SDK types.[object Object]and preserve revert markers on oldest/latest jumps while keeping a 500-message memory cap.Notes
bun --cwd packages/opencode test test/session/messages-pagination.test.ts test/server/session-messages.test.ts test/cli/tui/pagination-helpers.test.ts test/util/parse-link-header.test.ts(32 pass)bun turbo typecheck(pass)Related