#!/usr/bin/env bash
set -euo pipefail
# Run from the checkout after seed.ts, opening its seeded thread in the paired app.
# BACKEND and Metro must run from that checkout with T3CODE_DEV_SEED=0.
# The replay emits one completed turn, then a sleep-180 activity held open for 180 seconds.
: "${SESSION:?Set the leased agent-device session}"
: "${OUTPUT:?Set a directory for captures}"
agent-device record start "$OUTPUT/interaction.mp4" --session "$SESSION"
agent-device fill 'label="Ask anything"' 'Run the foreground command for three minutes' --session "$SESSION" --settle
agent-device back --session "$SESSION" --settle
agent-device press 'label="Send"' --session "$SESSION" --settle
agent-device wait text 'Running sleep' --session "$SESSION"
agent-device fill 'label="Ask anything"' 'Follow-up: summarize when the command finishes' --session "$SESSION" --settle
agent-device back --session "$SESSION" --settle
agent-device longpress 'label="Steer"' --session "$SESSION" --settle
agent-device press 'text="Queue"' --session "$SESSION" --settle
agent-device wait 10000 --session "$SESSION"
agent-device snapshot -i --session "$SESSION"
agent-device screenshot "$OUTPUT/accepted-follow-up.png" --session "$SESSION"
agent-device record stop --session "$SESSION"
