Recover orphaned conversation files on startup#204
Open
leonidasbarkas98-cpu wants to merge 2 commits into
Open
Recover orphaned conversation files on startup#204leonidasbarkas98-cpu wants to merge 2 commits into
leonidasbarkas98-cpu wants to merge 2 commits into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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