diff --git a/frontend/src/pages/FlowPilotSessionPage.tsx b/frontend/src/pages/FlowPilotSessionPage.tsx index 4c83c978..f79b4ecb 100644 --- a/frontend/src/pages/FlowPilotSessionPage.tsx +++ b/frontend/src/pages/FlowPilotSessionPage.tsx @@ -1,6 +1,6 @@ import { useEffect, useRef, useState } from 'react' -import { useParams, useSearchParams, useLocation } from 'react-router-dom' -import { Sparkles, Loader2 } from 'lucide-react' +import { useParams, useSearchParams, useLocation, useBlocker } from 'react-router-dom' +import { Sparkles, Loader2, AlertTriangle } from 'lucide-react' import { useFlowPilotSession } from '@/hooks/useFlowPilotSession' import { FlowPilotIntake, FlowPilotSession, SessionBriefing } from '@/components/flowpilot' import { aiSessionsApi } from '@/api' @@ -15,6 +15,13 @@ export default function FlowPilotSessionPage() { const fp = useFlowPilotSession() const prefillHandledRef = useRef(false) + // Block navigation when session is active + const isActiveSession = fp.session?.status === 'active' + const blocker = useBlocker( + ({ currentLocation, nextLocation }) => + !!isActiveSession && currentLocation.pathname !== nextLocation.pathname + ) + // Auto-submit when navigating from dashboard with prefilled problem useEffect(() => { if (prefill && !prefillHandledRef.current && !sessionId && !fp.session && !fp.isLoading) { @@ -153,6 +160,40 @@ export default function FlowPilotSessionPage() { // Active/completed session return (
+ You have an active troubleshooting session. If you leave, your session will be paused and you can resume it later. +
+