fix(install): preserve non-array hook entries during uninstall (#1824)

* fix(install): preserve non-array hook entries during uninstall

Uninstall filtering returned null for hook entries without a hooks
array, silently deleting user-owned entries with unexpected shapes.
Return the entry unchanged instead so only GSD hooks are removed.

* test(install): add regression test for non-array hook entry preservation (#1825)

Fix mirrored filterGsdHooks helper to match production code and add
test proving non-array hook entries survive uninstall filtering.
This commit is contained in:
Jeremy McSpadden
2026-04-05 22:07:59 -05:00
committed by GitHub
parent d52c880eec
commit 00c6a5ea68
2 changed files with 15 additions and 2 deletions

View File

@@ -4432,7 +4432,7 @@ function uninstall(isGlobal, runtime = 'claude') {
const before = JSON.stringify(settings.hooks[eventName]);
settings.hooks[eventName] = settings.hooks[eventName]
.map(entry => {
if (!entry.hooks || !Array.isArray(entry.hooks)) return null;
if (!entry.hooks || !Array.isArray(entry.hooks)) return entry;
// Filter out individual GSD hooks, keep user hooks
entry.hooks = entry.hooks.filter(h => !isGsdHookCommand(h.command));
return entry.hooks.length > 0 ? entry : null;