#!/usr/bin/env bash
# Run after pairing Host A and Host B on a fresh Pixel 9 Android dev client.
# Both host projects share https://github.com/example/shared-repo.git as origin.
# Use last project stays at its fresh default (on). No task is submitted.
# Usage: compose-flow.sh <session> <scratch-root>
set -euo pipefail
session=$1
out="$2/$(date -u +%Y%m%dT%H%M%SZ)"
mkdir -p "$out"
ad() { agent-device "$@" --session "$session"; }
press() { ad press "label=\"$1\"" --settle; }
press 'New thread'
ad snapshot -i
ad press "label=\"other, $2/projects/other\"" --settle
ad wait 'label="other"' 30000
press 'Navigate up'
press 'Filter threads'
press 'Environment'
press 'Host A'
press 'Filter threads'
press 'Project'
press 'shared-repo'
press 'Settings'
ad snapshot -i
press 'Environments, 2'
ad wait 'label="Enable Host A"' 30000
ad snapshot -i
press 'Enable Host A'
press 'Chats'
ad record start "$out/compose.mp4" --hide-touches
press 'Filter threads'
press 'Project'
ad screenshot "$out/filter.png"
ad screenshot "$out/filter-check.png"
ad back --settle
press 'New thread'
ad wait 'label="Choose environment, Host B, Connected"' 30000
ad snapshot -i
ad screenshot "$out/result.png"
ad screenshot "$out/result-check.png"
ad record stop
# Base: other on Host B. Head: shared-repo-b on Host B.
