From 9468fac99ee241226716e17d6506ce8238b48eb8 Mon Sep 17 00:00:00 2001 From: Amirhossein Khalili Date: Sat, 22 Aug 2026 15:54:09 +0800 Subject: [PATCH] fix: render ready AI insights immediately --- src/lib/components/AIInsightPanel.svelte | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib/components/AIInsightPanel.svelte b/src/lib/components/AIInsightPanel.svelte index 5034eee..a11b456 100644 --- a/src/lib/components/AIInsightPanel.svelte +++ b/src/lib/components/AIInsightPanel.svelte @@ -28,6 +28,7 @@ let sectionErrors = $state>>({}); let error = $state(''); let sequence = 0; + let activeScope = ''; const confidenceLabel = $derived( ( @@ -49,7 +50,10 @@ error = ''; try { const next = await api.latestAIInsight(requestedModule, requestedTerminalId, requestedPeriodId); - if (current === sequence) insight = next; + if (current === sequence) { + insight = next; + loading = false; + } } catch (cause) { if (current !== sequence) return; error = @@ -128,6 +132,9 @@ const requestedModule = module; const requestedTerminalId = terminalId; const requestedPeriodId = periodId; + const scope = `${requestedModule}\u0000${requestedTerminalId ?? ''}\u0000${requestedPeriodId ?? ''}`; + if (scope === activeScope) return; + activeScope = scope; insight = null; loading = true; void load(requestedModule, requestedTerminalId, requestedPeriodId); @@ -141,7 +148,7 @@
- {#if loading} + {#if loading && !insight}