Back up CLI --resume transcripts so idle tabs stay resumable - #26
Merged
Merged
Conversation
`claude --resume <id>` reads the CLI's own transcript at
~/.claude/projects/<encoded-cwd>/<id>.jsonl, which the CLI prunes by age
(cleanupPeriodDays, default 30). A workspace left idle past that window
loses its backing file and can no longer resume ("No conversation found
with session ID"), even though we still hold the full chat history.
Keep a rolling copy under ~/.config/flycrys/sessions/transcripts/. The
locate + copy run on a worker thread during autosave (sync only on
shutdown), gated on chat-history growth so there is zero idle churn and
the GTK main loop never touches the disk. Atomic temp+rename copy; a
stat-only up-to-date check skips redundant writes.
Tests cover the project-dir encoding, the up-to-date check, and the
atomic copy.
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.
Problem
Tabs left idle for weeks fail to resume with "No conversation found with session ID", even though the full chat history is still on screen.
Root cause:
claude --resume <id>reads the CLI's own transcript at~/.claude/projects/<encoded-cwd>/<id>.jsonl— not our chat history. The CLI prunes those by age (cleanupPeriodDays, default 30 days), so a long-idle workspace loses its backing file and can no longer be resumed.Fix
Keep a rolling backup of each session's CLI transcript under
~/.config/flycrys/sessions/transcripts/<id>.jsonl, so it survives the CLI's cleanup (and manual cleanup, disk wipes, machine migration).Note on recovery
This PR is backup only — no auto-restore on resume failure (by design). Resume keeps working because the live transcript is preserved; pair this with a raised
cleanupPeriodDaysso the CLI stops pruning the originals. If an original is ever lost, restoring is a manual file copy from the backup dir back to~/.claude/projects/<encoded-cwd>/.Tests
Unit tests cover the project-dir encoding, the up-to-date check, and the atomic copy (no temp files left behind).
cargo clippy --lib --bins -- -D warningsclean; full suite green.