Remove status and disk helpers left unused by the selector removal (#2651)

Stacked on #2649 (base commit dcd409f9da). Deleting
`infrastructureSelectors.ts` there removed the only production caller of
three more exports. `getInfrastructureSystemIdentitySortLabel` is
removed in the prose-sweep change. This removes the other two:

- `STATUS_SORT_ORDER` in `utils/status.ts`, plus the test that only
pinned its contents.
- `getResourceDiskSummary` in `utils/format.ts`, plus its two tests and
the now-unused `Resource` type import.

Neither is used inside its own module. The helpers
`getResourceDiskSummary` relied on (`normalizeDiskArray`,
`NormalizedDisk`) keep their other callers, and neither file has a
subsystem owner or contract entry.

## Verification

- Rollup was already tree-shaking both exports, so the production build
is byte-identical to the #2649 build (SHA-256 of every file in `dist`).
- `tsc`, eslint and the `src/utils` suites pass, apart from the six
`agentInstallCommand.test.ts` PTY lifecycle cases that always fail on
the Mac.
- Browser receipt `b5563a7bd4ae414b.json`, recorded on that build: the
Proxmox Workloads I/O emphasis and the Docker drawer change-history
facet chips, at 1920, 1440 and 390 wide.

It merges cleanly with current main and with #2650.
This commit is contained in:
rcourtman
2026-10-07 13:23:10 +01:00
committed by GitHub
5 changed files with 42 additions and 86 deletions
@@ -0,0 +1,42 @@
{
"version": 1,
"base_sha": "dcd409f9da0a7a7f35a2a4ad5a4354e0b1d3ee44",
"verified_at": "2026-10-07T10:50:00Z",
"result": "passed",
"changed_paths": [
"frontend-modern/src/utils/format.ts",
"frontend-modern/src/utils/status.ts"
],
"content_sha256": {
"frontend-modern/src/utils/format.ts": "7fe003f3aba64378896fc55a810e54642962296c14b2445335cd684dc7c26268",
"frontend-modern/src/utils/status.ts": "87df830a90ba87d28b74910244b1a8e2870cb2fcc6057c95207656860795fc94"
},
"routes": [
"/proxmox/overview",
"/docker"
],
"viewports": [
{
"width": 1920,
"height": 1080
},
{
"width": 1440,
"height": 900
},
{
"width": 390,
"height": 844
}
],
"states": [
"Production vite build of this tree is byte-identical (sha256 of every dist file) to the build of its parent dcd409f9da, because both removed exports were already tree-shaken; served embedded by a private DEMO_MODE mock backend on its own port",
"Proxmox overview workloads table at 1920: 161 guest rows, 512 Net I/O and Disk I/O values with top-outlier emphasis on 6 of them; at 390: 45 guest rows render with I/O columns hidden as before",
"Docker containers inline resource drawer for branch-portal-3 (REST list and websocket frames edited in Playwright to carry its real change history plus widened facet counts): Change history shows all nine facet badges with no +N chip, one line at 1440 and four wrapped lines at 390, no clipped badge",
"Console shows only the 401 and inline-style CSP messages the origin/main build also logs on these routes"
],
"interactions": [
"Demo auto sign-in, then direct navigation to /proxmox/overview and /docker",
"Typed branch-portal-3 into Search containers and clicked its row to open the inline resource drawer, then scrolled the Change history facet summary into view"
]
}
@@ -3,7 +3,6 @@ import {
formatPowerOnHours,
estimateTextWidth,
formatAnomalyRatio,
getResourceDiskSummary,
getShortImageName,
normalizeDiskArray,
ANOMALY_SEVERITY_CLASS,
@@ -338,33 +337,3 @@ describe('normalizeDiskArray', () => {
).toBeUndefined();
});
});
describe('getResourceDiskSummary', () => {
it('aggregates multiple agent-reported Windows volumes when the resource summary is absent', () => {
const gib = 1024 ** 3;
const summary = getResourceDiskSummary({
disk: undefined,
agent: {
disks: [
{ device: 'C:', mountpoint: 'C:\\', total: 499 * gib, used: 49.5 * gib },
{ device: 'F:', mountpoint: 'F:\\', total: 250 * gib, used: 2.75 * gib },
],
},
});
expect(summary).toMatchObject({
total: 749 * gib,
used: 52.25 * gib,
});
expect(summary?.usage).toBeCloseTo(6.98, 2);
});
it('keeps the canonical resource summary when one is available', () => {
expect(
getResourceDiskSummary({
disk: { current: 25, total: 400, used: 100, free: 300 },
agent: { disks: [{ total: 1000, used: 900 }] },
}),
).toEqual({ total: 400, used: 100, free: 300, usage: 25 });
});
});
@@ -25,7 +25,6 @@ import {
DEGRADED_HEALTH_STATUSES,
STOPPED_CONTAINER_STATES,
ERROR_CONTAINER_STATES,
STATUS_SORT_ORDER,
} from '@/utils/status';
describe('isNodeOnline', () => {
@@ -71,18 +70,6 @@ describe('status label helpers', () => {
expect(getCanonicalStatusLabel('custom_state')).toBe('custom_state');
});
it('exports the canonical status sort order used by selectors', () => {
expect(Array.from(STATUS_SORT_ORDER)).toEqual([
'online',
'degraded',
'paused',
'offline',
'stopped',
'unknown',
'running',
]);
});
it('returns a generic indicator for simple online/offline/warning states', () => {
expect(getSimpleStatusIndicator('online')).toEqual({ variant: 'success', label: 'Online' });
expect(getSimpleStatusIndicator('running')).toEqual({ variant: 'success', label: 'Running' });
-32
View File
@@ -1,6 +1,5 @@
// Type-safe formatting utilities
import type { Disk } from '@/types/api';
import type { Resource } from '@/types/resource';
type DiskInput = {
device?: string;
@@ -548,34 +547,3 @@ export function normalizeDiskArray(disks?: DiskInput[]): NormalizedDisk[] | unde
});
return normalized.length > 0 ? normalized : undefined;
}
export function getResourceDiskSummary(
resource: Pick<Resource, 'agent' | 'disk'>,
): NormalizedDisk | undefined {
if (resource.disk) {
const total = resource.disk.total ?? 0;
const used = resource.disk.used ?? 0;
return {
total,
used,
free: resource.disk.free ?? Math.max(total - used, 0),
usage: total > 0 ? (used / total) * 100 : resource.disk.current,
};
}
// Disks with unknown usage (sentinel -1) have no measured used/free to sum.
const disks = normalizeDiskArray(resource.agent?.disks)?.filter((disk) => disk.usage >= 0);
if (!disks || disks.length === 0) return undefined;
const total = disks.reduce((sum, disk) => sum + disk.total, 0);
if (total <= 0) return undefined;
const used = disks.reduce((sum, disk) => sum + disk.used, 0);
const free = disks.reduce((sum, disk) => sum + disk.free, 0);
return {
total,
used,
free,
usage: (used / total) * 100,
};
}
-10
View File
@@ -24,16 +24,6 @@ const STATUS_LABELS: Record<string, string> = {
stopped: 'Stopped',
};
export const STATUS_SORT_ORDER = [
'online',
'degraded',
'paused',
'offline',
'stopped',
'unknown',
'running',
] as const;
const normalize = (value?: string | null): string => (value || '').trim().toLowerCase();
export const formatStatusLabel = (value?: string | null, fallback = 'Unknown'): string => {