#!/usr/bin/env bash
set -euo pipefail
# Use each commit's fresh T3CODE_DEV_SEED=0 backend; never copy a database.
checkout="$1"; workspace="$2"; title="${3:-Draft and queue safety}"
cd "$checkout"
mkdir -p "$workspace"
if [ ! -e "$workspace/.git" ]; then
 git -C "$workspace" init -q -b main
 echo '# Route removal proof' > "$workspace/README.md"
 git -C "$workspace" add README.md
 git -C "$workspace" -c user.name=Proof -c user.email=proof@example.invalid commit -qm 'Initial sample'
fi
node apps/server/src/bin.ts project add "$workspace" --title 'Route removal proof' --base-dir "$checkout/.t3"
node apps/server/src/bin.ts thread start "$workspace" 'Prepare a route removal check' --title "$title" --provider devReplay --model multi-turn --wait --json --base-dir "$checkout/.t3"
# Pair the mobile client over plain-HTTP nip.io, or enable the account's T3 Connect
# environment. Stop only this backend, queue the message through the UI, and type
# the unsent draft. Run capture-route-flow.sh. Restart this backend and re-add
# the environment on base; on head return to the retained thread.
