fix(hooks): guard Notification auto-inject behind idle check; surface continue prompt in UI

The Notification hook was unconditionally injecting "Resolve the pending
question..." whenever Claude Code sent a notification event — even if the
user was actively at the keyboard typing their own reply. This caused the
double-prompt problem independently of the Stop hook fix.

Two changes:
1. handle_notification now applies the same 60s idle gate as handle_stop.
   If the user is active, the hook plays the attention sound only and exits —
   the user responds themselves. Auto-inject only fires when they're away.

2. The "continue" prompt entry in agent-prompts.json had style "internal"
   and slot null, making it invisible in the prompt library UI despite being
   the SSOT for this behavior. Changed to style "more" / slot 14 so it
   appears under the More button and can be read, used, and edited from the
   same place as every other prompt.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
g-butandClaude Sonnet 4.6 committed 2026-05-17 17:38:38 +02:00
1 parent d966e906f1
commit bbf45c9a21
1 file changed
+18
+18
View File
@@ -405,6 +405,24 @@ handle_notification() {
play_sound "window-attention"
# Only auto-inject the continue prompt when the user is away from the keyboard.
# If they're active (idle < 60s) they'll see the sound alert and respond themselves —
# injecting on top of their typing causes the double-prompt problem the Stop hook fix
# already addressed. Same idle detection logic used in handle_stop.
local _notif_idle
_notif_idle=$(
if command -v xprintidle >/dev/null 2>&1; then
ms=$(DISPLAY="${DISPLAY:-:0}" xprintidle 2>/dev/null || echo 99999999)
echo $(( ms / 1000 ))
else
DISPLAY="${DISPLAY:-:0}" python3 "$SCRIPT_DIR/get-idle-secs.py" 2>/dev/null || echo 9999
fi
)
if [ "${_notif_idle:-9999}" -lt 60 ]; then
log "notification: user active (idle=${_notif_idle}s) — skipping auto-inject"
exit 0
fi
prompt=$(get_prompt "continue")
[ -z "$prompt" ] && exit 0