#!/usr/bin/env bash
# Real Nitro iOS proof. Run once per checkout; fresh server data on each side.
# Required: CHECKOUT, DATA_DIR, PROJECT_DIR, SESSION, FORWARD_PID.
# Start server with T3CODE_DEV_SEED=0 vp run dev:server, record its port.
# Generate Nitro shims: (cd apps/mobile-nitro && vp exec nitro-ui prepare).
# Start its bundle: (cd apps/mobile-nitro && vp run start).
# Install: vp run mobile:install ios --app nitro --session "$SESSION".
# Run forward.py SERVER_PORT FORWARD_PORT and retain its printed PID.
# Pair Nitro with a CLI pairing URL targeting the forwarder; open Failed send proof.
set -eu
cd "$CHECKOUT"
node apps/server/src/bin.ts environment name 'Proof server' --base-dir "$DATA_DIR"
node apps/server/src/bin.ts project add "$PROJECT_DIR" --title 'Composer proof' --base-dir "$DATA_DIR"
node apps/server/src/bin.ts thread start "$PROJECT_DIR" Hello --title 'Failed send proof' --provider devReplay --model multi-turn --wait --json --base-dir "$DATA_DIR"
node apps/server/src/bin.ts thread start "$PROJECT_DIR" Hello --title 'New thread' --provider devReplay --model multi-turn --wait --json --base-dir "$DATA_DIR"
# On the opened thread (iPhone 17 Pro, light appearance, 402x874 logical pixels):
agent-device click 100 798 --session "$SESSION"
agent-device record start "$OUTPUT_DIR/interaction.mp4" --session "$SESSION"
agent-device type 'Compare with @New' --session "$SESSION"
agent-device click 93 385 --session "$SESSION"
# Select the first New thread mention, then disconnect before Send. A disconnect
# after Send retries the pending command on reconnect on this base commit.
kill -STOP "$FORWARD_PID"
kill -KILL "$FORWARD_PID"
agent-device click 368 516 --session "$SESSION"
agent-device screenshot "$OUTPUT_DIR/restored1.png" --session "$SESSION"
agent-device screenshot "$OUTPUT_DIR/restored2.png" --session "$SESSION"
agent-device record stop --session "$SESSION"
# Observe restored chip without editing: base unavailable/grey, head teal/thread icon.
# If dev warnings cover the chip, open the warning badge and Delete error for each
# warning; this dismisses dev chrome without focusing or editing the draft.
# Take the final stable screenshot pair after dismissing that badge.
# The head still is from a repeated run of the same steps; its video is the first
# complete run (warning badge overlaps the chip in that recording).
# Uploaded before assets redact the connection-error strip containing the old host name.
