Repository navigation
Fixed diff panel appearing despite bypassPermissions/acceptEdits when Claude cd'd into subdir - #140
Merged
Conversation
… Claude cd'd into subdir When Claude's working directory at edit time is a subdirectory of the session root (e.g. session started at /proj, Claude cd'd into /proj/submodules/Kotlin), the EDIT_MODE_REGISTRY lookup by exact key missed and fell back to EditMode.DEFAULT, causing the diff panel to appear even in bypassPermissions and acceptEdits modes. Fix: getEditModeForCwd() now falls back to a longest-prefix match when the exact key is not found. Added getSessionRootForCwd() using the same logic so the acceptEdits directory boundary check uses the session root rather than Claude's current cwd. Co-Authored-By: Claude Sonnet 4.6 <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.
Summary
getEditModeForCwd()used an exact key match againstEDIT_MODE_REGISTRY, but the hook'scwdis Claude's current working directory — which may be a subdirectory of the session root if Claudecd'd during the sessionEditMode.DEFAULT→ diff panel shown even inbypassPermissions/acceptEditsmodesPath.startsWith) when the exact key is not foundgetSessionRootForCwd()with the same logic so theacceptEditsdirectory boundary check uses the session root, not Claude's current subdirectory cwdTest plan
NetBeansMCPHandlerHookTest: registry key = session root, hook cwd = subdirectory — bothbypassPermissionsandacceptEditsnow auto-allow correctlybypassPermissionsmode, ask it to edit a file in a subdirectory → diff panel does not appear🤖 Generated with Claude Code