#!/usr/bin/env bash
set -euo pipefail
# UI driver used on both commits, after opening the existing empty New thread.
# Prerequisites: pooled Pixel 9 / Android 16, light theme, native 1080x2424 viewport;
# checkout's dev client loaded from its own Metro and paired to its fresh dev server;
# dup.png downloaded once from serve.py in Chrome. No provider turn is sent.
# Invoke in the directory that owns the device session.
: "${SESSION:?Set the already-paired agent-device session}"
: "${OUT:?Set a fresh output directory for this run}"
mkdir -p "$OUT"
ad() { agent-device "$@" --session "$SESSION"; }
ad record start "$OUT/flow.mp4" --scope device
for selection in 1 2; do
  ad press 'label="Add attachment"' --settle
  ad press 'text="Choose Files"' --settle
  ad wait 'text="dup.png"' 15000
  ad longpress 'text="dup.png"' --settle
  ad press 'text="Select"' --settle
  ad snapshot -i
done
ad screenshot "$OUT/final-1.png"
sleep 0.5
ad screenshot "$OUT/final-2.png"
ad record stop
# Compare final captures pixel-for-pixel; repeat stills if they differ.
# Expected observation: base has two dup.png chips and a +1 tile;
# head has one dup.png chip and one tile.
# Public captures mask only the environment label at x=140,y=148,w=550,h=50.
# The exported videos append the stable final screenshot for three seconds.
# A reconnect notification in the head recording also has its environment name masked.
