Fix resuming Claude Code sessions from different directories#11
Open
mb6611 wants to merge 1 commit into
Open
Conversation
When a Claude Code session is resumed from a different directory, Claude creates a new file that inherits the parent session's sessionId in its message content but is stored in the original project's folder. The old code: - Extracted sessionId from message content (could be parent's ID) - Used the cwd field from messages (could be a different directory) This caused `claude --resume <id>` to fail because Claude Code looks for sessions in project-specific folders based on the current working directory. The fix: - Use filename as session ID (what Claude Code expects for --resume) - Add resume_cwd() that decodes the project folder from file_path (e.g., "-Users-bob--config-nvim" -> "/Users/bob/.config/nvim") - cd to the decoded project folder before running claude --resume
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.
Summary
Fixes #10
When a Claude Code session is resumed from a different directory, Claude creates a new file that inherits the parent session's
sessionIdin its message content but is stored in the original project's folder.The old code:
sessionIdfrom message content (could be parent's ID)cwdfield from messages (could be a different directory)This caused
claude --resume <id>to fail because Claude Code looks for sessions in project-specific folders based on the current working directory.The fix
--resume)resume_cwd()that decodes the project folder fromfile_path(e.g.,
-Users-bob--config-nvim→/Users/bob/.config/nvim)cdto the decoded project folder before runningclaude --resumeTest plan