From 1d7faa32b586f856619da4c35bd4080e445d05cd Mon Sep 17 00:00:00 2001 From: Bastien Chanot Date: Tue, 1 Sep 2026 15:32:18 +0200 Subject: [PATCH] =?UTF-8?q?chore(hooks):=20notify-attention=20=E2=80=94=20?= =?UTF-8?q?bell=20+=20OSC=20777=20toast=20when=20Claude=20needs=20input?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Notification hook (permission_prompt|idle_prompt|agent_needs_input| elicitation_*) returns BEL x2 + OSC 777 via the terminalSequence JSON field (hooks have no controlling TTY). Client side over Remote-SSH: VS Code accessibility.signals.terminalBell sound:on for the beep, wenbopan.vscode-terminal-osc-notifier extension for the Windows toast. --- hooks/notify-attention.sh | 24 ++++++++++++++++++++++++ settings.json | 13 +++++++++++++ 2 files changed, 37 insertions(+) create mode 100755 hooks/notify-attention.sh diff --git a/hooks/notify-attention.sh b/hooks/notify-attention.sh new file mode 100755 index 0000000..b7a3ef7 --- /dev/null +++ b/hooks/notify-attention.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# Notification hook — signal the user through the terminal when Claude +# needs input (permission prompt, question, idle wait). +# +# Runs on the remote (Linux); the only channel that crosses SSH into the +# VS Code client is the terminal stream. Hooks have no controlling TTY, +# so the sequence goes through the supported `terminalSequence` JSON +# output field and Claude Code writes it to the terminal: +# - BEL x2 (double beep) -> sound, needs VS Code setting +# accessibility.signals.terminalBell { "sound": "on" } +# - OSC 777 notify -> Windows toast via the client-side extension +# "Terminal Notification" (wenbopan.vscode-terminal-osc-notifier) +# Both are invisible no-ops in terminals that ignore them. +set -u + +msg=$(jq -r '.message // .notification_type // empty' 2>/dev/null \ + | tr -d '\000-\037' | cut -c1-200) +[ -n "$msg" ] || msg="Claude Code needs your input" + +bell=$(printf '\a') +esc=$(printf '\033') +seq="${bell}${bell}${esc}]777;notify;Claude Code;${msg}${esc}\\" +jq -cn --arg seq "$seq" '{suppressOutput: true, terminalSequence: $seq}' +exit 0 diff --git a/settings.json b/settings.json index 2ddaa29..7efe32d 100644 --- a/settings.json +++ b/settings.json @@ -273,6 +273,19 @@ ] } ], + "Notification": [ + { + "matcher": "permission_prompt|idle_prompt|agent_needs_input|elicitation_dialog|elicitation_url_dialog", + "hooks": [ + { + "type": "command", + "command": "bash ~/.claude/hooks/notify-attention.sh", + "timeout": 5, + "statusMessage": "Ringing terminal bell..." + } + ] + } + ], "UserPromptSubmit": [ { "hooks": [