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 guest row runtime owners

rcourtman9e717b750d62
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 dfeebcb5e4..61efd75c00 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -27,13 +27,17 @@ 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/workloadSelectors.ts`
-9. `frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx`
-10. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts`
-11. `frontend-modern/src/components/Infrastructure/infrastructureSelectors.ts`
-12. `frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts`
-13. `frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx`
-14. `frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx`
+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/workloadSelectors.ts`
+12. `frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx`
+13. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts`
+14. `frontend-modern/src/components/Infrastructure/infrastructureSelectors.ts`
+15. `frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts`
+16. `frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx`
+17. `frontend-modern/src/components/Dashboard/__tests__/GuestRow.test.tsx`
+18. `frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx`
## Shared Boundaries
@@ -53,6 +57,7 @@ regression protection.
6. Deduplicate dashboard workload rows by canonical workload ID from `frontend-modern/src/utils/workloads.ts` rather than via local pass-through wrappers in `frontend-modern/src/components/Dashboard/Dashboard.tsx`
7. Render dashboard row identity directly from the shared canonical workload helper so row selection, hover, and fallback metadata lookup stay aligned with the same workload contract
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`
## Forbidden Paths
@@ -85,6 +90,13 @@ That runtime state owner now lives in
metadata persistence, workload-route synchronization, grouping/windowing, and
filter/sort state must extend through that owner instead of accreting back into
`frontend-modern/src/components/Dashboard/Dashboard.tsx`.
+The dashboard guest-row path now follows the same pattern: the render shell
+stays in `frontend-modern/src/components/Dashboard/GuestRow.tsx`, while the
+canonical row contract and per-row hot-path derivations live in
+`frontend-modern/src/components/Dashboard/guestRowModel.tsx` and
+`frontend-modern/src/components/Dashboard/useGuestRowState.ts`. Future row
+identity, column, anomaly-correlation, and link-state changes must extend
+through those owners instead of rebuilding row-local state inside 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 2126cbd647..b9bc379a50 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -2518,7 +2518,10 @@
],
"owned_files": [
"frontend-modern/src/components/Dashboard/Dashboard.tsx",
+ "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/useGuestRowState.ts",
"frontend-modern/src/components/Dashboard/workloadSelectors.ts",
"frontend-modern/src/components/Infrastructure/infrastructureSelectors.ts",
"frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts",
@@ -2563,7 +2566,10 @@
"match_prefixes": [],
"match_files": [
"frontend-modern/src/components/Dashboard/Dashboard.tsx",
+ "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/useGuestRowState.ts",
"frontend-modern/src/components/Dashboard/workloadSelectors.ts",
"frontend-modern/src/components/Infrastructure/infrastructureSelectors.ts",
"frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts",
@@ -2574,6 +2580,7 @@
"test_prefixes": [],
"exact_files": [
"frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx",
+ "frontend-modern/src/components/Dashboard/__tests__/GuestRow.test.tsx",
"frontend-modern/src/components/Dashboard/__tests__/workloadSelectors.test.ts",
"frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx"
]
diff --git a/frontend-modern/src/components/Dashboard/GuestRow.tsx b/frontend-modern/src/components/Dashboard/GuestRow.tsx
index 7d2f39ce89..6fd7502294 100644
--- a/frontend-modern/src/components/Dashboard/GuestRow.tsx
+++ b/frontend-modern/src/components/Dashboard/GuestRow.tsx
@@ -1,9 +1,9 @@
-import { createMemo, createSignal, createEffect, Show, For } from 'solid-js';
+import { createMemo, Show, For } from 'solid-js';
import { useTooltip } from '@/hooks/useTooltip';
import { TooltipPortal } from '@/components/shared/TooltipPortal';
import { useNavigate } from '@solidjs/router';
-import type { VM, Container, GuestNetworkInterface } from '@/types/api';
-import type { WorkloadGuest, ViewMode } from '@/types/workloads';
+import type { VM, GuestNetworkInterface } from '@/types/api';
+import type { WorkloadGuest } from '@/types/workloads';
import {
formatBytes,
formatUptime,
@@ -16,21 +16,9 @@ import { StackedDiskBar } from './StackedDiskBar';
import { StackedMemoryBar } from './StackedMemoryBar';
import { StatusDot } from '@/components/shared/StatusDot';
-import { getGuestPowerIndicator, isGuestRunning } from '@/utils/status';
-import { buildMetricKey } from '@/utils/metricsKeys';
-import {
- getCanonicalWorkloadId,
- getWorkloadMetricsKind,
- resolveWorkloadType,
-} from '@/utils/workloads';
-import { getWorkloadTypeBadge } from '@/components/shared/workloadTypeBadges';
-import { buildInfrastructureHrefForWorkload } from './infrastructureLink';
-import type { ColumnDef } from '@/hooks/useColumnVisibility';
+import { resolveWorkloadType } from '@/utils/workloads';
import { EnhancedCPUBar } from '@/components/Dashboard/EnhancedCPUBar';
-import { useBreakpoint } from '@/hooks/useBreakpoint';
import { UpdateButton } from '@/components/shared/ContainerUpdateBadge';
-import { getWorkloadDockerHostId } from './workloadSelectors';
-import { createVisibleCanonicalTypeColumn } from '@/utils/typeColumnDefinition';
import {
getDashboardGuestBackupStatusPresentation,
getDashboardGuestBackupTooltip,
@@ -39,77 +27,11 @@ import {
} from '@/utils/dashboardGuestPresentation';
import { useAlertsActivation } from '@/stores/alertsActivation';
-import { useAnomalyForMetric } from '@/hooks/useAnomalies';
+import type { GuestRowProps } from './guestRowModel';
+import { useGuestRowState } from './useGuestRowState';
type Guest = WorkloadGuest;
-interface IODistributionStats {
- median: number;
- mad: number;
- max: number;
- p97: number;
- p99: number;
- count: number;
-}
-
-export interface WorkloadIOEmphasis {
- network: IODistributionStats;
- diskIO: IODistributionStats;
-}
-
-const EMPTY_IO_DISTRIBUTION: IODistributionStats = {
- median: 0,
- mad: 0,
- max: 0,
- p97: 0,
- p99: 0,
- count: 0,
-};
-const EMPTY_IO_EMPHASIS: WorkloadIOEmphasis = {
- network: EMPTY_IO_DISTRIBUTION,
- diskIO: EMPTY_IO_DISTRIBUTION,
-};
-
-interface IOEmphasis {
- className: string;
- showOutlierHint: boolean;
-}
-
-const getOutlierEmphasis = (value: number, stats: IODistributionStats): IOEmphasis => {
- if (!Number.isFinite(value) || value <= 0 || stats.max <= 0) {
- return { className: 'text-muted', showOutlierHint: false };
- }
-
- if (stats.count < 4) {
- const ratio = value / stats.max;
- if (ratio >= 0.995) {
- return { className: 'text-base-content font-medium', showOutlierHint: true };
- }
- return { className: 'text-muted', showOutlierHint: false };
- }
-
- if (stats.mad > 0) {
- const modifiedZ = (0.6745 * (value - stats.median)) / stats.mad;
- if (modifiedZ >= 6.5 && value >= stats.p99) {
- return { className: 'text-base-content font-semibold', showOutlierHint: true };
- }
- if (modifiedZ >= 5.5 && value >= stats.p97) {
- return { className: 'text-base-content font-medium', showOutlierHint: true };
- }
- return { className: 'text-muted', showOutlierHint: false };
- }
-
- if (value >= stats.p99)
- return { className: 'text-base-content font-semibold', showOutlierHint: true };
- if (value >= stats.p97)
- return { className: 'text-base-content font-medium', showOutlierHint: true };
- if (value > 0) return { className: 'text-muted', showOutlierHint: false };
- return { className: 'text-muted', showOutlierHint: false };
-};
-
-const GROUPED_FIRST_CELL_INDENT = 'pl-3 sm:pl-5 lg:pl-8';
-const DEFAULT_FIRST_CELL_INDENT = 'pl-2 sm:pl-3';
-
// Type guard for VM vs Container
const isVM = (guest: Guest): guest is VM => {
return resolveWorkloadType(guest) === 'vm';
@@ -488,472 +410,60 @@ function InfoTooltipCell(props: { value: string; tooltip: string; type: string }
);
}
-// Column configuration using the priority system
-export const GUEST_COLUMNS: ColumnDef[] = [
- { id: 'name', label: 'Name', width: '200px', sortKey: 'name' },
- createVisibleCanonicalTypeColumn(),
- { id: 'info', label: 'Info', width: '100px' }, // Merged identifier: VMID for VMs/LXCs, image for app containers, namespace for pods
- { id: 'vmid', label: 'ID', width: '45px', sortKey: 'vmid' },
-
- // Core metrics
- { id: 'cpu', label: 'CPU', width: '140px', sortKey: 'cpu' },
- { id: 'memory', label: 'Mem', width: '140px', sortKey: 'memory' },
- { id: 'disk', label: 'Disk', width: '140px', sortKey: 'disk' },
-
- // Toggleable columns
- {
- id: 'ip',
- label: 'IP',
- icon: (
- <svg class="w-3.5 h-3.5 block" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path
- stroke-linecap="round"
- stroke-linejoin="round"
- stroke-width="2"
- d="M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"
- />
- </svg>
- ),
- width: '45px',
- toggleable: true,
- },
- {
- id: 'uptime',
- label: 'Uptime',
- icon: (
- <svg class="w-3.5 h-3.5 block" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path
- stroke-linecap="round"
- stroke-linejoin="round"
- stroke-width="2"
- d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"
- />
- </svg>
- ),
- width: '60px',
- toggleable: true,
- sortKey: 'uptime',
- },
- {
- id: 'node',
- label: 'Node',
- icon: (
- <svg class="w-3.5 h-3.5 block" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path
- stroke-linecap="round"
- stroke-linejoin="round"
- stroke-width="2"
- d="M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2m-2-4h.01M17 16h.01"
- />
- </svg>
- ),
- width: '70px',
- toggleable: true,
- sortKey: 'node',
- },
- {
- id: 'image',
- label: 'Image',
- icon: (
- <svg class="w-3.5 h-3.5 block" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <rect x="3" y="6" width="18" height="12" rx="2" />
- <path
- stroke-linecap="round"
- stroke-linejoin="round"
- stroke-width="2"
- d="M3 10h18M7 6v12M13 6v12"
- />
- </svg>
- ),
- width: '140px',
- minWidth: '120px',
- toggleable: true,
- sortKey: 'image',
- },
- {
- id: 'namespace',
- label: 'Namespace',
- icon: (
- <svg class="w-3.5 h-3.5 block" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path
- stroke-linecap="round"
- stroke-linejoin="round"
- stroke-width="2"
- d="M12 2l7 4v8l-7 4-7-4V6l7-4z"
- />
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v12" />
- </svg>
- ),
- width: '110px',
- minWidth: '90px',
- toggleable: true,
- sortKey: 'namespace',
- },
- {
- id: 'context',
- label: 'Context',
- icon: (
- <svg class="w-3.5 h-3.5 block" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path
- stroke-linecap="round"
- stroke-linejoin="round"
- stroke-width="2"
- d="M12 6v6m0 6h.01M4 6a8 8 0 018-4 8 8 0 018 4M4 18a8 8 0 008 4 8 8 0 008-4"
- />
- </svg>
- ),
- width: '120px',
- minWidth: '100px',
- toggleable: true,
- sortKey: 'contextLabel',
- },
- {
- id: 'backup',
- label: 'Backup',
- icon: (
- <svg class="w-3.5 h-3.5 block" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path
- stroke-linecap="round"
- stroke-linejoin="round"
- stroke-width="2"
- d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"
- />
- </svg>
- ),
- width: '50px',
- toggleable: true,
- },
- {
- id: 'tags',
- label: 'Tags',
- icon: (
- <svg class="w-3.5 h-3.5 block" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path
- stroke-linecap="round"
- stroke-linejoin="round"
- stroke-width="2"
- d="M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A1.994 1.994 0 013 12V7a4 4 0 014-4z"
- />
- </svg>
- ),
- width: '60px',
- toggleable: true,
- },
- { id: 'update', label: 'Update', width: '60px', toggleable: true },
- { id: 'os', label: 'OS', width: '45px', toggleable: true },
- {
- id: 'netIo',
- label: 'Net I/O',
- width: '130px',
- minWidth: '120px',
- toggleable: true,
- sortKey: 'netIo',
- },
- {
- id: 'diskIo',
- label: 'Disk I/O',
- width: '130px',
- minWidth: '120px',
- toggleable: true,
- sortKey: 'diskIo',
- },
-
- // Link column
- { id: 'link', label: '', width: '28px' },
-];
-
-/**
- * Columns relevant to each ViewMode.
- * - "all" uses the merged `info` column instead of vmid/image/namespace
- * - Type-specific views use the dedicated columns for that type
- */
-export const VIEW_MODE_COLUMNS: Record<ViewMode, Set<string> | null> = {
- all: new Set([
- 'name',
- 'type',
- 'info',
- 'cpu',
- 'memory',
- 'disk',
- 'ip',
- 'uptime',
- 'node',
- 'backup',
- 'tags',
- 'os',
- 'diskIo',
- 'netIo',
- 'link',
- ]),
- vm: new Set([
- 'name',
- 'vmid',
- 'cpu',
- 'memory',
- 'disk',
- 'ip',
- 'uptime',
- 'node',
- 'backup',
- 'tags',
- 'os',
- 'diskIo',
- 'netIo',
- 'link',
- ]),
- 'system-container': new Set([
- 'name',
- 'vmid',
- 'cpu',
- 'memory',
- 'disk',
- 'ip',
- 'uptime',
- 'node',
- 'backup',
- 'tags',
- 'os',
- 'diskIo',
- 'netIo',
- 'link',
- ]),
- 'app-container': new Set([
- 'name',
- 'cpu',
- 'memory',
- 'uptime',
- 'image',
- 'context',
- 'tags',
- 'update',
- 'link',
- ]),
- pod: new Set(['name', 'cpu', 'memory', 'image', 'namespace', 'context', 'link']),
-};
-
-interface GuestRowProps {
- guest: Guest;
- alertStyles?: {
- rowClass: string;
- indicatorClass: string;
- badgeClass: string;
- hasAlert: boolean;
- alertCount: number;
- severity: 'critical' | 'warning' | null;
- hasPoweredOffAlert?: boolean;
- hasNonPoweredOffAlert?: boolean;
- hasUnacknowledgedAlert?: boolean;
- unacknowledgedCount?: number;
- acknowledgedCount?: number;
- hasAcknowledgedOnlyAlert?: boolean;
- };
- customUrl?: string;
- onTagClick?: (tag: string) => void;
- activeSearch?: string;
- parentNodeOnline?: boolean;
- onCustomUrlUpdate?: (guestId: string, url: string) => void;
- isGroupedView?: boolean;
- /** IDs of columns that should be visible */
- visibleColumnIds?: string[];
- /** Click handler for the row */
- onClick?: () => void;
- /** Whether the row details are expanded */
- isExpanded?: boolean;
- /** Optional cross-row I/O emphasis stats for relative highlighting */
- ioEmphasis?: WorkloadIOEmphasis;
- /** Called when this row is hovered/unhovered */
- onHoverChange?: (guestId: string | null) => void;
-}
+export { GUEST_COLUMNS, VIEW_MODE_COLUMNS } from './guestRowModel';
+export type { GuestRowProps, WorkloadIOEmphasis } from './guestRowModel';
export function GuestRow(props: GuestRowProps) {
const navigate = useNavigate();
- const guestId = createMemo(() => getCanonicalWorkloadId(props.guest));
- const infrastructureHref = createMemo(() => buildInfrastructureHrefForWorkload(props.guest));
-
- // Use breakpoint hook directly for responsive behavior
- const { isMobile } = useBreakpoint();
-
- // PERFORMANCE: Use memoized Set for O(1) column visibility lookups instead of O(n) array.includes()
- const visibleColumnIdSet = createMemo(() =>
- props.visibleColumnIds ? new Set(props.visibleColumnIds) : null,
- );
-
- // Helper to check if a column is visible
- // If visibleColumnIds is not provided, show all columns for backwards compatibility
- const isColVisible = (colId: string) => {
- const set = visibleColumnIdSet();
- if (!set) return true;
- return set.has(colId);
- };
-
- const workloadType = createMemo(() => resolveWorkloadType(props.guest));
-
- // Create a stable key for per-resource metric correlation.
- const metricsKey = createMemo(() =>
- buildMetricKey(getWorkloadMetricsKind(props.guest), guestId()),
- );
-
- // Get anomalies for this guest's metrics (deterministic, no LLM)
- const cpuAnomaly = useAnomalyForMetric(guestId, () => 'cpu');
- const memoryAnomaly = useAnomalyForMetric(guestId, () => 'memory');
- const diskAnomaly = useAnomalyForMetric(guestId, () => 'disk');
-
- const [customUrl, setCustomUrl] = createSignal<string | undefined>(props.customUrl);
-
- const displayId = createMemo(() => {
- const provided = props.guest.displayId?.trim();
- if (provided) return provided;
- if (typeof props.guest.vmid === 'number' && props.guest.vmid > 0) {
- return String(props.guest.vmid);
- }
- return '';
- });
-
- const ipAddresses = createMemo(() => props.guest.ipAddresses ?? []);
- const networkInterfaces = createMemo(() => props.guest.networkInterfaces ?? []);
- const hasNetworkInterfaces = createMemo(() => networkInterfaces().length > 0);
- const osName = createMemo(() => props.guest.osName?.trim() ?? '');
- const osVersion = createMemo(() => props.guest.osVersion?.trim() ?? '');
- const agentVersion = createMemo(() => props.guest.agentVersion?.trim() ?? '');
- const hasOsInfo = createMemo(() => osName().length > 0 || osVersion().length > 0);
- const dockerImage = createMemo(() => props.guest.image?.trim() ?? '');
- const namespace = createMemo(() => props.guest.namespace?.trim() ?? '');
- const contextLabel = createMemo(() => props.guest.contextLabel?.trim() ?? '');
- const clusterName = createMemo(() => props.guest.clusterName?.trim() ?? '');
- const isPveWorkload = createMemo(() => {
- const t = workloadType();
- return t === 'vm' || t === 'system-container';
- });
-
- // Merged identifier for the "all" view — shows the most relevant ID per type
- const infoValue = createMemo(() => {
- const type = workloadType();
- if (type === 'vm' || type === 'system-container') return displayId();
- if (type === 'app-container') return dockerImage() ? getShortImageName(dockerImage()) : '';
- if (type === 'pod') return namespace();
- return '';
- });
- const infoTooltip = createMemo(() => {
- const type = workloadType();
- if (type === 'app-container') return dockerImage(); // Full image name in tooltip
- return infoValue();
- });
- const supportsBackup = createMemo(() => {
- const type = workloadType();
- return type === 'vm' || type === 'system-container';
- });
-
- const isOCIContainer = createMemo(() => {
- if (workloadType() !== 'system-container') return false;
- const container = props.guest as Container;
- return props.guest.type === 'oci-container' || container.isOci === true;
- });
-
- // OCI image info - extract clean image name from osTemplate (similar to Docker container image display)
- const ociImage = createMemo(() => {
- if (!isOCIContainer()) return null;
- const template = (props.guest as Container).osTemplate;
- if (!template) return null;
- // Strip common prefixes to get clean image reference
- let image = template;
- if (image.startsWith('oci:')) image = image.slice(4);
- if (image.startsWith('docker:')) image = image.slice(7);
- return image;
- });
-
- const typeInfo = createMemo(() => {
- if (isOCIContainer()) {
- return getWorkloadTypeBadge('oci-container', {
- title: `OCI Container${ociImage() ? ` • ${ociImage()}` : ''}`,
- });
- }
- if (workloadType() === 'app-container') {
- const runtime = (props.guest.containerRuntime || '').trim();
- const normalized = runtime.toLowerCase();
- const label =
- normalized === 'podman'
- ? 'Podman'
- : normalized === 'docker'
- ? 'Docker'
- : runtime
- ? runtime
- : 'Containers';
- const title =
- normalized === 'podman'
- ? 'Podman Container'
- : normalized === 'docker'
- ? 'Docker Container'
- : runtime
- ? `${runtime} Container`
- : 'Container (Docker-compatible runtime)';
- return getWorkloadTypeBadge('app-container', { label, title });
- }
- return getWorkloadTypeBadge(workloadType());
- });
-
- // Update custom URL when prop changes
- createEffect(() => {
- setCustomUrl(props.customUrl);
- });
+ const {
+ agentVersion,
+ clusterName,
+ contextLabel,
+ cpuAnomaly,
+ customUrl,
+ diskAnomaly,
+ diskIOEmphasis,
+ diskRead,
+ diskWrite,
+ displayId,
+ dockerHostId,
+ dockerImage,
+ firstCellIndent,
+ guestId,
+ guestStatus,
+ hasDiskUsage,
+ hasNetworkInterfaces,
+ hasOsInfo,
+ infoTooltip,
+ infoValue,
+ infrastructureHref,
+ ipAddresses,
+ isColVisible,
+ isMobile,
+ isPveWorkload,
+ isRunning,
+ lockLabel,
+ memoryAnomaly,
+ memoryPercentOnly,
+ memoryTooltip,
+ metricsKey,
+ namespace,
+ networkEmphasis,
+ networkIn,
+ networkInterfaces,
+ networkOut,
+ ociImage,
+ osName,
+ osVersion,
+ rowClass,
+ rowStyle,
+ supportsBackup,
+ typeInfo,
+ workloadType,
+ } = useGuestRowState(props);
const cpuPercent = createMemo(() => (props.guest.cpu || 0) * 100);
- // I/O metrics - must use memos for reactivity with WebSocket updates
- const diskRead = createMemo(() => props.guest.diskRead || 0);
- const diskWrite = createMemo(() => props.guest.diskWrite || 0);
- const networkIn = createMemo(() => props.guest.networkIn || 0);
- const networkOut = createMemo(() => props.guest.networkOut || 0);
- const ioEmphasis = createMemo(() => props.ioEmphasis ?? EMPTY_IO_EMPHASIS);
- const diskIOTotal = createMemo(() => diskRead() + diskWrite());
- const networkTotal = createMemo(() => networkIn() + networkOut());
- const diskIOEmphasis = createMemo(() => getOutlierEmphasis(diskIOTotal(), ioEmphasis().diskIO));
- const networkEmphasis = createMemo(() =>
- getOutlierEmphasis(networkTotal(), ioEmphasis().network),
- );
-
- const memoryExtraLines = createMemo(() => {
- if (!props.guest.memory) return undefined;
- const lines: string[] = [];
- const total = props.guest.memory.total ?? 0;
- if (
- props.guest.memory.balloon &&
- props.guest.memory.balloon > 0 &&
- props.guest.memory.balloon !== total
- ) {
- lines.push(`Balloon: ${formatBytes(props.guest.memory.balloon)}`);
- }
- if (props.guest.memory.swapTotal && props.guest.memory.swapTotal > 0) {
- const swapUsed = props.guest.memory.swapUsed ?? 0;
- lines.push(`Swap: ${formatBytes(swapUsed)} / ${formatBytes(props.guest.memory.swapTotal)}`);
- }
- return lines.length > 0 ? lines : undefined;
- });
- const memoryTooltip = createMemo(() => memoryExtraLines()?.join('\n') ?? undefined);
- const memoryPercentOnly = createMemo(() => {
- const memory = props.guest.memory;
- if (!memory) return undefined;
- if ((memory.total ?? 0) > 0) return undefined;
- const usage = memory.usage ?? 0;
- if (!Number.isFinite(usage) || usage <= 0) return undefined;
- return Math.max(0, Math.min(usage, 100));
- });
-
- const diskPercent = createMemo(() => {
- if (!props.guest.disk || props.guest.disk.total === 0) return 0;
- if (props.guest.disk.usage === -1) return -1;
- return (props.guest.disk.used / props.guest.disk.total) * 100;
- });
- const hasDiskUsage = createMemo(() => {
- if (!props.guest.disk) return false;
- if (props.guest.disk.total <= 0) return false;
- return diskPercent() !== -1;
- });
-
- const parentOnline = createMemo(() => props.parentNodeOnline !== false);
- const isRunning = createMemo(() => isGuestRunning(props.guest, parentOnline()));
- const guestStatus = createMemo(() => getGuestPowerIndicator(props.guest, parentOnline()));
- const lockLabel = createMemo(() => (props.guest.lock || '').trim());
-
const getDiskStatusTooltip = () => {
if (!isVM(props.guest)) return 'Disk stats unavailable';
@@ -961,55 +471,6 @@ export function GuestRow(props: GuestRowProps) {
return getDashboardGuestDiskStatusMessage(vm.diskStatusReason);
};
- const hasUnacknowledgedAlert = createMemo(() => !!props.alertStyles?.hasUnacknowledgedAlert);
- const hasAcknowledgedOnlyAlert = createMemo(() => !!props.alertStyles?.hasAcknowledgedOnlyAlert);
- const showAlertHighlight = createMemo(
- () => hasUnacknowledgedAlert() || hasAcknowledgedOnlyAlert(),
- );
-
- const alertAccentColor = createMemo(() => {
- if (!showAlertHighlight()) return undefined;
- if (hasUnacknowledgedAlert()) {
- return props.alertStyles?.severity === 'critical' ? '#ef4444' : '#eab308';
- }
- return '#9ca3af';
- });
-
- const rowClass = createMemo(() => {
- const base = 'transition-all duration-200 relative group cursor-pointer';
-
- if (props.isExpanded) {
- return `${base} bg-blue-50 dark:bg-blue-900 z-10 hover:shadow-sm`;
- }
-
- const hover = 'hover:shadow-sm';
- const alertBg = hasUnacknowledgedAlert()
- ? props.alertStyles?.severity === 'critical'
- ? 'bg-red-50 dark:bg-red-950'
- : 'bg-yellow-50 dark:bg-yellow-950'
- : '';
- const defaultHover = hasUnacknowledgedAlert() ? '' : 'hover:bg-surface-hover';
- const stoppedDimming = !isRunning() ? 'opacity-60' : '';
-
- return [base, hover, defaultHover, alertBg, stoppedDimming].filter(Boolean).join(' ');
- });
-
- const rowStyle = createMemo(() => {
- const styles: Record<string, string> = {
- 'min-height': '32px',
- };
-
- // Alert styling
- if (showAlertHighlight()) {
- const color = alertAccentColor();
- if (color) {
- styles['box-shadow'] = `inset 4px 0 0 0 ${color}`;
- }
- }
-
- return styles;
- });
-
return (
<>
<tr
@@ -1022,7 +483,7 @@ export function GuestRow(props: GuestRowProps) {
>
{/* Name - always visible */}
<td
- class={`pr-1.5 sm:pr-2 py-0.5 align-middle whitespace-nowrap ${props.isGroupedView ? GROUPED_FIRST_CELL_INDENT : DEFAULT_FIRST_CELL_INDENT}`}
+ class={`pr-1.5 sm:pr-2 py-0.5 align-middle whitespace-nowrap ${firstCellIndent()}`}
>
<div class="flex items-center gap-2 min-w-0">
<div class={`transition-transform duration-200 ${props.isExpanded ? 'rotate-90' : ''}`}>
@@ -1449,11 +910,11 @@ export function GuestRow(props: GuestRowProps) {
<td class="px-1.5 sm:px-2 py-0.5 align-middle">
<div class="flex justify-center">
<Show
- when={workloadType() === 'app-container' && getWorkloadDockerHostId(props.guest)}
+ when={workloadType() === 'app-container' && dockerHostId()}
>
<UpdateButton
updateStatus={props.guest.updateStatus}
- agentId={getWorkloadDockerHostId(props.guest)}
+ agentId={dockerHostId()}
containerId={props.guest.id ?? ''}
containerName={props.guest.name}
compact={true}
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 a056ba29c4..12309af1bd 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 guestRowSource from '../GuestRow.tsx?raw';
+import guestRowModelSource from '../guestRowModel.tsx?raw';
+import guestRowStateSource from '../useGuestRowState.ts?raw';
import {
filterWorkloads,
createWorkloadSortComparator,
@@ -461,10 +464,23 @@ describe('Dashboard performance contract', () => {
expect(dashboardSource).not.toContain('const [search, setSearch] = createSignal(');
expect(dashboardStateSource).toContain('useGroupedTableWindowing');
expect(dashboardStateSource).toContain('createWorkloadSortComparator');
+ expect(dashboardStateSource).toContain("from './guestRowModel'");
+ expect(dashboardStateSource).not.toContain("from './GuestRow'");
expect(dashboardSource).toContain('createMemo(() => getCanonicalWorkloadId(guest()))');
expect(dashboardStateSource).not.toContain('const guestId = () => {');
});
+ it('keeps guest row contract and hot-path state in canonical row owners', () => {
+ expect(guestRowSource).toContain('useGuestRowState');
+ expect(guestRowSource).not.toContain('export const GUEST_COLUMNS');
+ expect(guestRowSource).not.toContain('const guestId = createMemo(');
+ expect(guestRowModelSource).toContain('export const GUEST_COLUMNS');
+ expect(guestRowModelSource).toContain('export const VIEW_MODE_COLUMNS');
+ expect(guestRowStateSource).toContain('getCanonicalWorkloadId');
+ expect(guestRowStateSource).toContain('buildMetricKey');
+ expect(guestRowStateSource).toContain('getWorkloadTypeBadge');
+ });
+
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__/GuestRow.test.tsx b/frontend-modern/src/components/Dashboard/__tests__/GuestRow.test.tsx
index 82f903fe75..023114a922 100644
--- a/frontend-modern/src/components/Dashboard/__tests__/GuestRow.test.tsx
+++ b/frontend-modern/src/components/Dashboard/__tests__/GuestRow.test.tsx
@@ -108,7 +108,8 @@ vi.mock('../workloadSelectors', () => ({
}));
// After mocks, import
-import { GuestRow, GUEST_COLUMNS, VIEW_MODE_COLUMNS, type WorkloadIOEmphasis } from '../GuestRow';
+import { GuestRow } from '../GuestRow';
+import { GUEST_COLUMNS, VIEW_MODE_COLUMNS, type WorkloadIOEmphasis } from '../guestRowModel';
// ── Helpers ────────────────────────────────────────────────────────────
diff --git a/frontend-modern/src/components/Dashboard/guestRowModel.tsx b/frontend-modern/src/components/Dashboard/guestRowModel.tsx
new file mode 100644
index 0000000000..fa758bbcbc
--- /dev/null
+++ b/frontend-modern/src/components/Dashboard/guestRowModel.tsx
@@ -0,0 +1,338 @@
+import type { ColumnDef } from '@/hooks/useColumnVisibility';
+import type { WorkloadGuest, ViewMode } from '@/types/workloads';
+import { createVisibleCanonicalTypeColumn } from '@/utils/typeColumnDefinition';
+
+export interface IODistributionStats {
+ median: number;
+ mad: number;
+ max: number;
+ p97: number;
+ p99: number;
+ count: number;
+}
+
+export interface WorkloadIOEmphasis {
+ network: IODistributionStats;
+ diskIO: IODistributionStats;
+}
+
+export interface GuestRowProps {
+ guest: WorkloadGuest;
+ alertStyles?: {
+ rowClass: string;
+ indicatorClass: string;
+ badgeClass: string;
+ hasAlert: boolean;
+ alertCount: number;
+ severity: 'critical' | 'warning' | null;
+ hasPoweredOffAlert?: boolean;
+ hasNonPoweredOffAlert?: boolean;
+ hasUnacknowledgedAlert?: boolean;
+ unacknowledgedCount?: number;
+ acknowledgedCount?: number;
+ hasAcknowledgedOnlyAlert?: boolean;
+ };
+ customUrl?: string;
+ onTagClick?: (tag: string) => void;
+ activeSearch?: string;
+ parentNodeOnline?: boolean;
+ onCustomUrlUpdate?: (guestId: string, url: string) => void;
+ isGroupedView?: boolean;
+ visibleColumnIds?: string[];
+ onClick?: () => void;
+ isExpanded?: boolean;
+ ioEmphasis?: WorkloadIOEmphasis;
+ onHoverChange?: (guestId: string | null) => void;
+}
+
+export interface IOEmphasis {
+ className: string;
+ showOutlierHint: boolean;
+}
+
+export const EMPTY_IO_DISTRIBUTION: IODistributionStats = {
+ median: 0,
+ mad: 0,
+ max: 0,
+ p97: 0,
+ p99: 0,
+ count: 0,
+};
+
+export const EMPTY_IO_EMPHASIS: WorkloadIOEmphasis = {
+ network: EMPTY_IO_DISTRIBUTION,
+ diskIO: EMPTY_IO_DISTRIBUTION,
+};
+
+export const GROUPED_FIRST_CELL_INDENT = 'pl-3 sm:pl-5 lg:pl-8';
+export const DEFAULT_FIRST_CELL_INDENT = 'pl-2 sm:pl-3';
+
+export const getOutlierEmphasis = (
+ value: number,
+ stats: IODistributionStats,
+): IOEmphasis => {
+ if (!Number.isFinite(value) || value <= 0 || stats.max <= 0) {
+ return { className: 'text-muted', showOutlierHint: false };
+ }
+
+ if (stats.count < 4) {
+ const ratio = value / stats.max;
+ if (ratio >= 0.995) {
+ return { className: 'text-base-content font-medium', showOutlierHint: true };
+ }
+ return { className: 'text-muted', showOutlierHint: false };
+ }
+
+ if (stats.mad > 0) {
+ const modifiedZ = (0.6745 * (value - stats.median)) / stats.mad;
+ if (modifiedZ >= 6.5 && value >= stats.p99) {
+ return { className: 'text-base-content font-semibold', showOutlierHint: true };
+ }
+ if (modifiedZ >= 5.5 && value >= stats.p97) {
+ return { className: 'text-base-content font-medium', showOutlierHint: true };
+ }
+ return { className: 'text-muted', showOutlierHint: false };
+ }
+
+ if (value >= stats.p99) {
+ return { className: 'text-base-content font-semibold', showOutlierHint: true };
+ }
+ if (value >= stats.p97) {
+ return { className: 'text-base-content font-medium', showOutlierHint: true };
+ }
+ if (value > 0) {
+ return { className: 'text-muted', showOutlierHint: false };
+ }
+ return { className: 'text-muted', showOutlierHint: false };
+};
+
+export const GUEST_COLUMNS: ColumnDef[] = [
+ { id: 'name', label: 'Name', width: '200px', sortKey: 'name' },
+ createVisibleCanonicalTypeColumn(),
+ { id: 'info', label: 'Info', width: '100px' },
+ { id: 'vmid', label: 'ID', width: '45px', sortKey: 'vmid' },
+ { id: 'cpu', label: 'CPU', width: '140px', sortKey: 'cpu' },
+ { id: 'memory', label: 'Mem', width: '140px', sortKey: 'memory' },
+ { id: 'disk', label: 'Disk', width: '140px', sortKey: 'disk' },
+ {
+ id: 'ip',
+ label: 'IP',
+ icon: (
+ <svg class="w-3.5 h-3.5 block" fill="none" stroke="currentColor" viewBox="0 0 24 24">
+ <path
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ d="M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"
+ />
+ </svg>
+ ),
+ width: '45px',
+ toggleable: true,
+ },
+ {
+ id: 'uptime',
+ label: 'Uptime',
+ icon: (
+ <svg class="w-3.5 h-3.5 block" fill="none" stroke="currentColor" viewBox="0 0 24 24">
+ <path
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"
+ />
+ </svg>
+ ),
+ width: '60px',
+ toggleable: true,
+ sortKey: 'uptime',
+ },
+ {
+ id: 'node',
+ label: 'Node',
+ icon: (
+ <svg class="w-3.5 h-3.5 block" fill="none" stroke="currentColor" viewBox="0 0 24 24">
+ <path
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ d="M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2m-2-4h.01M17 16h.01"
+ />
+ </svg>
+ ),
+ width: '70px',
+ toggleable: true,
+ sortKey: 'node',
+ },
+ {
+ id: 'image',
+ label: 'Image',
+ icon: (
+ <svg class="w-3.5 h-3.5 block" fill="none" stroke="currentColor" viewBox="0 0 24 24">
+ <rect x="3" y="6" width="18" height="12" rx="2" />
+ <path
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ d="M3 10h18M7 6v12M13 6v12"
+ />
+ </svg>
+ ),
+ width: '140px',
+ minWidth: '120px',
+ toggleable: true,
+ sortKey: 'image',
+ },
+ {
+ id: 'namespace',
+ label: 'Namespace',
+ icon: (
+ <svg class="w-3.5 h-3.5 block" fill="none" stroke="currentColor" viewBox="0 0 24 24">
+ <path
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ d="M12 2l7 4v8l-7 4-7-4V6l7-4z"
+ />
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v12" />
+ </svg>
+ ),
+ width: '110px',
+ minWidth: '90px',
+ toggleable: true,
+ sortKey: 'namespace',
+ },
+ {
+ id: 'context',
+ label: 'Context',
+ icon: (
+ <svg class="w-3.5 h-3.5 block" fill="none" stroke="currentColor" viewBox="0 0 24 24">
+ <path
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ d="M12 6v6m0 6h.01M4 6a8 8 0 018-4 8 8 0 018 4M4 18a8 8 0 008 4 8 8 0 008-4"
+ />
+ </svg>
+ ),
+ width: '120px',
+ minWidth: '100px',
+ toggleable: true,
+ sortKey: 'contextLabel',
+ },
+ {
+ id: 'backup',
+ label: 'Backup',
+ icon: (
+ <svg class="w-3.5 h-3.5 block" fill="none" stroke="currentColor" viewBox="0 0 24 24">
+ <path
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"
+ />
+ </svg>
+ ),
+ width: '50px',
+ toggleable: true,
+ },
+ {
+ id: 'tags',
+ label: 'Tags',
+ icon: (
+ <svg class="w-3.5 h-3.5 block" fill="none" stroke="currentColor" viewBox="0 0 24 24">
+ <path
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ d="M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A1.994 1.994 0 013 12V7a4 4 0 014-4z"
+ />
+ </svg>
+ ),
+ width: '60px',
+ toggleable: true,
+ },
+ { id: 'update', label: 'Update', width: '60px', toggleable: true },
+ { id: 'os', label: 'OS', width: '45px', toggleable: true },
+ {
+ id: 'netIo',
+ label: 'Net I/O',
+ width: '130px',
+ minWidth: '120px',
+ toggleable: true,
+ sortKey: 'netIo',
+ },
+ {
+ id: 'diskIo',
+ label: 'Disk I/O',
+ width: '130px',
+ minWidth: '120px',
+ toggleable: true,
+ sortKey: 'diskIo',
+ },
+ { id: 'link', label: '', width: '28px' },
+];
+
+export const VIEW_MODE_COLUMNS: Record<ViewMode, Set<string> | null> = {
+ all: new Set([
+ 'name',
+ 'type',
+ 'info',
+ 'cpu',
+ 'memory',
+ 'disk',
+ 'ip',
+ 'uptime',
+ 'node',
+ 'backup',
+ 'tags',
+ 'os',
+ 'diskIo',
+ 'netIo',
+ 'link',
+ ]),
+ vm: new Set([
+ 'name',
+ 'vmid',
+ 'cpu',
+ 'memory',
+ 'disk',
+ 'ip',
+ 'uptime',
+ 'node',
+ 'backup',
+ 'tags',
+ 'os',
+ 'diskIo',
+ 'netIo',
+ 'link',
+ ]),
+ 'system-container': new Set([
+ 'name',
+ 'vmid',
+ 'cpu',
+ 'memory',
+ 'disk',
+ 'ip',
+ 'uptime',
+ 'node',
+ 'backup',
+ 'tags',
+ 'os',
+ 'diskIo',
+ 'netIo',
+ 'link',
+ ]),
+ 'app-container': new Set([
+ 'name',
+ 'cpu',
+ 'memory',
+ 'uptime',
+ 'image',
+ 'context',
+ 'tags',
+ 'update',
+ 'link',
+ ]),
+ pod: new Set(['name', 'cpu', 'memory', 'image', 'namespace', 'context', 'link']),
+};
diff --git a/frontend-modern/src/components/Dashboard/useDashboardState.ts b/frontend-modern/src/components/Dashboard/useDashboardState.ts
index d2a09f6f70..e6575b6f8e 100644
--- a/frontend-modern/src/components/Dashboard/useDashboardState.ts
+++ b/frontend-modern/src/components/Dashboard/useDashboardState.ts
@@ -2,7 +2,7 @@ import { createEffect, createMemo, createSignal, onCleanup, onMount, untrack } f
import { useLocation, useNavigate } from '@solidjs/router';
import type { VM, Container, Node } from '@/types/api';
import type { WorkloadGuest, ViewMode } from '@/types/workloads';
-import { GUEST_COLUMNS, VIEW_MODE_COLUMNS } from './GuestRow';
+import { GUEST_COLUMNS, VIEW_MODE_COLUMNS } from './guestRowModel';
import { useWebSocket } from '@/App';
import { useAlertsActivation } from '@/stores/alertsActivation';
import { GuestMetadataAPI } from '@/api/guestMetadata';
diff --git a/frontend-modern/src/components/Dashboard/useGuestRowState.ts b/frontend-modern/src/components/Dashboard/useGuestRowState.ts
new file mode 100644
index 0000000000..13b5076355
--- /dev/null
+++ b/frontend-modern/src/components/Dashboard/useGuestRowState.ts
@@ -0,0 +1,301 @@
+import { createMemo } from 'solid-js';
+
+import { useBreakpoint } from '@/hooks/useBreakpoint';
+import { useAnomalyForMetric } from '@/hooks/useAnomalies';
+import { buildMetricKey } from '@/utils/metricsKeys';
+import { getGuestPowerIndicator, isGuestRunning } from '@/utils/status';
+import { getShortImageName, formatBytes } from '@/utils/format';
+import {
+ getCanonicalWorkloadId,
+ getWorkloadMetricsKind,
+ resolveWorkloadType,
+} from '@/utils/workloads';
+import { getWorkloadTypeBadge } from '@/components/shared/workloadTypeBadges';
+
+import { buildInfrastructureHrefForWorkload } from './infrastructureLink';
+import { getWorkloadDockerHostId } from './workloadSelectors';
+import {
+ DEFAULT_FIRST_CELL_INDENT,
+ EMPTY_IO_EMPHASIS,
+ GROUPED_FIRST_CELL_INDENT,
+ getOutlierEmphasis,
+ type GuestRowProps,
+} from './guestRowModel';
+
+export function useGuestRowState(props: GuestRowProps) {
+ const { isMobile } = useBreakpoint();
+
+ const guestId = createMemo(() => getCanonicalWorkloadId(props.guest));
+ const infrastructureHref = createMemo(() => buildInfrastructureHrefForWorkload(props.guest));
+
+ const visibleColumnIdSet = createMemo(() =>
+ props.visibleColumnIds ? new Set(props.visibleColumnIds) : null,
+ );
+
+ const isColVisible = (colId: string) => {
+ const set = visibleColumnIdSet();
+ if (!set) return true;
+ return set.has(colId);
+ };
+
+ const workloadType = createMemo(() => resolveWorkloadType(props.guest));
+ const metricsKey = createMemo(() =>
+ buildMetricKey(getWorkloadMetricsKind(props.guest), guestId()),
+ );
+
+ const cpuAnomaly = useAnomalyForMetric(guestId, () => 'cpu');
+ const memoryAnomaly = useAnomalyForMetric(guestId, () => 'memory');
+ const diskAnomaly = useAnomalyForMetric(guestId, () => 'disk');
+
+ const customUrl = createMemo(() => props.customUrl?.trim() ?? '');
+
+ const displayId = createMemo(() => {
+ const provided = props.guest.displayId?.trim();
+ if (provided) return provided;
+ if (typeof props.guest.vmid === 'number' && props.guest.vmid > 0) {
+ return String(props.guest.vmid);
+ }
+ return '';
+ });
+
+ const ipAddresses = createMemo(() => props.guest.ipAddresses ?? []);
+ const networkInterfaces = createMemo(() => props.guest.networkInterfaces ?? []);
+ const hasNetworkInterfaces = createMemo(() => networkInterfaces().length > 0);
+ const osName = createMemo(() => props.guest.osName?.trim() ?? '');
+ const osVersion = createMemo(() => props.guest.osVersion?.trim() ?? '');
+ const agentVersion = createMemo(() => props.guest.agentVersion?.trim() ?? '');
+ const hasOsInfo = createMemo(() => osName().length > 0 || osVersion().length > 0);
+ const dockerImage = createMemo(() => props.guest.image?.trim() ?? '');
+ const namespace = createMemo(() => props.guest.namespace?.trim() ?? '');
+ const contextLabel = createMemo(() => props.guest.contextLabel?.trim() ?? '');
+ const clusterName = createMemo(() => props.guest.clusterName?.trim() ?? '');
+ const isPveWorkload = createMemo(() => {
+ const type = workloadType();
+ return type === 'vm' || type === 'system-container';
+ });
+
+ const infoValue = createMemo(() => {
+ const type = workloadType();
+ if (type === 'vm' || type === 'system-container') return displayId();
+ if (type === 'app-container') return dockerImage() ? getShortImageName(dockerImage()) : '';
+ if (type === 'pod') return namespace();
+ return '';
+ });
+
+ const infoTooltip = createMemo(() => {
+ if (workloadType() === 'app-container') return dockerImage();
+ return infoValue();
+ });
+
+ const supportsBackup = createMemo(() => {
+ const type = workloadType();
+ return type === 'vm' || type === 'system-container';
+ });
+
+ const isOCIContainer = createMemo(() => {
+ if (workloadType() !== 'system-container') return false;
+ return props.guest.type === 'oci-container' || props.guest.isOci === true;
+ });
+
+ const ociImage = createMemo(() => {
+ if (!isOCIContainer()) return null;
+
+ const template = props.guest.osTemplate;
+ if (!template) return null;
+
+ let image = template;
+ if (image.startsWith('oci:')) image = image.slice(4);
+ if (image.startsWith('docker:')) image = image.slice(7);
+ return image;
+ });
+
+ const typeInfo = createMemo(() => {
+ if (isOCIContainer()) {
+ return getWorkloadTypeBadge('oci-container', {
+ title: `OCI Container${ociImage() ? ` • ${ociImage()}` : ''}`,
+ });
+ }
+
+ if (workloadType() === 'app-container') {
+ const runtime = (props.guest.containerRuntime || '').trim();
+ const normalized = runtime.toLowerCase();
+ const label =
+ normalized === 'podman'
+ ? 'Podman'
+ : normalized === 'docker'
+ ? 'Docker'
+ : runtime
+ ? runtime
+ : 'Containers';
+ const title =
+ normalized === 'podman'
+ ? 'Podman Container'
+ : normalized === 'docker'
+ ? 'Docker Container'
+ : runtime
+ ? `${runtime} Container`
+ : 'Container (Docker-compatible runtime)';
+ return getWorkloadTypeBadge('app-container', { label, title });
+ }
+
+ return getWorkloadTypeBadge(workloadType());
+ });
+
+ const diskRead = createMemo(() => props.guest.diskRead || 0);
+ const diskWrite = createMemo(() => props.guest.diskWrite || 0);
+ const networkIn = createMemo(() => props.guest.networkIn || 0);
+ const networkOut = createMemo(() => props.guest.networkOut || 0);
+ const ioEmphasis = createMemo(() => props.ioEmphasis ?? EMPTY_IO_EMPHASIS);
+ const diskIOTotal = createMemo(() => diskRead() + diskWrite());
+ const networkTotal = createMemo(() => networkIn() + networkOut());
+ const diskIOEmphasis = createMemo(() => getOutlierEmphasis(diskIOTotal(), ioEmphasis().diskIO));
+ const networkEmphasis = createMemo(() =>
+ getOutlierEmphasis(networkTotal(), ioEmphasis().network),
+ );
+
+ const memoryExtraLines = createMemo(() => {
+ if (!props.guest.memory) return undefined;
+
+ const lines: string[] = [];
+ const total = props.guest.memory.total ?? 0;
+ if (
+ props.guest.memory.balloon &&
+ props.guest.memory.balloon > 0 &&
+ props.guest.memory.balloon !== total
+ ) {
+ lines.push(`Balloon: ${formatBytes(props.guest.memory.balloon)}`);
+ }
+ if (props.guest.memory.swapTotal && props.guest.memory.swapTotal > 0) {
+ const swapUsed = props.guest.memory.swapUsed ?? 0;
+ lines.push(`Swap: ${formatBytes(swapUsed)} / ${formatBytes(props.guest.memory.swapTotal)}`);
+ }
+ return lines.length > 0 ? lines : undefined;
+ });
+
+ const memoryTooltip = createMemo(() => memoryExtraLines()?.join('\n') ?? undefined);
+ const memoryPercentOnly = createMemo(() => {
+ const memory = props.guest.memory;
+ if (!memory) return undefined;
+ if ((memory.total ?? 0) > 0) return undefined;
+
+ const usage = memory.usage ?? 0;
+ if (!Number.isFinite(usage) || usage <= 0) return undefined;
+ return Math.max(0, Math.min(usage, 100));
+ });
+
+ const diskPercent = createMemo(() => {
+ if (!props.guest.disk || props.guest.disk.total === 0) return 0;
+ if (props.guest.disk.usage === -1) return -1;
+ return (props.guest.disk.used / props.guest.disk.total) * 100;
+ });
+
+ const hasDiskUsage = createMemo(() => {
+ if (!props.guest.disk) return false;
+ if (props.guest.disk.total <= 0) return false;
+ return diskPercent() !== -1;
+ });
+
+ const parentOnline = createMemo(() => props.parentNodeOnline !== false);
+ const isRunning = createMemo(() => isGuestRunning(props.guest, parentOnline()));
+ const guestStatus = createMemo(() => getGuestPowerIndicator(props.guest, parentOnline()));
+ const lockLabel = createMemo(() => (props.guest.lock || '').trim());
+
+ const hasUnacknowledgedAlert = createMemo(() => !!props.alertStyles?.hasUnacknowledgedAlert);
+ const hasAcknowledgedOnlyAlert = createMemo(() => !!props.alertStyles?.hasAcknowledgedOnlyAlert);
+ const showAlertHighlight = createMemo(
+ () => hasUnacknowledgedAlert() || hasAcknowledgedOnlyAlert(),
+ );
+
+ const alertAccentColor = createMemo(() => {
+ if (!showAlertHighlight()) return undefined;
+ if (hasUnacknowledgedAlert()) {
+ return props.alertStyles?.severity === 'critical' ? '#ef4444' : '#eab308';
+ }
+ return '#9ca3af';
+ });
+
+ const rowClass = createMemo(() => {
+ const base = 'transition-all duration-200 relative group cursor-pointer';
+
+ if (props.isExpanded) {
+ return `${base} bg-blue-50 dark:bg-blue-900 z-10 hover:shadow-sm`;
+ }
+
+ const hover = 'hover:shadow-sm';
+ const alertBg = hasUnacknowledgedAlert()
+ ? props.alertStyles?.severity === 'critical'
+ ? 'bg-red-50 dark:bg-red-950'
+ : 'bg-yellow-50 dark:bg-yellow-950'
+ : '';
+ const defaultHover = hasUnacknowledgedAlert() ? '' : 'hover:bg-surface-hover';
+ const stoppedDimming = !isRunning() ? 'opacity-60' : '';
+
+ return [base, hover, defaultHover, alertBg, stoppedDimming].filter(Boolean).join(' ');
+ });
+
+ const rowStyle = createMemo(() => {
+ const styles: Record<string, string> = { 'min-height': '32px' };
+ if (showAlertHighlight()) {
+ const color = alertAccentColor();
+ if (color) {
+ styles['box-shadow'] = `inset 4px 0 0 0 ${color}`;
+ }
+ }
+ return styles;
+ });
+
+ const firstCellIndent = createMemo(() =>
+ props.isGroupedView ? GROUPED_FIRST_CELL_INDENT : DEFAULT_FIRST_CELL_INDENT,
+ );
+
+ const dockerHostId = createMemo(() => getWorkloadDockerHostId(props.guest));
+
+ return {
+ cpuAnomaly,
+ customUrl,
+ diskAnomaly,
+ diskIOEmphasis,
+ diskPercent,
+ diskRead,
+ diskWrite,
+ displayId,
+ dockerHostId,
+ dockerImage,
+ firstCellIndent,
+ guestId,
+ guestStatus,
+ hasDiskUsage,
+ hasNetworkInterfaces,
+ hasOsInfo,
+ infoTooltip,
+ infoValue,
+ infrastructureHref,
+ ipAddresses,
+ isColVisible,
+ isMobile,
+ isOCIContainer,
+ isPveWorkload,
+ isRunning,
+ lockLabel,
+ memoryAnomaly,
+ memoryPercentOnly,
+ memoryTooltip,
+ metricsKey,
+ namespace,
+ networkEmphasis,
+ networkIn,
+ networkInterfaces,
+ networkOut,
+ ociImage,
+ osName,
+ osVersion,
+ supportsBackup,
+ typeInfo,
+ workloadType,
+ contextLabel,
+ clusterName,
+ agentVersion,
+ rowClass,
+ rowStyle,
+ };
+}
diff --git a/frontend-modern/src/components/Dashboard/workloadSelectors.ts b/frontend-modern/src/components/Dashboard/workloadSelectors.ts
index e947395ce8..e4f24bf4cc 100644
--- a/frontend-modern/src/components/Dashboard/workloadSelectors.ts
+++ b/frontend-modern/src/components/Dashboard/workloadSelectors.ts
@@ -1,6 +1,6 @@
import type { Node } from '@/types/api';
import type { WorkloadGuest, ViewMode } from '@/types/workloads';
-import type { WorkloadIOEmphasis } from './GuestRow';
+import type { WorkloadIOEmphasis } from './guestRowModel';
import { computeIOScale } from '@/components/Infrastructure/infrastructureSelectors';
import { parseFilterStack, evaluateFilterStack } from '@/utils/searchQuery';
import { DEGRADED_HEALTH_STATUSES, OFFLINE_HEALTH_STATUSES } from '@/utils/status';
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index d64502f623..b993cb418b 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -96,6 +96,8 @@ import recentAlertsPanelSource from '@/pages/DashboardPanels/RecentAlertsPanel.t
import storagePanelSource from '@/pages/DashboardPanels/StoragePanel.tsx?raw';
import recoveryStatusPanelSource from '@/pages/DashboardPanels/RecoveryStatusPanel.tsx?raw';
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 guestDrawerSource from '@/components/Dashboard/GuestDrawer.tsx?raw';
import dashboardGuestPresentationSource from '@/utils/dashboardGuestPresentation.ts?raw';
@@ -503,7 +505,10 @@ describe('frontend resource type boundaries', () => {
expect(infrastructureSummarySource).not.toContain("getOrgID() || 'default'");
expect(storageSummarySource).toContain('normalizeOrgScope(getOrgID())');
expect(storageSummarySource).not.toContain("getOrgID() || 'default'");
- expect(guestRowSource).toContain('getCanonicalWorkloadId');
+ expect(guestRowSource).toContain('useGuestRowState');
+ expect(guestRowSource).not.toContain('const guestId = createMemo(');
+ expect(guestRowStateSource).toContain('getCanonicalWorkloadId');
+ expect(guestRowModelSource).toContain('export const GUEST_COLUMNS');
expect(guestRowSource).not.toContain('buildGuestId');
expect(guestDrawerSource).toContain('getCanonicalWorkloadId');
expect(guestDrawerSource).not.toContain('const guestId = () => {');
diff --git a/scripts/release_control/subsystem_lookup_test.py b/scripts/release_control/subsystem_lookup_test.py
index 2ba9ef8aa7..1ac0bcb737 100644
--- a/scripts/release_control/subsystem_lookup_test.py
+++ b/scripts/release_control/subsystem_lookup_test.py
@@ -1771,6 +1771,36 @@ class SubsystemLookupTest(unittest.TestCase):
match["verification_requirement"]["exact_files"],
)
+ def test_lookup_paths_assigns_dashboard_guest_row_runtime_to_performance_and_scalability(self) -> None:
+ result = lookup_paths(
+ [
+ "frontend-modern/src/components/Dashboard/GuestRow.tsx",
+ "frontend-modern/src/components/Dashboard/guestRowModel.tsx",
+ "frontend-modern/src/components/Dashboard/useGuestRowState.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",
+ )
+
def test_lookup_paths_assigns_settings_page_shell_to_frontend_primitives(self) -> None:
result = lookup_paths(["frontend-modern/src/components/Settings/SettingsPageShell.tsx"])
self.assertEqual(result["unowned_runtime_files"], [])