#!/usr/bin/env bash
set -eu
# Run from each checkout with its isolated dev server already running.
# CODEX_HOME must contain working authentication and provider routing.
# MODEL is a supported Codex model; T3's codex provider uses this CODEX_HOME.
: "${CODEX_HOME:?}" "${MODEL:?}"
report_dir=$(cd "$(dirname "$0")" && pwd)
project_dir="$report_dir/sample-project"
mkdir -p "$project_dir"
node apps/server/src/bin.ts project add "$project_dir" --title 'Rating reproduction' --base-dir .t3
node apps/server/src/bin.ts thread start "$project_dir" "Call rating-repro's show_rating tool once to display its card. Do not call set_rating. Do not use any other tools." --title 'Rating app' --provider codex --model "$MODEL" --base-dir .t3 --wait
# In the web client, open Rating app, click Thumbs up and Confirm; verify Saved.
# Stop and restart only this checkout's dev server, with T3CODE_DEV_SEED=0.
# Then run:
node apps/server/src/bin.ts thread start "$project_dir" 'Reply only OK. Do not use tools.' --title 'Separate conversation' --provider codex --model "$MODEL" --base-dir .t3 --wait
# Reopen Rating app without sending a message; click Thumbs down and approve if prompted.
# Base: Not saved; persisted rating stays up. Head: Saved; persisted rating becomes down.
