opencode export outputs messages in wrong order for long sessions #4484

Open
opened 2026-02-16 17:44:20 -05:00 by yindo · 1 comment
Owner

Originally created by @jchuder on GitHub (Jan 9, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

opencode export <session_id> outputs messages in wrong order for long sessions. The first part of the conversation appears in the middle or end of the export.

Root cause: Session.messages() uses result.reverse() which only reverses the alphabetical order from Storage.list(). Message IDs are random strings (e.g., msg_19b9ed* vs msg_b9946c*), so alphabetical order ≠ chronological order.

Plugins

None

OpenCode version

1.1.8

Steps to reproduce

  1. Create a long session with 100+ messages over multiple hours/days
  2. Run opencode export <session_id>
  3. Check the message order — early messages appear in the middle or end instead of the beginning

Screenshot and/or share link

N/A

Operating System

macOS

Terminal

Ghostty

Originally created by @jchuder on GitHub (Jan 9, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description `opencode export <session_id>` outputs messages in wrong order for long sessions. The first part of the conversation appears in the middle or end of the export. **Root cause**: `Session.messages()` uses `result.reverse()` which only reverses the alphabetical order from `Storage.list()`. Message IDs are random strings (e.g., `msg_19b9ed*` vs `msg_b9946c*`), so alphabetical order ≠ chronological order. ### Plugins None ### OpenCode version 1.1.8 ### Steps to reproduce 1. Create a long session with 100+ messages over multiple hours/days 2. Run `opencode export <session_id>` 3. Check the message order — early messages appear in the middle or end instead of the beginning ### Screenshot and/or share link N/A ### Operating System macOS ### Terminal Ghostty
Author
Owner

@github-actions[bot] commented on GitHub (Jan 9, 2026):

This issue might be a duplicate of or related to existing issues. Please check:

  • #7380: old messages disappear - related to message persistence in long sessions
  • #6137: Cannot scroll to beginning of long conversations - also affects long session handling
  • #6548: feat: virtualized scrolling + paginated message loading - proposes solutions for long session message handling

These issues are related to message ordering/handling in long sessions but may have different root causes. Feel free to ignore if your specific case differs from these.

@github-actions[bot] commented on GitHub (Jan 9, 2026): This issue might be a duplicate of or related to existing issues. Please check: - #7380: old messages disappear - related to message persistence in long sessions - #6137: Cannot scroll to beginning of long conversations - also affects long session handling - #6548: feat: virtualized scrolling + paginated message loading - proposes solutions for long session message handling These issues are related to message ordering/handling in long sessions but may have different root causes. Feel free to ignore if your specific case differs from these.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4484