From abbabe7e8d2e32914f7df27c4ba3b3a51ac25ae1 Mon Sep 17 00:00:00 2001 From: mindesbunister Date: Thu, 17 Jul 2025 14:04:50 +0200 Subject: [PATCH] Fix multi-timeframe analysis sync issues - Ensure analysisInProgress flag is always reset in finally block - Remove duplicate concurrency flag resets from progress handlers - Fix inconsistent concurrency protection between single/multi timeframe - Prevents sync issues when selecting multiple timeframes for analysis --- components/AIAnalysisPanel.tsx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/components/AIAnalysisPanel.tsx b/components/AIAnalysisPanel.tsx index cbe9641..5fca6c3 100644 --- a/components/AIAnalysisPanel.tsx +++ b/components/AIAnalysisPanel.tsx @@ -126,7 +126,6 @@ export default function AIAnalysisPanel({ onAnalysisComplete }: AIAnalysisPanelP setEventSource(null) // Reset UI state when analysis completes setLoading(false) - analysisInProgress.current = false setProgress(null) } else if (progressData.type === 'connected') { console.log(`🔍 EventSource connected for ${sessionId}`) @@ -142,7 +141,6 @@ export default function AIAnalysisPanel({ onAnalysisComplete }: AIAnalysisPanelP console.log(`🔍 All steps completed for ${sessionId}, resetting UI state`) setTimeout(() => { setLoading(false) - analysisInProgress.current = false setProgress(null) es.close() setEventSource(null) @@ -378,7 +376,6 @@ export default function AIAnalysisPanel({ onAnalysisComplete }: AIAnalysisPanelP // Reset loading state immediately on error setLoading(false) - analysisInProgress.current = false setProgress(null) // Mark current active step as error @@ -398,11 +395,11 @@ export default function AIAnalysisPanel({ onAnalysisComplete }: AIAnalysisPanelP return prev }) } finally { - // Only reset loading for multi-timeframe analysis + // Always reset concurrency flag, but only reset loading for multi-timeframe analysis // Single timeframe analysis loading state is managed by progress tracking + analysisInProgress.current = false if (analysisTimeframes.length > 1) { setLoading(false) - analysisInProgress.current = false } } }