#!/usr/bin/env bash
# Start with the seeded Timestamp history thread open in the installed native dev client.
# Set Android Settings > Date & time to New York before launching the client.
set -eu
session="$1"
out="$2"
agent-device record start "$out/transition.mp4" --scope device --hide-touches --session "$session"
agent-device screenshot "$out/new-york.png" --session "$session"
agent-device open com.android.settings --session "$session"
agent-device press 'role="text" text="United States"' --session "$session" --settle
agent-device find 'role=autocompletetextview' fill Thailand --session "$session"
agent-device press 'role="text" text="Thailand"' --session "$session" --settle
agent-device screenshot "$out/bangkok-settings.png" --session "$session"
agent-device open com.t3tools.t3code.dev --session "$session"
sleep 2
agent-device find 'role=text-field' fill 'Message sent after switching to Bangkok' --session "$session"
agent-device press 'role=button label=Send' --session "$session"
agent-device keyboard dismiss --session "$session"
agent-device screenshot "$out/before-remount-a.png" --session "$session"
sleep 0.5
agent-device screenshot "$out/before-remount.png" --session "$session"
agent-device press 'role=button label="Navigate up"' --session "$session"
agent-device press 'role=button label="Another thread, Done"' --session "$session"
agent-device press 'role=button label="Navigate up"' --session "$session"
# Select Timestamp history from the current snapshot: its relative-age label changes.
agent-device snapshot -i --session "$session"
# Resume that thread, capture it, then stop recording.
