Skip to content

fix(tui): fetch full message history for export and copy - #1

Draft
cbarber wants to merge 1 commit into
devfrom
fix/export-full-transcript
Draft

cbarber wants to merge 1 commit into
devfrom
fix/export-full-transcript

Conversation

@cbarber

@cbarber cbarber commented Mar 28, 2026

Copy link
Copy Markdown
Owner

Summary

The TUI /export and /copy commands read from an in-memory message store capped at 100 entries for rendering performance. On sessions with compaction or more than 100 messages, this silently truncates the transcript — pre-compaction messages are stored in the database but never fetched.

The fix fetches all messages directly from the server for transcript generation, matching what the CLI opencode export command already does correctly.

Root cause

packages/opencode/src/cli/cmd/tui/context/sync.tsx initialises the store with limit: 100 (newest 100 messages only) and evicts the oldest message whenever the store exceeds 100 entries. Both session.copy and session.export read from this store via messages().

Fix

Replace messages() (in-memory store) with await sdk.client.session.messages({ sessionID }) (server fetch, no limit) in both handlers. Includes a unit test covering the >100-message and pre-compaction cases.

Closes anomalyco#16765


🤖 Created by agent

@cbarber
cbarber force-pushed the fix/export-full-transcript branch from b174a6d to 765cd99 Compare March 29, 2026 20:17
The TUI message store caps at 100 entries for rendering performance;
/export and /copy were reading from that store, producing truncated
transcripts on compacted or long sessions. Fetch all messages from the
server via a testable helper with no limit.

Authored-By: OpenCode (anthropic/claude-sonnet-4-6)
@cbarber
cbarber force-pushed the fix/export-full-transcript branch from 765cd99 to 7e8011b Compare March 29, 2026 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Track & save the actual FULL session transcript across compactions

1 participant