diff --git a/frontend/src/pages/FlowPilotSessionPage.tsx b/frontend/src/pages/FlowPilotSessionPage.tsx index 469ddacf..4c83c978 100644 --- a/frontend/src/pages/FlowPilotSessionPage.tsx +++ b/frontend/src/pages/FlowPilotSessionPage.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from 'react' +import { useEffect, useRef, useState } from 'react' import { useParams, useSearchParams, useLocation } from 'react-router-dom' import { Sparkles, Loader2 } from 'lucide-react' import { useFlowPilotSession } from '@/hooks/useFlowPilotSession' @@ -13,6 +13,15 @@ export default function FlowPilotSessionPage() { const prefill = (location.state as { prefill?: string } | null)?.prefill || '' const isPickup = searchParams.get('pickup') === 'true' const fp = useFlowPilotSession() + const prefillHandledRef = useRef(false) + + // Auto-submit when navigating from dashboard with prefilled problem + useEffect(() => { + if (prefill && !prefillHandledRef.current && !sessionId && !fp.session && !fp.isLoading) { + prefillHandledRef.current = true + fp.startSession({ intake_type: 'free_text', intake_content: { text: prefill } }) + } + }, [prefill, sessionId, fp.session, fp.isLoading]) // eslint-disable-line react-hooks/exhaustive-deps const [pickingUp, setPickingUp] = useState(false) // Load existing session if ID in URL