Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

Band and fold the storage History charts like the drawer charts

rcourtman8ae88cb6d184
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 52d585bf47..348cfb0b54 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -9205,6 +9205,16 @@ once, not on two gridlines, and the gridline itself stays. The end labels
always remain. `guest-storage-2263.cjs` records each chart's drawn time
labels and checks they stand apart; `pbs-history-refresh.cjs` checks the
drawer's network axis.
+The canvas `HistoryChart` draws the same min-max band the drawer charts do:
+when any bucket's lowest and highest readings differ
+(`hasHistoryChartSpread`), a 20% band spans them behind the line, so a short
+spike survives downsampling. It no longer fills the area under the line, so a
+storage chart reads like a drawer chart; a flat series is a line alone. A
+time label that repeats the one before it (a short window at a coarse label)
+is dropped (`withoutRepeatedHistoryTimeTicks`). Phone chart folds share one
+button, `PhoneChartsToggle` ("Show <names>" / "Show fewer charts",
+`aria-controls` naming the folded group, hidden from `sm` up); the drawer
+History and the disk detail both use it.
### Shared History single observations
diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
index 598f3cbaee..3b0a740a52 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -4032,7 +4032,8 @@ unchanged and "Retry history" still appears for a failed read. Its focus
handoff reads `document.activeElement` once, as the Retry branch is disposed.
Repeated gridline labels are blanked from the three labels each panel already
formats, and the canvas chart measures the time labels it already draws to
-choose how many fit. None adds a read or timer.
+choose how many fit. None adds a read or timer. The disk detail's phone fold
+removes reads rather than adding them: folded charts stay paused until opened.
The default stored-history legend resolves one latest timestamp from that
same bounded, normalized panel index, then looks up each configured series at
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 5368b5471a..7cd5d01485 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -2886,6 +2886,13 @@ canonical pre-handler authorization proof covering both transfer routes.
A disk detail mounted where it can be hidden (a guest drawer's Overview
behind Manage) takes `historyEnabled` and passes it to every chart,
history and live I/O alike, so a hidden disk reads nothing.
+ Below the `sm` breakpoint a disk detail shows its first History chart
+ and any chart whose SMART card is out of bounds (cards and charts share
+ labels, `getDiskDetailPhonePinnedChartLabels`); the remaining History
+ charts and the whole Live I/O section fold behind the shared
+ `PhoneChartsToggle`. A pinned chart stays pinned after its card recovers.
+ Folded charts read nothing until the toggle opens them; wider layouts
+ show and read every chart. Its charts draw the shared min-max band.
Storage-page pool growth readouts belong to that same contract: the table
may derive per-pool used-capacity deltas from the shared
`/api/storage-charts` summary payload, but it must not fan out row-local
diff --git a/frontend-modern/browser-tests/disk-history-collection.cjs b/frontend-modern/browser-tests/disk-history-collection.cjs
index 55e44ccd8c..6ae1fad795 100644
--- a/frontend-modern/browser-tests/disk-history-collection.cjs
+++ b/frontend-modern/browser-tests/disk-history-collection.cjs
@@ -137,6 +137,12 @@ const parent = false;
// Disk details have no tabs: SMART evidence, then History, in one view.
const historySection = page.getByTestId('disk-detail-history');
await historySection.waitFor();
+ // A phone folds every chart after the first behind one button; open it,
+ // as a reader inspecting the disk's history would.
+ if (phone) {
+ const fold = page.getByTestId('disk-detail-phone-toggle');
+ if (await fold.isVisible()) await fold.click();
+ }
await page.waitForTimeout(300);
await check('Stored ATA history is accessible before any current fields', async () => {
assert.equal(await page.locator('canvas[role="img"]').count(), 2);
diff --git a/frontend-modern/browser-tests/guest-storage-2263.cjs b/frontend-modern/browser-tests/guest-storage-2263.cjs
index 65dcf2b55f..5167f75cbc 100644
--- a/frontend-modern/browser-tests/guest-storage-2263.cjs
+++ b/frontend-modern/browser-tests/guest-storage-2263.cjs
@@ -95,11 +95,12 @@ const { chromium } = require('playwright');
start: end - 600_000,
end,
source: 'store',
+ // Disk reads spike inside their buckets; every other series is flat.
points: [0, 1, 2].map((i) => ({
timestamp: end - (2 - i) * 300_000,
value: 40 + i,
- min: 40 + i,
- max: 40 + i,
+ min: q.get('metric') === 'diskread' ? 10 + i : 40 + i,
+ max: q.get('metric') === 'diskread' ? 90 + i : 40 + i,
})),
},
});
@@ -122,10 +123,16 @@ const { chromium } = require('playwright');
const proto = CanvasRenderingContext2D.prototype;
const clear = proto.clearRect;
const fill = proto.fillText;
+ const fillShape = proto.fill;
proto.clearRect = function (...args) {
this.canvas.__labels = [];
+ this.canvas.__fills = [];
return clear.apply(this, args);
};
+ proto.fill = function (...args) {
+ (this.canvas.__fills ||= []).push(String(this.fillStyle));
+ return fillShape.apply(this, args);
+ };
proto.fillText = function (text, x, y, ...rest) {
(this.canvas.__labels ||= []).push({
text: String(text),
@@ -196,6 +203,62 @@ const { chromium } = require('playwright');
// with no Overview/History tabs to switch between.
assert.equal(await page.getByRole('tab').count(), 0);
assert.equal(await page.getByTestId('disk-detail-history').isVisible(), true);
+ const visibleCharts = () =>
+ page.evaluate(() =>
+ Array.from(document.querySelectorAll('canvas'))
+ .filter((canvas) => canvas.clientWidth > 0)
+ .map((canvas) => canvas.getAttribute('aria-label')),
+ );
+ const phoneToggle = page.getByTestId('disk-detail-phone-toggle');
+ if (width === 390) {
+ // A phone shows the first chart; the rest fold behind one button and
+ // read nothing until it is pressed.
+ assert.deepEqual(await visibleCharts(), ['Temperature chart']);
+ assert.equal(
+ await phoneToggle.innerText(),
+ 'Show Reallocated Sectors, Read, Write, Busy',
+ );
+ assert.deepEqual(
+ [...new Set(historyReads.filter((r) => r.width === width).map((r) => r.metric))],
+ ['smart_temp'],
+ );
+ await page.screenshot({
+ path: path.join(artifacts, `guest-storage-2263-phone-folded-${width}.png`),
+ fullPage: true,
+ });
+ const unfolded = page.waitForRequest((request) =>
+ request.url().includes('metric=diskread'),
+ );
+ await phoneToggle.click();
+ await unfolded;
+ assert.equal(await phoneToggle.getAttribute('aria-expanded'), 'true');
+ assert.equal(await phoneToggle.innerText(), 'Show fewer charts');
+ await page.getByRole('img', { name: 'Read chart' }).waitFor();
+ await page.waitForTimeout(300);
+ } else {
+ assert.equal(await phoneToggle.isVisible(), false, 'no fold above the phone breakpoint');
+ }
+ assert.equal((await visibleCharts()).length, 5);
+ // Spiky disk reads draw a min-max band behind their line; flat series do not.
+ // The canvas reports the band's 20%-alpha fill back as rgba(..., 0.2).
+ const fills = await page.evaluate(() =>
+ Object.fromEntries(
+ Array.from(document.querySelectorAll('canvas'), (canvas) => [
+ canvas.getAttribute('aria-label'),
+ canvas.__fills || [],
+ ]),
+ ),
+ );
+ assert.ok(
+ fills['Read chart'].some((fill) => /, 0\.2\)$/.test(fill)),
+ `Read chart band: ${JSON.stringify(fills['Read chart'])}`,
+ );
+ for (const flat of ['Temperature chart', 'Write chart', 'Busy chart']) {
+ assert.ok(
+ !fills[flat].some((fill) => /, 0\.2\)$/.test(fill)),
+ `${flat} must not draw a band: ${JSON.stringify(fills[flat])}`,
+ );
+ }
// Each chart's time labels stand apart, however narrow its card.
const timeLabels = await page.evaluate(() =>
Array.from(document.querySelectorAll('canvas'), (canvas) => ({
diff --git a/frontend-modern/browser-tests/history-touch.cjs b/frontend-modern/browser-tests/history-touch.cjs
index 09d84fd7af..abb8a8706c 100644
--- a/frontend-modern/browser-tests/history-touch.cjs
+++ b/frontend-modern/browser-tests/history-touch.cjs
@@ -64,6 +64,8 @@ const { chromium, webkit } = require('playwright');
if (dark) await page.evaluate(() => document.documentElement.classList.add('dark'));
const disk = page.getByRole('region', { name: 'Disk fixture' });
const pool = page.getByRole('region', { name: 'Pool fixture' });
+ // A phone folds the disk's charts after the first behind one button.
+ if (touch) await disk.getByTestId('disk-detail-phone-toggle').click();
const busy = disk.getByRole('img', { name: 'Busy chart', exact: true });
const description = chart => chart.evaluate(el => document.getElementById(el.getAttribute('aria-describedby')).textContent);
await page.waitForFunction(() => [...document.querySelectorAll('canvas')].some(el => el.getAttribute('aria-label') === 'Busy chart' && document.getElementById(el.getAttribute('aria-describedby')).textContent.includes('3 data points')));
diff --git a/frontend-modern/browser-verification/8f7358ada5585f26.json b/frontend-modern/browser-verification/8f7358ada5585f26.json
new file mode 100644
index 0000000000..3f0373c9d3
--- /dev/null
+++ b/frontend-modern/browser-verification/8f7358ada5585f26.json
@@ -0,0 +1,56 @@
+{
+ "version": 1,
+ "base_sha": "dc92693a2b7771a033ace97ff5512b7f34742a43",
+ "verified_at": "2026-10-14T11:52:00Z",
+ "result": "passed",
+ "changed_paths": [
+ "frontend-modern/src/components/Storage/DiskDetail.tsx",
+ "frontend-modern/src/components/Workloads/GuestDrawerHistory.tsx",
+ "frontend-modern/src/components/shared/PhoneChartsToggle.tsx",
+ "frontend-modern/src/components/shared/historyChartModel.ts",
+ "frontend-modern/src/components/shared/useHistoryChartState.ts",
+ "frontend-modern/src/features/storageBackups/diskDetailPresentation.ts"
+ ],
+ "content_sha256": {
+ "frontend-modern/src/components/Storage/DiskDetail.tsx": "03b1d6f65d32aac6bc5f55886fde0bf06fe94953db3eccbd738d7d4760000428",
+ "frontend-modern/src/components/Workloads/GuestDrawerHistory.tsx": "c48d4a7e5415ffe1d0f15607540c4588c985b06c0c32be83d67c86e29d13a0ea",
+ "frontend-modern/src/components/shared/PhoneChartsToggle.tsx": "95e68032c8b3e1b849f4334706ce3ef1f4a9dc6a2b8bccc9cf9582e7b6972923",
+ "frontend-modern/src/components/shared/historyChartModel.ts": "a53a10b572139188cca59efc326861da19795d33f3564d44490d29f69d856d62",
+ "frontend-modern/src/components/shared/useHistoryChartState.ts": "1a8760b01b853000a3ee22f333ad35bb5aa44b8dbdaceaed8b6104ab5803d723",
+ "frontend-modern/src/features/storageBackups/diskDetailPresentation.ts": "e72d7faa6e8c014c3e530a0c3b4c5c7f34572b78412b46cead334b261690731b"
+ },
+ "routes": [
+ "/browser-tests/guest-storage-2263.html (production GuestDrawerOverview disk detail, Chromium via Playwright 1.56.1 on pulse-dev)",
+ "/browser-tests/history-touch.html (production DiskDetail and StoragePoolDetail, Chromium and WebKit phones)",
+ "/browser-tests/disk-history-collection.html",
+ "/browser-tests/pool-ownership.html"
+ ],
+ "viewports": [
+ {
+ "width": 1440,
+ "height": 900
+ },
+ {
+ "width": 1365,
+ "height": 900
+ },
+ {
+ "width": 390,
+ "height": 844
+ }
+ ],
+ "states": [
+ "desktop disk detail: spiky disk reads draw a min-max band behind the line; flat Temperature, Write and Busy draw a line only, no area fill",
+ "phone disk detail: only Temperature shows and reads; \"Show Reallocated Sectors, Read, Write, Busy\" folds the rest, which read nothing",
+ "phone fold opened: all five charts read and show; button reads \"Show fewer charts\"",
+ "short windows state each time label once (11:00 AM, 11:01 AM, 11:02 AM; Oct 2 once)",
+ "pool capacity trend as a line; touch inspection, zero singleton and empty states",
+ "disk History collection states with the fold opened on a phone"
+ ],
+ "interactions": [
+ "phone fold toggle open",
+ "touch and pointer inspection on disk and pool charts",
+ "disk expand, Hide/Show overview, viewport resize",
+ "range changes on disk and pool pickers"
+ ]
+}
diff --git a/frontend-modern/src/components/Storage/DiskDetail.tsx b/frontend-modern/src/components/Storage/DiskDetail.tsx
index a68b196aaf..7473a4f697 100644
--- a/frontend-modern/src/components/Storage/DiskDetail.tsx
+++ b/frontend-modern/src/components/Storage/DiskDetail.tsx
@@ -1,8 +1,18 @@
-import { Component, For, Show, createEffect, createMemo } from 'solid-js';
+import {
+ Component,
+ For,
+ Show,
+ createEffect,
+ createMemo,
+ createSignal,
+ createUniqueId,
+} from 'solid-js';
import type { Resource } from '@/types/resource';
import { FormSelect } from '@/components/shared/FormSelect';
import { filterSelectClass } from '@/components/shared/FilterToolbar';
import { HistoryChart, HistoryChartHoverGroup } from '@/components/shared/HistoryChart';
+import { PhoneChartsToggle } from '@/components/shared/PhoneChartsToggle';
+import { useBreakpoint } from '@/hooks/useBreakpoint';
import type { HistoryTimeRange } from '@/api/charts';
import { maxHistoryDays } from '@/stores/license';
import {
@@ -19,6 +29,7 @@ import {
getDiskAttributeCardValueTextClass,
getDiskDetailHistoryFallbackMessage,
getDiskDetailLiveBadgeLabel,
+ getDiskDetailPhonePinnedChartLabels,
} from '@/features/storageBackups/diskDetailPresentation';
import {
STORAGE_DETAIL_BADGE_CLASS,
@@ -75,6 +86,31 @@ export const DiskDetail: Component<DiskDetailProps> = (props) => {
() => collectionMessages().length > 0 || attributeCards().length > 0,
);
+ // On a phone five stacked charts push everything after them off screen: show
+ // the first chart and any whose SMART card is out of bounds, fold the rest
+ // behind one button. A pinned chart stays pinned after its card recovers, so
+ // a reader mid-inspection does not lose it. Folded charts read nothing.
+ const { isBelow } = useBreakpoint();
+ const chartsId = createUniqueId();
+ const [showAllOnPhone, setShowAllOnPhone] = createSignal(false);
+ const pinnedLabels = new Set<string>();
+ const phonePinned = createMemo(() => {
+ for (const label of getDiskDetailPhonePinnedChartLabels(historyCharts(), attributeCards())) {
+ pinnedLabels.add(label);
+ }
+ return new Set(pinnedLabels);
+ });
+ const foldedOnPhone = (label: string) => !showAllOnPhone() && !phonePinned().has(label);
+ const showLiveIO = () => Boolean(metricResourceId() && liveIOAvailable());
+ const phoneFoldedLabels = createMemo(() =>
+ [
+ ...historyCharts().map((chart) => chart.label),
+ ...(showLiveIO() ? DISK_DETAIL_LIVE_CHARTS.map((chart) => chart.label) : []),
+ ].filter(foldedOnPhone),
+ );
+ const chartReads = (label: string) =>
+ props.historyEnabled !== false && !(isBelow('sm') && foldedOnPhone(label));
+
createEffect(() => {
const nextRange = resolveHistoryRangeWithinLimit(
chartRange(),
@@ -120,7 +156,7 @@ export const DiskDetail: Component<DiskDetailProps> = (props) => {
{/* One view: the SMART evidence behind the health verdict, then its
trend and live I/O. There is no separate History tab. */}
- <div class="space-y-3">
+ <div id={chartsId} class="space-y-3">
<Show when={collectionMessages().length > 0}>
<div class={STORAGE_DETAIL_EMPTY_CLASS} role="status">
<For each={collectionMessages()}>{(message) => <p>{message}</p>}</For>
@@ -173,7 +209,10 @@ export const DiskDetail: Component<DiskDetailProps> = (props) => {
<div class={STORAGE_DISK_DETAIL_HISTORY_GRID_CLASS}>
<For each={historyCharts()}>
{(chart) => (
- <div class={STORAGE_DETAIL_CARD_CLASS}>
+ <div
+ class={`${STORAGE_DETAIL_CARD_CLASS} ${foldedOnPhone(chart.label) ? 'max-sm:hidden' : ''}`}
+ data-phone-collapsed={foldedOnPhone(chart.label) ? 'true' : undefined}
+ >
<HistoryChart
resourceType="disk"
resourceId={historyResourceId()!}
@@ -186,7 +225,7 @@ export const DiskDetail: Component<DiskDetailProps> = (props) => {
hideSelector={true}
compact={true}
hideLock={true}
- enabled={props.historyEnabled}
+ enabled={chartReads(chart.label)}
/>
</div>
)}
@@ -196,8 +235,11 @@ export const DiskDetail: Component<DiskDetailProps> = (props) => {
</div>
</Show>
- <Show when={metricResourceId() && liveIOAvailable()}>
- <div class={STORAGE_DISK_DETAIL_SECTION_CLASS}>
+ <Show when={showLiveIO()}>
+ <div
+ class={`${STORAGE_DISK_DETAIL_SECTION_CLASS} ${showAllOnPhone() ? '' : 'max-sm:hidden'}`}
+ data-phone-collapsed={showAllOnPhone() ? undefined : 'true'}
+ >
<h4
class={`${STORAGE_DETAIL_SECTION_TITLE_CLASS} ${STORAGE_DISK_DETAIL_SECTION_HEADING_CLASS}`}
>
@@ -226,7 +268,7 @@ export const DiskDetail: Component<DiskDetailProps> = (props) => {
hideLock
height={120}
compact={true}
- enabled={props.historyEnabled}
+ enabled={chartReads(chart.label)}
/>
</div>
)}
@@ -235,6 +277,15 @@ export const DiskDetail: Component<DiskDetailProps> = (props) => {
</HistoryChartHoverGroup>
</div>
</Show>
+ <Show when={historyResourceId()}>
+ <PhoneChartsToggle
+ hiddenLabels={phoneFoldedLabels()}
+ expanded={showAllOnPhone()}
+ onToggle={() => setShowAllOnPhone((open) => !open)}
+ controls={chartsId}
+ testId="disk-detail-phone-toggle"
+ />
+ </Show>
</div>
</div>
);
diff --git a/frontend-modern/src/components/Storage/__tests__/DiskDetail.test.tsx b/frontend-modern/src/components/Storage/__tests__/DiskDetail.test.tsx
index 39fe0e0cf3..9f260918bd 100644
--- a/frontend-modern/src/components/Storage/__tests__/DiskDetail.test.tsx
+++ b/frontend-modern/src/components/Storage/__tests__/DiskDetail.test.tsx
@@ -1,4 +1,4 @@
-import { render, screen, within } from '@solidjs/testing-library';
+import { fireEvent, render, screen, within } from '@solidjs/testing-library';
import { createSignal, type JSX } from 'solid-js';
import { describe, expect, it, vi } from 'vitest';
import { DiskDetail } from '@/components/Storage/DiskDetail';
@@ -51,7 +51,77 @@ const buildDisk = (): Resource =>
},
}) as unknown as Resource;
+const atPhoneWidth = (run: () => void) => {
+ const width = window.innerWidth;
+ Object.defineProperty(window, 'innerWidth', { configurable: true, writable: true, value: 390 });
+ try {
+ run();
+ } finally {
+ Object.defineProperty(window, 'innerWidth', {
+ configurable: true,
+ writable: true,
+ value: width,
+ });
+ }
+};
+// metric -> [reads, folded on a phone]
+const chartStates = (): Record<string, [string | undefined, string]> =>
+ Object.fromEntries(
+ screen
+ .getAllByTestId('history-chart')
+ .map((chart) => [
+ chart.textContent!.split(':').at(-2),
+ [
+ chart.dataset.enabled,
+ chart.closest('[data-phone-collapsed="true"]') ? 'folded' : 'shown',
+ ],
+ ]),
+ );
+
describe('DiskDetail', () => {
+ it('shows the first chart on a phone and folds the rest behind one button that stops their reads', () => {
+ atPhoneWidth(() => {
+ render(() => <DiskDetail disk={buildDisk()} nodes={[]} />);
+ expect(chartStates()).toEqual({
+ smart_temp: ['true', 'shown'],
+ smart_reallocated_sectors: ['false', 'folded'],
+ diskread: ['false', 'folded'],
+ diskwrite: ['false', 'folded'],
+ disk: ['false', 'folded'],
+ });
+ const toggle = screen.getByTestId('disk-detail-phone-toggle');
+ expect(toggle).toHaveTextContent('Show Reallocated Sectors, Read, Write, Busy');
+ expect(toggle).toHaveAttribute('aria-expanded', 'false');
+ expect(document.getElementById(toggle.getAttribute('aria-controls')!)).not.toBeNull();
+ fireEvent.click(toggle);
+ expect(new Set(Object.values(chartStates()).map(([reads]) => reads))).toEqual(
+ new Set(['true']),
+ );
+ expect(document.querySelectorAll('[data-phone-collapsed="true"]')).toHaveLength(0);
+ expect(toggle).toHaveTextContent('Show fewer charts');
+ expect(toggle).toHaveAttribute('aria-expanded', 'true');
+ });
+ });
+
+ it('keeps a chart whose SMART card is out of bounds on a phone', () => {
+ const disk = buildDisk();
+ (disk.physicalDisk as { smart: { reallocatedSectors: number } }).smart.reallocatedSectors = 8;
+ atPhoneWidth(() => {
+ render(() => <DiskDetail disk={disk} nodes={[]} />);
+ expect(chartStates().smart_reallocated_sectors).toEqual(['true', 'shown']);
+ expect(screen.getByTestId('disk-detail-phone-toggle')).toHaveTextContent(
+ 'Show Read, Write, Busy',
+ );
+ });
+ });
+
+ it('reads every chart on a wider screen, where the fold does not apply', () => {
+ render(() => <DiskDetail disk={buildDisk()} nodes={[]} />);
+ expect(new Set(Object.values(chartStates()).map(([reads]) => reads))).toEqual(
+ new Set(['true']),
+ );
+ });
+
it('pauses every disk chart when its holder is hidden', () => {
const [shown, setShown] = createSignal(true);
render(() => <DiskDetail disk={buildDisk()} nodes={[]} historyEnabled={shown()} />);
diff --git a/frontend-modern/src/components/Workloads/GuestDrawerHistory.tsx b/frontend-modern/src/components/Workloads/GuestDrawerHistory.tsx
index 0d04bdcc4b..d4f6951377 100644
--- a/frontend-modern/src/components/Workloads/GuestDrawerHistory.tsx
+++ b/frontend-modern/src/components/Workloads/GuestDrawerHistory.tsx
@@ -17,6 +17,7 @@ import { filterSelectClass } from '@/components/shared/FilterToolbar';
import { Button } from '@/components/shared/Button';
import { InlineNotice } from '@/components/shared/InlineNotice';
import { LoadingSpinner } from '@/components/shared/LoadingSpinner';
+import { PhoneChartsToggle } from '@/components/shared/PhoneChartsToggle';
import {
HISTORY_CHART_RANGES,
formatHistoryChartTooltipValue,
@@ -1007,22 +1008,12 @@ export const GuestDrawerHistory: Component<GuestDrawerHistoryProps> = (props) =>
)}
</For>
</div>
- <Show when={phoneCollapsedGroups().length > 0 || showAllOnPhone()}>
- <button
- type="button"
- class="flex min-h-11 w-full items-center justify-center gap-1 rounded-xs border border-border bg-surface px-3 text-xs font-medium text-base-content sm:hidden"
- aria-controls={gridId}
- aria-expanded={showAllOnPhone()}
- data-testid="history-phone-toggle"
- onClick={() => setShowAllOnPhone((open) => !open)}
- >
- {showAllOnPhone()
- ? 'Show fewer charts'
- : `Show ${phoneCollapsedGroups()
- .map((group) => group.label)
- .join(', ')}`}
- </button>
- </Show>
+ <PhoneChartsToggle
+ hiddenLabels={phoneCollapsedGroups().map((group) => group.label)}
+ expanded={showAllOnPhone()}
+ onToggle={() => setShowAllOnPhone((open) => !open)}
+ controls={gridId}
+ />
</Show>
</Show>
</div>
diff --git a/frontend-modern/src/components/Workloads/__tests__/GuestDrawerHistory.inspection.test.tsx b/frontend-modern/src/components/Workloads/__tests__/GuestDrawerHistory.inspection.test.tsx
index f4ba65479e..4d275df80f 100644
--- a/frontend-modern/src/components/Workloads/__tests__/GuestDrawerHistory.inspection.test.tsx
+++ b/frontend-modern/src/components/Workloads/__tests__/GuestDrawerHistory.inspection.test.tsx
@@ -427,6 +427,9 @@ describe('drawer History on a phone', () => {
const toggle = screen.getByTestId('history-phone-toggle');
expect(toggle).toHaveClass('sm:hidden');
expect(toggle).toHaveAttribute('aria-expanded', 'false');
+ // The shared phone toggle controls the grid that holds the folded panels.
+ const grid = document.getElementById(toggle.getAttribute('aria-controls')!)!;
+ expect(grid.querySelectorAll('[data-testid="guest-history-group-chart"]')).toHaveLength(3);
expect(toggle).toHaveTextContent('Show Network I/O, Disk I/O');
fireEvent.click(toggle);
diff --git a/frontend-modern/src/components/shared/PhoneChartsToggle.tsx b/frontend-modern/src/components/shared/PhoneChartsToggle.tsx
new file mode 100644
index 0000000000..29257aeb9d
--- /dev/null
+++ b/frontend-modern/src/components/shared/PhoneChartsToggle.tsx
@@ -0,0 +1,28 @@
+import { Show, type Component } from 'solid-js';
+
+// Below the `sm` breakpoint a stack of charts can push everything after it
+// off the screen, so chart groups show their first chart (plus any carrying
+// a problem) and fold the rest behind this one full-width button. Wider
+// layouts always show every chart and never render it.
+export const PhoneChartsToggle: Component<{
+ /** Names of the charts folded away on a phone, in display order. */
+ hiddenLabels: readonly string[];
+ expanded: boolean;
+ onToggle: () => void;
+ /** Id of the element holding the folded charts. */
+ controls: string;
+ testId?: string;
+}> = (props) => (
+ <Show when={props.hiddenLabels.length > 0 || props.expanded}>
+ <button
+ type="button"
+ class="flex min-h-11 w-full items-center justify-center gap-1 rounded-xs border border-border bg-surface px-3 text-xs font-medium text-base-content sm:hidden"
+ aria-controls={props.controls}
+ aria-expanded={props.expanded}
+ data-testid={props.testId ?? 'history-phone-toggle'}
+ onClick={() => props.onToggle()}
+ >
+ {props.expanded ? 'Show fewer charts' : `Show ${props.hiddenLabels.join(', ')}`}
+ </button>
+ </Show>
+);
diff --git a/frontend-modern/src/components/shared/__tests__/HistoryChart.test.tsx b/frontend-modern/src/components/shared/__tests__/HistoryChart.test.tsx
index bf1f92255b..cdc7a68c54 100644
--- a/frontend-modern/src/components/shared/__tests__/HistoryChart.test.tsx
+++ b/frontend-modern/src/components/shared/__tests__/HistoryChart.test.tsx
@@ -18,8 +18,10 @@ import {
getHistoryChartTimeTickCount,
getHistoryChartTooltipLayout,
getHistoryChartYAxisLabels,
+ hasHistoryChartSpread,
HISTORY_CHART_RANGES,
withoutRepeatedHistoryAxisLabels,
+ withoutRepeatedHistoryTimeTicks,
} from '@/components/shared/historyChartModel';
it('distinguishes tiny positive percentage observations from zero in History labels', () => {
@@ -129,6 +131,85 @@ vi.mock('@/api/charts', () => ({
},
}));
+describe('History chart min-max band', () => {
+ const at = (timestamp: number, value: number, min = value, max = value) => ({
+ timestamp,
+ value,
+ min,
+ max,
+ });
+
+ it("spreads only when a bucket's lowest and highest readings differ", () => {
+ expect(hasHistoryChartSpread([at(1, 5), at(2, 6)])).toBe(false);
+ expect(hasHistoryChartSpread([at(1, 5), at(2, 6, 2, 30)])).toBe(true);
+ expect(hasHistoryChartSpread([at(1, 5, 2, 30)])).toBe(false);
+ });
+
+ let restoreContext = () => {};
+ // Records what the chart fills, with the fill colour in force at the time.
+ const recordFills = () => {
+ const fills: string[] = [];
+ const getContext = vi.mocked(HTMLCanvasElement.prototype.getContext);
+ const original = getContext.getMockImplementation()!;
+ restoreContext = () => getContext.mockImplementation(original);
+ getContext.mockImplementation(function () {
+ const ctx: Record<string, unknown> = {
+ fillStyle: '',
+ clearRect: vi.fn(() => fills.splice(0)),
+ setTransform: vi.fn(),
+ beginPath: vi.fn(),
+ moveTo: vi.fn(),
+ lineTo: vi.fn(),
+ stroke: vi.fn(),
+ fillText: vi.fn(),
+ closePath: vi.fn(),
+ fill: vi.fn(() => fills.push(String(ctx.fillStyle))),
+ arc: vi.fn(),
+ save: vi.fn(),
+ restore: vi.fn(),
+ setLineDash: vi.fn(),
+ measureText: vi.fn(() => ({ width: 40 })),
+ };
+ return ctx as never;
+ });
+ return fills;
+ };
+
+ it('draws a band behind the line for spiky buckets and no area fill for flat ones', async () => {
+ const request = vi.mocked(ChartsAPI.getMetricsHistory);
+ const fills = recordFills();
+ try {
+ request.mockResolvedValueOnce({
+ points: [at(1000, 10, 4, 60), at(2000, 12, 8, 14)],
+ source: 'store',
+ } as never);
+ const spiky = render(() => (
+ <HistoryChart resourceType="disk" resourceId="d" metric="diskread" color="#3b82f6" />
+ ));
+ await waitFor(() => expect(fills).toContain('#3b82f633'));
+ spiky.unmount();
+ fills.splice(0);
+ request.mockResolvedValueOnce({
+ points: [at(1000, 10), at(2000, 12)],
+ source: 'store',
+ } as never);
+ render(() => (
+ <HistoryChart resourceType="disk" resourceId="e" metric="diskread" color="#3b82f6" />
+ ));
+ await waitFor(() =>
+ expect(
+ document.getElementById(
+ screen.getByRole('img', { name: 'History chart' }).getAttribute('aria-describedby')!,
+ )!.textContent,
+ ).toContain('2 data points'),
+ );
+ expect(fills.filter((fill) => fill.startsWith('#3b82f6'))).toEqual([]);
+ } finally {
+ restoreContext();
+ }
+ });
+});
+
describe('History chart axis labels', () => {
it('fits as many time labels as the plot holds without touching', () => {
// "11:30 AM" is about 45px at 10px sans-serif; neighbours need 57px apart.
@@ -141,6 +222,23 @@ describe('History chart axis labels', () => {
expect(getHistoryChartTimeTickCount(0, 45)).toBe(4);
});
+ it('states a time label once when a short window repeats it', () => {
+ const tick = (label: string) => ({ timestamp: 0, label });
+ expect(
+ withoutRepeatedHistoryTimeTicks([tick('Oct 2'), tick('Oct 2'), tick('Oct 2')]).map(
+ (t) => t.label,
+ ),
+ ).toEqual(['Oct 2']);
+ expect(
+ withoutRepeatedHistoryTimeTicks([
+ tick('11:00 AM'),
+ tick('11:00 AM'),
+ tick('11:01 AM'),
+ tick('11:02 AM'),
+ ]).map((t) => t.label),
+ ).toEqual(['11:00 AM', '11:01 AM', '11:02 AM']);
+ });
+
it('blanks a middle gridline label that repeats a neighbour', () => {
expect(withoutRepeatedHistoryAxisLabels(['<1K/s', '<1K/s', '0'])).toEqual(['<1K/s', '', '0']);
expect(withoutRepeatedHistoryAxisLabels(['1', '1', '0'])).toEqual(['1', '', '0']);
diff --git a/frontend-modern/src/components/shared/historyChartModel.ts b/frontend-modern/src/components/shared/historyChartModel.ts
index 402f7f8aaa..106c1f6611 100644
--- a/frontend-modern/src/components/shared/historyChartModel.ts
+++ b/frontend-modern/src/components/shared/historyChartModel.ts
@@ -181,6 +181,14 @@ export function getHistoryChartDataMax(points: AggregatedMetricPoint[]) {
return max;
}
+/** True when any stored bucket's lowest and highest readings differ. */
+export function hasHistoryChartSpread(points: readonly AggregatedMetricPoint[]): boolean {
+ return (
+ points.length > 1 &&
+ points.some((point) => (point.max ?? point.value) > (point.min ?? point.value))
+ );
+}
+
export function getHistoryChartScale(points: AggregatedMetricPoint[], unit?: string) {
const minValue = 0;
const isPercentLike = unit === '%';
@@ -245,6 +253,17 @@ export function withoutRepeatedHistoryAxisLabels(labels: string[]): string[] {
);
}
+/**
+ * Time ticks left to right without one that reads the same as the tick
+ * before it: a short window at a coarse label ("Oct 2" four times, or
+ * "11:00 AM" twice) states its time once.
+ */
+export function withoutRepeatedHistoryTimeTicks<T extends { label: string }>(
+ ticks: readonly T[],
+): T[] {
+ return ticks.filter((tick, index) => index === 0 || tick.label !== ticks[index - 1].label);
+}
+
const HISTORY_CHART_TIME_LABEL_GAP = 12;
/**
diff --git a/frontend-modern/src/components/shared/useHistoryChartState.ts b/frontend-modern/src/components/shared/useHistoryChartState.ts
index 9b9a4a70c0..f3edfc2846 100644
--- a/frontend-modern/src/components/shared/useHistoryChartState.ts
+++ b/frontend-modern/src/components/shared/useHistoryChartState.ts
@@ -19,6 +19,8 @@ import {
getHistoryChartRightInset,
getHistoryChartScale,
getHistoryChartTimeTickCount,
+ hasHistoryChartSpread,
+ withoutRepeatedHistoryTimeTicks,
getHistoryChartYAxisLabels,
type HistoryChartProps,
type HistoryChartHoverPoint,
@@ -283,6 +285,7 @@ export function useHistoryChartState(
);
if (count < timeAxisTicks.length) timeAxisTicks = timeTicks(count);
}
+ timeAxisTicks = withoutRepeatedHistoryTimeTicks(timeAxisTicks);
ctx.strokeStyle = gridColor;
ctx.lineWidth = 1;
@@ -329,15 +332,32 @@ export function useHistoryChartState(
ctx.fillStyle = mainColor;
ctx.fill();
} else {
- ctx.beginPath();
- points.forEach((point, index) => {
- if (index === 0) ctx.moveTo(geometry.getX(point.timestamp), height - 20);
- ctx.lineTo(geometry.getX(point.timestamp), geometry.getY(point.value));
- });
- ctx.lineTo(geometry.getX(points[points.length - 1].timestamp), height - 20);
- ctx.closePath();
- ctx.fillStyle = `${mainColor}66`;
- ctx.fill();
+ // Each stored point is a bucket average with its lowest and highest
+ // reading. A band spans those extremes behind the line, so a short
+ // spike stays visible after downsampling; flat buckets draw no band.
+ // The drawer charts draw the same band.
+ if (hasHistoryChartSpread(points)) {
+ ctx.beginPath();
+ points.forEach((point, index) => {
+ const x = geometry.getX(point.timestamp);
+ const y = geometry.getY(Math.max(point.max ?? point.value, point.value));
+ if (index === 0) ctx.moveTo(x, y);
+ else ctx.lineTo(x, y);
+ });
+ for (let index = points.length - 1; index >= 0; index--) {
+ const point = points[index];
+ ctx.lineTo(
+ geometry.getX(point.timestamp),
+ geometry.getY(Math.min(point.min ?? point.value, point.value)),
+ );
+ }
+ ctx.closePath();
+ ctx.fillStyle = `${mainColor}33`;
+ ctx.fill();
+ ctx.strokeStyle = `${mainColor}73`;
+ ctx.lineWidth = 1;
+ ctx.stroke();
+ }
ctx.beginPath();
ctx.strokeStyle = mainColor;
diff --git a/frontend-modern/src/features/storageBackups/diskDetailPresentation.ts b/frontend-modern/src/features/storageBackups/diskDetailPresentation.ts
index 474110e99b..8854f7fed2 100644
--- a/frontend-modern/src/features/storageBackups/diskDetailPresentation.ts
+++ b/frontend-modern/src/features/storageBackups/diskDetailPresentation.ts
@@ -249,6 +249,21 @@ const NVME_DISK_HISTORY_CHARTS: readonly DiskDetailHistoryChartConfig[] = [
},
];
+/**
+ * Charts a phone keeps on screen when the rest fold behind one button: the
+ * first History chart, and any chart whose SMART card is out of bounds (the
+ * cards and charts share labels). Live I/O never pins.
+ */
+export function getDiskDetailPhonePinnedChartLabels(
+ historyCharts: readonly DiskDetailHistoryChartConfig[],
+ cards: readonly DiskDetailAttributeCard[],
+): string[] {
+ const failing = new Set(cards.filter((card) => !card.ok && !card.lastKnown).map((c) => c.label));
+ return historyCharts
+ .filter((chart, index) => index === 0 || failing.has(chart.label))
+ .map((chart) => chart.label);
+}
+
export function getDiskDetailHistoryCharts(
disk: PhysicalDiskPresentationData,
): readonly DiskDetailHistoryChartConfig[] {