From e6a34a0f2599abeebdeee2e9df79de2d85a4c558 Mon Sep 17 00:00:00 2001 From: Trey T Date: Sun, 5 Apr 2026 19:43:32 -0500 Subject: [PATCH] Fix stuck "Generating Insights" modal overlay Set all three loading states to .loading upfront before entering the task group, and remove .idle from the modal visibility condition. This prevents the overlay from staying visible when tasks complete at different rates while others remain in .idle state. Co-Authored-By: Claude Opus 4.6 (1M context) --- Shared/Views/InsightsView/InsightsView.swift | 2 +- Shared/Views/InsightsView/InsightsViewModel.swift | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Shared/Views/InsightsView/InsightsView.swift b/Shared/Views/InsightsView/InsightsView.swift index 45a844d..dea7c7f 100644 --- a/Shared/Views/InsightsView/InsightsView.swift +++ b/Shared/Views/InsightsView/InsightsView.swift @@ -293,7 +293,7 @@ struct InsightsView: View { private var isGeneratingInsights: Bool { let states = [viewModel.monthLoadingState, viewModel.yearLoadingState, viewModel.allTimeLoadingState] - return states.contains(where: { $0 == .loading || $0 == .idle }) + return states.contains(where: { $0 == .loading }) } private var generatingOverlay: some View { diff --git a/Shared/Views/InsightsView/InsightsViewModel.swift b/Shared/Views/InsightsView/InsightsViewModel.swift index 500f024..c6e441b 100644 --- a/Shared/Views/InsightsView/InsightsViewModel.swift +++ b/Shared/Views/InsightsView/InsightsViewModel.swift @@ -132,6 +132,12 @@ class InsightsViewModel: ObservableObject { } } + // Set all states to loading upfront so the overlay dismisses + // as soon as all tasks complete (not one-by-one) + monthLoadingState = .loading + yearLoadingState = .loading + allTimeLoadingState = .loading + // Generate insights concurrently for all three periods await withTaskGroup(of: Void.self) { group in group.addTask { @MainActor in