#!/usr/bin/env bash
# Portable form of the synthetic seeding commands used for both captures.
# Run from the tested checkout after starting T3 with T3CODE_DEV_SEED=0.
set -euo pipefail
scratch=${1:?pass a scratch parent}
run_dir="$scratch/$(date -u +%Y%m%dT%H%M%SZ)"
mkdir -p "$run_dir/projA" "$run_dir/projB" "$run_dir/code-profile/User"
printf '# Project A\n\nKeep this existing window open.\n' > "$run_dir/projA/README.md"
printf '# Project B\n\nOpen this project in a new window.\n' > "$run_dir/projB/README.md"
cat > "$run_dir/code-profile/User/settings.json" <<'JSON'
{"window.openFoldersInNewWindow":"off","security.workspace.trust.enabled":false,"workbench.startupEditor":"none","window.title":"${rootName} — Visual Studio Code","workbench.colorTheme":"Default Dark Modern","update.mode":"none","telemetry.telemetryLevel":"off"}
JSON
node apps/server/src/bin.ts project add "$run_dir/projB" --title 'Project B' --base-dir .t3
node apps/server/src/bin.ts thread start "$run_dir/projB" Start --title 'Open Project B' --provider devReplay --model multi-turn --base-dir .t3 --wait --json
printf '\nProject A: %s\nProject B: %s\nVS Code profile: %s\n' "$run_dir/projA" "$run_dir/projB" "$run_dir/code-profile"
# Put the real VS Code launcher on the server's PATH with this isolated profile.
# Open projA and its README, dismiss onboarding, and close the Chat sidebar.
# In the paired T3 web client select "Open Project B", then click
# Workspace > "Open in VS Code". Do not pass a window flag in the PATH wrapper.
# Record the X11 desktop while clicking; inspect window titles with wmctrl -l.
# Capture the final windows only after screenshots 500 ms apart match exactly.
# The fixed run's two windows were arranged side by side after opening.
