#!/usr/bin/env bash
set -euo pipefail
# Run from the checkout being proved. Set SESSION, SERVER_PORT, BASE_DIR,
# MOBILE_ORIGIN and PROJECT_PATH to an isolated, fresh test environment.
# Start backend with T3CODE_DEV_SEED=0 vp run dev --host 0.0.0.0.
# Prepare/install with vp run mobile:install android --session "$SESSION" --metro "$METRO_URL".
# Pair with .agents/skills/test-t3-mobile/scripts/pair-client.sh
#   "$SERVER_PORT" "$BASE_DIR" "$MOBILE_ORIGIN" agent-device --session "$SESSION".
# Synthetic file downloaded through Chrome: harbor-notes.txt, containing:
# Harbor notes: bring the blue folder aboard.
# Pixel 9, Android API 36, Gboard, portrait 1080x2424, light theme.
# Create/open a fresh draft in the synthetic project "Clipboard proof".
# File picker and Cut/Paste are native controls; no injected composer state.
: "${SESSION:?}" "${OUT:?}"
run_dir="$OUT/$(date -u +%Y%m%dT%H%M%SZ)"
mkdir -p "$run_dir"
ad() { agent-device "$@" --session "$SESSION"; }
ad fill 'role="text-field"' 'Paste two ' --settle
ad press 'label="Add attachment"' --settle
ad press 'text="Choose Files"' --settle
ad wait 'text="harbor-notes.txt"'
ad press 'text="harbor-notes.txt"' --settle
ad record start "$run_dir/cut-paste.mp4" --hide-touches
ad longpress 220 1335 1000 --settle
ad gesture pan 285 1387 515 0 1000
ad press 'role="group" text="Cut"' --settle
# Composer becomes one line after Cut. Long-press blank space at its end.
ad longpress 300 1463 1000 --settle
ad press 'role="group" text="Paste"' --settle
ad screenshot "$run_dir/after-paste.png"
ad record stop
# Base: unavailable alert. Dismiss OK to see the unavailable chip.
# Head: normal 1 KB chip, no alert. Select Replay (dev) > Showcase and Send;
# tap harbor-notes.txt in the sent message to verify its original contents.
# Do not restart/reload the app between Cut and Paste.
