Add anvillm-notify script for session state change notifications

- Add anvillm-notify script that polls session state files
- Sends desktop notification when session transitions running→idle
- Update mkfile with notify target
- Expose state via 9p in main.go
- Remove notification idea from IDEAS.md (implemented)
This commit is contained in:
Levi Neely 2026-02-11 16:30:57 +01:00
parent 9897070b57
commit fd13be576c
4 changed files with 55 additions and 10 deletions

View File

@ -11,16 +11,6 @@ Implementation sketch:
- Extract selected text from current window as the prompt
- Send prompt to the target session's tmux pane via `tmux send-keys`
## Notification on State Change
External polling script monitors 9p state files. When state changes from "running" to "idle", send desktop notification: "session {id} ({alias}) completed its work."
Implementation sketch:
- Poll `/mnt/anvillm/sessions/*/state` periodically
- Track previous state per session
- On transition running→idle, call `notify-send` or similar
- Bonus: watch all sessions, report which one finished
## Shared Context
Inject context from one session into another.

44
anvillm-notify Executable file
View File

@ -0,0 +1,44 @@
#!/bin/sh
# Poll all anvillm sessions and notify on running->idle transitions
# Track previous states: session_id=state
prev_states=""
get_sessions() {
9p read agent/list 2>/dev/null | awk '{print $1}'
}
get_state() {
9p read "agent/$1/state" 2>/dev/null
}
get_alias() {
9p read "agent/$1/alias" 2>/dev/null
}
get_prev() {
echo "$prev_states" | tr ' ' '\n' | grep "^$1=" | cut -d= -f2
}
set_prev() {
prev_states=$(echo "$prev_states" | tr ' ' '\n' | grep -v "^$1=" | tr '\n' ' ')
prev_states="$prev_states $1=$2"
}
while true; do
for id in $(get_sessions); do
[ -z "$id" ] && continue
state=$(get_state "$id")
prev=$(get_prev "$id")
if [ "$prev" = "running" ] && [ "$state" = "idle" ]; then
name=$(get_alias "$id")
[ -z "$name" ] && name=$id
notify-send "session $name completed its work"
fi
set_prev "$id" "$state"
done
sleep 1
done

View File

@ -60,6 +60,15 @@ func main() {
}
defer srv.Close()
// Start notification daemon in background
notifyCmd := exec.Command("anvillm-notify")
notifyCmd.Start()
defer func() {
if notifyCmd.Process != nil {
notifyCmd.Process.Kill()
}
}()
// Rename chat window when alias changes
var aliasChangeFunc func(Session)
aliasChangeFunc = func(sess Session) {

2
mkfile
View File

@ -4,6 +4,8 @@ all:V: install
build:V:
go build -o $INSTALL_PATH/Assist .
cp anvillm-notify $INSTALL_PATH/anvillm-notify
chmod +x $INSTALL_PATH/anvillm-notify
install:V: build