#!/usr/bin/env bash
# Run from the checkout under test after starting its fresh backend and Metro.
# Arguments: session, output-directory. Device: iPad Pro 13-inch (M5), iPadOS 27.2.
# Pair to the backend, open the synthetic "Windowed keyboard" thread, and maximize
# the app first. Settings > Multitasking & Gestures must be Windowed Apps.
set -euo pipefail
session="$1"
out="$2"
# Full-screen baseline: focus composer, inspect/capture, then hide keyboard.
agent-device press 'label="Ask anything" role=text-view' --session "$session" --settle
agent-device screenshot "$out/fullscreen.png" --session "$session"
agent-device press 'label="Hide keyboard"' --session "$session" --settle
# Resize from the full-screen lower-right corner. The OS centers the 375x761 window.
agent-device gesture pan 1027 1370 -647 -370 1500 --session "$session"
# End editing so reopening the keyboard does not show the caret's AutoFill menu.
agent-device press 500 700 --session "$session"
agent-device record start "$out/keyboard.mp4" --fps 10 --hide-touches --session "$session"
agent-device press 475 967 --session "$session" --settle
agent-device screenshot "$out/keyboard-a.png" --session "$session"
sleep 0.5
agent-device screenshot "$out/keyboard-b.png" --session "$session"
agent-device record stop --session "$session"
