diff options
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/e2e.sh | 59 | ||||
| -rwxr-xr-x | tests/pi-live.sh | 11 |
2 files changed, 69 insertions, 1 deletions
diff --git a/tests/e2e.sh b/tests/e2e.sh index e51b18d..0da517a 100755 --- a/tests/e2e.sh +++ b/tests/e2e.sh @@ -930,6 +930,65 @@ if command -v node >/dev/null; then expect "and leaves the footer" "grep -c '^status dingger-importance $' $EXTLOG" 1 fi +# --- 22. mark as unread ---------------------------------------------------- +# An idle agent marked unread is done again, last among done agents of its +# importance, until the user comes back to it. +echo "22. mark as unread" +t new-session -d -s unr -n u1 -c "$DIR" -x 120 -y 40 "$DIR/bin/pi" +t new-window -d -t unr: -n u2 -c "$DIR" "$DIR/bin/pi" +t new-window -d -t unr: -n u3 -c "$DIR" "$DIR/bin/pi" +t new-window -d -t unr: -n away -c "$DIR" "sleep 100000" +U1=$(t display -p -t unr:u1 '#{pane_id}'); U2=$(t display -p -t unr:u2 '#{pane_id}') +U3=$(t display -p -t unr:u3 '#{pane_id}'); AWAY=$(t display -p -t unr:away '#{pane_id}') +uqueue() { gopt @dingger_queue | tr ',' '\n' | grep -xE "$U1|$U2|$U3" | tr '\n' ' '; } +look() { t switch-client -c "$CLIENT" -t "$1"; $DINGGER poke; } +look "$AWAY" +report "$U3" "" low +for p in "$U3" "$U1"; do report "$p" working ""; report "$p" idle ""; expect "unr: $p done" "opt $p @agent_state" done; sleep 0.05; done +look "$U1" +expect "unr: looking at u1 sees it" "opt $U1 @agent_state" idle +look "$AWAY" +# u2 finishes after u1 was seen: by its old time, u1 would come first. +report "$U2" working ""; report "$U2" idle ""; expect "unr: $U2 done" "opt $U2 @agent_state" done +expect "unr: the queue without it" "uqueue" "$U2 $U3 " +look "$U1" +sleep 3.5; : >"$SOUNDS"; : >"$NOTES" +expect "dingger unread marks it" "$DINGGER unread --pane $U1" "marked unread" +expect "done again" "opt $U1 @agent_state" done +expect "last among done agents of its importance, before a low one" "uqueue" "$U2 $U1 $U3 " +expect "menu: shown as done" "mb --print | grep -F 'unr · u1' | cut -d' ' -f1" "✓" +$DINGGER poke; sleep 1; $DINGGER poke +expect "still looking at it: still done" "opt $U1 @agent_state" done +sleep 1 +expect "marking makes no sound" "cat $SOUNDS" "" +expect "and no notification" "cat $NOTES" "" +look "$AWAY" +expect "looking away: still done" "opt $U1 @agent_state" done 10 +look "$U1" +expect "coming back sees it" "opt $U1 @agent_state" idle +expect "unr: marked again" "$DINGGER unread --pane $U1" "marked unread" +$DINGGER focus --client "$CLIENT" --pane "$U1" +expect "a jump to it sees it" "opt $U1 @agent_state" idle +look "$AWAY" +expect "marked while away" "$DINGGER unread --pane $U1" "marked unread" +look "$U1" +expect "seen on arrival" "opt $U1 @agent_state" idle +expect "a done agent is refused" "$DINGGER unread --pane $U2 2>&1" "dingger: it is unread already (done)" +report "$U3" working ""; expect "unr: u3 working" "opt $U3 @agent_state" working +expect "a working agent is refused" "$DINGGER unread --pane $U3 2>&1" \ + "dingger: only an idle agent can be marked unread; this one is working" +expect "a pane without an agent is refused" "$DINGGER unread --pane $AWAY 2>&1" "dingger: no agent in pane $AWAY" +if command -v node >/dev/null; then + : >"$EXTLOG"; iext "$U1" session_start "/unread" + expect "/unread marks it" "opt $U1 @agent_state" done + expect "and says so" "grep -c '^notify marked unread: dingger shows it as done until you come back to it$' $EXTLOG" 1 + look "$AWAY"; look "$U1" + expect "unr: seen again" "opt $U1 @agent_state" idle + : >"$EXTLOG"; iext "$U1" session_start agent_start "/unread" + expect "/unread while working is refused" "grep -c '^notify only an idle agent can be marked unread$' $EXTLOG" 1 + expect "and changes nothing" "opt $U1 @agent_state" working +fi + # Every daemon this run started must stop with it. kill "$DAEMON_PID" "$DAEMON2_PID" 2>/dev/null expect "the test daemons stop" "ps -o pid= -p $DAEMON_PID,$DAEMON2_PID | wc -l | tr -d ' '" 0 diff --git a/tests/pi-live.sh b/tests/pi-live.sh index 3f4b4b8..9842343 100755 --- a/tests/pi-live.sh +++ b/tests/pi-live.sh @@ -7,7 +7,7 @@ # tests/pi-live.sh <pi binary> [dingger binary] # # Covers: identification, the extension's state and session reports, a turn -# (working, then done), /reload, an extension's blocked event, /importance, +# (working, then done), /reload, an extension's blocked event, /importance, /unread, # screen detection for a pi without the extension, restore (`pi --session`, # importance included), exit. set -u @@ -112,6 +112,15 @@ type_line agent "/importance high" expect "/importance high: the pane option" "t show -pv -t main:agent @dingger_importance 2>/dev/null" high 50 expect "and pi's footer (its last line)" "t capture-pane -p -t main:agent | grep -v '^ *$' | tail -1 | sed 's/^ *//'" "importance: high" 30 expect "saved in the session file" "grep -c '\"customType\":\"dingger-importance\"' \"\$(t show -pv -t main:agent @agent_session)\"" 1 30 +# Seen (what a jump does; no client is attached here), then marked unread. +t set -p -t main:agent @dingger_ack 1; "$DINGGER" poke +expect "seen: idle" "st agent" idle 50 +type_line agent "/unread" +expect "/unread: done again" "st agent" done 50 +# Not a turn (an unknown command would be sent to the model, and also end +# done): the daemon applied a mark, and pi said so. +expect "by a mark" "sed 's/\x1b\[[0-9;]*m//g' $D/daemon.log | grep -c 'mark unread target=main:agent applied=true'" 1 30 +expect "pi says so" "t capture-pane -p -t main:agent | grep -c 'marked unread: dingger shows it as done'" 1 30 echo "2. screen detection (pi without the extension)" t send-keys -t main:plain "PI_CODING_AGENT_DIR=$D/agent-plain pi $NO_MCP" Enter |
