#!/usr/bin/env bash
# Commands used for each side, parameterized to omit credentials and private metadata.
# Run from that side's checkout after vp i. Configure the OpenCode provider's
# binary path, serverUrl and serverPassword in its fresh .t3/userdata/settings.json.
# The same OpenCode 2.2.4 server and model selection were used for both sides.
set -euo pipefail
: "${WORKSPACE:?synthetic empty git repository}"
: "${MODEL:?available inexpensive model slug}"
: "${OPENCODE_BIN:?OpenCode 2.2.4 binary}"
: "${OPENCODE_URL:?authenticated OpenCode server URL}"
: "${OPENCODE_PASSWORD:?server password}"
export OPENCODE_PASSWORD
# Start once per checkout; keep and stop its exact process/session.
# T3CODE_DEV_SEED=0 vp run dev
node apps/server/src/bin.ts project add "$WORKSPACE" --title 'External prompt proof' --base-dir .t3
node apps/server/src/bin.ts thread start "$WORKSPACE" 'Привет' \
  --title 'External prompt comparison' --provider opencode --model "$MODEL" \
  --base-dir .t3 --wait --json
# Open the returned T3 thread in the paired browser. Wait for initial reply.
# Read this thread's nativeThreadRef.nativeId from its local provider-thread projection.
: "${SESSION_ID:?native ID for the T3-owned OpenCode session}"
# Browser: light theme, 1280x800 CSS viewport; collapse sidebar and details.
# Privacy-only CSS used for captures: [aria-label="Message input"]{visibility:hidden}
# This hides the model selector; it does not modify transcript content.
# Begin browser recording, then:
"$OPENCODE_BIN" run --server "$OPENCODE_URL" --session "$SESSION_ID" 'qwe!'
# Browser: capture completed reply; reload and inspect transcript again.
# Expected head: one qwe! USER bubble before the assistant reply, also after reload.
# Observed base: Background activity updated and assistant reply, no user bubble.
# Head: click external qwe! message's Edit from here, then Revert and keep changes.
# GET /api/session/$SESSION_ID/message using OpenCode Basic auth before and after:
# head history returns to just the initial Привет exchange. See native-rewind.json.
# Base has no external prompt bubble or corresponding Edit from here control.
