Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Refine workload history hover interaction
rcourtmane882ce3a5df7
diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.mdindex 07cc915dbb..a14370a330 100644--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md@@ -554,9 +554,12 @@ range control is part of the same hot-path state owner: bar mode must not starthistory fetches, and sparkline ranges must stay bounded to the governed compacttable windows. Expanded history belongs in the existing guest drawer chartsurface, where longer-range reads stay demand-driven and scoped to the selected-workload. The drawer history view must preserve visual density by grouping+workload. Its range control belongs in the drawer chrome rather than a dedicated+chart row. The drawer history view must preserve visual density by groupingrelated series into utilization, network I/O, and disk I/O charts rather than-repeating one chart frame per metric.+repeating one chart frame per metric. Those grouped charts must still support+inline hover inspection by updating the existing legend values and showing only+the hovered timestamp, so density does not remove point-in-time metric detail.The investigation enrichment path in `MaybeInvestigateFinding`adds at most one operator-state projection lookup per investigationdiff --git a/frontend-modern/src/components/Workloads/GuestDrawer.test.tsx b/frontend-modern/src/components/Workloads/GuestDrawer.test.tsxindex 704ce95ac4..c5efa9d4b3 100644--- a/frontend-modern/src/components/Workloads/GuestDrawer.test.tsx+++ b/frontend-modern/src/components/Workloads/GuestDrawer.test.tsx@@ -1,20 +1,15 @@import { describe, it, expect, vi, afterEach, beforeEach } from 'vitest';-import { render, screen, fireEvent, cleanup, waitFor } from '@solidjs/testing-library';+import { render, screen, fireEvent, cleanup, waitFor, within } from '@solidjs/testing-library';import type { WorkloadGuest } from '@/types/workloads';import type { Memory, Disk, GuestNetworkInterface } from '@/types/api';import { getCanonicalWorkloadId } from '@/utils/workloads';// ── Mocks ──────────────────────────────────────────────────────────────-const mockNavigate = vi.fn();const chartsApiMocks = vi.hoisted(() => ({getMetricsHistory: vi.fn(),}));-vi.mock('@solidjs/router', () => ({- useNavigate: () => mockNavigate,-}));-vi.mock('@/api/charts', async () => {const actual = await vi.importActual<typeof import('@/api/charts')>('@/api/charts');return {@@ -203,6 +198,56 @@ describe('GuestDrawer', () => {expect(screen.getByText('Utilization')).toBeInTheDocument();expect(screen.getByText('Network I/O')).toBeInTheDocument();expect(screen.getByText('Disk I/O')).toBeInTheDocument();+ expect(screen.getByTestId('guest-history-range-control')).toBeInTheDocument();+ expect(screen.queryByText('Open related infrastructure')).toBeNull();+ });++ it('updates grouped metric header values on History chart hover', async () => {+ render(() => <GuestDrawer guest={makeGuest()} onClose={vi.fn()} />);++ await fireEvent.click(screen.getByText('History'));++ await waitFor(() => {+ expect(chartsApiMocks.getMetricsHistory).toHaveBeenCalled();+ });+ const utilizationChart = screen.getAllByTestId('guest-history-group-chart')[0];+ const plot = within(utilizationChart).getByTestId('guest-history-plot');+ plot.getBoundingClientRect = () =>+ ({+ bottom: 100,+ height: 100,+ left: 0,+ right: 360,+ top: 0,+ width: 360,+ x: 0,+ y: 0,+ toJSON: () => ({}),+ }) as DOMRect;++ expect(utilizationChart).toHaveTextContent('20.0%');+ expect(utilizationChart).toHaveTextContent('30.0%');+ expect(utilizationChart).toHaveTextContent('40.0%');++ await fireEvent.mouseMove(plot, { clientX: 180, clientY: 50 });++ expect(+ within(utilizationChart).getByTestId('guest-history-hover-time').textContent,+ ).toBeTruthy();+ expect(within(utilizationChart).queryByTestId('guest-history-tooltip')).toBeNull();+ expect(utilizationChart).toHaveTextContent('CPU');+ expect(utilizationChart).toHaveTextContent('15.0%');+ expect(utilizationChart).toHaveTextContent('Memory');+ expect(utilizationChart).toHaveTextContent('25.0%');+ expect(utilizationChart).toHaveTextContent('Disk');+ expect(utilizationChart).toHaveTextContent('35.0%');++ await fireEvent.pointerLeave(plot);++ expect(within(utilizationChart).queryByTestId('guest-history-hover-time')).toBeNull();+ expect(utilizationChart).toHaveTextContent('20.0%');+ expect(utilizationChart).toHaveTextContent('30.0%');+ expect(utilizationChart).toHaveTextContent('40.0%');});it('switches back to Overview tab', async () => {@@ -215,45 +260,6 @@ describe('GuestDrawer', () => {});});- // ── Infrastructure navigation ──-- describe('infrastructure link', () => {- it('navigates to proxmox infrastructure for a VM', async () => {- render(() => (- <GuestDrawer guest={makeGuest({ node: 'pve1', type: 'qemu' })} onClose={vi.fn()} />- ));- await fireEvent.click(screen.getByText('Open related infrastructure'));- expect(mockNavigate).toHaveBeenCalledTimes(1);- const path = mockNavigate.mock.calls[0][0] as string;- expect(path).toContain('infrastructure');- expect(path).toContain('proxmox');- });-- it('navigates to docker infrastructure for an app-container workload', async () => {- render(() => (- <GuestDrawer- guest={makeGuest({ workloadType: 'app-container', contextLabel: 'my-host' })}- onClose={vi.fn()}- />- ));- await fireEvent.click(screen.getByText('Open related infrastructure'));- const path = mockNavigate.mock.calls[0][0] as string;- expect(path).toContain('source=docker');- });-- it('navigates to kubernetes infrastructure for a pod workload', async () => {- render(() => (- <GuestDrawer- guest={makeGuest({ workloadType: 'pod', contextLabel: 'my-cluster' })}- onClose={vi.fn()}- />- ));- await fireEvent.click(screen.getByText('Open related infrastructure'));- const path = mockNavigate.mock.calls[0][0] as string;- expect(path).toContain('kubernetes');- });- });-// ── System card ──describe('System card', () => {diff --git a/frontend-modern/src/components/Workloads/GuestDrawer.tsx b/frontend-modern/src/components/Workloads/GuestDrawer.tsxindex e72580d6ca..a175e10352 100644--- a/frontend-modern/src/components/Workloads/GuestDrawer.tsx+++ b/frontend-modern/src/components/Workloads/GuestDrawer.tsx@@ -1,13 +1,11 @@-import { Component, Suspense } from 'solid-js';-import { useNavigate } from '@solidjs/router';+import { Component, Show, Suspense } from 'solid-js';import { DiscoveryTab } from '../Discovery/DiscoveryTab';import type { GuestDrawerProps } from './guestDrawerModel';import { useGuestDrawerState } from './useGuestDrawerState';-import { GuestDrawerHistory } from './GuestDrawerHistory';+import { GuestDrawerHistory, GuestDrawerHistoryRangeSelect } from './GuestDrawerHistory';import { GuestDrawerOverview } from './GuestDrawerOverview';export const GuestDrawer: Component<GuestDrawerProps> = (props) => {- const navigate = useNavigate();const {activeTab,agentLabel,@@ -25,13 +23,14 @@ export const GuestDrawer: Component<GuestDrawerProps> = (props) => {hasHistorySupport,hasNetworkInterfaces,hasOsInfo,+ historyRange,historyTarget,- infrastructureHref,ipAddresses,guestOsSummary,memoryExtraLines,networkInterfaces,normalizedTags,+ setHistoryRange,switchTab,webInterfaceTargetLabel,} = useGuestDrawerState(props);@@ -43,53 +42,53 @@ export const GuestDrawer: Component<GuestDrawerProps> = (props) => {{props.guest.name} details</h2>{/* Tabs */}- <div class="flex items-center gap-6 border-b border-border px-1 mb-1">- <button- onClick={() => switchTab('overview')}- class={`pb-2 text-sm font-medium transition-colors relative ${- activeTab() === 'overview' ? 'text-blue-600 dark:text-blue-400' : ' hover:text-muted'- }`}- >- Overview- {activeTab() === 'overview' && (- <div class="absolute bottom-0 left-0 right-0 h-0.5 bg-blue-600 dark:bg-blue-400 rounded-t-full" />- )}- </button>- {hasHistorySupport() && (- <button- onClick={() => switchTab('history')}- class={`pb-2 text-sm font-medium transition-colors relative ${- activeTab() === 'history' ? 'text-blue-600 dark:text-blue-400' : ' hover:text-muted'- }`}- >- History- {activeTab() === 'history' && (- <div class="absolute bottom-0 left-0 right-0 h-0.5 bg-blue-600 dark:bg-blue-400 rounded-t-full" />- )}- </button>- )}- {hasDiscoverySupport() && (+ <div class="mb-1 flex items-center justify-between gap-3 border-b border-border px-1">+ <div class="flex items-center gap-6"><button- onClick={() => switchTab('discovery')}+ onClick={() => switchTab('overview')}class={`pb-2 text-sm font-medium transition-colors relative ${- activeTab() === 'discovery' ? 'text-blue-600 dark:text-blue-400' : ' hover:text-muted'+ activeTab() === 'overview' ? 'text-blue-600 dark:text-blue-400' : ' hover:text-muted'}`}>- Discovery- {activeTab() === 'discovery' && (+ Overview+ {activeTab() === 'overview' && (<div class="absolute bottom-0 left-0 right-0 h-0.5 bg-blue-600 dark:bg-blue-400 rounded-t-full" />)}</button>- )}- </div>- <div class="flex justify-end">- <button- type="button"- onClick={() => navigate(infrastructureHref())}- class="inline-flex items-center rounded border border-border bg-surface-alt px-2.5 py-1 text-xs font-medium text-base-content transition-colors hover:bg-surface-hover"- >- Open related infrastructure- </button>+ {hasHistorySupport() && (+ <button+ onClick={() => switchTab('history')}+ class={`pb-2 text-sm font-medium transition-colors relative ${+ activeTab() === 'history' ? 'text-blue-600 dark:text-blue-400' : ' hover:text-muted'+ }`}+ >+ History+ {activeTab() === 'history' && (+ <div class="absolute bottom-0 left-0 right-0 h-0.5 bg-blue-600 dark:bg-blue-400 rounded-t-full" />+ )}+ </button>+ )}+ {hasDiscoverySupport() && (+ <button+ onClick={() => switchTab('discovery')}+ class={`pb-2 text-sm font-medium transition-colors relative ${+ activeTab() === 'discovery'+ ? 'text-blue-600 dark:text-blue-400'+ : ' hover:text-muted'+ }`}+ >+ Discovery+ {activeTab() === 'discovery' && (+ <div class="absolute bottom-0 left-0 right-0 h-0.5 bg-blue-600 dark:bg-blue-400 rounded-t-full" />+ )}+ </button>+ )}+ </div>+ <Show when={hasHistorySupport() && activeTab() === 'history'}>+ <div class="pb-1">+ <GuestDrawerHistoryRangeSelect range={historyRange()} onRangeChange={setHistoryRange} />+ </div>+ </Show></div>{/* Use CSS hidden instead of Show to avoid mount/unmount which causes scroll jumps.@@ -119,7 +118,7 @@ export const GuestDrawer: Component<GuestDrawerProps> = (props) => {{hasHistorySupport() && activeTab() === 'history' && (<div style={{ 'overflow-anchor': 'none' }}>- <GuestDrawerHistory target={historyTarget()} />+ <GuestDrawerHistory target={historyTarget()} range={historyRange()} /></div>)}diff --git a/frontend-modern/src/components/Workloads/GuestDrawerHistory.tsx b/frontend-modern/src/components/Workloads/GuestDrawerHistory.tsxindex 3ec09fc191..e18e75297b 100644--- a/frontend-modern/src/components/Workloads/GuestDrawerHistory.tsx+++ b/frontend-modern/src/components/Workloads/GuestDrawerHistory.tsx@@ -9,7 +9,10 @@ import {type SingleMetricHistoryResponse,} from '@/api/charts';import { filterSelectClass } from '@/components/shared/FilterToolbar';-import { HISTORY_CHART_RANGES } from '@/components/shared/historyChartModel';+import {+ HISTORY_CHART_RANGES,+ formatHistoryChartTimeLabel,+} from '@/components/shared/historyChartModel';import { createNonSuspendingQuery } from '@/hooks/createNonSuspendingQuery';import { isRangeLocked, loadRuntimeCapabilities, maxHistoryDays } from '@/stores/license';@@ -26,9 +29,15 @@ import {} from './guestDrawerModel';interface GuestDrawerHistoryProps {+ range: HistoryTimeRange;target: GuestDrawerHistoryTarget | null;}+interface GuestDrawerHistoryRangeSelectProps {+ onRangeChange: (range: HistoryTimeRange) => void;+ range: HistoryTimeRange;+}+interface GuestDrawerHistoryQueryKey {resourceType: ResourceType;resourceId: string;@@ -39,12 +48,17 @@ interface GuestDrawerHistoryGroupChartProps {group: GuestDrawerHistoryGroupConfig;loading: boolean;metrics: Record<string, AggregatedMetricPoint[] | undefined>;+ range: HistoryTimeRange;}const GUEST_DRAWER_HISTORY_MAX_POINTS = 240;const GUEST_DRAWER_HISTORY_POLL_MS = 30_000;const GUEST_DRAWER_HISTORY_CHART_WIDTH = 360;const GUEST_DRAWER_HISTORY_CHART_HEIGHT = 92;+const GUEST_DRAWER_HISTORY_PLOT_LEFT = 34;+const GUEST_DRAWER_HISTORY_PLOT_RIGHT = 8;+const GUEST_DRAWER_HISTORY_PLOT_TOP = 8;+const GUEST_DRAWER_HISTORY_PLOT_BOTTOM = 18;const EMPTY_HISTORY_RESPONSE: AllMetricsHistoryResponse = {resourceType: '',@@ -73,6 +87,27 @@ const formatRangeLabel = (range: HistoryTimeRange): string => {}};+export const GuestDrawerHistoryRangeSelect: Component<GuestDrawerHistoryRangeSelectProps> = (+ props,+) => (+ <>+ <label class="sr-only" for="guest-history-range">+ History range+ </label>+ <select+ id="guest-history-range"+ class={`${filterSelectClass} h-7 py-0 text-[11px]`}+ data-testid="guest-history-range-control"+ value={props.range}+ onChange={(event) => props.onRangeChange(event.currentTarget.value as HistoryTimeRange)}+ >+ <For each={HISTORY_CHART_RANGES}>+ {(option) => <option value={option}>{formatRangeLabel(option)}</option>}+ </For>+ </select>+ </>+);+const normalizeHistoryResponse = (result: SingleMetricHistoryResponse | AllMetricsHistoryResponse,): AllMetricsHistoryResponse => {@@ -99,7 +134,51 @@ const getAxisLabel = (unit: string, pct: number): string => {return '0';};+const clampNumber = (value: number, min: number, max: number): number =>+ Math.min(Math.max(value, min), max);++const getGuestDrawerHistoryX = (timestamp: number, startTime: number, endTime: number): number => {+ const plotWidth =+ GUEST_DRAWER_HISTORY_CHART_WIDTH -+ GUEST_DRAWER_HISTORY_PLOT_LEFT -+ GUEST_DRAWER_HISTORY_PLOT_RIGHT;+ const timeSpan = Math.max(1, endTime - startTime);+ return GUEST_DRAWER_HISTORY_PLOT_LEFT + ((timestamp - startTime) / timeSpan) * plotWidth;+};++const getGuestDrawerHistoryY = (+ value: number,+ scale: { minValue: number; maxValue: number },+): number => {+ const plotHeight =+ GUEST_DRAWER_HISTORY_CHART_HEIGHT -+ GUEST_DRAWER_HISTORY_PLOT_TOP -+ GUEST_DRAWER_HISTORY_PLOT_BOTTOM;+ const valueSpan = Math.max(1, scale.maxValue - scale.minValue);+ const bounded = clampNumber(value, scale.minValue, scale.maxValue);+ return GUEST_DRAWER_HISTORY_PLOT_TOP + (1 - (bounded - scale.minValue) / valueSpan) * plotHeight;+};++const findClosestGuestDrawerHistoryPoint = (+ points: readonly AggregatedMetricPoint[],+ timestamp: number,+): AggregatedMetricPoint | null => {+ if (points.length === 0) return null;++ let closest = points[0];+ let closestDistance = Math.abs(points[0].timestamp - timestamp);+ for (const point of points.slice(1)) {+ const distance = Math.abs(point.timestamp - timestamp);+ if (distance < closestDistance) {+ closest = point;+ closestDistance = distance;+ }+ }+ return closest;+};+const GuestDrawerHistoryGroupChart: Component<GuestDrawerHistoryGroupChartProps> = (props) => {+ const [hoverTimestamp, setHoverTimestamp] = createSignal<number | null>(null);const series = createMemo(() =>props.group.series.map((config) => ({...config,@@ -110,6 +189,62 @@ const GuestDrawerHistoryGroupChart: Component<GuestDrawerHistoryGroupChartProps>const scale = createMemo(() => getGuestDrawerHistoryScale(series(), props.group.unit));const bounds = createMemo(() => getGuestDrawerHistoryRangeBounds(series()));const hasDrawableData = createMemo(() => drawableSeries().length > 0 && bounds() !== null);+ const hoveredSeries = createMemo(() => {+ const timestamp = hoverTimestamp();+ const rangeBounds = bounds();+ if (timestamp === null || !rangeBounds) return [];++ return drawableSeries()+ .map((item) => {+ const point = findClosestGuestDrawerHistoryPoint(item.points, timestamp);+ if (!point) return null;+ return {+ ...item,+ point,+ x: getGuestDrawerHistoryX(point.timestamp, rangeBounds.startTime, rangeBounds.endTime),+ y: getGuestDrawerHistoryY(point.value, scale()),+ };+ })+ .filter((item): item is NonNullable<typeof item> => item !== null);+ });+ const hoverX = createMemo(() => hoveredSeries()[0]?.x ?? null);+ const hoveredByMetric = createMemo(() => {+ const byMetric = new Map<string, ReturnType<typeof hoveredSeries>[number]>();+ for (const item of hoveredSeries()) {+ byMetric.set(item.metric, item);+ }+ return byMetric;+ });+ const displaySeries = createMemo(() =>+ series().map((item) => {+ const hovered = hoveredByMetric().get(item.metric);+ return {+ ...item,+ displayPoints: hovered ? [hovered.point] : item.points,+ };+ }),+ );+ const hoverTimeLabel = createMemo(() => {+ const point = hoveredSeries()[0]?.point;+ return point ? formatHistoryChartTimeLabel(point.timestamp, props.range) : '';+ });++ const handleHoverMove = (event: MouseEvent & { currentTarget: SVGSVGElement }) => {+ const rangeBounds = bounds();+ if (!rangeBounds) return;++ const rect = event.currentTarget.getBoundingClientRect();+ if (rect.width <= 0) return;++ const pointerX = ((event.clientX - rect.left) / rect.width) * GUEST_DRAWER_HISTORY_CHART_WIDTH;+ const plotRight = GUEST_DRAWER_HISTORY_CHART_WIDTH - GUEST_DRAWER_HISTORY_PLOT_RIGHT;+ const clampedX = clampNumber(pointerX, GUEST_DRAWER_HISTORY_PLOT_LEFT, plotRight);+ const plotWidth = plotRight - GUEST_DRAWER_HISTORY_PLOT_LEFT;+ const ratio = (clampedX - GUEST_DRAWER_HISTORY_PLOT_LEFT) / Math.max(1, plotWidth);+ setHoverTimestamp(+ rangeBounds.startTime + ratio * (rangeBounds.endTime - rangeBounds.startTime),+ );+ };return (<section@@ -118,18 +253,30 @@ const GuestDrawerHistoryGroupChart: Component<GuestDrawerHistoryGroupChartProps>data-history-group={props.group.id}><div class="mb-2 flex flex-wrap items-start justify-between gap-x-4 gap-y-1">- <h4 class="text-xs font-semibold uppercase tracking-wide text-muted">- {props.group.label}- </h4>+ <div class="inline-flex items-baseline gap-2">+ <h4 class="text-xs font-semibold uppercase tracking-wide text-muted">+ {props.group.label}+ </h4>+ <Show when={hoverTimeLabel()}>+ {(label) => (+ <span+ class="text-[10px] font-semibold tabular-nums text-base-content"+ data-testid="guest-history-hover-time"+ >+ {label()}+ </span>+ )}+ </Show>+ </div><div class="flex flex-wrap justify-end gap-x-3 gap-y-1 text-[11px] text-muted">- <For each={series()}>+ <For each={displaySeries()}>{(item) => (<span class="inline-flex items-center gap-1"><svg aria-hidden="true" class="h-2.5 w-2.5 shrink-0" viewBox="0 0 10 10"><circle cx="5" cy="5" r="4" fill={item.color} /></svg><span class="font-medium text-base-content">{item.label}</span>- <span>{getGuestDrawerHistoryValueLabel(item.points, item.unit)}</span>+ <span>{getGuestDrawerHistoryValueLabel(item.displayPoints, item.unit)}</span></span>)}</For>@@ -150,7 +297,11 @@ const GuestDrawerHistoryGroupChart: Component<GuestDrawerHistoryGroupChartProps></For><svgaria-label={`${props.group.label} history`}- class="absolute inset-0 h-full w-full"+ class="absolute inset-0 h-full w-full cursor-crosshair"+ data-testid="guest-history-plot"+ onMouseMove={handleHoverMove}+ onPointerLeave={() => setHoverTimestamp(null)}+ onPointerMove={handleHoverMove}preserveAspectRatio="none"role="img"viewBox={`0 0 ${GUEST_DRAWER_HISTORY_CHART_WIDTH} ${GUEST_DRAWER_HISTORY_CHART_HEIGHT}`}@@ -193,6 +344,33 @@ const GuestDrawerHistoryGroupChart: Component<GuestDrawerHistoryGroupChartProps></For>)}</Show>+ <Show when={hoverX() !== null && hoveredSeries().length > 0}>+ <line+ x1={hoverX() ?? 0}+ x2={hoverX() ?? 0}+ y1={GUEST_DRAWER_HISTORY_PLOT_TOP}+ y2={GUEST_DRAWER_HISTORY_CHART_HEIGHT - GUEST_DRAWER_HISTORY_PLOT_BOTTOM}+ stroke="currentColor"+ stroke-dasharray="3 3"+ stroke-width="1"+ class="text-base-content/50"+ vector-effect="non-scaling-stroke"+ />+ <For each={hoveredSeries()}>+ {(item) => (+ <circle+ cx={item.x}+ cy={item.y}+ fill={item.color}+ r="3"+ stroke="currentColor"+ stroke-width="1"+ class="text-surface"+ vector-effect="non-scaling-stroke"+ />+ )}+ </For>+ </Show></svg><Show when={!hasDrawableData() && !props.loading}><div class="absolute inset-x-8 inset-y-2 flex items-center justify-center rounded-sm bg-surface/80 text-xs text-muted">@@ -210,13 +388,11 @@ const GuestDrawerHistoryGroupChart: Component<GuestDrawerHistoryGroupChartProps>};export const GuestDrawerHistory: Component<GuestDrawerHistoryProps> = (props) => {- const [range, setRange] = createSignal<HistoryTimeRange>(GUEST_DRAWER_HISTORY_DEFAULT_RANGE);-onMount(() => {void loadRuntimeCapabilities();});- const locked = createMemo(() => isRangeLocked(range()));+ const locked = createMemo(() => isRangeLocked(props.range));const historyQuery = createNonSuspendingQuery<AllMetricsHistoryResponse,GuestDrawerHistoryQueryKey@@ -227,7 +403,7 @@ export const GuestDrawerHistory: Component<GuestDrawerHistoryProps> = (props) =>return {resourceType: target.resourceType,resourceId: target.resourceId,- range: range(),+ range: props.range,};},fetcher: async (key) =>@@ -253,28 +429,12 @@ export const GuestDrawerHistory: Component<GuestDrawerHistoryProps> = (props) =>fallback={<div class="py-6 text-center text-sm text-muted">History unavailable</div>}><div class="space-y-3">- <div class="flex items-center justify-end">- <label class="sr-only" for="guest-history-range">- History range- </label>- <select- id="guest-history-range"- class={filterSelectClass}- value={range()}- onChange={(event) => setRange(event.currentTarget.value as HistoryTimeRange)}- >- <For each={HISTORY_CHART_RANGES}>- {(option) => <option value={option}>{formatRangeLabel(option)}</option>}- </For>- </select>- </div>-<Showwhen={!locked()}fallback={<div class="rounded-sm border border-border bg-surface p-5 text-sm text-muted">- {formatRangeLabel(range())} history is not enabled on this instance. Current runtime- allows {maxHistoryDays()} days.+ {formatRangeLabel(props.range)} history is not enabled on this instance. Current+ runtime allows {maxHistoryDays()} days.</div>}>@@ -293,6 +453,7 @@ export const GuestDrawerHistory: Component<GuestDrawerHistoryProps> = (props) =>group={group}loading={historyQuery.loading() && !historyQuery.resolvedOnce()}metrics={metrics()}+ range={props.range}/>)}</For>diff --git a/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.performance.contract.test.tsx b/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.performance.contract.test.tsxindex 4d9f5943d0..19990155ac 100644--- a/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.performance.contract.test.tsx+++ b/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.performance.contract.test.tsx@@ -48,6 +48,7 @@ import metricBarSource from '../MetricBar.tsx?raw';import metricBarModelSource from '../metricBarModel.ts?raw';import metricBarStateSource from '../useMetricBarState.ts?raw';import guestDrawerSource from '../GuestDrawer.tsx?raw';+import guestDrawerHistorySource from '../GuestDrawerHistory.tsx?raw';import guestDrawerOverviewSource from '../GuestDrawerOverview.tsx?raw';import guestDrawerModelSource from '../guestDrawerModel.ts?raw';import guestRowSource from '../GuestRow.tsx?raw';@@ -1050,13 +1051,19 @@ describe('Workloads performance contract', () => {it('keeps guest drawer runtime and derivations in canonical drawer owners', () => {expect(guestDrawerSource).toContain('useGuestDrawerState');expect(guestDrawerSource).toContain('GuestDrawerOverview');+ expect(guestDrawerSource).toContain('GuestDrawerHistoryRangeSelect');+ expect(guestDrawerSource).not.toContain('Open related infrastructure');+ expect(guestDrawerHistorySource).toContain('data-testid="guest-history-hover-time"');+ expect(guestDrawerHistorySource).toContain('data-testid="guest-history-range-control"');+ expect(guestDrawerHistorySource).toContain('onPointerMove={handleHoverMove}');expect(guestDrawerSource).not.toContain('const guestId = () =>');expect(guestDrawerSource).not.toContain('const infrastructureHref = () =>');expect(guestDrawerSource).not.toContain('Filesystems');expect(guestDrawerSource).not.toContain('WebInterfaceUrlField');expect(guestDrawerStateSource).toContain('getCanonicalWorkloadId');- expect(guestDrawerStateSource).toContain('buildInfrastructureHrefForWorkload');- expect(guestDrawerStateSource).toContain("from '@/routing/resourceLinks'");+ expect(guestDrawerStateSource).toContain('historyRange');+ expect(guestDrawerStateSource).not.toContain('buildInfrastructureHrefForWorkload');+ expect(guestDrawerStateSource).not.toContain("from '@/routing/resourceLinks'");expect(guestDrawerStateSource).toContain("from './workloadTopology'");expect(guestDrawerStateSource).not.toContain('./infrastructureLink');expect(guestDrawerStateSource).toContain('getDiscoveryResourceTypeForWorkload');diff --git a/frontend-modern/src/components/Workloads/useGuestDrawerState.ts b/frontend-modern/src/components/Workloads/useGuestDrawerState.tsindex 6b11866085..32ed09c147 100644--- a/frontend-modern/src/components/Workloads/useGuestDrawerState.ts+++ b/frontend-modern/src/components/Workloads/useGuestDrawerState.ts@@ -1,5 +1,6 @@import { createEffect, createMemo, createSignal } from 'solid-js';+import type { HistoryTimeRange } from '@/api/charts';import { useAlertsActivation } from '@/stores/alertsActivation';import { getDiscoveryLoadingState } from '@/utils/discoveryPresentation';import type { DisplayMetricType } from '@/utils/metricThresholds';@@ -9,7 +10,6 @@ import {hasDiscoverySupportForWorkload,getWebInterfaceTargetLabelForWorkload,} from '@/utils/workloads';-import { buildInfrastructureHrefForWorkload } from '@/routing/resourceLinks';import {getDiscoveryHostIdForWorkload,@@ -21,6 +21,7 @@ import {getGuestDrawerAgentLabel,getGuestDrawerAgentTitle,getGuestDrawerBackupPresentation,+ GUEST_DRAWER_HISTORY_DEFAULT_RANGE,getGuestDrawerHistoryTarget,getGuestDrawerMemoryExtraLines,getGuestDrawerNetworkInterfaces,@@ -34,6 +35,9 @@ import {export function useGuestDrawerState(props: GuestDrawerProps) {const alertsActivation = useAlertsActivation();const [activeTab, setActiveTab] = createSignal<GuestDrawerTab>('overview');+ const [historyRange, setHistoryRange] = createSignal<HistoryTimeRange>(+ GUEST_DRAWER_HISTORY_DEFAULT_RANGE,+ );const guestId = createMemo(() => getCanonicalWorkloadId(props.guest));const alertThresholdScope = createMemo(() => getWorkloadAlertThresholdScope(props.guest));@@ -49,7 +53,6 @@ export function useGuestDrawerState(props: GuestDrawerProps) {),);const diskThresholds = metricThresholds('disk');- const infrastructureHref = createMemo(() => buildInfrastructureHrefForWorkload(props.guest));const osName = createMemo(() => props.guest.osName || '');const osVersion = createMemo(() => props.guest.osVersion || '');const guestOsSummary = createMemo(() => {@@ -113,7 +116,7 @@ export function useGuestDrawerState(props: GuestDrawerProps) {hasNetworkInterfaces,hasOsInfo,historyTarget,- infrastructureHref,+ historyRange,ipAddresses,memoryExtraLines,networkInterfaces,@@ -121,6 +124,7 @@ export function useGuestDrawerState(props: GuestDrawerProps) {osName,osVersion,switchTab,+ setHistoryRange,webInterfaceTargetLabel,};}