diff --git a/apps/desktop/src/main/lib/agent-setup/agent-wrappers.ts b/apps/desktop/src/main/lib/agent-setup/agent-wrappers.ts index 345d66a4f89..69690817ad2 100644 --- a/apps/desktop/src/main/lib/agent-setup/agent-wrappers.ts +++ b/apps/desktop/src/main/lib/agent-setup/agent-wrappers.ts @@ -82,6 +82,15 @@ export function getClaudeSettingsContent(notifyPath: string): string { PermissionRequest: [ { matcher: "*", hooks: [{ type: "command", command: notifyPath }] }, ], + // Notification hook fires when Claude Code needs user attention + // - permission_prompt: permission dialogs + // - elicitation_dialog: when Claude asks questions via MCP tool elicitation + Notification: [ + { + matcher: "permission_prompt|elicitation_dialog", + hooks: [{ type: "command", command: notifyPath }], + }, + ], }, }; diff --git a/apps/desktop/src/main/lib/agent-setup/notify-hook.ts b/apps/desktop/src/main/lib/agent-setup/notify-hook.ts index 5026f3a6ac2..55c7053716d 100644 --- a/apps/desktop/src/main/lib/agent-setup/notify-hook.ts +++ b/apps/desktop/src/main/lib/agent-setup/notify-hook.ts @@ -4,7 +4,7 @@ import { PORTS } from "shared/constants"; import { HOOKS_DIR } from "./paths"; export const NOTIFY_SCRIPT_NAME = "notify.sh"; -export const NOTIFY_SCRIPT_MARKER = "# Superset agent notification hook"; +export const NOTIFY_SCRIPT_MARKER = "# Superset agent notification hook v3"; const NOTIFY_SCRIPT_TEMPLATE_PATH = path.join( __dirname, diff --git a/apps/desktop/src/main/lib/agent-setup/templates/notify-hook.template.sh b/apps/desktop/src/main/lib/agent-setup/templates/notify-hook.template.sh index fc5dd405184..0dd8240544f 100644 --- a/apps/desktop/src/main/lib/agent-setup/templates/notify-hook.template.sh +++ b/apps/desktop/src/main/lib/agent-setup/templates/notify-hook.template.sh @@ -30,6 +30,21 @@ fi # Map UserPromptSubmit to Start for simpler handling [ "$EVENT_TYPE" = "UserPromptSubmit" ] && EVENT_TYPE="Start" +# Handle Notification hook - check notification_type for user attention events +if [ "$EVENT_TYPE" = "Notification" ]; then + NOTIFICATION_TYPE=$(echo "$INPUT" | grep -oE '"notification_type"[[:space:]]*:[[:space:]]*"[^"]*"' | grep -oE '"[^"]*"$' | tr -d '"') + case "$NOTIFICATION_TYPE" in + permission_prompt|elicitation_dialog) + # Both permission prompts and question dialogs need user attention + EVENT_TYPE="PermissionRequest" + ;; + *) + # Ignore other notification types + exit 0 + ;; + esac +fi + # If no event type was found, skip the notification # This prevents parse failures from causing false completion notifications [ -z "$EVENT_TYPE" ] && exit 0