import { useStore } from "../store"; export function QueryInput() { const query = useStore((s) => s.query); const selectedId = useStore((s) => s.selectedId); const sending = useStore((s) => s.sending); const sessionStarting = useStore((s) => s.sessionStarting); const messages = useStore((s) => s.messages); const setQuery = useStore((s) => s.setQuery); const sendMessage = useStore((s) => s.sendMessage); const busy = sending || sessionStarting; const hasChat = messages.length > 0; async function onSend() { const text = query.trim(); if (!text || busy) return; // Attach scenario_id only on the first turn — the server prepends the // scenario question once; follow-ups are pure text against the same // multi-turn context. const scenarioForTurn = hasChat ? undefined : selectedId; setQuery(""); await sendMessage(text, scenarioForTurn); } function onKeyDown(e: React.KeyboardEvent) { // Enter submits, Shift+Enter newlines. if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); void onSend(); } } return (

{hasChat ? "Follow up" : "Ask the agent"}

{hasChat ? "The model sees prior turns — ask for Monte Carlo, sensitivity sweeps, or probe another cell." : "The agent will decompose your question, dispatch the solver and surrogate, and — if asked — run a Monte Carlo ensemble or sensitivity sweep."}