#!/usr/bin/env bash
# Commands used for the manual Android proof of issue 38669.
# Run from the checkout that owns the leased agent-device session.
# Before this sequence, on EACH commit:
# - Start a fresh server with T3CODE_DEV_SEED=0 and Metro from that commit.
# - Install with vp run mobile:install android --session "$SESSION" --metro "$METRO".
# - Pair a fresh credential using the repository pair-client.sh helper.
# - In the UI, create a thread in the server project, choose Replay (dev) > Showcase,
#   send hello, and wait for the recorded reply to complete.
# - Rename the connection to Evidence through Settings > Environments > details.
# - Phone: Pixel 9, Android 16/API36, English (US), UTC, 12-hour clock, light theme.
# - Start with Android automatic date/time on (November 29, 2026).
set -euo pipefail
: "${SESSION:?Name the leased device session}"
: "${OUTPUT_ROOT:?Choose a scratch output directory}"
run_dir="$OUTPUT_ROOT/$(date -u +%Y%m%dT%H%M%SZ)"
mkdir -p "$run_dir"
ad() { agent-device "$@" --session "$SESSION"; }
ad open com.android.settings --activity '.Settings$DateTimeSettingsActivity'
ad press 'text="Automatic date and time"' --settle
ad press 'text="Date"' --settle
ad press 'label="30"' --settle
ad press 'label="OK"' --settle
ad open com.t3tools.t3code.dev
# Navigate from the current screen to Chats and reopen General Greeting.
# This remount makes the older-day date prefix visible.
ad press 'label="Navigate up"' --settle
ad press 'label="Chats"' --settle
ad press 'label="General Greeting, 1d"' --settle
ad wait text hello
ad record start "$run_dir/language-change.mp4" --scope device
ad press 'label="Navigate up"' --settle
ad press 'label="Settings"' --settle
ad press 'label="General"' --settle
ad press 'label="Language, English"' --settle
ad press 'label="Deutsch"' --settle
ad press 'label="Chats"' --settle
ad press 'label="General Greeting, 1 T."' --settle
ad wait text hello
ad screenshot "$run_dir/first.png"
sleep 0.5
ad screenshot "$run_dir/second.png"
cmp "$run_dir/first.png" "$run_dir/second.png"
ad record stop
# Observed on base: both timestamps 11/29 9:21 AM.
# Observed on head: both timestamps 29.11. 9:28 AM.
# Time differs because each fresh conversation was created in its own real run.
# Restore automatic date/time before preparing the next commit or releasing device.
