dashboard.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/bash
  2. # Enhanced dashboard launcher with auto-open
  3. # Usage: ./scripts/dashboard.sh [port] [auto-open]
  4. set -e
  5. PORT=${1:-8000}
  6. AUTO_OPEN=${2:-true}
  7. # Colors
  8. GREEN='\033[0;32m'
  9. BLUE='\033[0;34m'
  10. YELLOW='\033[1;33m'
  11. NC='\033[0m'
  12. echo -e "${BLUE}🚀 Starting OpenCode Agents Dashboard...${NC}"
  13. echo -e "${BLUE}📊 Results directory: evals/results${NC}"
  14. echo -e "${BLUE}🌐 URL: http://localhost:$PORT${NC}"
  15. echo ""
  16. # Navigate to results directory
  17. cd "$(dirname "$0")/../evals/results" || exit 1
  18. # Check if results exist
  19. if [ ! -f "latest.json" ]; then
  20. echo -e "${YELLOW}⚠️ No test results found yet.${NC}"
  21. echo -e "${YELLOW} Run tests first: npm test${NC}"
  22. echo ""
  23. fi
  24. # Start server in background
  25. ./serve.sh "$PORT" &
  26. SERVER_PID=$!
  27. # Wait for server to start
  28. sleep 2
  29. # Auto-open browser
  30. if [ "$AUTO_OPEN" = "true" ]; then
  31. echo -e "${GREEN}🌐 Opening browser...${NC}"
  32. if command -v open &> /dev/null; then
  33. open "http://localhost:$PORT"
  34. elif command -v xdg-open &> /dev/null; then
  35. xdg-open "http://localhost:$PORT"
  36. elif command -v start &> /dev/null; then
  37. start "http://localhost:$PORT"
  38. else
  39. echo -e "${YELLOW}⚠️ Could not auto-open browser. Please visit: http://localhost:$PORT${NC}"
  40. fi
  41. fi
  42. echo ""
  43. echo -e "${GREEN}✅ Dashboard running (PID: $SERVER_PID)${NC}"
  44. echo -e "${YELLOW}Press Ctrl+C to stop${NC}"
  45. echo ""
  46. # Wait for Ctrl+C
  47. wait $SERVER_PID