From 633b096f0aab3f6075bd30887283b2fb89cf0a9f Mon Sep 17 00:00:00 2001 From: Eliauk Date: Thu, 16 Jul 2026 09:34:48 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20prune=20once=20per=20event=20=E2=80=94?= =?UTF-8?q?=20pruning=20inside=20the=20append=20loop=20strips=20sibling=20?= =?UTF-8?q?groups=20on=20a=20shared=20event?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With two hooks registered on the same event (e.g. two PostToolUse/Bash entries), processing the second spec re-pruned the event list and silently dropped the group just added for the first. Latent with a single spec per event; bites as soon as a second one exists. Co-Authored-By: Claude Fable 5 --- install.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index 9ce3131..670a0b3 100755 --- a/install.sh +++ b/install.sh @@ -69,16 +69,19 @@ if mode == "uninstall": print("fable-mode hooks removed from %s" % settings_path) sys.exit(0) -# install: prune our old entries first (handles moves/upgrades), then add fresh. +# install: prune our old entries first (handles moves/upgrades), then add +# fresh. Prune ONCE per event before appending — pruning inside the append +# loop would strip the groups just added for an earlier spec on the same +# event (two hooks share PostToolUse/Bash). added = 0 +for event in {e for e, _, _ in SPECS}: + hooks[event] = prune(hooks.get(event, [])) for event, matcher, fname in SPECS: - entries = prune(hooks.get(event, [])) group = {"hooks": [{"type": "command", "command": "python3 %s" % os.path.join(hooks_dir, fname)}]} if matcher: group["matcher"] = matcher - entries.append(group) - hooks[event] = entries + hooks[event].append(group) added += 1 data["hooks"] = hooks