#!/usr/bin/env bash
set -euo pipefail
# Run from either clean evidence checkout after vp i. Requires Copilot CLI 1.0.112.
# TOKEN is inherited privately; never print it or include it in an upload.
export GH_TOKEN="$(gh auth token)"
export T3CODE_DEV_SEED=0
: "${COPILOT_BIN:?Set to the absolute path of the real copilot executable}"
: "${DEMO_DIR:?Set to an empty synthetic git repository}"
python3 - <<'CONFIG'
import json,os,pathlib
p=pathlib.Path('.t3/userdata')
p.mkdir(parents=True,exist_ok=True)
(p/'settings.json').write_text(json.dumps({'providerInstances':{'copilot':{'driver':'acpRegistry','displayName':'GitHub Copilot','enabled':True,'config':{'source':'local','commandPath':os.environ['COPILOT_BIN'],'commandArgs':['--acp'],'customModels':['claude-sonnet-5.5']}}}}))
CONFIG
# After writing this configuration, start the app in another terminal with:
# GH_TOKEN="$(gh auth token)" T3CODE_DEV_SEED=0 vp run dev
# Wait for its Listening and pairingUrl messages, then continue these CLI commands.
node apps/server/src/bin.ts project add "$DEMO_DIR" --title 'Background agents' --base-dir .t3
node apps/server/src/bin.ts thread start "$DEMO_DIR" 'Reply with only READY.' --title 'Copilot background completion' --provider copilot --model claude-sonnet-5.5 --base-dir .t3 --json --wait
# Pair the preview browser using the startup URL. Open the returned thread by URL.
# Use a 1280x900 viewport, default light theme, and close Thread details.
# Start browser recording, paste prompt.txt into the composer, press Enter.
# Wait for both background agents to complete and the native session/prompt to return.
# Capture the conversation, then stop recording. Compare ALL DONE visibility.
# Restart the server, reopen the same thread, and send: Reply with just the word PONG
# Capture whether replay duplicates messages or reopens completed subagents.
