#!/usr/bin/env bash
# Prerequisites: an isolated server with T3CODE_DEV_SEED=0 and the public GitHub
# app client ID enabled; matching Metro checkout, installed Pixel 9 dev client,
# paired through pair-client.sh. Set PROOF_REPO, PROOF_HOME, PROOF_ORIGIN,
# PROOF_OUT, PROOF_SIDE and PROOF_SESSION. Keep second-client.mjs beside this file.
set -euo pipefail
cd "$PROOF_REPO"
ad() { agent-device "$@" --session "$PROOF_SESSION"; }
# Seed through the real server CLI; use the same empty workspace on each side.
node apps/server/src/bin.ts project add "$PROOF_PROJECT" --title 'Disposable project' --base-dir "$PROOF_HOME"
ad press --settle 'text="Settings"'
ad press --settle 'text="Source control & issues"'
ad press --settle 'text="Manage GitHub"'
ad press --settle 'text="T3 Code for GitHub, Sign in"'
ad wait 'text="Open GitHub"'
ad press 'text="Open GitHub"'
ad back
ad press --settle 'text="Navigate up"'
ad press --settle 'text="Navigate up"'
ad press --settle 'text="Projects"'
ad press --settle 'text="Filter settings environments and projects"'
ad press --settle 'text="All projects"'
ad press --settle 'text="Disposable project"'
ad record start "$PROOF_OUT/$PROOF_SIDE-raw.mp4"
ad press --settle 'text="Remove project"'
node "$(dirname "$0")/second-client.mjs"
ad press --settle 'text="OK"'
ad press --settle 'text="Remove project"'
ad screenshot "$PROOF_OUT/$PROOF_SIDE-final-raw.png"
ad record stop
# Record an additional screenshot after the remote command has settled and
# compare its pixels with the first one before publishing a still.
ad screenshot "$PROOF_OUT/$PROOF_SIDE-stable.png"
