#!/usr/bin/env bash
# Run from the after checkout. SESSION must be leased through agent-device first.
set -euo pipefail
scratch=/tmp/lead-32994-r2/evidence-capture-1/20261110T112332
# Before checkout and installation used:
# git -C /home/user/t3code worktree add /home/user/wt/pr-32994-before fa2f4ff2a2bac5ac92e07749f6b83b0003d642a0
# (cd /home/user/wt/pr-32994-before && vp install)
# Native client prepared before lease with vp run mobile:install android --prepare.
# Shared backend, fresh and synthetic only:
T3CODE_DEV_SEED=0 vp run dev --home-dir "$scratch/server" --host 0.0.0.0 --port 14551 > "$scratch/server.log" 2>&1 &
backend_pid=$!
# After backend readiness, run python3 "$scratch/seed-f4.py".
# Each Metro runs from that side's apps/mobile directory:
# REACT_NATIVE_PACKAGER_HOSTNAME=fs-51.tail131df4.ts.net vp run dev:client --port 8081  # before
# REACT_NATIVE_PACKAGER_HOSTNAME=fs-51.tail131df4.ts.net vp run dev:client --port 8082  # after
# Native client shared; install using vp run mobile:install android --session f4compact32994 --metro http://fs-51.tail131df4.ts.net:8081
# Pair with .agents/skills/test-t3-mobile/scripts/pair-client.sh 14551 "$scratch/server" http://fs-51.tail131df4.ts.net:14551 agent-device --session f4compact32994
# pool-adb.mjs uses the currently-owned lease ID; replace it when reproducing with a new lease.
node "$scratch/pool-adb.mjs" shell wm size 945x2100
node "$scratch/pool-adb.mjs" shell wm density 420
node "$scratch/pool-adb.mjs" shell settings put system font_scale 1.5
node "$scratch/pool-adb.mjs" shell cmd uimode night yes
# Relauch each side's development-client URL (8081 before, 8082 after), then:
# node "$scratch/runtime.mjs" <port> "$scratch/environment-expression.txt" "$scratch/<side>-environment.json"
# Open Preview checks via agent-device press, then:
# node "$scratch/runtime.mjs" <port> "$scratch/long-path-expression.txt"
# python3 "$scratch/capture-f4.py" <before|after> full
# python3 "$scratch/build-diffs.py"
# On completion reset before returning the lease:
node "$scratch/pool-adb.mjs" shell wm size reset
node "$scratch/pool-adb.mjs" shell wm density reset
node "$scratch/pool-adb.mjs" shell settings put system font_scale 1.0
agent-device close --session f4compact32994
kill "$backend_pid"
