mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-11-29 17:21:13 +01:00
Show actual Proxmox Nodes disk use below one percent (#4910)
**Show actual Proxmox Nodes disk use below one percent** Use the canonical disk reader's measured byte pair for the node's aggregate, Disk sort and History current label before falling back to the reported percentage. Do not re-scale disk percentage points in History. Keep small measurements distinct from zero and from 1%, and leave the individual filesystem bars and fullest-disk mode intact. Refs #4905 Contract-Neutral: Restores the existing disk percentage-point and missing-measurement behavior on the Proxmox Nodes table; no wire, history, or other chart or disk contract changes. **Record matched Proxmox Nodes disk browser proof** Bind the current bars, History, sorting and preserved controls to the exact production builds at desktop and phone widths. --- Fleet candidate `20261122T182627Z-web-product` from the `web-product` lane. Reviewed tip `3f7938ae9152b066362850f8f255a633c50e0d27` on `main`. [How Pulse handles triage](https://github.com/rcourtman/Pulse/blob/main/docs/AI_TRANSPARENCY.md)
This commit is contained in:
39
frontend-modern/browser-verification/7aa9a5093b9a187e.json
Normal file
39
frontend-modern/browser-verification/7aa9a5093b9a187e.json
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"version": 1,
|
||||
"base_sha": "54648323456c73ce9aaff3bfd8df5ebb547c2a8d",
|
||||
"verified_at": "2026-11-22T18:45:57.155Z",
|
||||
"result": "passed",
|
||||
"changed_paths": [
|
||||
"frontend-modern/src/components/Workloads/StackedDiskBar.tsx",
|
||||
"frontend-modern/src/components/Workloads/stackedDiskBarModel.ts",
|
||||
"frontend-modern/src/features/proxmox/ProxmoxNodesTable.tsx"
|
||||
],
|
||||
"content_sha256": {
|
||||
"frontend-modern/src/components/Workloads/StackedDiskBar.tsx": "9791294691b43d6a5c741132f7ff93f2d88d49d1ce9be2e94a826f796a3755f5",
|
||||
"frontend-modern/src/components/Workloads/stackedDiskBarModel.ts": "7a2ae4970538ef6bbdcd1cc38b01220e7a4c70681a42a3ca0175ac01d2c91111",
|
||||
"frontend-modern/src/features/proxmox/ProxmoxNodesTable.tsx": "14ed7d3a8996b9855e6238b5ea07af32d91fed4bc0e0e30d5f07c387708ba298"
|
||||
},
|
||||
"routes": [
|
||||
"/proxmox/overview"
|
||||
],
|
||||
"viewports": [
|
||||
{
|
||||
"width": 1440,
|
||||
"height": 900
|
||||
},
|
||||
{
|
||||
"width": 360,
|
||||
"height": 800
|
||||
}
|
||||
],
|
||||
"states": [
|
||||
"Matched production frontend builds on the parent and the repaired source, with identical Proxmox registry output and node history samples from an offline fixture. Chromium 141.0.7390.37 with Playwright 1.56.1, light desktop and dark touch phone. 206 assertions passed; all 16 captures inspected.",
|
||||
"Nodes shows 0.49%, 0.88%, 1%, and 1.13% as distinct measurements. Used and total bytes remain visible on desktop. The real zero, full disk and unavailable states are still distinct.",
|
||||
"A two-filesystem node still shows both individual bars and its 94% fullest reading on desktop, and the existing 94% compact summary on phone. CPU, history curves and table widths were unchanged.",
|
||||
"The live tooltip retains the used/capacity pair. The stored point tooltip adds a percent unit without changing the sample or its time; the current reading beside History uses the same units as the live bar."
|
||||
],
|
||||
"interactions": [
|
||||
"Use keyboard or touch to sort Disk from its actual aggregate, toggle sort and restore the original order. Unavailable sorts after measured values.",
|
||||
"Expand the narrow node preview, open View (inside Filters on phone), switch from Bars to Trends and back, and read and hover actual chart data. No external or mutating request."
|
||||
]
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Show, For } from 'solid-js';
|
||||
import { AnimatedNumber } from '@/components/shared/AnimatedNumber';
|
||||
import { TooltipPortal } from '@/components/shared/TooltipPortal';
|
||||
import { formatPercent } from '@/utils/format';
|
||||
import { type StackedDiskBarProps } from './stackedDiskBarModel';
|
||||
import { useStackedDiskBarState } from './useStackedDiskBarState';
|
||||
|
||||
@@ -110,7 +109,7 @@ export function StackedDiskBar(props: StackedDiskBarProps) {
|
||||
<Show when={!presentation().unavailable} fallback="N/A">
|
||||
<AnimatedNumber
|
||||
value={presentation().displayPercentValue}
|
||||
format={formatPercent}
|
||||
format={presentation().displayPercentFormat}
|
||||
/>
|
||||
</Show>
|
||||
</span>
|
||||
|
||||
@@ -140,6 +140,29 @@ describe('StackedDiskBar', () => {
|
||||
render(() => <StackedDiskBar aggregateDisk={agg} />);
|
||||
expect(screen.getByText('75%')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('uses a supplied aggregate label without changing the fill or per-disk labels', async () => {
|
||||
const aggregate = { total: 10_000, used: 88, usage: 0.88 };
|
||||
const formatAggregatePercent = (percent: number) => `${percent.toFixed(2)}%`;
|
||||
const { container } = render(() => (
|
||||
<>
|
||||
<StackedDiskBar
|
||||
aggregateDisk={aggregate}
|
||||
formatAggregatePercent={formatAggregatePercent}
|
||||
/>
|
||||
<StackedDiskBar
|
||||
aggregateDisk={aggregate}
|
||||
disks={[makeDisk()]}
|
||||
formatAggregatePercent={formatAggregatePercent}
|
||||
/>
|
||||
</>
|
||||
));
|
||||
expect(screen.getByText('0.88%')).toHaveAttribute('aria-label', '0.88%');
|
||||
expect(getSingleBarFill(container)).toHaveAttribute('width', '0.88');
|
||||
expect(screen.getByText('50%')).toBeInTheDocument();
|
||||
await fireEvent.mouseEnter(getBarTrigger(container));
|
||||
expect(document.querySelector('[data-tooltip-portal]')).toHaveTextContent('0.88%');
|
||||
});
|
||||
});
|
||||
|
||||
it.each([Infinity, -Infinity, Number.NaN, -100, 0, undefined])(
|
||||
|
||||
@@ -16,6 +16,8 @@ import type { MetricDisplayThresholds } from '@/utils/metricThresholds';
|
||||
export interface StackedDiskBarProps {
|
||||
disks?: Disk[];
|
||||
aggregateDisk?: Disk;
|
||||
/** Format the aggregate reading only, not the individual filesystem bars or max. */
|
||||
formatAggregatePercent?: (percent: number) => string;
|
||||
mode?: 'stacked' | 'aggregate' | 'mini' | 'vertical-bars';
|
||||
summaryStrategy?: 'total' | 'max';
|
||||
showDiskCount?: boolean;
|
||||
@@ -75,6 +77,7 @@ export interface StackedDiskBarPresentation {
|
||||
containerClass: string;
|
||||
diskCountLabel: string;
|
||||
diskCountTitle: string;
|
||||
displayPercentFormat: (percent: number) => string;
|
||||
displayLabel: string;
|
||||
displayPercentValue: number;
|
||||
displaySublabel: string;
|
||||
@@ -199,6 +202,7 @@ function buildTooltipContent(
|
||||
disks: Disk[],
|
||||
options: {
|
||||
aggregateDisk: Disk | undefined;
|
||||
formatAggregatePercent?: (percent: number) => string;
|
||||
aggregateMode: boolean;
|
||||
current: boolean;
|
||||
unavailable: boolean;
|
||||
@@ -255,7 +259,10 @@ function buildTooltipContent(
|
||||
? getMetricColorRgba(percentValue, 'disk', options.thresholds)
|
||||
: UNKNOWN_DISK_COLOR,
|
||||
label: 'Total',
|
||||
percent: options.unavailable || percentValue === null ? '—' : formatPercent(percentValue),
|
||||
percent:
|
||||
options.unavailable || percentValue === null
|
||||
? '—'
|
||||
: (options.formatAggregatePercent ?? formatPercent)(percentValue),
|
||||
total: hasTotal ? formatBytes(aggregate.total!) : '—',
|
||||
used: options.unavailable || !hasUsed ? '?' : formatBytes(aggregate.used!),
|
||||
},
|
||||
@@ -355,7 +362,11 @@ export function buildStackedDiskBarPresentation(
|
||||
const maxLabelFull = maxInfo
|
||||
? `${valuePrefix ? 'Last known highest' : 'Highest'} usage: ${maxInfo.label} ${formatPercent(maxInfo.percent)}`
|
||||
: '';
|
||||
const displayLabel = unavailable ? 'N/A' : formatPercent(displayPercentValue);
|
||||
const displayPercentFormat =
|
||||
!summarizeDisks && !useMaxSummary && hasAggregateUsage
|
||||
? (props.formatAggregatePercent ?? formatPercent)
|
||||
: formatPercent;
|
||||
const displayLabel = unavailable ? 'N/A' : displayPercentFormat(displayPercentValue);
|
||||
const displaySublabel =
|
||||
unavailable ||
|
||||
(useMaxSummary && maxInfo) ||
|
||||
@@ -446,6 +457,7 @@ export function buildStackedDiskBarPresentation(
|
||||
const verticalBarsLabelTitle = verticalBarsMode && maxInfo ? maxLabelFull : '';
|
||||
const tooltipContent = buildTooltipContent(allDisks, {
|
||||
aggregateDisk: props.aggregateDisk,
|
||||
formatAggregatePercent: props.formatAggregatePercent,
|
||||
aggregateMode,
|
||||
current,
|
||||
unavailable,
|
||||
@@ -471,6 +483,7 @@ export function buildStackedDiskBarPresentation(
|
||||
: 'metric-text w-full h-4 flex items-center justify-center',
|
||||
diskCountLabel,
|
||||
diskCountTitle,
|
||||
displayPercentFormat,
|
||||
displayLabel,
|
||||
displayPercentValue,
|
||||
displaySublabel,
|
||||
|
||||
@@ -32,7 +32,7 @@ import { TableCell, TableRow } from '@/components/shared/Table';
|
||||
import { getSimpleStatusIndicator } from '@/utils/status';
|
||||
import { getNodeExternalUrl } from '@/utils/nodes';
|
||||
import { asTrimmedString } from '@/utils/stringUtils';
|
||||
import { normalizeDiskArray } from '@/utils/format';
|
||||
import { formatPercent, normalizeDiskArray } from '@/utils/format';
|
||||
import { buildMetricKeyForUnifiedResource } from '@/utils/metricsKeys';
|
||||
import { useWorkloadTableMetricHistory } from '@/components/Workloads/useWorkloadTableMetricHistory';
|
||||
import { getWorkloadTableLayoutMode } from '@/components/Workloads/guestRowModel';
|
||||
@@ -69,7 +69,7 @@ import {
|
||||
} from '@/components/Workloads/workloadMetricHistoryModel';
|
||||
import { formatTemperature, getTemperatureTextClass } from '@/utils/temperature';
|
||||
import type { Disk, Node as LegacyNode } from '@/types/api';
|
||||
import type { Resource } from '@/types/resource';
|
||||
import { getDiskPercent, type Resource } from '@/types/resource';
|
||||
import { hasCurrentProxmoxUpdateEvidence } from '@/utils/proxmoxUpdateEvidence';
|
||||
import { nodeFromResource } from '@/utils/resourceStateAdapters';
|
||||
import {
|
||||
@@ -112,6 +112,17 @@ const formatNodeUptime = (
|
||||
};
|
||||
};
|
||||
|
||||
// Disk usage is already in percentage points. Under 2%, retain hundredths so
|
||||
// 0.88% is not shown as the same reading as 1%, or a small reading as empty.
|
||||
const formatLowNodeDiskPercent = (value: number): string | undefined => {
|
||||
if (value <= 0 || value >= 2) return undefined;
|
||||
return value < 0.01 ? '<0.01%' : `${Number(value.toFixed(2))}%`;
|
||||
};
|
||||
const formatNodeDiskBarPercent = (value: number): string =>
|
||||
formatLowNodeDiskPercent(value) ?? formatPercent(value);
|
||||
const formatNodeDiskHistoryPercent = (value: number): string =>
|
||||
formatLowNodeDiskPercent(value) ?? formatPlatformTablePercentValue(value);
|
||||
|
||||
type GuestCounts = { vms: number; containers: number };
|
||||
|
||||
const countGuestsForNode = (guests: Resource[], node: Resource): GuestCounts => {
|
||||
@@ -195,7 +206,7 @@ const getHostSortValue = (
|
||||
return typeof node.memory?.current === 'number' ? node.memory.current : null;
|
||||
}
|
||||
case 'disk':
|
||||
return node.disk?.current ?? null;
|
||||
return getDiskPercent(node) ?? null;
|
||||
case 'temp':
|
||||
return typeof node.temperature === 'number' && node.temperature > 0 ? node.temperature : null;
|
||||
case 'uptime':
|
||||
@@ -536,14 +547,17 @@ export const ProxmoxNodesTable: Component<{
|
||||
!memoryTotal() && getPlatformTableFiniteMetric(node.memory?.current) !== undefined
|
||||
? getPlatformTableFiniteMetric(node.memory?.current)
|
||||
: undefined;
|
||||
const diskPercent = () => getPlatformTableFiniteMetric(node.disk?.current) ?? 0;
|
||||
const diskPercent = createMemo(() => getDiskPercent(node));
|
||||
const diskHistoryLabel = () => {
|
||||
const value = diskPercent();
|
||||
return value === undefined ? undefined : formatNodeDiskHistoryPercent(value);
|
||||
};
|
||||
const aggregateDisk = (): Disk | undefined => {
|
||||
if (!node.disk) return undefined;
|
||||
const total = getPlatformTableFiniteMetric(node.disk.total) ?? 0;
|
||||
const used = getPlatformTableFiniteMetric(node.disk.used) ?? 0;
|
||||
const free = getPlatformTableFiniteMetric(node.disk.free) ?? 0;
|
||||
const usage = getPlatformTableFiniteMetric(node.disk.current) ?? 0;
|
||||
return { total, used, free, usage } as Disk;
|
||||
const { total, used, free } = node.disk;
|
||||
// Match the canonical disk reader: measured bytes beat the
|
||||
// redundant percentage; unavailable is never an empty disk.
|
||||
return { total, used, free, usage: diskPercent() ?? -1 };
|
||||
};
|
||||
const legacyNode = () => projectResourceToLegacyNode(node);
|
||||
const externalUrl = () => {
|
||||
@@ -797,16 +811,15 @@ export const ProxmoxNodesTable: Component<{
|
||||
summaryStrategy="max"
|
||||
disks={normalizeDiskArray(node.agent?.disks)}
|
||||
aggregateDisk={aggregateDisk()}
|
||||
formatAggregatePercent={formatNodeDiskBarPercent}
|
||||
thresholds={diskThresholds()}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<MetricMiniSparkline
|
||||
series={diskSeries()}
|
||||
valueLabel={formatPlatformTablePercentValue(diskPercent(), {
|
||||
normalizeRatio: true,
|
||||
clamp: true,
|
||||
})}
|
||||
valueLabel={diskHistoryLabel()}
|
||||
formatValue={formatNodeDiskHistoryPercent}
|
||||
title={`${name()} disk history`}
|
||||
{...historyCursorProps()}
|
||||
/>
|
||||
|
||||
@@ -44,12 +44,34 @@ vi.mock('@/components/Workloads/StackedMemoryBar', () => ({
|
||||
}));
|
||||
|
||||
vi.mock('@/components/Workloads/StackedDiskBar', () => ({
|
||||
StackedDiskBar: () => <div data-testid="stacked-disk-bar" />,
|
||||
StackedDiskBar: (props: {
|
||||
aggregateDisk?: { usage?: number; used?: number; total?: number };
|
||||
formatAggregatePercent?: (value: number) => string;
|
||||
}) => (
|
||||
<div
|
||||
data-testid="stacked-disk-bar"
|
||||
data-usage={props.aggregateDisk?.usage}
|
||||
data-used={props.aggregateDisk?.used}
|
||||
data-total={props.aggregateDisk?.total}
|
||||
>
|
||||
{props.aggregateDisk?.usage !== undefined && props.aggregateDisk.usage >= 0
|
||||
? props.formatAggregatePercent?.(props.aggregateDisk.usage)
|
||||
: null}
|
||||
</div>
|
||||
),
|
||||
}));
|
||||
|
||||
vi.mock('@/components/Workloads/MetricMiniSparkline', () => ({
|
||||
MetricMiniSparkline: (props: { title?: string; valueContent?: JSX.Element }) => (
|
||||
<div data-testid="metric-mini-sparkline" data-title={props.title}>
|
||||
MetricMiniSparkline: (props: {
|
||||
title?: string;
|
||||
valueContent?: JSX.Element;
|
||||
valueLabel?: string;
|
||||
}) => (
|
||||
<div
|
||||
data-testid="metric-mini-sparkline"
|
||||
data-title={props.title}
|
||||
data-value-label={props.valueLabel}
|
||||
>
|
||||
{props.valueContent}
|
||||
</div>
|
||||
),
|
||||
@@ -137,6 +159,82 @@ afterEach(() => {
|
||||
});
|
||||
|
||||
describe('ProxmoxNodesTable', () => {
|
||||
it.each([
|
||||
[0, 0, '0%', '0.0%'],
|
||||
[49, 49, '0.49%', '0.49%'],
|
||||
[88, 88, '0.88%', '0.88%'],
|
||||
[100, 100, '1%', '1%'],
|
||||
[113, 1.13, '1.13%', '1.13%'],
|
||||
[10_000, 100, '100%', '100.0%'],
|
||||
])('uses %i measured disk bytes in bars and History', (used, current, bar, history) => {
|
||||
const [mode, setMode] = createSignal<'bars' | 'sparklines'>('bars');
|
||||
const { container } = render(() => (
|
||||
<ProxmoxNodesTable
|
||||
nodes={[
|
||||
makeNodeResource({ disk: { total: 10_000, used, current }, cpu: { current: 12.5 } }),
|
||||
]}
|
||||
guests={[]}
|
||||
metricDisplayMode={mode}
|
||||
metricHoverMode={() => 'details'}
|
||||
emptyIcon={<span />}
|
||||
emptyTitle="No Proxmox VE nodes"
|
||||
emptyDescription="No nodes"
|
||||
/>
|
||||
));
|
||||
const diskBar = screen.getByTestId('stacked-disk-bar');
|
||||
expect(diskBar).toHaveTextContent(bar);
|
||||
expect(diskBar).toHaveAttribute('data-used', String(used));
|
||||
expect(diskBar).toHaveAttribute('data-total', '10000');
|
||||
|
||||
setMode('sparklines');
|
||||
expect(container.querySelector('[data-title="pve-node-1 disk history"]')).toHaveAttribute(
|
||||
'data-value-label',
|
||||
history,
|
||||
);
|
||||
expect(container.querySelector('[data-title="pve-node-1 CPU history"]')).toHaveAttribute(
|
||||
'data-value-label',
|
||||
'12.5%',
|
||||
);
|
||||
});
|
||||
|
||||
it('orders measured disk use ahead of unknown and keeps percentage-only readings', async () => {
|
||||
const { container } = render(() => (
|
||||
<ProxmoxNodesTable
|
||||
nodes={[
|
||||
makeNodeResource({ disk: { total: 10_000, used: 88, current: 88 } }),
|
||||
makeNodeResource({
|
||||
id: 'agent:pve-node-2',
|
||||
name: 'pve-node-2',
|
||||
disk: { current: 1.13 },
|
||||
}),
|
||||
makeNodeResource({
|
||||
id: 'agent:pve-node-3',
|
||||
name: 'pve-node-3',
|
||||
disk: { total: 10_000, current: -1 },
|
||||
}),
|
||||
]}
|
||||
guests={[]}
|
||||
metricDisplayMode={() => 'sparklines'}
|
||||
emptyIcon={<span />}
|
||||
emptyTitle="No Proxmox VE nodes"
|
||||
emptyDescription="No nodes"
|
||||
/>
|
||||
));
|
||||
await fireEvent.click(screen.getByRole('button', { name: 'Disk' }));
|
||||
const rows = Array.from(container.querySelectorAll('[data-proxmox-host-row]'));
|
||||
expect(rows.map((row) => row.getAttribute('data-proxmox-host-row'))).toEqual([
|
||||
'agent:pve-node-2',
|
||||
'agent:pve-node-1',
|
||||
'agent:pve-node-3',
|
||||
]);
|
||||
const diskLabel = (name: string) =>
|
||||
container
|
||||
.querySelector(`[data-title="${name} disk history"]`)
|
||||
?.getAttribute('data-value-label');
|
||||
expect(diskLabel('pve-node-2')).toBe('1.13%');
|
||||
expect(diskLabel('pve-node-3')).toBeNull();
|
||||
});
|
||||
|
||||
it('uses the shared workload search to narrow the host preview and count', () => {
|
||||
render(() => (
|
||||
<ProxmoxNodesTable
|
||||
|
||||
Reference in New Issue
Block a user