feat(tui): load conversation and session history
Summary
Adds on-demand message loading UI to the TUI, enabling users to access message history beyond the initial 100-message window.
Depends on: #8996 (adds ts_before and breakpoint API parameters)
Problem
Users cannot access message history beyond the initial 100 messages loaded on session init:
- Resolves #6137 - Cannot scroll to beginning of long conversations
- Resolves #4918 - Feature request: pagination for messages & sessions
- Resolves #7380 - Old messages disappear
- Related to #6548
Solution
Two loading modes accessed via a "Load more messages" banner when 100+ messages are present:
- Load conversation history - Loads messages up to the next compaction summary, providing relevant context without overwhelming the UI
- Load full session history - Loads all remaining messages for complete session reconstruction
Key features:
- Only pulls missing messages (uses
ts_beforetimestamp anchoring) - Zero breaking changes - all parameters optional
- Message roll-off maintained - works with existing 100-message pruning
- Toast notifications show message counts
Why Two PRs?
This PR was split from the original #8627 to separate concerns:
-
#8996 (API foundation) - Adds
ts_beforeandbreakpointparams toSession.messages(). This is a foundational capability that benefits:- This TUI implementation
- Web client (currently reloads all messages)
- SDK consumers building custom integrations
- Other pagination approaches (#8535, #6656)
-
This PR (TUI consumer) - Implements the user-facing feature using the API
This separation allows the API enhancement to merge independently and unblock multiple consumers.
Implementation
Client (sync.tsx):
-
loadConversationHistory()- calls API withbreakpoint: true -
loadFullSessionHistory()- calls API without breakpoint
UI (routes/session/index.tsx):
- Synthetic
__load_more__message prepended when 100+ messages - Clickable options with hover states
- Loading state prevents duplicate requests
Screenshots
From original PR #8627:
Option to load conversation or full session:
Loading conversation history:
Loading full session history: