Clean up Claude Code hooks on disconnect#783
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthrough
ChangesClaude Code agent cleanup
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@memanto/cli/connect/engine.py`:
- Around line 396-416: The hook removal logic in the session-start cleanup is
matching only on command, which can delete user-authored hooks that merely share
the same Memanto sync command. Update the filtering in engine.py around the
session_start hook loop so it only removes hooks whose full shape matches the
managed payload from agent.hook_config.hook_payload, using the existing
expected_commands logic as part of a stricter comparison against fields like
command, matcher, type, and timeout.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 839931f7-7140-48f6-9e25-ea9e44f5be1e
📒 Files selected for processing (2)
memanto/cli/connect/engine.pytests/test_connect_engine.py
Related to #770
Flaw summary
memanto connect claude-codeinstalls a Memanto-managed Claude CodeSessionStarthook and theBash(memanto:*)permission, butmemanto disconnect/memanto removeonly deleted Memanto metadata. The Claude configuration remained modified after disconnect, so future Claude Code sessions could still invoke Memanto hooks or keep stale Memanto permissions even after the user explicitly removed the integration.This is a setup and UX roadblock for adoption because disconnecting an agent should leave the Claude Code config in the same state except for unrelated user-managed hooks and permissions.
Reproduction
claude-codeso Memanto adds itsSessionStarthook andBash(memanto:*)permission.memanto disconnect <agent-id>or the remove flow..claude/settings.json.Before this change, the Memanto hook and permission are still present even though the agent has been removed from Memanto metadata.
Fix
SessionStarthook entries when removing a Claude Code agent.Bash(memanto:*)permission.Validation
Summary by CodeRabbit