You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implements progressive history loading with two distinct modes for accessing older messages in long-running sessions.
## Implementation
**Server API Enhancement**
Added two optional parameters to Session.messages():
- ts_before: Unix timestamp for loading messages older than a specific point
- breakpoint: Boolean flag controlling whether to stop at compaction summaries
**Client Load Functions**
- loadConversationHistory(): Loads messages up to the next compaction summary
- loadFullSessionHistory(): Loads entire remaining session history without stopping
Both functions use the earliest loaded message timestamp as an anchor point,
eliminating the need for index tracking or offset calculations.
**UI Integration**
Displays "Load more messages" when 100+ messages are present, offering two
clickable options. Toast notifications show the count of messages loaded.
Uses a synthetic message pattern for clean, reactive positioning.
## Design Decisions
**Timestamp-Based Anchoring**
Uses message timestamps as immutable reference points rather than maintaining
counts or offsets. This eliminates state tracking complexity and race conditions.
**Truthiness Pattern for Breakpoint**
The breakpoint parameter uses standard boolean coercion (z.coerce.boolean).
Omitting the parameter (undefined) is falsy and loads everything. Sending true
stops at compaction summaries. This follows the established pattern used by
other boolean parameters like 'roots'.
**Two Loading Modes**
- Conversation history: Stops at compaction summaries to show context
- Full history: Loads all remaining messages for complete reconstruction
**Non-Disruptive**
All parameters are optional. Existing functionality remains unchanged.
Zero breaking changes to any existing code paths.
## Technical Details
The server iterates through messages in reverse chronological order, skipping
messages newer than ts_before. When breakpoint is truthy and a compaction
message is encountered, iteration stops. Results are reversed before returning
to maintain chronological order.
The client prepends loaded messages to the beginning of the existing array,
maintaining sort order with oldest messages first.
## Files Changed
- packages/opencode/src/session/index.ts - Core loading logic
- packages/opencode/src/server/server.ts - HTTP endpoint parameters
- packages/opencode/src/cli/cmd/tui/context/sync.tsx - Load functions
- packages/opencode/src/cli/cmd/tui/routes/session/index.tsx - UI
- packages/sdk/* - Generated SDK types
Total: 176 lines added across 7 files
0 commit comments