Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

fix(dashboard-v2): only refetch on-screen panels on time change/auto-refresh (#12113)

Abhi kumar181feb3eb943
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/SectionGrid/SectionGridItem.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/SectionGrid/SectionGridItem.tsx
index 3ce1e18157..671a449d13 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/SectionGrid/SectionGridItem.tsx
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/PanelsAndSectionsLayout/Section/SectionGrid/SectionGridItem.tsx
@@ -10,8 +10,8 @@ const VIEWPORT_OBSERVER_OPTIONS: IntersectionObserverInit = {
rootMargin: '200px',
};
-// Start observing after RGL's mount unfold settles, so transient off-screen
-// panels don't latch as visible.
+// Start observing after RGL's mount unfold settles, so a panel that only
+// transiently overlaps the viewport during layout doesn't fire a throwaway fetch.
const OBSERVER_START_DELAY_MS = 350;
interface SectionGridItemProps {
@@ -21,9 +21,9 @@ interface SectionGridItemProps {
}
/**
- * Lazy-loads a single panel: watches its own viewport intersection (latched) and
- * passes it to the presentational Panel as `isVisible`, so a board of many panels
- * only fetches what's on screen.
+ * Lazy-loads a single panel: tracks its live viewport intersection and passes it to
+ * the presentational Panel as `isVisible`, so a board of many panels only fetches
+ * (and refetches on time change / auto-refresh) what's on screen.
*/
function SectionGridItem({
panel,
@@ -34,7 +34,9 @@ function SectionGridItem({
const isVisible = useIntersectionObserver(
containerRef,
VIEWPORT_OBSERVER_OPTIONS,
- true,
+ // Not once: track the live viewport so a time change / auto-refresh only
+ // refetches on-screen panels (off-screen ones stay query-disabled).
+ false,
OBSERVER_START_DELAY_MS,
);
useScrollIntoView(panelId, containerRef);
diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/hooks/useGetQueryRangeV5.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/hooks/useGetQueryRangeV5.ts
index 66663baabd..efe1e1b63e 100644
--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/hooks/useGetQueryRangeV5.ts
+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/hooks/useGetQueryRangeV5.ts
@@ -57,5 +57,8 @@ export function useGetQueryRangeV5({
retry: retryUnlessClientError,
keepPreviousData,
cacheTime,
+ // A resolved window is immutable per key, so a panel scrolled back into view
+ // serves cache instead of refetching; a key change or manual refetch still runs.
+ staleTime: Infinity,
});
}