#!/bin/bash

# Quick diagnostic to check what's in Firestore for the handoff

PROJECT_ID="$1"

if [ -z "$PROJECT_ID" ]; then
  echo "Usage: ./check-firestore-handoff.sh <projectId>"
  echo ""
  echo "Get your project ID from the URL:"
  echo "  http://localhost:3000/default/project/[PROJECT_ID]/v_ai_chat"
  exit 1
fi

echo "Checking Firestore for project: $PROJECT_ID"
echo ""
echo "Run this in your browser console to check the data:"
echo ""
echo "// Copy-paste this into browser console (F12):"
echo "const { getFirestore, doc, getDoc } = await import('https://www.gstatic.com/firebasejs/10.7.1/firebase-firestore.js');"
echo "const db = getFirestore();"
echo "const snap = await getDoc(doc(db, 'projects', '$PROJECT_ID'));"
echo "console.log('Project data:', snap.data());"
echo "console.log('Handoff:', snap.data()?.phaseData?.phaseHandoffs?.collector);"
echo ""
echo "Or just paste this shortened version:"
echo ""
echo "firebase.firestore().doc('projects/$PROJECT_ID').get().then(d => console.log('Handoff:', d.data()?.phaseData?.phaseHandoffs?.collector));"

