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:
@@ -31,6 +31,7 @@ Each run writes its logs to `smoketest/results/<time>/`, one per scenario, and p
|
||||
| `10-configure` | `--help`, `--list` (nothing on stderr; agent sign-ins and the sandbox item hidden until they apply), the menu, an unknown item, the Core item's first question, and refusing to run as root |
|
||||
| `20-goa` | `goa-account` with Online Accounts 3.50. It adds Nextcloud and email (quoting a name), adding again changes nothing, and it pauses email and ends the pause. Test a Core takes an unreachable mail server as a sign-in failure, not a wrong password. Removing leaves nothing in the keyring. |
|
||||
| `30-core-local` | Superpanel's entry, Element's config (in ~/.config, or the Flatpak's folder), and the COSMIC Files sidebar. The sidebar check reads and writes ron's pretty format with network places and escaped names, keeps COSMIC Files' defaults, and leaves a file it can't read alone. Then davfs2's secret, read back. |
|
||||
| `35-claude-notify` | `system/claude-notify` with a fake /proc and a stand-in `notify-send`: it names COSMIC Terminal, found among Claude's parent processes, or the Flatpak it runs in, shows the project folder and Claude's message, and names no app it has no desktop entry for. `configure agents` writes its hooks, swaps the old notify-send ones for them, keeps your own hooks and settings, and changes nothing the second time. |
|
||||
| `40-backup` | restic and rclone from apt, with `rclone serve webdav` standing in for Nextcloud and the secrets in the keyring. `system/backup` makes a snapshot that leaves out caches and the install, a file restores from it, and without the passphrase it fails. |
|
||||
| `45-tailnet` | `lib/tailnet.sh` with a stand-in `tailscale`: the other online computers, without phones; nothing when Tailscale is stopped or missing. `configure ai-servers` and `configure storage` ask the tailnet's machines as well as mDNS's, list a machine found both ways once by its tailnet name, and mount a tailnet server at /mnt/<short name>. |
|
||||
| `50-sandbox` *(all)* | Node.js and srt download and install. A stand-in agent can't read `~/.ssh` or Federated Connector's settings, or write outside its project, reaches allowed sites only, and won't start in your home folder. A new bash finds the sandboxed command first. |
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
# shellcheck shell=bash
|
||||
# Scenarios set what the runner and items read
|
||||
# shellcheck disable=SC2034
|
||||
DESCRIPTION="Claude Code's notifications name the app Claude runs in, and old hooks are swapped"
|
||||
TIER=quick
|
||||
|
||||
# A fake /proc: pid $1 runs $2 under pid $3
|
||||
fake_proc() {
|
||||
mkdir -p "$PROC/$1"
|
||||
echo "$2" > "$PROC/$1/comm"
|
||||
printf 'Name:\t%s\nPPid:\t%s\n' "$2" "$3" > "$PROC/$1/status"
|
||||
}
|
||||
|
||||
scenario() {
|
||||
local bin="$HOME/.local/bin" sent="$HOME/sent" notify="$CONNECTOR/system/claude-notify" apps
|
||||
PROC="$HOME/proc"
|
||||
apps="$HOME/.local/share/applications"
|
||||
mkdir -p "$bin" "$apps"
|
||||
# A stand-in notify-send that records its arguments, one per line
|
||||
printf '#!/bin/bash\nprintf "%%s\\n" "$@" > %q\n' "$sent" > "$bin/notify-send"
|
||||
chmod +x "$bin/notify-send"
|
||||
|
||||
step "system/claude-notify"
|
||||
# COSMIC Terminal (40) runs bash (41), which runs claude (42), which runs the hook
|
||||
fake_proc 40 cosmic-term 1
|
||||
fake_proc 41 bash 40
|
||||
fake_proc 42 claude 41
|
||||
touch "$apps/com.system76.CosmicTerm.desktop"
|
||||
echo '{"message": "Claude needs your permission", "cwd": "/home/pop/Projects/demo"}' \
|
||||
| XDG_DATA_DIRS="$HOME/none" CLAUDE_NOTIFY_PROC="$PROC" CLAUDE_NOTIFY_PID=42 "$notify" 'Needs your input'
|
||||
check "it names COSMIC Terminal" grep -qxF -- "--hint=string:desktop-entry:com.system76.CosmicTerm" "$sent"
|
||||
check "the title is the project folder" grep -qxF "Claude Code: demo" "$sent"
|
||||
check "the body is Claude's message" grep -qxF "Claude needs your permission" "$sent"
|
||||
echo '{"cwd": "/home/pop/Projects/demo"}' \
|
||||
| XDG_DATA_DIRS="$HOME/none" CLAUDE_NOTIFY_PROC="$PROC" CLAUDE_NOTIFY_PID=42 "$notify" 'Task completed'
|
||||
check "without a message, the hook's own text" grep -qxF "Task completed" "$sent"
|
||||
rm "$apps/com.system76.CosmicTerm.desktop"
|
||||
echo '{}' | XDG_DATA_DIRS="$HOME/none" CLAUDE_NOTIFY_PROC="$PROC" CLAUDE_NOTIFY_PID=42 "$notify" 'Task completed'
|
||||
check_not "no app it can't find a desktop entry for" grep -q desktop-entry "$sent"
|
||||
echo '{}' | XDG_DATA_DIRS="$HOME/none" FLATPAK_ID=com.vscodium.codium "$notify" 'Task completed'
|
||||
check "inside a Flatpak, the Flatpak" grep -qxF -- "--hint=string:desktop-entry:com.vscodium.codium" "$sent"
|
||||
|
||||
step "configure agents' hooks"
|
||||
source "$CONNECTOR/configure.d/30-agents.sh"
|
||||
rm -f "$CLAUDE_SETTINGS"
|
||||
check "claude_notifications writes them" claude_notifications
|
||||
check_eq "through claude-notify" "$CLAUDE_NOTIFY 'Needs your input'" \
|
||||
"$(jq -r '.hooks.Notification[0].hooks[0].command' "$CLAUDE_SETTINGS")"
|
||||
check_not "they aren't the old ones" old_claude_notifications
|
||||
|
||||
# Settings written before claude-notify, with a hook of your own
|
||||
cat > "$CLAUDE_SETTINGS" << 'EOF'
|
||||
{
|
||||
"model": "opus",
|
||||
"hooks": {
|
||||
"Notification": [{"matcher": "", "hooks": [{"type": "command", "command": "notify-send 'Claude Code' 'Needs your input'"}]}],
|
||||
"Stop": [{"matcher": "", "hooks": [
|
||||
{"type": "command", "command": "notify-send 'Claude Code' 'Task completed'"},
|
||||
{"type": "command", "command": "my-own-hook"}
|
||||
]}]
|
||||
}
|
||||
}
|
||||
EOF
|
||||
check "old hooks are found" old_claude_notifications
|
||||
check "claude_notifications swaps them" claude_notifications
|
||||
check_not "they're gone" old_claude_notifications
|
||||
check_eq "Stop runs claude-notify" "$CLAUDE_NOTIFY 'Task completed'" \
|
||||
"$(jq -r '.hooks.Stop[0].hooks[0].command' "$CLAUDE_SETTINGS")"
|
||||
check_eq "your own hook stays" my-own-hook "$(jq -r '.hooks.Stop[0].hooks[1].command' "$CLAUDE_SETTINGS")"
|
||||
check_eq "and your other settings" opus "$(jq -r .model "$CLAUDE_SETTINGS")"
|
||||
cp "$CLAUDE_SETTINGS" "$HOME/before.json"
|
||||
claude_notifications > /dev/null
|
||||
check "running it again changes nothing" cmp -s "$CLAUDE_SETTINGS" "$HOME/before.json"
|
||||
|
||||
rm -rf "$PROC" "$sent" "$bin/notify-send" "$HOME/before.json" "$HOME/.claude"
|
||||
}
|
||||
Reference in New Issue
Block a user