#!/usr/bin/env bash
# Manual proof command transcript, run in sections against a paired dev client.
# Base b1f3fbfcf7f42b20b1262d457da0157f8af3443e; head 81b47b3b0f98f89ff2cba2ea3d0b274185c02611.
# iPhone 17 Pro, iOS 27.2, light, 402x874 logical points.
# Each checkout: vp i; T3CODE_DEV_SEED=0 vp run dev:server --host 0.0.0.0 --port <port>.
# Metro: REACT_NATIVE_PACKAGER_HOSTNAME=<device-reachable-host> vp run dev:client --port <metro-port>.
# Install via vp run mobile:install ios --session <session>, then the repo's pair-client.sh.
# The fresh server bootstraps its checkout as a project. Rename it "Review demo" using project rename.
# Set PR_LINK to t3code-dev://pull-requests/<environment>/<project>/pingdotgg%2Ft3code/34407.
set -euo pipefail
: "${SESSION:?agent-device session}" "${OUT:?new evidence directory}"
ad() { agent-device "$@" --session "$SESSION"; }
press() { ad press "label=\"$1\""; }
first='View diff for apps/mobile/src/features/pull-requests/pullRequestFileFilters.ts, 30 additions, 9 deletions'
second='View diff for apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx, 69 additions, 11 deletions'
third='View diff for apps/mobile/src/features/pull-requests/usePullRequestFilesViewed.ts, 8 additions, 0 deletions'
still() {
  ad screenshot "$OUT/$1-a.png"
  sleep 0.5
  ad screenshot "$OUT/$1.png"
  python3 - "$OUT/$1-a.png" "$OUT/$1.png" <<'PY'
from PIL import Image,ImageChops
import sys
assert ImageChops.difference(Image.open(sys.argv[1]),Image.open(sys.argv[2])).getbbox() is None
PY
}
case "${1:?common|head|reset}" in
common)
  ad open com.t3tools.t3code.dev "${PR_LINK:?}"
  ad record start "$OUT/flow.mp4"
  press 'Changed files'
  press "$first"
  ad click 382 144 # Native diff's Viewed checkbox, inspected on both commits.
  press Back
  press 'Filter review files'
  still filter
  ad snapshot -i
  # Base: menu has only Hide test files. Head: also Hide viewed files.
  ;;
head)
  press 'Hide viewed files'
  still hidden
  press "$second"
  press 'Diff options'
  ad snapshot -i
  ad click 110 110
  press 'Changed files'
  press 'Filter review files'
  still picker
  ad click 40 470
  press Close
  ad click 382 144
  press 'Changed files'
  ad snapshot -i
  press Close
  still retained
  press Back
  ad snapshot -i
  press 'Filter review files'
  press 'Hide viewed files'
  still restored
  # Persistence: relaunch, wait for loading to finish, open PR_LINK again, press Changed files.
  # Repeated with filter off (18 files/2 viewed) and on (16 files/2 hidden).
  # Draft retention: open third, tap line (180,300), fill the focused comment with
  # "Proof draft: retain this file while reviewing.", Save draft, mark Viewed, Back.
  # It stays in the list (16 files/2 hidden) with Submit review · 1.
  # Delete the private draft in Submit review > pending comment > Delete draft > Delete.
  # It then disappears (15 files/3 hidden). Hide test files reduces this to 14/3 viewed/1 test hidden.
  ;;
reset)
  # Run after both filters have been turned off, and the private draft deleted.
  for file in "$first" "$second" "$third"; do
    press "$file, viewed"
    ad click 382 144
    press Back
  done
  ad snapshot -i # Confirm 18 changed files · 0 viewed.
  ;;
esac
