#!/usr/bin/env bash
set -euo pipefail
# Reproduction setup; native-flow.py is the same interaction driver for each side.
# Run from the corresponding immutable checkout. Do not seed from any live state.
side="${1:?before or after}"; run_root="${2:?new timestamped directory below evidence-capture}"
case "$run_root" in /tmp/lead-32681-r2/evidence-capture/*) ;; *) exit 2;; esac
mkdir -p "$run_root/B/github.com/pingdotgg"
T3CODE_DEV_SEED=0 vp run dev --host 0.0.0.0 --home-dir "$run_root/$side/t3-home" > "$run_root/$side-dev.log" 2>&1 &
server_job=$!; printf '%s\n' "$server_job" > "$run_root/$side-server-job.pid"
# In web Settings -> Threads -> New projects, use the app controls to set:
# Add project starts in: <run_root>/B ; Clone into host folders: ON.
# No SQLite writes, project records, clone, or paid agent turns are required.
# Start only one side's Metro at a time to stay within this VM's inotify limit:
# (cd apps/mobile; REACT_NATIVE_PACKAGER_HOSTNAME=<VM tailnet DNS> vp run dev:client --port <8081|8082>)
# Lease and connect as device-pool describes; install only through:
# vp run mobile:install android --session n1-32681 --metro http://<VM tailnet DNS>:<Metro port>
# Pair with .agents/skills/test-t3-mobile/scripts/pair-client.sh using the actual
# backend port, this side's home, reachable origin and --session n1-32681.
# Each side has one connection (clear client state between sides), dark theme,
# 1.0 default Android font scaling. Open t3code-dev://new/add-project, then run:
# python3 <run_root>/native-flow.py <side> --session n1-32681
wait "$server_job"
