Skip to content

Commit e865070

Browse files
garyshengclaude
andcommitted
fix: prevent duplicate hooks when both global and local installs exist
The installer now removes peon-ping hooks from the other settings scope (global vs local) after registering, so users never get double sounds. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6594d4c commit e865070

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

install.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,44 @@ with open(settings_path, 'w') as f:
613613
print('Hooks registered for: ' + ', '.join(events))
614614
"
615615

616+
# --- Remove peon-ping hooks from the OTHER settings scope to prevent doubles ---
617+
if [ "$LOCAL_MODE" = true ]; then
618+
OTHER_SETTINGS="$GLOBAL_BASE/settings.json"
619+
else
620+
OTHER_SETTINGS="$LOCAL_BASE/settings.json"
621+
fi
622+
623+
if [ -f "$OTHER_SETTINGS" ] && [ "$OTHER_SETTINGS" != "$SETTINGS" ]; then
624+
python3 -c "
625+
import json, os
626+
627+
path = '$OTHER_SETTINGS'
628+
try:
629+
with open(path) as f:
630+
settings = json.load(f)
631+
except:
632+
exit(0)
633+
634+
hooks = settings.get('hooks', {})
635+
changed = False
636+
for event, entries in list(hooks.items()):
637+
filtered = [
638+
e for e in entries
639+
if not any('peon-ping/peon.sh' in h.get('command', '') for h in e.get('hooks', []))
640+
]
641+
if len(filtered) != len(entries):
642+
hooks[event] = filtered
643+
changed = True
644+
645+
if changed:
646+
settings['hooks'] = hooks
647+
with open(path, 'w') as f:
648+
json.dump(settings, f, indent=2)
649+
f.write('\n')
650+
print('Removed duplicate peon-ping hooks from ' + path)
651+
" 2>/dev/null || true
652+
fi
653+
616654
# --- Initialize state (fresh install only) ---
617655
if [ "$UPDATING" = false ]; then
618656
echo '{}' > "$INSTALL_DIR/.state.json"

0 commit comments

Comments
 (0)