Skip to content

Recover orphaned conversation files on startup#204

Open
leonidasbarkas98-cpu wants to merge 2 commits into
andrepimenta:mainfrom
leonidasbarkas98-cpu:feat/orphaned-conversation-recovery
Open

Recover orphaned conversation files on startup#204
leonidasbarkas98-cpu wants to merge 2 commits into
andrepimenta:mainfrom
leonidasbarkas98-cpu:feat/orphaned-conversation-recovery

Conversation

@leonidasbarkas98-cpu

Copy link
Copy Markdown

If the conversation index is lost or a crash prevents indexing, conversation JSON files become invisible to the history UI. On startup the conversations directory is now scanned and unindexed files are re-added (schema-guarded: messages array + sessionId required, totalCost defaulted), then the index is re-sorted by start time and persisted once.

This is the recovery part of PR #181, reimplemented on current main.

🤖 Generated with Claude Code

Jonas Kunert and others added 2 commits July 22, 2026 07:17
Scan the conversations directory for .json files missing from the
workspace-state index (e.g. after a crash or window reload) and
re-add them via _updateConversationIndex so they show up in history
again instead of being silently lost.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…drepimenta#10)

- Re-sort the index by startTime after recovering orphaned files
  instead of unshifting them, so an old recovered conversation is no
  longer mistaken for the latest one (which would resume --resume
  into a stale sessionId).
- Validate parsed conversation data (messages array, sessionId,
  numeric totalCost) before indexing it, so a foreign/old-schema
  JSON file can no longer produce a broken index entry.
- Build recovered entries in-memory and persist the index once after
  the scan instead of once per recovered file, avoiding unordered
  stacked workspaceState writes. Extracted _buildConversationIndexEntry
  so the normal save path and recovery share the same entry shape.
- Load the conversation index before _initializeConversations() runs,
  since recovery inside it depends on the index already being loaded.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant