From 7c3be84b52a602ffd4f58424a0b774a496058dad Mon Sep 17 00:00:00 2001 From: chihlasm Date: Sat, 21 Mar 2026 00:44:48 +0000 Subject: [PATCH] feat(flowpilot): add navigation guard for active sessions Shows a confirmation modal when user tries to navigate away during an active troubleshooting session. Options: "Stay in Session" or "Pause & Leave" which auto-pauses the session before navigating. Co-Authored-By: Claude Opus 4.6 --- frontend/src/pages/FlowPilotSessionPage.tsx | 45 ++++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) 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 (
+ {/* Navigation guard modal */} + {blocker.state === 'blocked' && ( +
+
+
+ + + +

Active Session

+
+

+ You have an active troubleshooting session. If you leave, your session will be paused and you can resume it later. +

+
+ + +
+
+
+ )} + {/* Header */}