// Path: /src/App.jsx import { useState } from 'react'; import { getHubStatus, submitQueryToHub } from './utils/api.js'; function App() { const [query, setQuery] = useState(''); const [response, setResponse] = useState(null); const [history, setHistory] = useState([]); // Client-side history const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const [diagResult, setDiagResult] = useState(null); const clearState = () => { setError(null); setResponse(null); setDiagResult(null); }; const handleSubmit = async (e) => { e.preventDefault(); if (!query.trim()) return; setLoading(true); clearState(); try { const data = await submitQueryToHub(query); if (data && data.status === 'success') { setResponse(data); // Add successful query to the start of the history setHistory(prev => [{ query, response: data }, ...prev]); } else { setError(data.error || data.message || 'An unknown error occurred.'); } } catch (err) { setError(`A connection error occurred. Please ensure the Hub is running.`); } finally { setLoading(false); } }; const handleHealthCheck = async () => { setLoading(true); clearState(); try { const data = await getHubStatus(); setDiagResult({ type: 'Health Check', data }); } catch (err) { setError('Health check failed. Ensure the Hub is running.'); } finally { setLoading(false); } }; const handleAgentCheck = async () => { setLoading(true); clearState(); try { const data = await submitQueryToHub("List one vessel name."); setDiagResult({ type: 'Agent + DB Test', data }); } catch (err) { setError('Agent/DB test failed. Ensure the Hub and all services are running correctly.'); } finally { setLoading(false); } }; return (

Astoria Console