From 371027a85f44470880b1436d59fa97774e9c8642 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 15 Nov 2026 17:43:11 +0100 Subject: 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. --- scripts/ux-check.sh | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100755 scripts/ux-check.sh (limited to 'scripts') 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 @@ +#!/usr/bin/env bash +# Drives the editor on a real terminal (tmux) and checks the things byte-level +# tests cannot see: that a multi-line prompt is drawn where it belongs, and that +# moving the caret inside it does not erase the output above. +set -uo pipefail + +here=$(cd "$(dirname "$0")/.." && pwd) +port=${PORT:-8791} +session=agent686-ux +work=$(mktemp -d) +mock_pid= +fail=0 + +cleanup() { + tmux kill-session -t "$session" 2>/dev/null + [ -n "$mock_pid" ] && kill "$mock_pid" 2>/dev/null + rm -rf "$work" +} +trap cleanup EXIT + +fail_msg() { + echo "FAIL: $*" >&2 + fail=1 +} + +python3 "$here/scripts/mock-provider.py" --port "$port" --quiet --delay 0 >/dev/null 2>&1 & +mock_pid=$! +sleep 0.6 + +tmux kill-session -t "$session" 2>/dev/null +tmux new-session -d -s "$session" -x 80 -y 24 +tmux send-keys -t "$session" \ + "clear; cd $work && AGENT686_DATA=$work/.data OPENCODE_API_KEY=test \ + $here/target/debug/agent686 --yolo --base-url http://127.0.0.1:$port/v1" Enter +sleep 1.5 + +# One turn so there is output above the prompt that must survive. +tmux send-keys -t "$session" "hi" Enter +sleep 1.2 +screen=$(tmux capture-pane -p -t "$session") +echo "$screen" | grep -q "Hello from the mock provider" || fail_msg "the turn produced no answer" +grep_line=$(echo "$screen" | grep -n "Hello from the mock provider" | head -1 | cut -d: -f1) + +# Two-line prompt, no trailing newline. +printf 'line one\nline two' | tmux load-buffer -b uxcheck - +tmux paste-buffer -p -b uxcheck -t "$session" +sleep 0.5 +paste_y=$(tmux display-message -p -t "$session" '#{cursor_y}') + +tmux send-keys -t "$session" Home +sleep 0.4 +home_y=$(tmux display-message -p -t "$session" '#{cursor_y}') +[ "$home_y" -eq $((paste_y - 1)) ] || fail_msg "Home put the caret on row $home_y, expected $((paste_y - 1))" + +tmux send-keys -t "$session" Right +sleep 0.4 +right_y=$(tmux display-message -p -t "$session" '#{cursor_y}') +[ "$right_y" -eq "$home_y" ] || fail_msg "Right moved the caret to row $right_y, expected $home_y" + +screen=$(tmux capture-pane -p -t "$session") +if ! echo "$screen" | grep -q "Hello from the mock provider"; then + fail_msg "moving the caret inside a two-line prompt erased the output above it" +fi +if ! echo "$screen" | grep -q "line two"; then + fail_msg "the second prompt line disappeared" +fi +if ! echo "$screen" | grep -q "^> line one"; then + fail_msg "the first prompt line is not drawn with its prompt" +fi + +# Submitting must not duplicate the block or leave the answer mid-line. +tmux send-keys -t "$session" Enter +sleep 1.0 +screen=$(tmux capture-pane -p -t "$session") +[ "$(echo "$screen" | grep -c '^line two$')" -eq 1 ] \ + || fail_msg "the submitted prompt should appear exactly once" +if echo "$screen" | grep -q 'line two.*Hello from the mock'; then + fail_msg "the answer was written on the same line as the prompt" +fi + +if [ "$fail" -ne 0 ]; then + echo "--- final screen ---" >&2 + echo "$screen" >&2 + exit 1 +fi +echo "ux-check: ok (two-line prompt, caret movement, output above intact)" -- cgit v1.2.3