#!/usr/bin/env bash
# Manual proof recipe. Run once per commit in separate worktrees and fresh homes.
# Requires: WORKTREE, RUN_DIR, DEVICE_HOST, SERVER_PORT, METRO_PORT, SESSION, SIDE.
set -euo pipefail
cd "$WORKTREE"
# Prepare with vp i, then vp run mobile:install ios --prepare.
# Lease an iPhone 18 Pro through the pool and install with:
# vp run mobile:install ios --session "$SESSION"
# Start (retain this shell; stop with Ctrl-C after captures):
# T3CODE_DEV_SEED=0 GH_TOKEN=scenario-only-token \
# NODE_OPTIONS="--import=$RUN_DIR/upstream.mjs" \
# node scripts/scenarios/start-app.ts mobile "$RUN_DIR/home" \
#   "$SERVER_PORT" "$METRO_PORT" "$DEVICE_HOST"
# Once server-runtime.json exists, copy seed.ts into scripts/scenarios and run:
# node scripts/scenarios/seed.ts "$RUN_DIR/home" "$SERVER_PORT"
# Open the dev client against Metro, then pair using:
# bash .agents/skills/test-t3-mobile/scripts/pair-client.sh \
#   "$SERVER_PORT" "$RUN_DIR/home" "http://$DEVICE_HOST:$SERVER_PORT" \
#   agent-device --session "$SESSION"
# In Settings, disable stale environments; select this side's environment in PRs.
# Start at Open / All PRs / All labels. Swipe the filter row horizontally if needed.
a=(agent-device)
a+=(--session "$SESSION")
agent-device record start "$RUN_DIR/$SIDE.mp4" --session "$SESSION"
agent-device click 'label="Filter by label"' --session "$SESSION"
agent-device snapshot -i --session "$SESSION"
# Capture the settled menu; compare two screenshots >=500ms apart before retaining one.
agent-device click 'text="Bug"' --session "$SESSION"
agent-device click 'label="Filter by label"' --session "$SESSION"
agent-device snapshot -i --session "$SESSION"
# Base exposes an unchecked alternate spelling; head exposes the sole checked choice.
if [ "$SIDE" = base ]; then
  agent-device click 'text="bug"' --session "$SESSION"
else
  agent-device click 'text="Bug"' --session "$SESSION"
fi
agent-device snapshot -i --session "$SESSION"
# Capture settled result: base Labels 2 / two rows; head Labels / three rows.
agent-device record stop --session "$SESSION"
agent-device click 'label="Filter by author"' --session "$SESSION"
agent-device snapshot -i --session "$SESSION"
# Base: Contributor + contributor. Head: Contributor only.
# Capture settled author menu. Close session and stop owned processes after uploads.
