#!/usr/bin/env bash
# Synthetic evidence reproduction. Run each side in a separate terminal.
# Usage: bash reproduce.sh before|after
set -euo pipefail
side="${1:?before or after}"
evidence_root=/tmp/issue-lead-33607-r1/evidence-capture-1
case "$side" in
 before) checkout=/home/ubuntu/wt/issue-33607-before; capture_home="$evidence_root/before-home"; revision=ee59ab22a819acb0544d85cd6cca0e4aa8c7c444 ;;
 after) checkout=/home/ubuntu/wt/issue-33607-evidence-after; capture_home="$evidence_root/after-pinned-home"; revision=e972d495d8823997d2e3c85a3f251e3ef91fa794 ;;
 *) exit 2 ;;
esac
# Create immutable worktrees beside the main checkout and install before this step.
actual_revision=$(git -C "$checkout" rev-parse HEAD)
test "$actual_revision" = "$revision"
cd "$checkout"
T3CODE_DEV_SEED=0 T3CODE_AUTO_BOOTSTRAP_PROJECT_FROM_CWD=0 vp run dev --host 0.0.0.0 --home-dir "$capture_home"
# In another terminal, after startup, run:
# python3 seed.py CHECKOUT CAPTURE_HOME web
# Pair the T3 preview browser privately using this server's startup URL.
# Invoke runWeb exported by web-driver.mjs with the actual preview tab and web port.
# Native: prepare both checkouts SERIALly: vp run mobile:install android --prepare
# Lease Pixel 9 using device-pool, from /home/ubuntu/t3code, session issue-33607-evidence.
# Install via absolute CHECKOUT/scripts/mobile-native-client.ts ensure android --session ...
# Metro: REACT_NATIVE_PACKAGER_HOSTNAME=<vm-tailnet-host> vp run dev:client --port 18081 (before), 18082 (after), cwd apps/mobile.
# Add F08 with seed.py CHECKOUT CAPTURE_HOME mobile after web captures.
# Run mobile-proxy.mjs; set proxy-target.txt to the current server port.
# Open that side's Expo dev-client bundle. Run mobile-driver.py pair SIDE after app startup.
# Settings > Filter settings environments and projects > All projects > solo-repo.
# Capture S12-index; Projects > capture S12-overview. Do not edit Name.
# Clear only this synthetic app's state between sides; switch proxy target.
# Stop tracked terminal processes, close the device lease and preview tabs when done.
