Files
splinter/tests/test_a2a_ui.sh
T
lotherk bff47eede8 ui: palette roles, a working unlimited usage count, /goal as the recap
Three things the screen and the goal were getting wrong.

Colours. The theme had one accent for the user and grey for everything
else. theme.h now carries agent, think, tool and notice colours. A CDE
palette maps them to sets 7 (answer), 3 (reasoning), 6 (tool) and 8
(status); Xresources uses colour10/11/14/13 on dark and 2/3/6/5 on
light. Role colours keep their hue and are pushed from the surface only
when they would disappear; each role has a slightly different minimum,
so even a monochrome palette yields distinguishable steps. The 256-colour
mapping now takes the nearest cube/ramp entry instead of rounding each
channel down, which turned a dark orange into grey 240.

Usage. sp_usage_get() only counted requests inside a declared window. A
provider without limit= therefore always read "0 calls" in the sidebar,
although every call was in its log. Calls are now counted when no window
is declared; test_usage covers it.

Goal. /goal <text> set a variable and answered "goal set" without starting
a turn. The engine now starts the recap prompt: the model writes a short
recap, the focus plugin remembers that answer and injects it every seventh
turn (SPLINTER_FOCUS_EVERY still overrides). /recap is gone as a command;
its old behaviour is what /goal does now. A palette and a wiki page are
not enough to make that visible: the prompt, the confirmation entry and
the sidebar goal all show up in the chat.

Tests: palette role separation and indexed roles in test_theme, four
unlimited calls in test_usage, recap capture/injection and the missing
/recap in test_focus, and a settle delay so the UI tests type after
ui_read_line() owns the keyboard. make check: all tests passed.
2026-11-16 17:48:22 +00:00

96 lines
2.8 KiB
Bash
Executable File

#!/bin/sh
# splinter -- the A2A streaming transport, driven through the curses UI.
#
# The engine turns streaming on for a front end that can take it,
# so this is where SendStreamingMessage is exercised: artifact chunks arrive
# live, the final status note is not appended to them, and a stream whose only
# answer is the final status message still produces text.
set -u
cd "$(dirname "$0")/.." || exit 1
if ! command -v tmux >/dev/null 2>&1; then
echo "test_a2a_ui: skipped (no tmux)"
exit 0
fi
D=$(mktemp -d "${TMPDIR:-/var/tmp}/splinter-a2a-ui-XXXXXX") || exit 1
unset TMUX TMUX_PANE
export TMUX_TMPDIR="$D"
# kill-server below: only ever on the server this test started, never the
# user's (see test_ui.sh for why $TMUX has to go as well).
own_server() {
if [ -n "${TMUX:-}" ] || [ "${TMUX_TMPDIR:-}" != "$D" ]; then
echo "test_a2a_ui: refusing to touch a tmux server this test does not own" >&2
exit 1
fi
}
S=splinter-a2a-ui-$$
P=$((20000 + ($$ % 20000)))
F=
fails=0
cleanup() {
own_server
tmux kill-server 2>/dev/null
[ -n "$F" ] && kill "$F" 2>/dev/null
rm -rf "$D"
}
trap cleanup EXIT
check() { if "$@"; then :; else echo "FAIL $*"; fails=$((fails + 1)); fi; }
shows() {
for i in $(seq 1 30); do
tmux capture-pane -t $S -p | grep -q -- "$1" && return 0
sleep 0.5
done
return 1
}
done_turn() {
for i in $(seq 1 40); do
tmux capture-pane -t $S -p | grep -q 'working' || return 0
sleep 0.5
done
return 1
}
typed() { tmux send-keys -t $S -l "$1"; }
key() { tmux send-keys -t $S "$@"; }
mkdir -p "$D/home"
python3 -I tests/fake_a2a.py "$P" "$D/req.log" &
F=$!
for i in $(seq 1 50); do
curl -s -o /dev/null "http://127.0.0.1:$P/x" && break
sleep 0.2
done
tmux new-session -d -s $S -x 110 -y 30 \
"HOME=$D/home SPLINTER_LOCALE=en \
SPLINTER_A2A_URL=http://127.0.0.1:$P/rpc \
./splinter --no-config --plugin plugins/a2a/a2a.so \
--transport a2a --chat 2>/dev/null; echo \$? > $D/rc"
shows 'Enter sends'
# the ready entry is drawn before ui_read_line() owns the keyboard; give the
# first wgetch a moment, or the first byte of the first prompt can be lost
sleep 1
# artifact chunks stream; the completed status note is not appended
typed 'stream bitte'; key Enter
check shows 'teil eins teil zwei'
check done_turn
if tmux capture-pane -t $S -p | grep -q -- 'fertig'; then
echo "FAIL the final status note leaked into the answer"
fails=$((fails + 1))
fi
# no artifact: the final status message is the answer
typed 'streamstatus'; key Enter
check shows 'nur status'
check done_turn
# the wire method, not the blocking one
grep -q '"method":"SendStreamingMessage"' "$D/req.log"
check test $? -eq 0
# quit cleanly
key C-u C-d
for i in $(seq 1 20); do [ -s "$D/rc" ] && break; sleep 0.5; done
check test "$(cat "$D/rc" 2>/dev/null)" = 0
if [ "$fails" -eq 0 ]; then echo "test_a2a_ui: ok"; exit 0; fi
exit 1