aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/ux-check.sh
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-11-15 17:43:11 +0100
committersalmonik <salmonik@tuta.io>2026-11-15 17:43:11 +0100
commit371027a85f44470880b1436d59fa97774e9c8642 (patch)
treefc6d750fec65dd3a892a370baf16550efb6cb634 /scripts/ux-check.sh
parent0.6.0: transcript viewer, turn summary, yolo floor, model/version records (diff)
downloadagent686-371027a85f44470880b1436d59fa97774e9c8642.tar.gz
agent686-371027a85f44470880b1436d59fa97774e9c8642.zip
0.6.1: redraw from the caret row, not the block height
A two-line prompt with the caret moved up made the next redraw overshoot by one row and clear the line above, erasing the model's output. The editor now tracks the caret's row. Adds scripts/ux-check.sh, which drives tmux and asserts the rendered screen: byte-level tests cannot see misplaced cursors or erased rows.
Diffstat (limited to '')
-rwxr-xr-xscripts/ux-check.sh86
1 files changed, 86 insertions, 0 deletions
diff --git a/scripts/ux-check.sh b/scripts/ux-check.sh
new file mode 100755
index 0000000..019f63d
--- /dev/null
+++ b/scripts/ux-check.sh
@@ -0,0 +1,86 @@
1#!/usr/bin/env bash
2# Drives the editor on a real terminal (tmux) and checks the things byte-level
3# tests cannot see: that a multi-line prompt is drawn where it belongs, and that
4# moving the caret inside it does not erase the output above.
5set -uo pipefail
6
7here=$(cd "$(dirname "$0")/.." && pwd)
8port=${PORT:-8791}
9session=agent686-ux
10work=$(mktemp -d)
11mock_pid=
12fail=0
13
14cleanup() {
15 tmux kill-session -t "$session" 2>/dev/null
16 [ -n "$mock_pid" ] && kill "$mock_pid" 2>/dev/null
17 rm -rf "$work"
18}
19trap cleanup EXIT
20
21fail_msg() {
22 echo "FAIL: $*" >&2
23 fail=1
24}
25
26python3 "$here/scripts/mock-provider.py" --port "$port" --quiet --delay 0 >/dev/null 2>&1 &
27mock_pid=$!
28sleep 0.6
29
30tmux kill-session -t "$session" 2>/dev/null
31tmux new-session -d -s "$session" -x 80 -y 24
32tmux send-keys -t "$session" \
33 "clear; cd $work && AGENT686_DATA=$work/.data OPENCODE_API_KEY=test \
34 $here/target/debug/agent686 --yolo --base-url http://127.0.0.1:$port/v1" Enter
35sleep 1.5
36
37# One turn so there is output above the prompt that must survive.
38tmux send-keys -t "$session" "hi" Enter
39sleep 1.2
40screen=$(tmux capture-pane -p -t "$session")
41echo "$screen" | grep -q "Hello from the mock provider" || fail_msg "the turn produced no answer"
42grep_line=$(echo "$screen" | grep -n "Hello from the mock provider" | head -1 | cut -d: -f1)
43
44# Two-line prompt, no trailing newline.
45printf 'line one\nline two' | tmux load-buffer -b uxcheck -
46tmux paste-buffer -p -b uxcheck -t "$session"
47sleep 0.5
48paste_y=$(tmux display-message -p -t "$session" '#{cursor_y}')
49
50tmux send-keys -t "$session" Home
51sleep 0.4
52home_y=$(tmux display-message -p -t "$session" '#{cursor_y}')
53[ "$home_y" -eq $((paste_y - 1)) ] || fail_msg "Home put the caret on row $home_y, expected $((paste_y - 1))"
54
55tmux send-keys -t "$session" Right
56sleep 0.4
57right_y=$(tmux display-message -p -t "$session" '#{cursor_y}')
58[ "$right_y" -eq "$home_y" ] || fail_msg "Right moved the caret to row $right_y, expected $home_y"
59
60screen=$(tmux capture-pane -p -t "$session")
61if ! echo "$screen" | grep -q "Hello from the mock provider"; then
62 fail_msg "moving the caret inside a two-line prompt erased the output above it"
63fi
64if ! echo "$screen" | grep -q "line two"; then
65 fail_msg "the second prompt line disappeared"
66fi
67if ! echo "$screen" | grep -q "^> line one"; then
68 fail_msg "the first prompt line is not drawn with its prompt"
69fi
70
71# Submitting must not duplicate the block or leave the answer mid-line.
72tmux send-keys -t "$session" Enter
73sleep 1.0
74screen=$(tmux capture-pane -p -t "$session")
75[ "$(echo "$screen" | grep -c '^line two$')" -eq 1 ] \
76 || fail_msg "the submitted prompt should appear exactly once"
77if echo "$screen" | grep -q 'line two.*Hello from the mock'; then
78 fail_msg "the answer was written on the same line as the prompt"
79fi
80
81if [ "$fail" -ne 0 ]; then
82 echo "--- final screen ---" >&2
83 echo "$screen" >&2
84 exit 1
85fi
86echo "ux-check: ok (two-line prompt, caret movement, output above intact)"