#!/bin/bash
# Pear Testing Script
# Manages the pear-dev tmux session for testing
set -e
PEAR_KEY="pear://18x3enb54ttcr6uuhg5hh1cqzwi8ydnm658fmgyyjkzoqxd1ybso"
SESSION="pear-dev"
echo "🧪 Pear Testing Setup"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
# Check if pear-dev session exists
if ! tmux has-session -t $SESSION 2>/dev/null; then
echo "📺 Creating tmux session: $SESSION"
# Create session with first window
tmux new-session -d -s $SESSION -n "hw-web" -c "$PWD"
# Create additional windows
tmux new-window -t $SESSION -n "hw-cli" -c "$PWD"
tmux new-window -t $SESSION -n "hw-logs" -c "$PWD"
echo "✅ Created 3 windows: hw-web, hw-cli, hw-logs"
else
echo "✅ Session $SESSION already exists"
fi
echo ""
echo "🌐 Starting web server in tmux window: hw-web"
# Stop any existing web server
tmux send-keys -t $SESSION:hw-web C-c 2>/dev/null || true
sleep 1
# Start web server
tmux send-keys -t $SESSION:hw-web "pear run $PEAR_KEY web 4004 --network" Enter
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "✅ Testing Environment Ready!"
echo ""
echo "📊 Tmux Windows:"
echo " - hw-web: Web server on port 4004"
echo " - hw-cli: CLI testing"
echo " - hw-logs: Logs and debugging"
echo ""
echo "🔗 Access:"
echo " Local: http://localhost:4004"
echo " Network: http://tabertron.local:4004"
echo ""
echo "📺 Commands:"
echo " Attach: tmux attach -t $SESSION"
echo " Switch: Ctrl+B then 0/1/2 (window number)"
echo " Detach: Ctrl+B then D"
echo ""
echo "⏹️ Stop testing:"
echo " ./scripts/pear-stop.sh"
echo ""