#!/usr/bin/env bash
# Consolidated seed recipe for the manual two-commit browser reproduction.
# Run once in each checkout with a fresh T3 home and a separate synthetic project.
# Set CLAUDE_MODEL to an available inexpensive Claude model before running.
set -euo pipefail
: "${CLAUDE_MODEL:?Set an available Claude model}"
: "${DEMO_DIR:?Set an empty synthetic project directory}"
vp i
T3CODE_DEV_SEED=0 vp run dev > dev.log 2>&1 &
DEV_PID=$!
trap 'kill "$DEV_PID"' EXIT
# Wait for the startup pairingUrl before continuing, then pair the browser.
read -r -p 'Press Enter after dev startup and browser pairing: '
python3 - <<'PY'
import json
p='.t3/userdata/settings.json'
s=json.load(open(p))
s['providerInstances']['claude']={'driver':'claudeAgent','displayName':'Claude','enabled':True,'config':{}}
open(p,'w').write(json.dumps(s,indent=2))
PY
mkdir -p "$DEMO_DIR"
git init "$DEMO_DIR"
node apps/server/src/bin.ts project add --base-dir .t3 --title 'Background work demo' "$DEMO_DIR"
read -r -p 'Project ID printed above: ' DEMO_PROJECT
node apps/server/src/bin.ts thread start --base-dir .t3 --provider claude --model "$CLAUDE_MODEL" --title 'Background agent continuity' "$DEMO_PROJECT" 'Use the Agent tool with run_in_background=true to start exactly one background subagent. Its task is to run 30 sequential Bash steps: for each N from 1 to 30 run sleep 8 and then append step N to agent.log in the project directory. Do not put the shell itself in the background; the Agent tool must be the background work. Once launched reply only launched and end your turn without waiting.'
# Browser: open the resulting thread; close the details panel.
# In the model/permissions picker choose Auto-accept edits from Full access.
# Send: Reply with just the word ok.
# Observe the retry message (head) or session restart without warning (base).
# Keep observing agent.log: head continues; base stops before step 30.
read -r -p 'Press Enter only after recording the browser result and log continuation: '
