Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions apps/desktop/src/main/lib/agent-setup/agent-wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }],
},
],
},
};

Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/main/lib/agent-setup/notify-hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down