diff --git a/frontend/components/dashboard/scan-terminal/TemperatureChartCanvas.tsx b/frontend/components/dashboard/scan-terminal/TemperatureChartCanvas.tsx index 4646ea4f..a6c254e2 100644 --- a/frontend/components/dashboard/scan-terminal/TemperatureChartCanvas.tsx +++ b/frontend/components/dashboard/scan-terminal/TemperatureChartCanvas.tsx @@ -50,6 +50,26 @@ function hasDrawableTemperatureChartContent({ ); } +function isFallbackReferenceSeries(series: EvidenceSeries) { + return series.key === "current" && series.label === "Current reference"; +} + +function hasDrawablePrimaryTemperatureChartContent({ + activeSeries, + probabilityOverlay, + zoomedData, +}: { + activeSeries: EvidenceSeries[]; + probabilityOverlay: ProbabilityOverlay | null; + zoomedData: Array>; +}) { + return hasDrawableTemperatureChartContent({ + activeSeries: activeSeries.filter((series) => !isFallbackReferenceSeries(series)), + probabilityOverlay, + zoomedData, + }); +} + function shouldKeepTemperatureChartLoading({ row, isHourlyLoading, @@ -65,7 +85,7 @@ function shouldKeepTemperatureChartLoading({ }) { if (!row?.city) return false; if (!isHourlyLoading) return false; - return !hasDrawableTemperatureChartContent({ activeSeries, probabilityOverlay, zoomedData }); + return !hasDrawablePrimaryTemperatureChartContent({ activeSeries, probabilityOverlay, zoomedData }); } function TemperatureChartSkeleton({ compact }: { compact: boolean }) { @@ -225,7 +245,7 @@ function TemperatureChartCanvasComponent({ }); const shouldRenderChart = canRenderChart && hasDrawableChartContent; const shouldShowEmptyState = Boolean(row?.city) && !isHourlyLoading && !hasDrawableChartContent; - const shouldShowBackgroundRefresh = isHourlyLoading && hasDrawableChartContent; + const shouldShowBackgroundRefresh = isHourlyLoading && hasDrawableChartContent && !shouldShowChartLoading; const shouldShowUnavailableState = Boolean(row?.city) && Boolean(detailError) && !isHourlyLoading && !hasDrawableChartContent; const shouldShowBackgroundError = showDetailErrorBadge && Boolean(row?.city) && !isHourlyLoading && hasDrawableChartContent && diff --git a/frontend/components/dashboard/scan-terminal/__tests__/terminalGridPolicy.test.ts b/frontend/components/dashboard/scan-terminal/__tests__/terminalGridPolicy.test.ts index 87b35d13..eb48829d 100644 --- a/frontend/components/dashboard/scan-terminal/__tests__/terminalGridPolicy.test.ts +++ b/frontend/components/dashboard/scan-terminal/__tests__/terminalGridPolicy.test.ts @@ -265,7 +265,7 @@ export function runTests() { "temperature chart should render once a visible series has drawable values", ); assert( - !__shouldKeepTemperatureChartLoadingForTest({ + __shouldKeepTemperatureChartLoadingForTest({ row: { city: "Moscow" } as any, isHourlyLoading: true, activeSeries: [ @@ -283,6 +283,6 @@ export function runTests() { { label: "05:00", ts: 2, current: 13 }, ], }), - "temperature chart must render seeded or cached data immediately while full detail continues loading in the background", + "temperature chart should keep the loading overlay when the only drawable series is the fallback Current reference line", ); }