#!/usr/bin/env bash
# Parameterized version of the CLI seed used for both real-app runs.
# Run from the checkout under test, with its isolated dev server already running.
# Supply T3_HOME, PROJECT_DIR and an available PI_MODEL; identifiers are intentionally omitted.
set -euo pipefail
: "${T3_HOME:?}" "${PROJECT_DIR:?}" "${PI_MODEL:?}"
mkdir -p "$PROJECT_DIR"
git -C "$PROJECT_DIR" init -q
git -C "$PROJECT_DIR" -c user.name=Evidence -c user.email=evidence@example.com commit --allow-empty -qm Initial
node apps/server/src/bin.ts project add --base-dir "$T3_HOME" --title 'Rewind evidence' "$PROJECT_DIR"
first=$(node apps/server/src/bin.ts thread start --base-dir "$T3_HOME" --title 'Saved Pi conversation' --provider pi --model "$PI_MODEL" --wait --json "$PROJECT_DIR" 'Create a file named one.txt containing first. Reply only: Created one.txt.')
thread=$(printf '%s' "$first" | python3 -c 'import json,sys; print(json.load(sys.stdin)["threadId"])')
node apps/server/src/bin.ts thread send --base-dir "$T3_HOME" --wait --json "$thread" 'Create a file named two.txt containing second. Reply only: Created two.txt.'
printf 'Open thread %s after restarting the dev server.\n' "$thread"
# Stop the tracked dev-server session and restart with T3CODE_DEV_SEED=0 vp run dev.
# Browser: open this conversation; close thread details; expand the second Agent prompt.
# Record: Edit from here -> Revert and keep changes.
# Base: rollback error; second turn remains; empty composer.
# Head: second turn removed; second prompt restored to composer.
# On head replace the restored prompt with this exact follow-up and send:
# From the retained conversation history only, which files did you create? Do not inspect the filesystem or use tools. Reply with only the filenames.
# Observed head reply: one.txt
# Capture environment: Chromium web, light theme, 1280x800 CSS pixels, DPR 2.
# Public captures crop out sidebar and bottom model controls (x=256..1280,y=0..734).
# AI-assisted; verified with the tests and tools listed above.
