#!/usr/bin/env bash
set -euo pipefail
# Prerequisites: the real app from SIDE's commit, fresh server state seeded with
# manual-scheduled-seed.ts, paired to that server, at Settings > Scheduled tasks.
# SESSION is an already leased iPhone 18 Pro; OUT is a new capture directory.
# Remove the previous environment before pairing the other server: reinstalling
# the dev client preserves its saved connections on this simulator.
agent-device record start "$OUT/mobile.mp4" --session "$SESSION"
agent-device press 'role=button label="New task"' --settle --session "$SESSION"
python3 capture-stable.py "$OUT/controls.png" "$SESSION"
if [ "$SIDE" = head ]; then
  agent-device is visible 'role=button label=Plan' --session "$SESSION"
  agent-device press 'role=button label=Plan' --settle --session "$SESSION"
else
  agent-device is absent 'role=button label=Plan' --session "$SESSION"
fi
agent-device press 'role=button label=Back' --settle --session "$SESSION"
python3 capture-stable.py "$OUT/after-back.png" "$SESSION"
agent-device record stop --session "$SESSION"
