Skip to content

fix(windows): clean up agent hooks on uninstallation - #445

Open
Ohualtex wants to merge 5 commits into
Louis-CFM:mainfrom
Ohualtex:fix/antigravity-uninstall-hook-cleanup
Open

Ohualtex wants to merge 5 commits into
Louis-CFM:mainfrom
Ohualtex:fix/antigravity-uninstall-hook-cleanup

Conversation

@Ohualtex

Copy link
Copy Markdown
Contributor

Summary

Fixes #430

When Coucou is uninstalled on Windows, the NSIS uninstaller deletes %LOCALAPPDATA%\Coucou\bin\coucou-hook.exe. Previously, agent configuration files under %USERPROFILE% were left behind. Because Google Antigravity fails closed on broken PreToolUse hook commands, all subsequent tool calls in Antigravity were denied with Tool call denied by pre-tool hook.

Changes

  1. Uninstaller Hook Execution (hooks.nsh):
    • NSIS_HOOK_PREUNINSTALL now executes Coucou.exe --uninstall-hooks before removing the binary folder, ensuring agent configurations are restored before coucou-hook.exe is deleted.
  2. Headless Uninstall CLI Flag (main.rs, lib.rs):
    • Added --uninstall-hooks (aliases: --clean-hooks, --uninstall) command-line arguments to Coucou.exe.
    • Runs agents::uninstall_all() and hooks::uninstall_all() headlessly without launching the Tauri GUI.
  3. Clean File Removal for Empty Configs (agents.rs):
    • Updated Agent::Antigravity uninstall logic so that if Coucou was the only hook group in hooks.json, the empty file is deleted rather than leaving a stale {} behind. Any third-party or user-defined hooks are preserved intact.
  4. Documentation:
    • Documented automated cleanup and recovery instructions in docs/AGENTS.md and windows/README.md.
  5. Testing:
    • Added unit tests in agents.rs and hooks.rs verifying uninstall_all behavior and file removal when no other hooks exist.

When Coucou is uninstalled on Windows, the NSIS uninstaller removes
coucou-hook.exe from %LOCALAPPDATA%\Coucou\bin, but previously left
agent configuration files untouched. Because Google Antigravity fails
closed on broken PreToolUse hook binaries, any tool call failed with:
`Tool call denied by pre-tool hook`.

- Add `Coucou.exe --uninstall-hooks` (and `--clean-hooks` / `--uninstall`)
  CLI flags to execute headless hook cleanups across all agents.
- In NSIS `hooks.nsh`, run `Coucou.exe --uninstall-hooks` before deleting
  binaries and local directories.
- In `agents.rs`, remove `hooks.json` entirely when Coucou was its only
  content, while preserving any user-defined hooks.
- Add unit tests for `uninstall_all` across agents and hooks.
- Document uninstallation behavior and recovery in `docs/AGENTS.md` and
  `windows/README.md`.

Closes Louis-CFM#430
@afpruivo

Copy link
Copy Markdown
Contributor

Tested on Windows 11, building this branch and running coucou.exe --uninstall-hooks against two throwaway home folders (with USERPROFILE pointing at them):

  • Antigravity and Claude Code configured with Coucou's hooks, plus a hook group and a Claude Code hook of the user's own: all Coucou entries were removed, the user's own hooks were kept, and a dated backup of settings.json was made.
  • Coucou's group the only one in hooks.json: the file is deleted, as described.

cargo test --lib passes (460). I didn't run the real uninstaller end to end. #802 reports the same problem as #430, so this would fix it too. 👍

@afpruivo

Copy link
Copy Markdown
Contributor

One more thing from running the tests: the new filesystem test in hooks.rs redirects the home folder, but status_line_previous_path() still points at the real %LOCALAPPDATA%\Coucou\bin\statusline-previous.json. Running cargo test wrote test data there, deleted it, and left a statusline-previous.json.bak-… behind. On a machine where the user had a saved status line, the test would delete it. Could that path be redirected in the test too?

@Ohualtex

Copy link
Copy Markdown
Contributor Author

Thanks for catching this, @afpruivo — you were right. Redirecting the home folder left the saved status line pointing at the real local-data directory.

Fixed in cbe3105: the filesystem test now redirects both paths into its own temporary directory without changing process-wide environment variables. A regression test checks thread isolation and cleanup after a panic.

All 52 Rust tests passed in an isolated harness on macOS using both Windows and Linux path rules. Files outside the test sandbox remained unchanged. A native Windows rerun would still be welcome.

@afpruivo

Copy link
Copy Markdown
Contributor

Thanks @Ohualtex! Reran it natively on Windows 11 at cbe3105: cargo test --lib → 461 passed, 0 failed (4 ignored). This time nothing outside the test sandbox was touched: the real Claude settings and Coucou's data folders stayed unchanged after the run. Looks good to me 👍

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Google Antigravity tool calls blocked by pre-tool hook after uninstalling Coucou CLI

2 participants