#!/usr/bin/env bash
set -euo pipefail
# Run from the tested checkout after manual-proof-seed.ts and manual-proof-launch.ts.
# Arguments: state JSON, agent-device session, output directory (new per run).
state_file=$1
session=$2
out=$3
thread_url=$(node -e 'const s=JSON.parse(require("node:fs").readFileSync(process.argv[1],"utf8")); process.stdout.write(`t3code-dev://threads/${s.envA}/${encodeURIComponent(s.launch.threadId)}`)' "$state_file")
agent-device open com.t3tools.t3code.dev "$thread_url" --session "$session"
agent-device press 'role=button text="Worked for"' --session "$session" --settle
# From the returned snapshot, press the group labelled Show the showcase, Completed, on Remote demo.
# Both runs used the completed subagent row, not the final-response link.
agent-device press 'role=group text="Show the showcase, Completed, on Remote demo"' --session "$session" --settle
agent-device record start "$out/thinking.mp4" --hide-touches --session "$session"
agent-device press 'role=button text="Thinking"' --session "$session" --settle
agent-device scroll top --session "$session" --settle
agent-device record stop --session "$session"
agent-device screenshot "$out/expanded.png" --session "$session"
sleep 0.5
agent-device screenshot "$out/expanded-stable.png" --session "$session"
compare -metric AE "$out/expanded.png" "$out/expanded-stable.png" null:
