From 60b380ae1eeb53a3e2bf934aaf5817feab75d6c1 Mon Sep 17 00:00:00 2001 From: chihlasm Date: Sat, 21 Mar 2026 00:18:43 +0000 Subject: [PATCH] fix(dashboard): auto-submit FlowPilot session when prefill from dashboard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When user types a problem on the dashboard and hits Enter, skip the intake form and start the session immediately — no double-enter. Co-Authored-By: Claude Opus 4.6 --- frontend/src/pages/FlowPilotSessionPage.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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