Claude notifications: clicking one brings back the app Claude runs in
Ports CoreDesktop's 4fb3539. The hooks ran notify-send from inside Claude, so the desktop couldn't tell which app the notification came from and clicking it did nothing. system/claude-notify finds the terminal or editor among Claude's parent processes (or tmux's client, or the Flatpak) and names it in the desktop-entry hint. The title shows the project folder and the body Claude's own message. configure agents writes the hooks through it, and swaps the old notify-send ones for it, only where they're still the ones it wrote. update doesn't change settings, so old hooks make configure agents to do until it has swapped them. Smoketest: 35-claude-notify. TEST.md: click one on COSMIC. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+39
-12
@@ -104,18 +104,44 @@ turn_on_claude_sandbox() {
|
||||
echo "Claude Code runs the commands it starts in its own sandbox."
|
||||
}
|
||||
|
||||
# A desktop notification when Claude Code needs you or is done, if you have no
|
||||
# settings of your own yet
|
||||
# A desktop notification when Claude Code needs you or is done, through
|
||||
# system/claude-notify so that clicking one brings back the app Claude runs in.
|
||||
# The hook runs in a shell, which expands ~.
|
||||
# shellcheck disable=SC2088
|
||||
CLAUDE_NOTIFY="~/.local/share/federated-connector/connector/system/claude-notify"
|
||||
OLD_NOTIFY_INPUT="notify-send 'Claude Code' 'Needs your input'"
|
||||
OLD_NOTIFY_DONE="notify-send 'Claude Code' 'Task completed'"
|
||||
|
||||
# Settings written before claude-notify ran notify-send itself, so clicking
|
||||
# did nothing: true while either of those two hooks is still there
|
||||
old_claude_notifications() {
|
||||
jq -e --arg input "$OLD_NOTIFY_INPUT" --arg done "$OLD_NOTIFY_DONE" \
|
||||
'[.hooks.Notification[]?.hooks[]?, .hooks.Stop[]?.hooks[]? | objects | .command]
|
||||
| any(. == $input or . == $done)' "$CLAUDE_SETTINGS" &> /dev/null
|
||||
}
|
||||
|
||||
# Your own settings are left alone: the hooks are added only if you have no
|
||||
# settings yet, and changed only where they're still the ones written here
|
||||
claude_notifications() {
|
||||
[ -f "$CLAUDE_SETTINGS" ] && return 0
|
||||
edit_json "$CLAUDE_SETTINGS" '{}' \
|
||||
--arg needs "notify-send 'Claude Code' 'Needs your input'" \
|
||||
--arg finished "notify-send 'Claude Code' 'Task completed'" \
|
||||
'.hooks = {
|
||||
Notification: [{matcher: "", hooks: [{type: "command", command: $needs}]}],
|
||||
Stop: [{matcher: "", hooks: [{type: "command", command: $finished}]}]
|
||||
}' || return 1
|
||||
echo "Claude Code shows a notification when it needs you and when it's done."
|
||||
if [ ! -f "$CLAUDE_SETTINGS" ]; then
|
||||
edit_json "$CLAUDE_SETTINGS" '{}' \
|
||||
--arg needs "$CLAUDE_NOTIFY 'Needs your input'" \
|
||||
--arg finished "$CLAUDE_NOTIFY 'Task completed'" \
|
||||
'.hooks = {
|
||||
Notification: [{matcher: "", hooks: [{type: "command", command: $needs}]}],
|
||||
Stop: [{matcher: "", hooks: [{type: "command", command: $finished}]}]
|
||||
}' || return 1
|
||||
echo "Claude Code shows a notification when it needs you and when it's done."
|
||||
elif old_claude_notifications; then
|
||||
edit_json "$CLAUDE_SETTINGS" '{}' \
|
||||
--arg old_input "$OLD_NOTIFY_INPUT" --arg new_input "$CLAUDE_NOTIFY 'Needs your input'" \
|
||||
--arg old_done "$OLD_NOTIFY_DONE" --arg new_done "$CLAUDE_NOTIFY 'Task completed'" '
|
||||
def swap(old; new):
|
||||
if type == "object" and .command == old then .command = new else . end;
|
||||
(.hooks.Notification[]?.hooks[]?) |= swap($old_input; $new_input)
|
||||
| (.hooks.Stop[]?.hooks[]?) |= swap($old_done; $new_done)' || return 1
|
||||
echo "Clicking Claude Code's notifications brings back the app it runs in."
|
||||
fi
|
||||
}
|
||||
|
||||
# --- Hermes' gateway and Cline Desktop -----------------------------------------------
|
||||
@@ -189,7 +215,8 @@ sandbox_cline() {
|
||||
|
||||
sandbox_ready() {
|
||||
srt_path > /dev/null && on_path && pkg_installed "${SANDBOX_PACKAGES[@]}" && bwrap_works \
|
||||
&& { ! agent_installed claude || claude_sandbox_on; } && gateway_ok && cline_ok
|
||||
&& { ! agent_installed claude || { claude_sandbox_on && ! old_claude_notifications; }; } \
|
||||
&& gateway_ok && cline_ok
|
||||
}
|
||||
|
||||
is_configured() {
|
||||
|
||||
Reference in New Issue
Block a user