#!/bin/bash
# usage: batch.sh name "query" [name "query" ...]  -- runs up to 3 in parallel
cd /srv/mrd/fjord__claude-code__fable-5-1__attempt4/work
run() { timeout 400 python3 tools/shoot.py "http://127.0.0.1:8123/index.html?$2" "shots/$1.png" --w ${W:-1280} --h ${H:-720} $EXTRA > "shots/$1.log" 2>&1; echo "== $1: $(grep -E 'ready|stats|console|EXCEPTION|log\.' shots/$1.log | tr '\n' ' ' | cut -c1-400)"; }
while [ $# -gt 1 ]; do
  run "$1" "$2" &
  shift 2
  while [ $(jobs -r | wc -l) -ge 3 ]; do sleep 1; done
done
wait
