#!/usr/bin/env bash
# Manual reproduction commands used on each commit, parameterized for portability.
# Run from the commit's installed checkout with its isolated server and Metro ready.
# CHECKOUT_HOME is fresh server state, PROJECT is the same synthetic git repository,
# DEVICE_ORIGIN is the device-reachable server origin; METRO_URL is device-reachable.
set -euo pipefail
: "${CHECKOUT_HOME:?}" "${PROJECT:?}" "${SERVER_PORT:?}" "${DEVICE_ORIGIN:?}" "${METRO_URL:?}" "${SESSION:?}" "${OUTPUT:?}"
mkdir -p "$OUTPUT"
T3CODE_PORT="$SERVER_PORT" node apps/server/src/bin.ts project add "$PROJECT" --title 'Composer accessibility' --base-dir "$CHECKOUT_HOME"
vp run mobile:install ios --session "$SESSION"
encoded_metro=$(node -e 'process.stdout.write(encodeURIComponent(process.argv[1]))' "$METRO_URL")
agent-device open com.t3tools.t3code.dev "t3code-dev://expo-development-client/?url=$encoded_metro&disableOnboarding=1&disableFab=1&disableAutoLaunch=1" --session "$SESSION"
# On the initial base launch, iOS displayed its Open confirmation; it was accepted.
# Wait for Add environment before pairing. Subsequent launch did not show a prompt.
agent-device wait text 'Add environment' 60000 --session "$SESSION"
.agents/skills/test-t3-mobile/scripts/pair-client.sh "$SERVER_PORT" "$CHECKOUT_HOME" "$DEVICE_ORIGIN" agent-device --session "$SESSION"
agent-device wait absent 'label="Connecting to environment"' 60000 --session "$SESSION"
agent-device press 'label="New chat"' --session "$SESSION" --settle
agent-device press 'label="Composer accessibility"' --session "$SESSION" --settle
agent-device snapshot --json --session "$SESSION" > "$OUTPUT/composer-tree.json"
agent-device screenshot "$OUTPUT/composer-1.png" --session "$SESSION"
# The manual run took these screenshots more than 500 ms apart.
agent-device screenshot "$OUTPUT/composer-2.png" --session "$SESSION"
compare -metric AE "$OUTPUT/composer-1.png" "$OUTPUT/composer-2.png" null:
# Observed: base ComposerTextView has no label or value; head label is Ask anything.
