#!/usr/bin/env bash
# Run from the tested checkout after pairing its fresh server and selecting
# Pulls > Filter > Project > menu. Record the same interaction on either commit.
set -euo pipefail
: "${SESSION:?Set the agent-device session}"
: "${OUTPUT:?Set a fresh output directory}"
mkdir -p "$OUTPUT"
ad() { agent-device "$@" --session "$SESSION"; }
ad press 'label="Search pull requests"' --settle
ad record start "$OUTPUT/search.mp4"
ad fill 'role="text-field"' cafe --settle
ad fill 'role="text-field"' caf --settle
# Gboard: hold e and slide right onto the composed acute-accent variant.
ad gesture drag 'label="e"' 'label="r"' 700 300 100
ad keyboard dismiss
ad snapshot -i --json > "$OUTPUT/tree.json"
ad screenshot "$OUTPUT/stable-a.png" --normalize-status-bar
sleep 0.5
ad screenshot "$OUTPUT/stable-b.png" --normalize-status-bar
ad record stop
python3 - "$OUTPUT/tree.json" <<'PY'
import json,sys
for node in json.load(open(sys.argv[1]))['data']['nodes']:
    if node.get('editable'):
        print('Query code points:', [f'U+{ord(c):04X}' for c in node.get('value', '')])
PY
