Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(events): show Pulse loading skeleton on time-window changes (LFE-14575) (#15544)

Nikita Kabardin429ec4fff651
diff --git a/web/src/features/events/components/outlier-strip/EventsOutlierStrip.tsx b/web/src/features/events/components/outlier-strip/EventsOutlierStrip.tsx
index 11a0168fa7..bdaf818187 100644
--- a/web/src/features/events/components/outlier-strip/EventsOutlierStrip.tsx
+++ b/web/src/features/events/components/outlier-strip/EventsOutlierStrip.tsx
@@ -20,6 +20,7 @@ import {
type OutlierStripDrillTrigger,
} from "./OutlierBarStrip";
import {
+ canReuseOutlierPlaceholder,
OUTLIER_STRIP_METRICS,
outlierStripQueryMetrics,
pickChartGranularity,
@@ -252,10 +253,26 @@ export function EventsOutlierStrip({
{
// Wait for the first width measurement — it decides the bucket size.
enabled: validRange && width > 0,
- // Keep the previous bins on refetch (auto-refresh ticks re-key the query
- // via the re-evaluated relative window) — a persistent band must not
- // flash to a skeleton every interval.
- placeholderData: (prev) => prev,
+ // Keep the previous bins ONLY across same-grid refetches (auto-refresh
+ // ticks re-key the query via the re-evaluated relative window) — a
+ // persistent band must not flash to a skeleton every interval. A grid
+ // change (drill-in, Back, preset hop) rendered stale bins as misplaced
+ // bars for the whole fetch on slow projects (LFE-14575) — those show
+ // the skeleton instead.
+ placeholderData: (prev, prevQuery) => {
+ const prevInput = (
+ prevQuery?.queryKey?.[1] as
+ | { input?: { query?: QueryType } }
+ | undefined
+ )?.input?.query;
+ if (!prev || !prevInput?.timeDimension) return undefined;
+ return canReuseOutlierPlaceholder(
+ { granularity: prevInput.timeDimension.granularity },
+ { granularity: granularity.granularity },
+ )
+ ? prev
+ : undefined;
+ },
meta: { silentHttpCodes: [422] },
trpc: { context: { skipBatch: true } },
},
diff --git a/web/src/features/events/components/outlier-strip/lib/binning.clienttest.ts b/web/src/features/events/components/outlier-strip/lib/binning.clienttest.ts
index af296a9f92..a43c1f6323 100644
--- a/web/src/features/events/components/outlier-strip/lib/binning.clienttest.ts
+++ b/web/src/features/events/components/outlier-strip/lib/binning.clienttest.ts
@@ -1,5 +1,6 @@
import { describe, it, expect } from "vitest";
import {
+ canReuseOutlierPlaceholder,
OUTLIER_STRIP_METRICS,
outlierStripQueryMetrics,
outlierStripResultColumn,
@@ -239,3 +240,24 @@ describe("outlierStripResultColumn", () => {
expect(outlierStripResultColumn("latency", "p95")).toBe("p95_latency");
});
});
+
+describe("canReuseOutlierPlaceholder (LFE-14575)", () => {
+ // The bucket grid is epoch-aligned, so same-granularity bins are
+ // positionally correct on ANY window slide — granularity equality is the
+ // whole rule. A ratio-based overlap gate regressed short-window +
+ // long-interval auto-refresh (30m preset sliding 15m = 50% overlap).
+ it("keeps held-over bins across any same-granularity slide, however large", () => {
+ expect(
+ canReuseOutlierPlaceholder({ granularity: "5m" }, { granularity: "5m" }),
+ ).toBe(true);
+ });
+
+ it("rejects a granularity change (drill-in / Back / preset hop)", () => {
+ expect(
+ canReuseOutlierPlaceholder(
+ { granularity: "1d" },
+ { granularity: "hour" },
+ ),
+ ).toBe(false);
+ });
+});
diff --git a/web/src/features/events/components/outlier-strip/lib/binning.ts b/web/src/features/events/components/outlier-strip/lib/binning.ts
index c71d3f8e9a..bed40012aa 100644
--- a/web/src/features/events/components/outlier-strip/lib/binning.ts
+++ b/web/src/features/events/components/outlier-strip/lib/binning.ts
@@ -362,3 +362,19 @@ export function prepareOutlierSeries(params: {
return { dense, maxValue, ticks };
}
+
+/**
+ * Whether bins fetched for a previous query window may stand in for the next
+ * one while it loads (LFE-14575). The bucket grid is epoch-aligned, so bins
+ * from the SAME granularity land at correct positions on any slid or shifted
+ * window — reuse is always honest there (an auto-refresh tick of any interval
+ * against any preset dims the held-over bars instead of flashing a skeleton).
+ * A granularity change (drill-in, browser Back, preset hop) is the case where
+ * stale bins render as misplaced bars; those show the loading skeleton. A
+ * same-granularity hop to a disjoint window degrades to the all-zero
+ * placeholder backstop in the container.
+ */
+export const canReuseOutlierPlaceholder = (
+ prev: { granularity: string },
+ next: { granularity: string },
+): boolean => prev.granularity === next.granularity;