falcode: fix spawn error handlers (crash fix) + real oc-notify.sh notifier
- falcode.ts: add child.on('error') handlers so a missing notify binary
(e.g. /bin/true on NixOS) can no longer take down pi via uncaughtException
- scripts/oc-notify.sh: real notifier (notify-send + ntfy) replacing the no-op
- oc-notify.sh also deployed to ~/.local/state/falcode-zellij/ on all machines
This commit is contained in:
55
scripts/oc-notify.sh
Executable file
55
scripts/oc-notify.sh
Executable file
@@ -0,0 +1,55 @@
|
||||
#!/bin/sh
|
||||
# falcode agent-completion notifier.
|
||||
#
|
||||
# Spawned by the falcode pi extension (falcode.ts -> fireNotification) when an
|
||||
# agent's turn finishes (working -> waiting_user_input) with:
|
||||
# --agent <pi|opencode> --pane-name <cwd-basename> --status idle
|
||||
# --session <zellij-session> --pane-id <n>
|
||||
#
|
||||
# Sends a desktop popup (notify-send) and an ntfy push so Sam knows the agent
|
||||
# finished. Must never exit non-zero in a way that could disturb the caller.
|
||||
|
||||
agent=""
|
||||
pane_name=""
|
||||
status=""
|
||||
session=""
|
||||
pane_id=""
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--agent) agent="$2"; shift 2 ;;
|
||||
--pane-name) pane_name="$2"; shift 2 ;;
|
||||
--status) status="$2"; shift 2 ;;
|
||||
--session) session="$2"; shift 2 ;;
|
||||
--pane-id) pane_id="$2"; shift 2 ;;
|
||||
*) shift ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Only notify on agent-finish transitions.
|
||||
[ "$status" = "idle" ] || exit 0
|
||||
|
||||
[ -z "$pane_name" ] && pane_name="$agent"
|
||||
[ -z "$pane_name" ] && pane_name="pi"
|
||||
|
||||
title="✓ $pane_name finished"
|
||||
body="$agent agent done"
|
||||
[ -n "$session" ] && body="$body · $session"
|
||||
|
||||
# 1) Desktop popup
|
||||
if command -v notify-send >/dev/null 2>&1; then
|
||||
notify-send -a "Pi" "$title" "$body" >/dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
# 2) ntfy push (phone/desktop clients). PI_NTFY_TOPIC comes from
|
||||
# ~/.config/environment.d/10-secrets.conf; fall back to the lab topic.
|
||||
topic="${PI_NTFY_TOPIC:-http://192.168.20.35:8099/PI_NTFY_TOPIC}"
|
||||
if command -v curl >/dev/null 2>&1; then
|
||||
curl -s -o /dev/null \
|
||||
-H "Title: $title" \
|
||||
-H "Tags: white_check_mark" \
|
||||
-d "$body" \
|
||||
"$topic" >/dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user