#!/bin/bash
# On macOS, run once per checkout after vp i:
# T3CODE_DEV_SEED=0 vp run dist:desktop:artifact --platform mac --target dir --arch arm64 --output-dir "$OUT"
# node sign-probe-build.mjs "$ENTITLEMENTS"
# codesign --force --deep --sign - --options runtime --entitlements "$ENTITLEMENTS" "$APP"
# swiftc photoprobe.swift -o "$PROBE"
set -euo pipefail
: "${APP:?Built app bundle}" "${RUN_DIR:?Fresh private run directory}" "${PROBE:?Compiled photoprobe}" "${CDP_PORT:?Unused loopback port}"
mkdir -p "$RUN_DIR/home"
cp "$PROBE" "$RUN_DIR/home/photoprobe"
open -n --env "HOME=$RUN_DIR/home" --env "T3CODE_HOME=$RUN_DIR/t3" --env T3CODE_DISABLE_AUTO_UPDATE=1 "$APP" --args "--remote-debugging-port=$CDP_PORT"
# Cancel the isolated HOME's Keychain Not Found dialog if shown.
# Drive the actual Electron renderer through drive-electron.mjs and Playwright:
# Start without an agent -> Start without a project -> Meta+j.
# In the integrated terminal: cd "$HOME"; export PS1='probe> '; clear
# Start native screen recording, then type ./photoprobe and press Enter.
# Base: status 0 -> status 2 immediately, no Photos prompt.
# Head: status 0 -> native Photos prompt naming T3 Code (Beta).
# Click Don't Allow on head; status after request becomes 2.
# No privacy permissions were reset or modified through System Settings.
