opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat(tui): load conversation and session history

Open ryanwyler opened this issue 13 hours ago • 1 comments

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:

  1. Load conversation history - Loads messages up to the next compaction summary, providing relevant context without overwhelming the UI
  2. Load full session history - Loads all remaining messages for complete session reconstruction

Key features:

  • Only pulls missing messages (uses ts_before timestamp 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:

  1. #8996 (API foundation) - Adds ts_before and breakpoint params to Session.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)
  2. 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 with breakpoint: 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: Load options

Loading conversation history: Conversation history

Loading full session history: Full session

ryanwyler avatar Jan 17 '26 00:01 ryanwyler