Conversation
| let mut all_installed = true; | ||
| for hooks_path in Self::hooks_paths() { | ||
| if !hooks_path.exists() { | ||
| all_installed = false; | ||
| continue; | ||
| } | ||
|
|
||
| let content = fs::read_to_string(&hooks_path)?; | ||
| let existing: Value = | ||
| serde_json::from_str(&content).unwrap_or_else(|_| json!({})); | ||
|
|
||
| let has_hooks = HOOK_EVENTS.iter().all(|event| { | ||
| existing | ||
| .get("hooks") | ||
| .and_then(|h| h.get(*event)) | ||
| .and_then(|v| v.as_array()) | ||
| .map(|arr| { | ||
| arr.iter().any(|item| { | ||
| item.get("command") | ||
| .and_then(|c| c.as_str()) | ||
| .map(is_git_ai_checkpoint_command) | ||
| .unwrap_or(false) | ||
| }) | ||
| }) | ||
| .unwrap_or(false) | ||
| }); | ||
|
|
||
| if !has_hooks { | ||
| all_installed = false; | ||
| } | ||
| } | ||
|
|
||
| Ok(HookCheckResult { | ||
| tool_installed: true, | ||
| hooks_installed: all_installed, | ||
| hooks_up_to_date: all_installed, | ||
| }) |
There was a problem hiding this comment.
🔴 check_hooks requires ALL locations to have hooks, preventing uninstall when hooks exist in only one location
The new check_hooks sets hooks_installed to true only when hooks are present in every path returned by hooks_paths(). Before this PR, hooks were only written to ~/.codeium/windsurf/hooks.json. After this upgrade, check_hooks also requires ~/.codeium/hooks.json to exist and contain hooks. For any user upgrading from the prior version, ~/.codeium/hooks.json won't exist, so check_hooks returns hooks_installed: false.
The uninstall flow at src/commands/install_hooks.rs:461-464 skips the tool entirely when hooks_installed is false:
if !check_result.hooks_installed {
continue;
}This means uninstall-hooks will silently skip Windsurf and leave the existing hooks in ~/.codeium/windsurf/hooks.json in place. The fix would be to use an any_installed check (are hooks in any location?) rather than requiring all locations.
Prompt for agents
In src/mdm/agents/windsurf.rs, the check_hooks function (lines 202-252) currently requires hooks to be present in ALL locations for hooks_installed to be true. This breaks the uninstall flow in src/commands/install_hooks.rs:461-464 which skips uninstall when hooks_installed is false.
Change the check_hooks logic to track two separate booleans: any_installed (hooks found in at least one location) and all_installed (hooks found in every location). Use any_installed for hooks_installed (so uninstall works when hooks exist in any location) and all_installed for hooks_up_to_date (so install knows to fill in missing locations).
Specifically, replace the single all_installed boolean with:
let mut any_installed = false;
let mut all_installed = true;
In the loop body, when has_hooks is true for a path, set any_installed = true. When has_hooks is false or the file doesn't exist, set all_installed = false.
Then return:
HookCheckResult {
tool_installed: true,
hooks_installed: any_installed,
hooks_up_to_date: all_installed,
}
Was this helpful? React with 👍 or 👎 to provide feedback.
Fix for #757
Appears that we have to register hooks in both locations for the time being.