#!/bin/bash
# Prerequisites: ibus-mozc, xdotool, dbus-run-session, xvfb-run; vp i in a current-main checkout.
# Save the accompanying scenario under scripts/scenarios/ime-app-shortcuts.e2e.ts.
# Use headed Chromium so real X11 keys pass through IBus/Mozc.
set -eu
if [ "${IME_PROOF_SESSION:-}" != 1 ]; then
  export IME_PROOF_SESSION=1
  exec dbus-run-session -- xvfb-run -a -s '-screen 0 1440x1000x24' bash "$0"
fi
proof_scratch=$(mktemp -d)
export GTK_IM_MODULE=ibus QT_IM_MODULE=ibus XMODIFIERS=@im=ibus
export IBUS_ADDRESS="unix:path=$proof_scratch/ibus-socket"
export T3_SCENARIO_INHERIT_ENV='DISPLAY,IBUS_ADDRESS,DBUS_SESSION_BUS_ADDRESS,GTK_IM_MODULE,QT_IM_MODULE,XMODIFIERS,T3CODE_DEV_SEED'
export T3CODE_DEV_SEED=0
ibus-daemon --address="$IBUS_ADDRESS" --xim --panel disable &
ibus_pid=$!
trap 'kill "$ibus_pid" 2>/dev/null || true' EXIT
sleep 2
ibus list-engine > "$proof_scratch/engines.txt"
python3 - <<'PY'
p='scripts/prove-scenario.ts'
s=open(p).read().replace('["run", scenarioPath, "--target", target, "--output", path.relative(scripts, outDir)]', '["run", scenarioPath, "--headed", "--target", target, "--output", path.relative(scripts, outDir)]')
open(p,'w').write(s)
PY
# Review and redact workspace paths in the picker before uploading artifacts.
vp run scenarios:prove scripts/scenarios/ime-app-shortcuts.e2e.ts --base fc65ae038080ae989b74f6c2a0b5b66f3d18e049 --head d5d257d758a383ae83ac8d3677460568463e15d3
