Repository navigation
Keep the mailbox of a Claude Code session when the agent changes directory - #6
Merged
Merged
Conversation
…ctory The hooks named the mailbox from the cwd of the hook input. Claude Code sets that cwd to the new directory after each cd of the agent. The shim named the mailbox from the session registry, which keeps the directory where the session started. After a cd, a team command thus made a lead with a second mailbox, and the shim did not listen to it: the lead got its mail only when a hook ran. The hooks and the shim now name the mailbox from CLAUDE_PROJECT_DIR, the directory where the session started. Claude Code sets it for the hooks and for the stdio MCP servers, and it does not change. The cwd of the hook input, and the cwd of the registry, stay as the fallback. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.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.
Problem
A lead session received no mail in real time. The daemon answered
no-wake-configuredfor each message to it.The hooks named the mailbox from the
cwdof the hook input. Claude Code sets thatcwdto the new directory after eachcdof the agent. The shim named the mailbox from the session registry, which keeps the directory where the session started. After acd, the same session thus had two mailboxes: the team command made the second one the lead, and the shim listened to the first one.Fix
The hooks and the shim name the mailbox from
CLAUDE_PROJECT_DIR. Claude Code sets it for the hooks and for the stdio MCP servers, and it stays on the directory where the session started. Thecwdof the hook input and of the registry stay as the fallback.A session that does no
cdkeeps its mailbox name.Tests
the_project_directory_names_the_mailbox: the choice of the directory, with and without the variable.a_changed_working_directory_keeps_the_mailbox:/lead xfrom a hook with anothercwdapplies to the mailbox of the start.the_registry_names_the_mailbox_from_the_project_directory: the shim, when the registry gives another directory.cargo test: 170 passed.🤖 Generated with Claude Code