#!/usr/bin/env bash

# Kill any existing FAEA tmux session
tmux kill-session -t faea-workers 2>/dev/null

# 1. Start a fresh session with the first window named 'orchestrator'
tmux new-session -d -s faea-workers -n orchestrator bash

# 2. Create the 'browser' and 'extractor' windows
tmux new-window -t faea-workers:1 -n browser bash
tmux new-window -t faea-workers:2 -n extractor bash

# 3. Send the Docker commands to each window
# We use 'C-m' to simulate pressing the Enter key
tmux send-keys -t faea-workers:0 "docker exec -it -e PYTHONPATH=/app faea-orchestrator-1 python src/orchestrator/worker.py" C-m
tmux send-keys -t faea-workers:1 "docker exec -it -e PYTHONPATH=/app faea-camoufox-pool-1 python src/orchestrator/worker.py" C-m
tmux send-keys -t faea-workers:2 "docker logs -f faea-curl-pool-1" C-m

# 4. Final step: Switch to the orchestrator window and attach
tmux select-window -t faea-workers:0
tmux attach -t faea-workers
