Skip to content

[BUG] Archive action causes 4+ hours of session data loss on Windows Desktop #20903

@bobcy2015

Description

@bobcy2015

Description

When clicking the "Archive" button in OpenCode Desktop for Windows, all conversation history from the current session that hasn't been persisted to the database is permanently lost. This is a critical data loss bug.

Impact

  • Severity: Critical (data loss)
  • Affected Users: All Windows Desktop users
  • Data Lost: 4+ hours of conversation history (in my case)

Steps to Reproduce

  1. Open OpenCode Desktop on Windows 10/11
  2. Start a new conversation and chat for several hours
  3. Do NOT manually save/export the conversation
  4. Click the "Archive" button in the session list
  5. The current session disappears from the list
  6. All messages from ~17:57 to ~21:40 are permanently lost

Expected Behavior

  • Archiving a session should save all pending messages to the database first
  • Archived sessions should be recoverable via an "Unarchive" function
  • Users should be warned if there are unsaved messages before archiving

Actual Behavior

  • Session data in memory is NOT persisted before archiving
  • No confirmation dialog warns about unsaved data
  • No way to recover the archived session
  • Database shows no record of the lost conversation

Technical Evidence

Database Query Results

Queried ~/.local/share/opencode/opencode.db:

SELECT id, slug, title, time_updated FROM session ORDER BY time_updated DESC LIMIT 10;
Session ID Title Last Updated (Local Time)
ses_2adb34a58ffelj8oJzw2806lGG GitHub 项目本地部署与启动流程 2026-04-03 14:49:12
ses_2ac431abcffefonOJboRolkgoG 恢复归档会话记录 2026-04-03 14:37:59
ses_2ad40870affew5ZoDh95e1eu2N T2: 禁用危险 Sandbox 参数 2026-04-03 13:44:49

All sessions were last updated BEFORE 17:00, but I was actively chatting until 21:40.

File System Analysis

Checked ~/.local/share/opencode/storage/session_diff/:

  • All session diff files are empty (2 bytes, content: [])
  • No session data persisted between 17:57-21:40

Timeline

Time Event
14:49 Last session saved to database
17:57 Started new conversation (NOT in database)
21:40 Clicked "Archive" button
21:40+ 4+ hours of conversation history lost

Root Cause Analysis

Based on source code review and database analysis:

  1. Session auto-save mechanism is broken - Messages are not being persisted to the database in real-time
  2. Archive action does not trigger a save - Clicking archive should flush pending messages first
  3. No warning dialog - Users are not warned about unsaved data before archiving
  4. No recovery mechanism - Archived sessions cannot be recovered

Suggested Fixes

Immediate (Critical)

  1. Add confirmation dialog before archiving if there are unsaved messages
  2. Force save pending messages before executing archive action
  3. Add warning toast if archive is attempted with pending data

Long-term

  1. Implement proper session persistence - Auto-save messages every N seconds
  2. Add unarchive functionality - Allow users to recover archived sessions
  3. Add session backup - Create backup before destructive operations

Workarounds (for users)

Until this is fixed, users should:

  1. Regularly export conversations using /export command (Ctrl+X X)
  2. Avoid clicking "Archive" button until the bug is fixed
  3. Use TUI version (opencode command) - community PR feat: add session archive/unarchive support to TUI #13961 adds archive/unarchive support

Related Issues

Related PRs

Plugins

No response

OpenCode version

No response

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

Windows 11

Terminal

OpenCode Desktop App

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingwebRelates to opencode on web / desktopwindows

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions