#!/usr/bin/env bash
set -euo pipefail
# Run for each revision after starting its isolated dev server with T3CODE_DEV_SEED=0,
# adding a synthetic project titled "Photo picker proof", seeding one Replay (dev)
# multi-turn message "Start", pairing Safari, and opening that thread by URL.
# Use a pooled iPhone 18 Pro running iOS 27.2. SESSION is the leased session.
# The library's first stock photo is IMG_0006.jpeg.
: "${SESSION:?Set the pooled-device session}"
ad() { agent-device "$@" --session "$SESSION"; }
photo() {
  ad click 'label="Attach files"' --settle
  ad click 'label="Photo Library" role=cell' --settle
  ad wait 'label="Photo, March 30, 2018, 12:14 PM" role=image' 30000
  ad click 'label="Photo, March 30, 2018, 12:14 PM" role=image' --settle
  ad click 'label="Done" role=button' --settle
}
# Empty prompt: on base the composer collapses and silently drops the photo.
ad click 'label="Expand composer"' --settle
photo
ad snapshot -i
# On head, remove the successful empty-prompt attachment to restore the same
# starting state for the one-line case. Base has no attachment to remove.
# ad click 'label="Remove IMG_0006.jpeg"' --settle
# Expand only if the composer is collapsed.
# ad click 'label="Expand composer"' --settle
ad click 'label="Message Photo picker proof"' --settle
# Dismiss iOS's first-use typing tutorial with Continue if it appears.
ad type 'first'
photo
ad snapshot -i
# Base has Send message; head has Submit message (expanded attachment composer).
# Click the visible send control, then wait for "second fixture turn complete".
# Wrapped-prompt control, after sending the one-line case:
# ad click 'label="Expand composer"' --settle
# ad click 'label="Message Photo picker proof"' --settle
# ad type 'This is a long prompt that wraps onto multiple lines and keeps the phone composer expanded.'
# photo
# ad snapshot -i
# In this run, head saved the one-line message with IMG_0006.jpeg.
# Replay then rejected model execution: ACP driver did not negotiate image prompt support.
# On head, an additional empty-prompt picker selection after that send also retained
# IMG_0006.jpeg. We removed it before running the wrapped-prompt control.
# Base: only the wrapped control shows IMG_0006.jpeg and its preview.
# Head: every selection shows IMG_0006.jpeg and its preview.
