From 9068f3bc6cfa4b2b51c5a6ba4e7cc41d70ad9ef6 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Thu, 11 Jun 2026 21:50:20 +0100 Subject: [PATCH] history(drawer): restore sub-day ranges to the metrics history select v5 drawers offered 1h/6h/12h history zoom; the v6 shared range list started at 24 hours, so an operator investigating a spike from the last hour got a day-wide chart. The backend chart range parser and the HistoryTimeRange type already support the shorter windows; only the shared HISTORY_CHART_RANGES list and the drawer labels were missing them. StoragePoolDetail keeps its own narrower range list and is unaffected. Flagged by the Machines page v5 parity audit; applies to every drawer History tab. --- .../src/components/Workloads/GuestDrawerHistory.tsx | 6 ++++++ .../components/shared/__tests__/HistoryChart.test.tsx | 4 ++-- .../src/components/shared/historyChartModel.ts | 11 ++++++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/frontend-modern/src/components/Workloads/GuestDrawerHistory.tsx b/frontend-modern/src/components/Workloads/GuestDrawerHistory.tsx index 807aa0577..c88851e13 100644 --- a/frontend-modern/src/components/Workloads/GuestDrawerHistory.tsx +++ b/frontend-modern/src/components/Workloads/GuestDrawerHistory.tsx @@ -74,6 +74,12 @@ const EMPTY_HISTORY_RESPONSE: AllMetricsHistoryResponse = { const formatRangeLabel = (range: HistoryTimeRange): string => { switch (range) { + case '1h': + return '1 hour'; + case '6h': + return '6 hours'; + case '12h': + return '12 hours'; case '24h': return '24 hours'; case '7d': diff --git a/frontend-modern/src/components/shared/__tests__/HistoryChart.test.tsx b/frontend-modern/src/components/shared/__tests__/HistoryChart.test.tsx index 0e031c8f5..ee4a76560 100644 --- a/frontend-modern/src/components/shared/__tests__/HistoryChart.test.tsx +++ b/frontend-modern/src/components/shared/__tests__/HistoryChart.test.tsx @@ -118,8 +118,8 @@ describe('HistoryChart', () => { expect(screen.getByText('History')).toBeInTheDocument(); }); - it('exposes the Relay history range as a first-class chart option', () => { - expect(HISTORY_CHART_RANGES).toEqual(['24h', '7d', '14d', '30d', '90d']); + it('exposes the sub-day and Relay history ranges as first-class chart options', () => { + expect(HISTORY_CHART_RANGES).toEqual(['1h', '6h', '12h', '24h', '7d', '14d', '30d', '90d']); }); it('positions the tooltip beside the hovered point when there is chart space', () => { diff --git a/frontend-modern/src/components/shared/historyChartModel.ts b/frontend-modern/src/components/shared/historyChartModel.ts index 683021896..66154aab6 100644 --- a/frontend-modern/src/components/shared/historyChartModel.ts +++ b/frontend-modern/src/components/shared/historyChartModel.ts @@ -31,7 +31,16 @@ export interface HistoryChartTooltipLayout { height: number; } -export const HISTORY_CHART_RANGES: HistoryTimeRange[] = ['24h', '7d', '14d', '30d', '90d']; +export const HISTORY_CHART_RANGES: HistoryTimeRange[] = [ + '1h', + '6h', + '12h', + '24h', + '7d', + '14d', + '30d', + '90d', +]; export function formatHistoryChartTooltipValue(value: number, unit?: string): string { if (unit === '%') return `${value.toFixed(1)}%`;