From f4ceb2e23892f6ff031f9852e6451607ccd01d98 Mon Sep 17 00:00:00 2001 From: Harshul Rathod Date: Thu, 24 Sep 2026 22:54:15 +0530 Subject: [PATCH 1/3] fix(app): pulse number, bar and pie tiles while a dashboard refreshes A dashboard refresh moves the time range, so each tile refetches under a new query key. With `placeholderData: prev => prev`, react-query v5 keeps the query in `success` state while it refetches, so `isLoading` stays false and only `isPlaceholderData` is true. Number, bar and pie tiles pulsed on `isLoading` alone, so they showed stale values with no sign of loading. Pulse on `isLoading || isPlaceholderData`, as DBTimeChart already does, and return `isPlaceholderData` from useCategoricalChart for bar and pie. Refs #3205 --- .changeset/dashboard-tiles-refresh-pulse.md | 9 ++++ packages/app/src/components/DBBarChart.tsx | 3 +- packages/app/src/components/DBNumberChart.tsx | 13 +++--- packages/app/src/components/DBPieChart.tsx | 3 +- .../components/__tests__/DBBarChart.test.tsx | 45 +++++++++++++++++++ .../__tests__/DBNumberChart.test.tsx | 30 +++++++++++++ .../components/__tests__/DBPieChart.test.tsx | 45 +++++++++++++++++++ .../components/charts/CategoricalChart.tsx | 10 ++--- 8 files changed, 145 insertions(+), 13 deletions(-) create mode 100644 .changeset/dashboard-tiles-refresh-pulse.md diff --git a/.changeset/dashboard-tiles-refresh-pulse.md b/.changeset/dashboard-tiles-refresh-pulse.md new file mode 100644 index 0000000000..13588b524c --- /dev/null +++ b/.changeset/dashboard-tiles-refresh-pulse.md @@ -0,0 +1,9 @@ +--- +'@hyperdx/app': patch +--- + +fix: show that number, bar and pie tiles are refreshing + +During a dashboard refresh these tiles kept the previous result on screen with +no sign that new data was loading, so stale values looked current. They now +pulse while the refetch runs, like line and stacked-bar time charts already do. diff --git a/packages/app/src/components/DBBarChart.tsx b/packages/app/src/components/DBBarChart.tsx index c95bdd5064..b3b62593e4 100644 --- a/packages/app/src/components/DBBarChart.tsx +++ b/packages/app/src/components/DBBarChart.tsx @@ -64,6 +64,7 @@ export const DBBarChart = (props: CategoricalChartProps) => { toolbarItems, data, isLoading, + isPlaceholderData, isError, error, chartData, @@ -98,7 +99,7 @@ export const DBBarChart = (props: CategoricalChartProps) => { prev, queryKeyPrefix, enabled, - }, - ); + }); // The value is the first numeric value in the first row of the result const valueColumn = data?.meta @@ -387,7 +385,10 @@ export default function DBNumberChart({ No data found within time range. ) : ( -
+
{config.backgroundChart && ( { toolbarItems, data, isLoading, + isPlaceholderData, isError, error, chartData, @@ -125,7 +126,7 @@ export const DBPieChart = (props: CategoricalChartProps) => { { expect(screen.getByText('Loading Chart Data...')).toBeInTheDocument(); }); + describe('refresh indicator', () => { + const groupedData = { + data: [ + { status: 'success', count: 100 }, + { status: 'error', count: 50 }, + ], + meta: [ + { name: 'status', type: 'String' }, + { name: 'count', type: 'UInt64' }, + ], + }; + + it('pulses while a refetch is showing the previous result', () => { + mockUseQueriedChartConfig.mockReturnValue({ + data: groupedData, + isLoading: false, + isPlaceholderData: true, + isError: false, + }); + + renderWithMantine(); + expect( + screen + .getByTestId('bar-chart-container') + .querySelector('.effect-pulse'), + ).not.toBeNull(); + }); + + it('does not pulse once fresh data has loaded', () => { + mockUseQueriedChartConfig.mockReturnValue({ + data: groupedData, + isLoading: false, + isPlaceholderData: false, + isError: false, + }); + + renderWithMantine(); + expect( + screen + .getByTestId('bar-chart-container') + .querySelector('.effect-pulse'), + ).toBeNull(); + }); + }); + it('handles error state correctly', () => { mockUseQueriedChartConfig.mockReturnValue({ data: undefined, diff --git a/packages/app/src/components/__tests__/DBNumberChart.test.tsx b/packages/app/src/components/__tests__/DBNumberChart.test.tsx index e97b35ecb4..f209049896 100644 --- a/packages/app/src/components/__tests__/DBNumberChart.test.tsx +++ b/packages/app/src/components/__tests__/DBNumberChart.test.tsx @@ -210,6 +210,36 @@ describe('DBNumberChart', () => { expect(screen.getByText('Loading Chart Data...')).toBeInTheDocument(); }); + describe('refresh indicator', () => { + it('pulses while a refetch is showing the previous value', () => { + mockUseQueriedChartConfig.mockReturnValue({ + data: { data: [{ value: 1234 }] }, + isLoading: false, + isPlaceholderData: true, + isError: false, + }); + + renderWithMantine(); + expect( + screen.getByTestId('number-chart-value').closest('.effect-pulse'), + ).not.toBeNull(); + }); + + it('does not pulse once the fresh value has loaded', () => { + mockUseQueriedChartConfig.mockReturnValue({ + data: { data: [{ value: 1234 }] }, + isLoading: false, + isPlaceholderData: false, + isError: false, + }); + + renderWithMantine(); + expect( + screen.getByTestId('number-chart-value').closest('.effect-pulse'), + ).toBeNull(); + }); + }); + it('handles error state correctly', () => { mockUseQueriedChartConfig.mockReturnValue({ data: undefined, diff --git a/packages/app/src/components/__tests__/DBPieChart.test.tsx b/packages/app/src/components/__tests__/DBPieChart.test.tsx index 37d8e612ec..9d45753c72 100644 --- a/packages/app/src/components/__tests__/DBPieChart.test.tsx +++ b/packages/app/src/components/__tests__/DBPieChart.test.tsx @@ -69,6 +69,51 @@ describe('DBPieChart', () => { expect(screen.getByText('Loading Chart Data...')).toBeInTheDocument(); }); + describe('refresh indicator', () => { + const groupedData = { + data: [ + { status: 'success', count: 100 }, + { status: 'error', count: 50 }, + ], + meta: [ + { name: 'status', type: 'String' }, + { name: 'count', type: 'UInt64' }, + ], + }; + + it('pulses while a refetch is showing the previous result', () => { + mockUseQueriedChartConfig.mockReturnValue({ + data: groupedData, + isLoading: false, + isPlaceholderData: true, + isError: false, + }); + + renderWithMantine(); + expect( + screen + .getByTestId('pie-chart-container') + .querySelector('.effect-pulse'), + ).not.toBeNull(); + }); + + it('does not pulse once fresh data has loaded', () => { + mockUseQueriedChartConfig.mockReturnValue({ + data: groupedData, + isLoading: false, + isPlaceholderData: false, + isError: false, + }); + + renderWithMantine(); + expect( + screen + .getByTestId('pie-chart-container') + .querySelector('.effect-pulse'), + ).toBeNull(); + }); + }); + it('handles error state correctly', () => { mockUseQueriedChartConfig.mockReturnValue({ data: undefined, diff --git a/packages/app/src/components/charts/CategoricalChart.tsx b/packages/app/src/components/charts/CategoricalChart.tsx index 936af713cd..bc4bd6f4ae 100644 --- a/packages/app/src/components/charts/CategoricalChart.tsx +++ b/packages/app/src/components/charts/CategoricalChart.tsx @@ -56,14 +56,12 @@ export function useCategoricalChart({ const { data: mvOptimizationData } = useMVOptimizationExplanation(builderQueriedConfig); - const { data, isLoading, isError, error } = useQueriedChartConfig( - queriedConfig, - { + const { data, isLoading, isError, error, isPlaceholderData } = + useQueriedChartConfig(queriedConfig, { placeholderData: (prev: any) => prev, queryKey: [queryKeyPrefix, queriedConfig], enabled, - }, - ); + }); const toolbarItems = useMemo(() => { const allToolbarItems: React.ReactNode[] = []; @@ -130,6 +128,8 @@ export function useCategoricalChart({ toolbarItems, data, isLoading, + // True while a refetch (e.g. dashboard refresh) shows the previous result + isPlaceholderData, isError, error, chartData, From 175d8ddc183d4129b15fb307023ee29336f4a93f Mon Sep 17 00:00:00 2001 From: Harshul Rathod Date: Fri, 25 Sep 2026 00:26:22 +0530 Subject: [PATCH 2/3] fix(app): pulse empty results and the pie legend during a refresh - An empty previous result rendered "No data found within time range." without any refresh sign. The number, bar and pie tiles now pulse that message while a refetch runs. - The pie legend sat outside the pulsing chart, so its values looked current during a refresh. Pulse the container that holds both. --- packages/app/src/components/DBBarChart.tsx | 4 ++- packages/app/src/components/DBNumberChart.tsx | 4 ++- packages/app/src/components/DBPieChart.tsx | 12 ++++---- .../components/__tests__/DBBarChart.test.tsx | 14 +++++++++ .../__tests__/DBNumberChart.test.tsx | 14 +++++++++ .../components/__tests__/DBPieChart.test.tsx | 30 ++++++++++++++----- 6 files changed, 62 insertions(+), 16 deletions(-) diff --git a/packages/app/src/components/DBBarChart.tsx b/packages/app/src/components/DBBarChart.tsx index b3b62593e4..503af6913a 100644 --- a/packages/app/src/components/DBBarChart.tsx +++ b/packages/app/src/components/DBBarChart.tsx @@ -85,7 +85,9 @@ export const DBBarChart = (props: CategoricalChartProps) => { variant={props.errorVariant} /> ) : data?.data.length === 0 ? ( -
+
No data found within time range.
) : ( diff --git a/packages/app/src/components/DBNumberChart.tsx b/packages/app/src/components/DBNumberChart.tsx index bde5a15039..14b68fbd42 100644 --- a/packages/app/src/components/DBNumberChart.tsx +++ b/packages/app/src/components/DBNumberChart.tsx @@ -381,7 +381,9 @@ export default function DBNumberChart({ ) : resultError ? ( ) : data?.data.length === 0 ? ( -
+
No data found within time range.
) : ( diff --git a/packages/app/src/components/DBPieChart.tsx b/packages/app/src/components/DBPieChart.tsx index 4cecaa1c5e..2c629c10c8 100644 --- a/packages/app/src/components/DBPieChart.tsx +++ b/packages/app/src/components/DBPieChart.tsx @@ -112,7 +112,9 @@ export const DBPieChart = (props: CategoricalChartProps) => { ) : responseFormatError ? ( ) : data?.data.length === 0 ? ( -
+
No data found within time range.
) : ( @@ -122,12 +124,10 @@ export const DBPieChart = (props: CategoricalChartProps) => { justify="center" h="100%" style={{ flexGrow: 1, overflow: 'hidden' }} + // Pulse the pie and its legend together: the legend shows values too + className={isLoading || isPlaceholderData ? 'effect-pulse' : ''} > - + { .querySelector('.effect-pulse'), ).toBeNull(); }); + + it('pulses the empty state while a refetch is running', () => { + mockUseQueriedChartConfig.mockReturnValue({ + data: { data: [], meta: groupedData.meta }, + isLoading: false, + isPlaceholderData: true, + isError: false, + }); + + renderWithMantine(); + expect(screen.getByText('No data found within time range.')).toHaveClass( + 'effect-pulse', + ); + }); }); it('handles error state correctly', () => { diff --git a/packages/app/src/components/__tests__/DBNumberChart.test.tsx b/packages/app/src/components/__tests__/DBNumberChart.test.tsx index f209049896..08d8120c2e 100644 --- a/packages/app/src/components/__tests__/DBNumberChart.test.tsx +++ b/packages/app/src/components/__tests__/DBNumberChart.test.tsx @@ -238,6 +238,20 @@ describe('DBNumberChart', () => { screen.getByTestId('number-chart-value').closest('.effect-pulse'), ).toBeNull(); }); + + it('pulses the empty state while a refetch is running', () => { + mockUseQueriedChartConfig.mockReturnValue({ + data: { data: [] }, + isLoading: false, + isPlaceholderData: true, + isError: false, + }); + + renderWithMantine(); + expect(screen.getByText('No data found within time range.')).toHaveClass( + 'effect-pulse', + ); + }); }); it('handles error state correctly', () => { diff --git a/packages/app/src/components/__tests__/DBPieChart.test.tsx b/packages/app/src/components/__tests__/DBPieChart.test.tsx index 9d45753c72..335e7f25e1 100644 --- a/packages/app/src/components/__tests__/DBPieChart.test.tsx +++ b/packages/app/src/components/__tests__/DBPieChart.test.tsx @@ -90,10 +90,12 @@ describe('DBPieChart', () => { }); renderWithMantine(); + expect(screen.getByTestId('pie-chart-container')).toHaveClass( + 'effect-pulse', + ); + // The legend shows values too, so it pulses along with the pie expect( - screen - .getByTestId('pie-chart-container') - .querySelector('.effect-pulse'), + screen.getByTestId('pie-chart-legend').closest('.effect-pulse'), ).not.toBeNull(); }); @@ -106,11 +108,23 @@ describe('DBPieChart', () => { }); renderWithMantine(); - expect( - screen - .getByTestId('pie-chart-container') - .querySelector('.effect-pulse'), - ).toBeNull(); + expect(screen.getByTestId('pie-chart-container')).not.toHaveClass( + 'effect-pulse', + ); + }); + + it('pulses the empty state while a refetch is running', () => { + mockUseQueriedChartConfig.mockReturnValue({ + data: { data: [], meta: groupedData.meta }, + isLoading: false, + isPlaceholderData: true, + isError: false, + }); + + renderWithMantine(); + expect(screen.getByText('No data found within time range.')).toHaveClass( + 'effect-pulse', + ); }); }); From f94a99c7721dda176c7aa9b5ab08b7ab21ccfe1e Mon Sep 17 00:00:00 2001 From: Harshul Rathod Date: Fri, 25 Sep 2026 01:11:03 +0530 Subject: [PATCH 3/3] refactor(app): build the empty-state pulse class with classnames Review round 2: - Use `cx` for the empty-state pulse class in the number, bar and pie tiles instead of a template string with a leading space. - Test that the number tile pulses while `isLoading` is true with a value on screen. `useQueriedChartConfig`'s `isLoading` also covers the MV-optimization check, so it can be true while a value is shown. --- packages/app/src/components/DBBarChart.tsx | 6 +++++- packages/app/src/components/DBNumberChart.tsx | 6 +++++- packages/app/src/components/DBPieChart.tsx | 6 +++++- .../components/__tests__/DBNumberChart.test.tsx | 16 ++++++++++++++++ 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/packages/app/src/components/DBBarChart.tsx b/packages/app/src/components/DBBarChart.tsx index 503af6913a..dcbd026378 100644 --- a/packages/app/src/components/DBBarChart.tsx +++ b/packages/app/src/components/DBBarChart.tsx @@ -1,4 +1,5 @@ import { memo } from 'react'; +import cx from 'classnames'; import { Bar, BarChart, @@ -86,7 +87,10 @@ export const DBBarChart = (props: CategoricalChartProps) => { /> ) : data?.data.length === 0 ? (
No data found within time range.
diff --git a/packages/app/src/components/DBNumberChart.tsx b/packages/app/src/components/DBNumberChart.tsx index 14b68fbd42..308def077c 100644 --- a/packages/app/src/components/DBNumberChart.tsx +++ b/packages/app/src/components/DBNumberChart.tsx @@ -1,4 +1,5 @@ import { useLayoutEffect, useMemo, useRef, useState } from 'react'; +import cx from 'classnames'; import { ErrorBoundary } from 'react-error-boundary'; import { filterColumnMetaByType, @@ -382,7 +383,10 @@ export default function DBNumberChart({ ) : data?.data.length === 0 ? (
No data found within time range.
diff --git a/packages/app/src/components/DBPieChart.tsx b/packages/app/src/components/DBPieChart.tsx index 2c629c10c8..7409bd0698 100644 --- a/packages/app/src/components/DBPieChart.tsx +++ b/packages/app/src/components/DBPieChart.tsx @@ -1,4 +1,5 @@ import { memo } from 'react'; +import cx from 'classnames'; import { Cell, Pie, PieChart, ResponsiveContainer, Tooltip } from 'recharts'; import { Box, Flex, ScrollArea, Text } from '@mantine/core'; @@ -113,7 +114,10 @@ export const DBPieChart = (props: CategoricalChartProps) => { ) : data?.data.length === 0 ? (
No data found within time range.
diff --git a/packages/app/src/components/__tests__/DBNumberChart.test.tsx b/packages/app/src/components/__tests__/DBNumberChart.test.tsx index 08d8120c2e..672581a9ab 100644 --- a/packages/app/src/components/__tests__/DBNumberChart.test.tsx +++ b/packages/app/src/components/__tests__/DBNumberChart.test.tsx @@ -225,6 +225,22 @@ describe('DBNumberChart', () => { ).not.toBeNull(); }); + it('pulses while still loading with a value on screen', () => { + // useQueriedChartConfig's isLoading also covers the MV-optimization + // check, which can be pending while a value is shown + mockUseQueriedChartConfig.mockReturnValue({ + data: { data: [{ value: 1234 }] }, + isLoading: true, + isPlaceholderData: false, + isError: false, + }); + + renderWithMantine(); + expect( + screen.getByTestId('number-chart-value').closest('.effect-pulse'), + ).not.toBeNull(); + }); + it('does not pulse once the fresh value has loaded', () => { mockUseQueriedChartConfig.mockReturnValue({ data: { data: [{ value: 1234 }] },