-
Notifications
You must be signed in to change notification settings - Fork 6.5k
feat(session): bi-directional cursor-based pagination (#6548) #8535
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
base: dev
Are you sure you want to change the base?
feat(session): bi-directional cursor-based pagination (#6548) #8535
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
…nd navigation Implements cursor-based pagination for message loading to handle long sessions without memory explosion with absolute navigation via Home/End keys. API changes: - Add 'before' cursor param: fetch messages older than cursor (newest first) - Add 'after' cursor param: fetch messages newer than cursor (oldest first) - Add 'oldest' param: start from oldest messages (for jumpToOldest) - Link headers with rel="prev"/"next" for cursor discovery (RFC 5005) TUI changes: - loadOlder/loadNewer actions with sliding window eviction (500 msg limit) - jumpToOldest (Home): fetches oldest page via ?oldest=true - jumpToLatest (End): fetches newest page, preserves revert marker - Detached mode: ignores SSE when viewing history to prevent gaps Implementation: - Binary.lowerBound for efficient cursor lookup - parseLinkHeader utility for RFC 5988 parsing - Message.stream() reverse option for ascending order - Smart parts cleanup: only deletes parts for evicted messages Tests: - Unit tests for pagination logic and cursor handling - API tests for before/after/oldest params and Link headers Resolves: anomalyco#6548
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
Summary
This PR implements bi-directional cursor-based pagination for message loading to support long session histories without performance degradation. Closes #6548.
before/after/oldestcursor support with RFC 5005 Link headersContext
Supersedes #6656 by @ry2009 (earlier partial implementation). This PR is a ground-up rewrite that adds:
beforeandaftercursors)oldestparam for jumping to beginning of historyparseLinkHeaderutility instead of brittle string matchingChanges
Backend (
session/index.ts,server/server.ts,message-v2.ts)before,after, andoldestcursor params toSession.messages()ascendingoption toMessageV2.stream()for oldest-first iterationBinary.lowerBoundto util for efficient cursor lookuprel="prev"→ older,rel="next"→ newerTUI (
sync.tsx,routes/session/index.tsx)message_pagestate tracking (hasOlder,hasNewer,loading,error)loadOlder/loadNewerwith scroll position restorationjumpToOldest(Home key) /jumpToLatest(End key) for absolute navigationjumpToLatestpreserves revert marker when jumping to newesthasNewer=true)Tests
messages-pagination.test.tssession-messages.test.tsparse-link-header.test.tsTesting
Related