#!/usr/bin/env bash
# Real Android share-sheet driver, run once for each checkout with its fresh backend.
# Prerequisites: installed and paired T3 Code Dev; vacation.png and notes.pdf
# downloaded through Chrome to Downloads; Files open with neither selected.
set -euo pipefail
: "${SESSION:?Set the leased agent-device session}"
: "${OUT:?Set a new capture directory}"
agent-device snapshot -i --session "$SESSION"
agent-device record start "$OUT/share.mp4" --scope device --session "$SESSION"
agent-device longpress 'text="vacation.png"' --settle --session "$SESSION"
agent-device press 'text="notes.pdf"' --settle --session "$SESSION"
agent-device press 'label="Share"' --settle --session "$SESSION"
agent-device swipe 520 1800 520 700 --session "$SESSION"
agent-device snapshot -i --session "$SESSION"
agent-device press 'label="T3 Code Dev"' --settle --session "$SESSION"
# Wait until the image has imported, then capture the accessibility label and composer.
agent-device wait 'label="Send" enabled=true' 20000 --session "$SESSION"
agent-device snapshot -i --session "$SESSION" > "$OUT/accessibility.txt"
agent-device screenshot "$OUT/composer-1.png" --session "$SESSION"
agent-device screenshot "$OUT/composer-2.png" --session "$SESSION"
agent-device record stop --session "$SESSION"
# Expected base label: Open msf:18 (Downloads document ID may differ).
# Expected head label: Open vacation.png. Both retain the notes.pdf chip.
# Uploads redact the environment hostname and crop stills to the composer.
