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.

Split dashboard disk list runtime owners

rcourtman44e8f84a9a59
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 1f395f6173..f40a6102a4 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -27,21 +27,25 @@ regression protection.
5. `internal/api/slo_bench_test.go`
6. `frontend-modern/src/components/Dashboard/Dashboard.tsx`
7. `frontend-modern/src/components/Dashboard/useDashboardState.ts`
-8. `frontend-modern/src/components/Dashboard/GuestRow.tsx`
-9. `frontend-modern/src/components/Dashboard/guestRowModel.tsx`
-10. `frontend-modern/src/components/Dashboard/useGuestRowState.ts`
-11. `frontend-modern/src/components/Dashboard/GuestDrawer.tsx`
-12. `frontend-modern/src/components/Dashboard/guestDrawerModel.ts`
-13. `frontend-modern/src/components/Dashboard/useGuestDrawerState.ts`
-14. `frontend-modern/src/components/Dashboard/workloadSelectors.ts`
-15. `frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx`
-16. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts`
-17. `frontend-modern/src/components/Infrastructure/infrastructureSelectors.ts`
-18. `frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts`
-19. `frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx`
-20. `frontend-modern/src/components/Dashboard/__tests__/GuestRow.test.tsx`
-21. `frontend-modern/src/components/Dashboard/GuestDrawer.test.tsx`
-22. `frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx`
+8. `frontend-modern/src/components/Dashboard/DiskList.tsx`
+9. `frontend-modern/src/components/Dashboard/diskListModel.ts`
+10. `frontend-modern/src/components/Dashboard/useDiskListState.ts`
+11. `frontend-modern/src/components/Dashboard/GuestRow.tsx`
+12. `frontend-modern/src/components/Dashboard/guestRowModel.tsx`
+13. `frontend-modern/src/components/Dashboard/useGuestRowState.ts`
+14. `frontend-modern/src/components/Dashboard/GuestDrawer.tsx`
+15. `frontend-modern/src/components/Dashboard/guestDrawerModel.ts`
+16. `frontend-modern/src/components/Dashboard/useGuestDrawerState.ts`
+17. `frontend-modern/src/components/Dashboard/workloadSelectors.ts`
+18. `frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx`
+19. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts`
+20. `frontend-modern/src/components/Infrastructure/infrastructureSelectors.ts`
+21. `frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts`
+22. `frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx`
+23. `frontend-modern/src/components/Dashboard/__tests__/DiskList.test.tsx`
+24. `frontend-modern/src/components/Dashboard/__tests__/GuestRow.test.tsx`
+25. `frontend-modern/src/components/Dashboard/GuestDrawer.test.tsx`
+26. `frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx`
## Shared Boundaries
@@ -63,6 +67,7 @@ regression protection.
8. Format infrastructure sensor labels through the shared `frontend-modern/src/utils/textPresentation.ts` presentation helper instead of maintaining a local title-casing implementation in `frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts`
9. Extend dashboard row contract and per-row hot-path derivations through `frontend-modern/src/components/Dashboard/guestRowModel.tsx` and `frontend-modern/src/components/Dashboard/useGuestRowState.ts` rather than rebuilding column metadata, row identity, or anomaly correlation inside `frontend-modern/src/components/Dashboard/GuestRow.tsx`
10. Extend dashboard drawer derivations and runtime wiring through `frontend-modern/src/components/Dashboard/guestDrawerModel.ts` and `frontend-modern/src/components/Dashboard/useGuestDrawerState.ts` rather than rebuilding canonical guest identity, discovery routing, or drawer-local normalization inside `frontend-modern/src/components/Dashboard/GuestDrawer.tsx`
+11. Extend dashboard disk-list derivations and fallback runtime wiring through `frontend-modern/src/components/Dashboard/diskListModel.ts` and `frontend-modern/src/components/Dashboard/useDiskListState.ts` rather than rebuilding usage math, progress-state mapping, or tooltip fallback logic inside `frontend-modern/src/components/Dashboard/DiskList.tsx`
## Forbidden Paths
@@ -110,6 +115,13 @@ and workload-derived navigation state live in
`frontend-modern/src/components/Dashboard/useGuestDrawerState.ts`. Future
drawer runtime changes must extend through those owners instead of adding
more mixed state and helper drift back into the shell.
+The dashboard disk list now follows the same pattern: the shell stays in
+`frontend-modern/src/components/Dashboard/DiskList.tsx`, while disk-row
+presentation derivations and fallback tooltip/runtime wiring live in
+`frontend-modern/src/components/Dashboard/diskListModel.ts` and
+`frontend-modern/src/components/Dashboard/useDiskListState.ts`. Future disk
+usage math, threshold-color routing, and fallback handling must extend
+through those owners instead of accreting back into the shell.
The unified resource table hot path is now also governed as explicit
performance-owned runtime, with shared ownership against the unified-resource
diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.json
index 298b4581ec..9b4b76ec6f 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -2518,11 +2518,14 @@
],
"owned_files": [
"frontend-modern/src/components/Dashboard/Dashboard.tsx",
+ "frontend-modern/src/components/Dashboard/DiskList.tsx",
+ "frontend-modern/src/components/Dashboard/diskListModel.ts",
"frontend-modern/src/components/Dashboard/GuestDrawer.tsx",
"frontend-modern/src/components/Dashboard/guestDrawerModel.ts",
"frontend-modern/src/components/Dashboard/GuestRow.tsx",
"frontend-modern/src/components/Dashboard/guestRowModel.tsx",
"frontend-modern/src/components/Dashboard/useDashboardState.ts",
+ "frontend-modern/src/components/Dashboard/useDiskListState.ts",
"frontend-modern/src/components/Dashboard/useGuestDrawerState.ts",
"frontend-modern/src/components/Dashboard/useGuestRowState.ts",
"frontend-modern/src/components/Dashboard/workloadSelectors.ts",
@@ -2539,6 +2542,7 @@
"test_prefixes": [],
"exact_files": [
"frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx",
+ "frontend-modern/src/components/Dashboard/__tests__/DiskList.test.tsx",
"internal/api/router_bench_test.go",
"internal/api/slo_bench_test.go",
"pkg/metrics/store_bench_test.go",
@@ -2569,11 +2573,14 @@
"match_prefixes": [],
"match_files": [
"frontend-modern/src/components/Dashboard/Dashboard.tsx",
+ "frontend-modern/src/components/Dashboard/DiskList.tsx",
+ "frontend-modern/src/components/Dashboard/diskListModel.ts",
"frontend-modern/src/components/Dashboard/GuestDrawer.tsx",
"frontend-modern/src/components/Dashboard/guestDrawerModel.ts",
"frontend-modern/src/components/Dashboard/GuestRow.tsx",
"frontend-modern/src/components/Dashboard/guestRowModel.tsx",
"frontend-modern/src/components/Dashboard/useDashboardState.ts",
+ "frontend-modern/src/components/Dashboard/useDiskListState.ts",
"frontend-modern/src/components/Dashboard/useGuestDrawerState.ts",
"frontend-modern/src/components/Dashboard/useGuestRowState.ts",
"frontend-modern/src/components/Dashboard/workloadSelectors.ts",
@@ -2586,6 +2593,7 @@
"test_prefixes": [],
"exact_files": [
"frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx",
+ "frontend-modern/src/components/Dashboard/__tests__/DiskList.test.tsx",
"frontend-modern/src/components/Dashboard/__tests__/GuestRow.test.tsx",
"frontend-modern/src/components/Dashboard/__tests__/workloadSelectors.test.ts",
"frontend-modern/src/components/Dashboard/GuestDrawer.test.tsx",
diff --git a/frontend-modern/src/components/Dashboard/DiskList.tsx b/frontend-modern/src/components/Dashboard/DiskList.tsx
index 8691a60f9f..88afbf99c2 100644
--- a/frontend-modern/src/components/Dashboard/DiskList.tsx
+++ b/frontend-modern/src/components/Dashboard/DiskList.tsx
@@ -1,62 +1,37 @@
import { For, Show } from 'solid-js';
-import type { Disk } from '@/types/api';
-import { formatBytes } from '@/utils/format';
-import { getMetricColorClass } from '@/utils/metricThresholds';
-import { getDashboardGuestDiskStatusMessage } from '@/utils/dashboardGuestPresentation';
-
-interface DiskListProps {
- disks: Disk[];
- diskStatusReason?: string;
-}
+import type { DiskListProps } from './diskListModel';
+import { useDiskListState } from './useDiskListState';
export function DiskList(props: DiskListProps) {
- const getUsagePercent = (disk: Disk) => {
- if (!disk.total || disk.total <= 0) return 0;
- return (disk.used / disk.total) * 100;
- };
-
- const getDiskStatusTooltip = () => {
- return getDashboardGuestDiskStatusMessage(props.diskStatusReason);
- };
+ const { diskPresentation, diskStatusTooltip, hasDisks } = useDiskListState(props);
return (
<Show
- when={props.disks && props.disks.length > 0}
+ when={hasDisks()}
fallback={
- <span class="text-slate-400 text-sm" title={getDiskStatusTooltip()}>
+ <span class="text-slate-400 text-sm" title={diskStatusTooltip()}>
-
</span>
}
>
<div class="flex flex-col gap-1.5">
- <For each={props.disks}>
+ <For each={diskPresentation()}>
{(disk) => {
- const usage = getUsagePercent(disk);
- const label = disk.mountpoint || disk.device || 'Unknown';
- const hasCapacity = disk.total && disk.total > 0;
-
return (
<div class="rounded border border-border bg-surface-hover px-1.5 py-1 text-[10px] leading-tight shadow-sm">
- <div
- class="truncate text-base-content"
- title={label !== 'Unknown' ? label : undefined}
- >
- {label}
- </div>
- <div class="mt-0.5 text-[9px] text-muted">
- {hasCapacity
- ? `${formatBytes(disk.used)}/${formatBytes(disk.total)}`
- : 'Usage unavailable'}
+ <div class="truncate text-base-content" title={disk.labelTitle}>
+ {disk.label}
</div>
+ <div class="mt-0.5 text-[9px] text-muted">{disk.usageText}</div>
<div class="relative mt-1 h-1.5 w-full overflow-hidden rounded bg-surface-hover">
<div
- class={`absolute inset-y-0 left-0 ${getMetricColorClass(usage, 'disk')}`}
- style={{ width: `${Math.min(usage, 100)}%` }}
+ class={`absolute inset-y-0 left-0 ${disk.progressClass}`}
+ style={{ width: disk.progressWidth }}
/>
</div>
<div class="mt-0.5 flex items-center justify-between text-[9px] font-medium text-muted">
- <span>{hasCapacity ? `${usage.toFixed(0)}%` : '—'}</span>
- <span>{disk.type?.toUpperCase() ?? ''}</span>
+ <span>{disk.usagePercentLabel}</span>
+ <span>{disk.typeLabel}</span>
</div>
</div>
);
diff --git a/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx b/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx
index 9481ec1d40..536e3dac81 100644
--- a/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx
+++ b/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx
@@ -5,6 +5,9 @@ import type { Resource } from '@/types/resource';
import { Dashboard } from '../Dashboard';
import dashboardSource from '../Dashboard.tsx?raw';
import dashboardStateSource from '../useDashboardState.ts?raw';
+import diskListSource from '../DiskList.tsx?raw';
+import diskListModelSource from '../diskListModel.ts?raw';
+import diskListStateSource from '../useDiskListState.ts?raw';
import guestDrawerSource from '../GuestDrawer.tsx?raw';
import guestDrawerModelSource from '../guestDrawerModel.ts?raw';
import guestRowSource from '../GuestRow.tsx?raw';
@@ -496,6 +499,15 @@ describe('Dashboard performance contract', () => {
expect(guestDrawerModelSource).toContain('export const normalizeGuestDrawerTags');
});
+ it('keeps disk-list runtime and derivations in canonical disk-list owners', () => {
+ expect(diskListSource).toContain('useDiskListState');
+ expect(diskListSource).not.toContain('const getUsagePercent =');
+ expect(diskListSource).not.toContain('const getDiskStatusTooltip =');
+ expect(diskListStateSource).toContain('getDashboardGuestDiskStatusMessage');
+ expect(diskListModelSource).toContain('export const buildDashboardDiskPresentation');
+ expect(diskListModelSource).toContain('export const getDashboardDiskUsagePercent');
+ });
+
it('filterWorkloads returns all guests when no filters active', () => {
const guests = makeGuests(PROFILES.S);
const result = filterWorkloads({
diff --git a/frontend-modern/src/components/Dashboard/__tests__/DiskList.test.tsx b/frontend-modern/src/components/Dashboard/__tests__/DiskList.test.tsx
index e484bdc24f..30cca0e3fc 100644
--- a/frontend-modern/src/components/Dashboard/__tests__/DiskList.test.tsx
+++ b/frontend-modern/src/components/Dashboard/__tests__/DiskList.test.tsx
@@ -1,6 +1,10 @@
import { describe, it, expect, afterEach } from 'vitest';
import { render, screen, cleanup } from '@solidjs/testing-library';
import { DiskList } from '../DiskList';
+import {
+ buildDashboardDiskPresentation,
+ getDashboardDiskUsagePercent,
+} from '../diskListModel';
import type { Disk } from '@/types/api';
function makeDisk(overrides: Partial<Disk> = {}): Disk {
@@ -129,6 +133,11 @@ describe('DiskList', () => {
});
describe('usage calculation', () => {
+ it('derives usage percent through the canonical disk-list model', () => {
+ const disk = makeDisk({ used: 26843545600, total: 107374182400 });
+ expect(getDashboardDiskUsagePercent(disk)).toBe(25);
+ });
+
it('calculates usage percent correctly', () => {
// 25 GB used / 100 GB total = 25%
const disk = makeDisk({ used: 26843545600, total: 107374182400 });
@@ -272,6 +281,16 @@ describe('DiskList', () => {
});
describe('disk type display', () => {
+ it('builds disk presentation through the canonical disk-list model', () => {
+ const presentation = buildDashboardDiskPresentation(
+ makeDisk({ mountpoint: undefined, device: undefined, type: 'ext4' }),
+ 0,
+ );
+ expect(presentation.label).toBe('Unknown');
+ expect(presentation.labelTitle).toBeUndefined();
+ expect(presentation.typeLabel).toBe('EXT4');
+ });
+
it('uppercases disk type', () => {
const disk = makeDisk({ type: 'ext4' });
render(() => <DiskList disks={[disk]} />);
diff --git a/frontend-modern/src/components/Dashboard/diskListModel.ts b/frontend-modern/src/components/Dashboard/diskListModel.ts
new file mode 100644
index 0000000000..6843fe506e
--- /dev/null
+++ b/frontend-modern/src/components/Dashboard/diskListModel.ts
@@ -0,0 +1,71 @@
+import type { Disk } from '@/types/api';
+
+import { formatBytes } from '@/utils/format';
+import { getMetricColorClass } from '@/utils/metricThresholds';
+
+export interface DiskListProps {
+ disks: Disk[];
+ diskStatusReason?: string;
+}
+
+export interface DashboardDiskPresentation {
+ key: string;
+ label: string;
+ labelTitle?: string;
+ progressClass: string;
+ progressWidth: string;
+ typeLabel: string;
+ usageText: string;
+ usagePercentLabel: string;
+}
+
+export const hasDashboardDiskCapacity = (disk: Disk): boolean =>
+ typeof disk.total === 'number' && disk.total > 0;
+
+export const getDashboardDiskUsagePercent = (disk: Disk): number => {
+ if (!hasDashboardDiskCapacity(disk)) {
+ return 0;
+ }
+
+ return (disk.used / disk.total) * 100;
+};
+
+export const getDashboardDiskLabel = (disk: Disk): string =>
+ disk.mountpoint || disk.device || 'Unknown';
+
+export const getDashboardDiskLabelTitle = (label: string): string | undefined =>
+ label !== 'Unknown' ? label : undefined;
+
+export const getDashboardDiskUsageText = (disk: Disk): string =>
+ hasDashboardDiskCapacity(disk)
+ ? `${formatBytes(disk.used)}/${formatBytes(disk.total)}`
+ : 'Usage unavailable';
+
+export const getDashboardDiskUsagePercentLabel = (disk: Disk): string =>
+ hasDashboardDiskCapacity(disk) ? `${getDashboardDiskUsagePercent(disk).toFixed(0)}%` : '—';
+
+export const getDashboardDiskProgressClass = (disk: Disk): string =>
+ getMetricColorClass(getDashboardDiskUsagePercent(disk), 'disk');
+
+export const getDashboardDiskProgressWidth = (disk: Disk): string =>
+ `${Math.min(getDashboardDiskUsagePercent(disk), 100)}%`;
+
+export const getDashboardDiskTypeLabel = (disk: Disk): string => disk.type?.toUpperCase() ?? '';
+
+export const buildDashboardDiskPresentation = (
+ disk: Disk,
+ index: number,
+): DashboardDiskPresentation => {
+ const label = getDashboardDiskLabel(disk);
+
+ return {
+ key: `${disk.mountpoint ?? ''}:${disk.device ?? ''}:${index}`,
+ label,
+ labelTitle: getDashboardDiskLabelTitle(label),
+ progressClass: getDashboardDiskProgressClass(disk),
+ progressWidth: getDashboardDiskProgressWidth(disk),
+ typeLabel: getDashboardDiskTypeLabel(disk),
+ usageText: getDashboardDiskUsageText(disk),
+ usagePercentLabel: getDashboardDiskUsagePercentLabel(disk),
+ };
+};
diff --git a/frontend-modern/src/components/Dashboard/useDiskListState.ts b/frontend-modern/src/components/Dashboard/useDiskListState.ts
new file mode 100644
index 0000000000..15f265966e
--- /dev/null
+++ b/frontend-modern/src/components/Dashboard/useDiskListState.ts
@@ -0,0 +1,21 @@
+import { createMemo } from 'solid-js';
+
+import { getDashboardGuestDiskStatusMessage } from '@/utils/dashboardGuestPresentation';
+
+import { buildDashboardDiskPresentation, type DiskListProps } from './diskListModel';
+
+export function useDiskListState(props: DiskListProps) {
+ const hasDisks = createMemo(() => props.disks.length > 0);
+ const diskStatusTooltip = createMemo(() =>
+ getDashboardGuestDiskStatusMessage(props.diskStatusReason),
+ );
+ const diskPresentation = createMemo(() =>
+ props.disks.map((disk, index) => buildDashboardDiskPresentation(disk, index)),
+ );
+
+ return {
+ diskPresentation,
+ diskStatusTooltip,
+ hasDisks,
+ };
+}
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index 655aa0dfc8..464bddf800 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -99,6 +99,8 @@ import guestRowSource from '@/components/Dashboard/GuestRow.tsx?raw';
import guestRowModelSource from '@/components/Dashboard/guestRowModel.tsx?raw';
import guestRowStateSource from '@/components/Dashboard/useGuestRowState.ts?raw';
import dashboardDiskListSource from '@/components/Dashboard/DiskList.tsx?raw';
+import dashboardDiskListModelSource from '@/components/Dashboard/diskListModel.ts?raw';
+import dashboardDiskListStateSource from '@/components/Dashboard/useDiskListState.ts?raw';
import guestDrawerSource from '@/components/Dashboard/GuestDrawer.tsx?raw';
import guestDrawerModelSource from '@/components/Dashboard/guestDrawerModel.ts?raw';
import guestDrawerStateSource from '@/components/Dashboard/useGuestDrawerState.ts?raw';
@@ -3222,7 +3224,12 @@ describe('frontend resource type boundaries', () => {
expect(guestRowSource).not.toContain(
'No filesystems found. VM may be booting or using a Live ISO.',
);
- expect(dashboardDiskListSource).toContain('getDashboardGuestDiskStatusMessage');
+ expect(dashboardDiskListSource).toContain('useDiskListState');
+ expect(dashboardDiskListSource).not.toContain('getDashboardGuestDiskStatusMessage');
+ expect(dashboardDiskListSource).not.toContain('const getUsagePercent =');
+ expect(dashboardDiskListStateSource).toContain('getDashboardGuestDiskStatusMessage');
+ expect(dashboardDiskListModelSource).toContain('export const buildDashboardDiskPresentation');
+ expect(dashboardDiskListModelSource).toContain('export const getDashboardDiskUsagePercent');
expect(dashboardDiskListSource).not.toContain(
'No filesystems found. VM may be booting or using a Live ISO.',
);
diff --git a/scripts/release_control/subsystem_lookup_test.py b/scripts/release_control/subsystem_lookup_test.py
index c78681c925..dd07d813ba 100644
--- a/scripts/release_control/subsystem_lookup_test.py
+++ b/scripts/release_control/subsystem_lookup_test.py
@@ -1826,6 +1826,36 @@ class SubsystemLookupTest(unittest.TestCase):
"docs/release-control/v6/internal/subsystems/performance-and-scalability.md",
)
self.assertEqual(match["lane_context"]["lane_id"], "L10")
+
+ def test_lookup_paths_assigns_dashboard_disk_list_runtime_to_performance_and_scalability(self) -> None:
+ result = lookup_paths(
+ [
+ "frontend-modern/src/components/Dashboard/DiskList.tsx",
+ "frontend-modern/src/components/Dashboard/diskListModel.ts",
+ "frontend-modern/src/components/Dashboard/useDiskListState.ts",
+ ]
+ )
+ self.assertEqual(result["unowned_runtime_files"], [])
+ self.assertEqual(
+ {item["subsystem"] for item in result["impacted_subsystems"]},
+ {"performance-and-scalability"},
+ )
+ for file_entry in result["files"]:
+ self.assertEqual(file_entry["classification"], "runtime")
+ self.assertEqual(
+ {match["subsystem"] for match in file_entry["matches"]},
+ {"performance-and-scalability"},
+ )
+ match = file_entry["matches"][0]
+ self.assertEqual(
+ match["contract"],
+ "docs/release-control/v6/internal/subsystems/performance-and-scalability.md",
+ )
+ self.assertEqual(match["lane_context"]["lane_id"], "L10")
+ self.assertEqual(
+ match["verification_requirement"]["id"],
+ "dashboard-workload-hot-path",
+ )
self.assertEqual(
match["verification_requirement"]["id"],
"dashboard-workload-hot-path",