From 91e3f807076bc5f91839190df4a8742bb68d02b0 Mon Sep 17 00:00:00 2001
From: chihlasm
Date: Fri, 3 Apr 2026 05:56:29 +0000
Subject: [PATCH] fix: clear cockpit state on session switch and add loading
placeholders
- Reset triageMeta, psaTicketId, steps, and completedSteps when
activeChatId changes (prevents stale triage data from previous session
showing while AI processes the new one)
- Split the activeChatId and activeActions reset effects so triage
only resets on session switch, not on every new action set
- Add loading placeholders to cockpit work zone: spinner + "analyzing"
text in steps panel, "questions will appear here" in right panel
- Add centered "Starting session..." loader to FlowPilot page when
loading with no messages yet (prefill creation period)
Co-Authored-By: Claude Opus 4.6 (1M context)
---
frontend/src/pages/CockpitPage.tsx | 70 +++++++++++++++++++---------
frontend/src/pages/FlowPilotPage.tsx | 6 +++
2 files changed, 55 insertions(+), 21 deletions(-)
diff --git a/frontend/src/pages/CockpitPage.tsx b/frontend/src/pages/CockpitPage.tsx
index 79c7bbc6..ed954d05 100644
--- a/frontend/src/pages/CockpitPage.tsx
+++ b/frontend/src/pages/CockpitPage.tsx
@@ -87,11 +87,23 @@ export default function CockpitPage() {
prevMessageCountRef.current = session.messages.length
}, [session.messages.length, showOnboarding])
- // Reset local step UI when switching cases or when a new action set arrives.
+ // Reset all cockpit-local state when switching cases.
+ // Triage data gets repopulated via onSessionLoadedRef after the async fetch.
useEffect(() => {
setActiveStepIndex(0)
setCompletedSteps(new Set())
- }, [session.activeChatId, session.activeActions])
+ setTriageMeta({
+ client_name: null, asset_name: null, issue_category: null,
+ triage_hypothesis: null, evidence_items: [],
+ })
+ setPsaTicketId(null)
+ }, [session.activeChatId])
+
+ // Reset step UI when a new action set arrives from AI.
+ useEffect(() => {
+ setActiveStepIndex(0)
+ setCompletedSteps(new Set())
+ }, [session.activeActions])
// ── Triage handlers ──
@@ -306,28 +318,44 @@ export default function CockpitPage() {
{/* Left: Steps panel */}
-
+ {session.loading && session.activeActions.length === 0 ? (
+
+
+
FlowPilot is analyzing the issue...
+
+ ) : (
+
+ )}
{/* Right: FlowPilot Asks + What We Know */}
-
{
- void session.sendMessage(answer, { clearComposer: false })
- }}
- loading={session.loading}
- />
-
+ {session.loading && session.activeQuestions.length === 0 && triageMeta.evidence_items.length === 0 ? (
+
+
+
Questions and evidence will appear here
+
+ ) : (
+ <>
+ {
+ void session.sendMessage(answer, { clearComposer: false })
+ }}
+ loading={session.loading}
+ />
+
+ >
+ )}
diff --git a/frontend/src/pages/FlowPilotPage.tsx b/frontend/src/pages/FlowPilotPage.tsx
index f8152404..f1b97156 100644
--- a/frontend/src/pages/FlowPilotPage.tsx
+++ b/frontend/src/pages/FlowPilotPage.tsx
@@ -149,6 +149,12 @@ export default function FlowPilotPage() {
)}
+ {session.messages.length === 0 && session.loading && (
+
+
+
Starting session...
+
+ )}
{session.messages.map((msg, i) => (