#!/usr/bin/env bash
# Parameterized record of the seed commands used on BOTH commits.
# Browser actions below were driven through T3 Code's preview tools.
# Requires: vp i in checkout; omp 19.0.1 launched with Bun 1.4.5;
# isolated omp HOME with anthropic/claude-haiku-5-5 configured for an authorized endpoint.
# Do not put credentials in this script or upload the private models.yml.
set -euo pipefail
: "${CHECKOUT:?Set the checkout under test}"
: "${EVIDENCE_HOME:?Set a fresh, isolated T3 home for this side}"
: "${PROJECT:?Set the synthetic project directory}"
: "${OMP_WRAPPER:?Set the executable that launches omp with its isolated HOME}"
: "${PORT_OFFSET:?Set a free dev port offset}"
mkdir -p "$EVIDENCE_HOME/userdata" "$PROJECT"
printf '# Compact demo\nSynthetic reproduction workspace.\n' > "$PROJECT/README.md"
git init --quiet --initial-branch=main "$PROJECT"
python3 - <<'PY'
import os,json,pathlib
home=pathlib.Path(os.environ['EVIDENCE_HOME'])
settings={'defaultModelSelection':{'instanceId':'omp','model':'anthropic/claude-haiku-5-5'},'providerInstances':{'omp':{'driver':'acpRegistry','displayName':'omp','enabled':True,'config':{'source':'local','commandPath':os.environ['OMP_WRAPPER'],'commandArgs':['acp']}}}}
(home/'userdata/settings.json').write_text(json.dumps(settings))
PY
cd "$CHECKOUT"
# Run in a retained terminal, then execute the following seed commands from another terminal:
# T3CODE_DEV_SEED=0 T3CODE_PORT_OFFSET="$PORT_OFFSET" T3CODE_AUTO_BOOTSTRAP_PROJECT_FROM_CWD=0 vp run dev --home-dir "$EVIDENCE_HOME"
read -r -p 'Start that dev command in a retained terminal; press Enter when ready. '
node apps/server/src/bin.ts project add "$PROJECT" --title 'Compact demo' --base-dir "$EVIDENCE_HOME"
node apps/server/src/bin.ts thread start "$PROJECT" 'Reply with the single word ok' --title 'Compact after session reload' --provider omp --model anthropic/claude-haiku-5-5 --wait --json --base-dir "$EVIDENCE_HOME"
# Confirm reply "ok". Stop the server gracefully (SIGTERM to its captured PID),
# confirm session/close succeeded in the provider log, and restart with the SAME home.
# Pair the preview browser, open /<environmentId>/<URL-encoded threadId> directly.
# Browser: Chromium, 1280x800 CSS pixels, DPR 2, light theme, details panel closed.
# Start recording. Type /compact into the message textbox.
# Observe the agent's '/compact Compact the conversation' option; click Submit message.
# Base 392526768806ab7b36854ad9a401955c4bec6a85: unsupported-provider error.
# Head 90d58c2175a694ab6ca4147f17c31c970d1e02c4: compaction complete, context compacted.
# Stop recording after the result. Blur the composer; take two stills 550 ms apart
# and require identical image hashes before retaining the second.
