fix(dashboard): auto-submit FlowPilot session when prefill from dashboard

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 <noreply@anthropic.com>
This commit is contained in:
2026-03-21 00:18:43 +00:00
parent 3d911d2dc9
commit 60b380ae1e

View File

@@ -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