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 enhanced CPU bar runtime owners

rcourtman42b7be76df04
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 027568f5b4..e4c8fa4bd2 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -42,35 +42,40 @@ regression protection.
20. `frontend-modern/src/components/Dashboard/MetricBar.tsx`
21. `frontend-modern/src/components/Dashboard/metricBarModel.ts`
22. `frontend-modern/src/components/Dashboard/useMetricBarState.ts`
-23. `frontend-modern/src/components/Dashboard/DiskList.tsx`
-24. `frontend-modern/src/components/Dashboard/diskListModel.ts`
-25. `frontend-modern/src/components/Dashboard/useDiskListState.ts`
-26. `frontend-modern/src/components/Dashboard/GuestRow.tsx`
-27. `frontend-modern/src/components/Dashboard/guestRowModel.tsx`
-28. `frontend-modern/src/components/Dashboard/useGuestRowState.ts`
-29. `frontend-modern/src/components/Dashboard/GuestDrawer.tsx`
-30. `frontend-modern/src/components/Dashboard/guestDrawerModel.ts`
-31. `frontend-modern/src/components/Dashboard/useGuestDrawerState.ts`
-32. `frontend-modern/src/components/Dashboard/workloadSelectors.ts`
-33. `frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx`
-34. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts`
-35. `frontend-modern/src/components/Infrastructure/infrastructureSelectors.ts`
-36. `frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts`
-37. `frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx`
-38. `frontend-modern/src/components/Dashboard/__tests__/DashboardFilter.test.tsx`
-39. `frontend-modern/src/components/Dashboard/__tests__/useDashboardFilterState.test.ts`
-40. `frontend-modern/src/components/Dashboard/MetricBar.test.tsx`
-41. `frontend-modern/src/components/Dashboard/__tests__/useMetricBarState.test.tsx`
-42. `frontend-modern/src/components/Dashboard/ThresholdSlider.test.tsx`
-43. `frontend-modern/src/components/Dashboard/__tests__/useThresholdSliderState.test.ts`
-44. `frontend-modern/src/components/Dashboard/__tests__/StackedDiskBar.test.tsx`
-45. `frontend-modern/src/components/Dashboard/__tests__/useStackedDiskBarState.test.tsx`
-46. `frontend-modern/src/components/Dashboard/StackedMemoryBar.test.tsx`
-47. `frontend-modern/src/components/Dashboard/__tests__/useStackedMemoryBarState.test.tsx`
-48. `frontend-modern/src/components/Dashboard/__tests__/DiskList.test.tsx`
-49. `frontend-modern/src/components/Dashboard/__tests__/GuestRow.test.tsx`
-50. `frontend-modern/src/components/Dashboard/GuestDrawer.test.tsx`
-51. `frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx`
+23. `frontend-modern/src/components/Dashboard/EnhancedCPUBar.tsx`
+24. `frontend-modern/src/components/Dashboard/enhancedCpuBarModel.ts`
+25. `frontend-modern/src/components/Dashboard/useEnhancedCPUBarState.ts`
+26. `frontend-modern/src/components/Dashboard/DiskList.tsx`
+27. `frontend-modern/src/components/Dashboard/diskListModel.ts`
+28. `frontend-modern/src/components/Dashboard/useDiskListState.ts`
+29. `frontend-modern/src/components/Dashboard/GuestRow.tsx`
+30. `frontend-modern/src/components/Dashboard/guestRowModel.tsx`
+31. `frontend-modern/src/components/Dashboard/useGuestRowState.ts`
+32. `frontend-modern/src/components/Dashboard/GuestDrawer.tsx`
+33. `frontend-modern/src/components/Dashboard/guestDrawerModel.ts`
+34. `frontend-modern/src/components/Dashboard/useGuestDrawerState.ts`
+35. `frontend-modern/src/components/Dashboard/workloadSelectors.ts`
+36. `frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx`
+37. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts`
+38. `frontend-modern/src/components/Infrastructure/infrastructureSelectors.ts`
+39. `frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts`
+40. `frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx`
+41. `frontend-modern/src/components/Dashboard/__tests__/DashboardFilter.test.tsx`
+42. `frontend-modern/src/components/Dashboard/__tests__/useDashboardFilterState.test.ts`
+43. `frontend-modern/src/components/Dashboard/MetricBar.test.tsx`
+44. `frontend-modern/src/components/Dashboard/__tests__/useMetricBarState.test.tsx`
+45. `frontend-modern/src/components/Dashboard/__tests__/EnhancedCPUBar.test.tsx`
+46. `frontend-modern/src/components/Dashboard/__tests__/useEnhancedCPUBarState.test.tsx`
+47. `frontend-modern/src/components/Dashboard/ThresholdSlider.test.tsx`
+48. `frontend-modern/src/components/Dashboard/__tests__/useThresholdSliderState.test.ts`
+49. `frontend-modern/src/components/Dashboard/__tests__/StackedDiskBar.test.tsx`
+50. `frontend-modern/src/components/Dashboard/__tests__/useStackedDiskBarState.test.tsx`
+51. `frontend-modern/src/components/Dashboard/StackedMemoryBar.test.tsx`
+52. `frontend-modern/src/components/Dashboard/__tests__/useStackedMemoryBarState.test.tsx`
+53. `frontend-modern/src/components/Dashboard/__tests__/DiskList.test.tsx`
+54. `frontend-modern/src/components/Dashboard/__tests__/GuestRow.test.tsx`
+55. `frontend-modern/src/components/Dashboard/GuestDrawer.test.tsx`
+56. `frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx`
## Shared Boundaries
@@ -98,6 +103,7 @@ regression protection.
14. Extend stacked disk-bar capacity math, segment/tooltip derivation, and resize-observer runtime through `frontend-modern/src/components/Dashboard/stackedDiskBarModel.ts` and `frontend-modern/src/components/Dashboard/useStackedDiskBarState.ts` rather than rebuilding disk-bar-local state, mode branching, and tooltip shaping inside `frontend-modern/src/components/Dashboard/StackedDiskBar.tsx`
15. Extend stacked memory-bar capacity math, balloon/swap derivation, and resize-observer runtime through `frontend-modern/src/components/Dashboard/stackedMemoryBarModel.ts` and `frontend-modern/src/components/Dashboard/useStackedMemoryBarState.ts` rather than rebuilding memory-bar-local state, tooltip shaping, and label-fit logic inside `frontend-modern/src/components/Dashboard/StackedMemoryBar.tsx`
16. Extend metric-bar width, label-fit logic, and resize-observer runtime through `frontend-modern/src/components/Dashboard/metricBarModel.ts` and `frontend-modern/src/components/Dashboard/useMetricBarState.ts` rather than rebuilding metric-local state and threshold mapping inside `frontend-modern/src/components/Dashboard/MetricBar.tsx`
+17. Extend enhanced CPU bar usage/anomaly presentation and tooltip runtime through `frontend-modern/src/components/Dashboard/enhancedCpuBarModel.ts` and `frontend-modern/src/components/Dashboard/useEnhancedCPUBarState.ts` rather than rebuilding tooltip-local state and CPU-threshold formatting inside `frontend-modern/src/components/Dashboard/EnhancedCPUBar.tsx`
## Forbidden Paths
@@ -197,6 +203,15 @@ resize-observer lifecycle lives in
`frontend-modern/src/components/Dashboard/useMetricBarState.ts`. Future
metric-bar runtime changes must extend through those owners instead of
reintroducing mixed resize state and label-fit logic into the shell.
+The dashboard enhanced CPU bar now follows that same pattern: the shell stays
+in `frontend-modern/src/components/Dashboard/EnhancedCPUBar.tsx`, while usage
+formatting, anomaly presentation, tooltip load-average formatting, and
+threshold-driven label state live in
+`frontend-modern/src/components/Dashboard/enhancedCpuBarModel.ts` and
+tooltip lifecycle lives in
+`frontend-modern/src/components/Dashboard/useEnhancedCPUBarState.ts`. Future
+CPU-bar runtime changes must extend through those owners instead of
+reintroducing mixed tooltip state and formatting logic 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 79795e7c32..aeccd95c7b 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -2522,6 +2522,8 @@
"frontend-modern/src/components/Dashboard/dashboardFilterModel.ts",
"frontend-modern/src/components/Dashboard/DiskList.tsx",
"frontend-modern/src/components/Dashboard/diskListModel.ts",
+ "frontend-modern/src/components/Dashboard/EnhancedCPUBar.tsx",
+ "frontend-modern/src/components/Dashboard/enhancedCpuBarModel.ts",
"frontend-modern/src/components/Dashboard/GuestDrawer.tsx",
"frontend-modern/src/components/Dashboard/guestDrawerModel.ts",
"frontend-modern/src/components/Dashboard/GuestRow.tsx",
@@ -2537,6 +2539,7 @@
"frontend-modern/src/components/Dashboard/useDashboardFilterState.ts",
"frontend-modern/src/components/Dashboard/useDashboardState.ts",
"frontend-modern/src/components/Dashboard/useDiskListState.ts",
+ "frontend-modern/src/components/Dashboard/useEnhancedCPUBarState.ts",
"frontend-modern/src/components/Dashboard/useGuestDrawerState.ts",
"frontend-modern/src/components/Dashboard/useGuestRowState.ts",
"frontend-modern/src/components/Dashboard/useMetricBarState.ts",
@@ -2559,8 +2562,10 @@
"frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx",
"frontend-modern/src/components/Dashboard/__tests__/DashboardFilter.test.tsx",
"frontend-modern/src/components/Dashboard/__tests__/DiskList.test.tsx",
+ "frontend-modern/src/components/Dashboard/__tests__/EnhancedCPUBar.test.tsx",
"frontend-modern/src/components/Dashboard/__tests__/StackedDiskBar.test.tsx",
"frontend-modern/src/components/Dashboard/__tests__/useDashboardFilterState.test.ts",
+ "frontend-modern/src/components/Dashboard/__tests__/useEnhancedCPUBarState.test.tsx",
"frontend-modern/src/components/Dashboard/__tests__/useMetricBarState.test.tsx",
"frontend-modern/src/components/Dashboard/__tests__/useStackedDiskBarState.test.tsx",
"frontend-modern/src/components/Dashboard/__tests__/useStackedMemoryBarState.test.tsx",
@@ -2602,6 +2607,8 @@
"frontend-modern/src/components/Dashboard/dashboardFilterModel.ts",
"frontend-modern/src/components/Dashboard/DiskList.tsx",
"frontend-modern/src/components/Dashboard/diskListModel.ts",
+ "frontend-modern/src/components/Dashboard/EnhancedCPUBar.tsx",
+ "frontend-modern/src/components/Dashboard/enhancedCpuBarModel.ts",
"frontend-modern/src/components/Dashboard/GuestDrawer.tsx",
"frontend-modern/src/components/Dashboard/guestDrawerModel.ts",
"frontend-modern/src/components/Dashboard/GuestRow.tsx",
@@ -2617,6 +2624,7 @@
"frontend-modern/src/components/Dashboard/useDashboardFilterState.ts",
"frontend-modern/src/components/Dashboard/useDashboardState.ts",
"frontend-modern/src/components/Dashboard/useDiskListState.ts",
+ "frontend-modern/src/components/Dashboard/useEnhancedCPUBarState.ts",
"frontend-modern/src/components/Dashboard/useGuestDrawerState.ts",
"frontend-modern/src/components/Dashboard/useGuestRowState.ts",
"frontend-modern/src/components/Dashboard/useMetricBarState.ts",
@@ -2635,9 +2643,11 @@
"frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx",
"frontend-modern/src/components/Dashboard/__tests__/DashboardFilter.test.tsx",
"frontend-modern/src/components/Dashboard/__tests__/DiskList.test.tsx",
+ "frontend-modern/src/components/Dashboard/__tests__/EnhancedCPUBar.test.tsx",
"frontend-modern/src/components/Dashboard/__tests__/GuestRow.test.tsx",
"frontend-modern/src/components/Dashboard/__tests__/StackedDiskBar.test.tsx",
"frontend-modern/src/components/Dashboard/__tests__/useDashboardFilterState.test.ts",
+ "frontend-modern/src/components/Dashboard/__tests__/useEnhancedCPUBarState.test.tsx",
"frontend-modern/src/components/Dashboard/__tests__/useMetricBarState.test.tsx",
"frontend-modern/src/components/Dashboard/__tests__/useStackedDiskBarState.test.tsx",
"frontend-modern/src/components/Dashboard/__tests__/useStackedMemoryBarState.test.tsx",
diff --git a/frontend-modern/src/components/Dashboard/EnhancedCPUBar.tsx b/frontend-modern/src/components/Dashboard/EnhancedCPUBar.tsx
index b12a6d0a7a..6870f2bb4d 100644
--- a/frontend-modern/src/components/Dashboard/EnhancedCPUBar.tsx
+++ b/frontend-modern/src/components/Dashboard/EnhancedCPUBar.tsx
@@ -1,60 +1,41 @@
-import { Show, createMemo } from 'solid-js';
-import { formatPercent, formatAnomalyRatio, ANOMALY_SEVERITY_CLASS } from '@/utils/format';
-import { useTooltip } from '@/hooks/useTooltip';
+import { Show } from 'solid-js';
import { TooltipPortal } from '@/components/shared/TooltipPortal';
-import { getMetricColorClass } from '@/utils/metricThresholds';
-import type { AnomalyReport } from '@/types/aiIntelligence';
-
-interface EnhancedCPUBarProps {
- usage: number; // CPU Usage % (0-100)
- loadAverage?: number; // 1-minute load average
- cores?: number; // Number of cores
- model?: string; // CPU Model name (for tooltip)
- resourceId?: string;
- anomaly?: AnomalyReport | null; // Baseline anomaly if detected
-}
+import { type EnhancedCPUBarProps } from './enhancedCpuBarModel';
+import { useEnhancedCPUBarState } from './useEnhancedCPUBarState';
export function EnhancedCPUBar(props: EnhancedCPUBarProps) {
- const tip = useTooltip();
-
- // Bar color based on usage (from centralized thresholds)
- const barColor = createMemo(() => getMetricColorClass(props.usage, 'cpu'));
-
- const anomalyRatio = createMemo(() => formatAnomalyRatio(props.anomaly));
+ const state = useEnhancedCPUBarState(props);
+ const presentation = state.presentation;
return (
<div class="metric-text w-full h-4 flex items-center justify-center">
<div
class="relative w-full h-full overflow-hidden bg-surface-hover rounded"
- onMouseEnter={tip.onMouseEnter}
- onMouseLeave={tip.onMouseLeave}
+ onMouseEnter={state.handleMouseEnter}
+ onMouseLeave={state.handleMouseLeave}
>
- {/* Usage Bar */}
<div
- class={`absolute top-0 left-0 h-full transition-all duration-300 ${barColor()}`}
- style={{ width: `${Math.min(props.usage, 100)}%` }}
+ class={`absolute top-0 left-0 h-full transition-all duration-300 ${presentation().barClass}`}
+ style={{ width: presentation().barWidth }}
/>
- {/* Label with optional anomaly indicator */}
<span class="absolute inset-0 flex items-center justify-center text-[10px] font-semibold text-base-content leading-none pointer-events-none">
- {formatPercent(props.usage)}
+ {presentation().displayUsage}
<Show when={props.cores}>
<span class="hidden sm:inline font-normal text-muted ml-1">({props.cores})</span>
</Show>
- {/* Anomaly indicator */}
- <Show when={props.anomaly && anomalyRatio()}>
+ <Show when={presentation().hasAnomaly}>
<span
- class={`ml-1 font-bold animate-pulse ${ANOMALY_SEVERITY_CLASS[props.anomaly!.severity] || 'text-yellow-400'}`}
- title={props.anomaly!.description}
+ class={`ml-1 font-bold animate-pulse ${presentation().anomalyClass}`}
+ title={presentation().anomalyDescription}
>
- {anomalyRatio()}
+ {presentation().anomalyRatio}
</span>
</Show>
</span>
</div>
- {/* Tooltip */}
- <TooltipPortal when={tip.show()} x={tip.pos().x} y={tip.pos().y}>
+ <TooltipPortal when={state.tooltipVisible()} x={state.tip.pos().x} y={state.tip.pos().y}>
<div class="min-w-[160px]">
<div class="font-medium mb-1 text-slate-300 border-b border-border pb-1">CPU Details</div>
@@ -64,15 +45,15 @@ export function EnhancedCPUBar(props: EnhancedCPUBarProps) {
<div class="flex justify-between gap-3 py-0.5">
<span class="text-slate-400">Usage</span>
- <span class={`font-medium ${props.usage > 90 ? 'text-red-400' : 'text-base-content'}`}>
- {formatPercent(props.usage)}
+ <span class={`font-medium ${presentation().tooltipUsageClass}`}>
+ {presentation().displayUsage}
</span>
</div>
- <Show when={props.loadAverage !== undefined}>
+ <Show when={presentation().displayLoadAverage !== undefined}>
<div class="flex justify-between gap-3 py-0.5">
<span class="text-slate-400">Load (1m)</span>
- <span class="font-medium text-base-content">{props.loadAverage?.toFixed(2)}</span>
+ <span class="font-medium text-base-content">{presentation().displayLoadAverage}</span>
</div>
</Show>
</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 39eb049dd5..118db7c8dd 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
@@ -11,6 +11,9 @@ import dashboardFilterStateSource from '../useDashboardFilterState.ts?raw';
import thresholdSliderSource from '../ThresholdSlider.tsx?raw';
import thresholdSliderModelSource from '../thresholdSliderModel.ts?raw';
import thresholdSliderStateSource from '../useThresholdSliderState.ts?raw';
+import enhancedCpuBarSource from '../EnhancedCPUBar.tsx?raw';
+import enhancedCpuBarModelSource from '../enhancedCpuBarModel.ts?raw';
+import enhancedCpuBarStateSource from '../useEnhancedCPUBarState.ts?raw';
import stackedDiskBarSource from '../StackedDiskBar.tsx?raw';
import stackedDiskBarModelSource from '../stackedDiskBarModel.ts?raw';
import stackedDiskBarStateSource from '../useStackedDiskBarState.ts?raw';
@@ -556,6 +559,19 @@ describe('Dashboard performance contract', () => {
expect(metricBarModelSource).toContain('getMetricColorClass');
});
+ it('keeps enhanced CPU bar runtime and derivations in canonical owners', () => {
+ expect(enhancedCpuBarSource).toContain('useEnhancedCPUBarState');
+ expect(enhancedCpuBarSource).not.toContain('const tip = useTooltip()');
+ expect(enhancedCpuBarSource).not.toContain('const barColor = createMemo(() =>');
+ expect(enhancedCpuBarSource).not.toContain('const anomalyRatio = createMemo(() =>');
+ expect(enhancedCpuBarStateSource).toContain('useTooltip');
+ expect(enhancedCpuBarModelSource).toContain(
+ 'export function buildEnhancedCPUBarPresentation',
+ );
+ expect(enhancedCpuBarModelSource).toContain('getMetricColorClass');
+ expect(enhancedCpuBarModelSource).toContain('tooltipUsageClass');
+ });
+
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');
diff --git a/frontend-modern/src/components/Dashboard/__tests__/useEnhancedCPUBarState.test.tsx b/frontend-modern/src/components/Dashboard/__tests__/useEnhancedCPUBarState.test.tsx
new file mode 100644
index 0000000000..f8b1ecf679
--- /dev/null
+++ b/frontend-modern/src/components/Dashboard/__tests__/useEnhancedCPUBarState.test.tsx
@@ -0,0 +1,48 @@
+import { afterEach, describe, expect, it } from 'vitest';
+import { cleanup, render } from '@solidjs/testing-library';
+import { useEnhancedCPUBarState } from '@/components/Dashboard/useEnhancedCPUBarState';
+
+afterEach(() => {
+ cleanup();
+});
+
+describe('useEnhancedCPUBarState', () => {
+ it('centralizes enhanced CPU bar derivations and tooltip state', async () => {
+ let captured: ReturnType<typeof useEnhancedCPUBarState> | undefined;
+
+ const Harness = () => {
+ captured = useEnhancedCPUBarState({
+ usage: 95,
+ loadAverage: 2.345,
+ anomaly: {
+ resource_id: 'vm-100',
+ resource_name: 'test-vm',
+ resource_type: 'qemu',
+ metric: 'cpu',
+ current_value: 95,
+ baseline_mean: 30,
+ baseline_std_dev: 5,
+ z_score: 11,
+ severity: 'critical',
+ description: 'CPU usage is abnormally high',
+ },
+ });
+ return <div onMouseEnter={captured.handleMouseEnter} onMouseLeave={captured.handleMouseLeave} />;
+ };
+
+ const { container } = render(() => <Harness />);
+
+ expect(captured).toBeDefined();
+ expect(captured!.presentation().barWidth).toBe('95%');
+ expect(captured!.presentation().displayLoadAverage).toBe('2.35');
+ expect(captured!.presentation().tooltipUsageClass).toBe('text-red-400');
+ expect(captured!.presentation().hasAnomaly).toBe(true);
+
+ container.firstElementChild?.dispatchEvent(new MouseEvent('mouseenter', { bubbles: true }));
+ expect(captured!.tooltipVisible()).toBe(true);
+
+ container.firstElementChild?.dispatchEvent(new MouseEvent('mouseleave', { bubbles: true }));
+ expect(captured!.tooltipVisible()).toBe(false);
+ });
+});
+
diff --git a/frontend-modern/src/components/Dashboard/enhancedCpuBarModel.ts b/frontend-modern/src/components/Dashboard/enhancedCpuBarModel.ts
new file mode 100644
index 0000000000..bae517de7b
--- /dev/null
+++ b/frontend-modern/src/components/Dashboard/enhancedCpuBarModel.ts
@@ -0,0 +1,46 @@
+import type { AnomalyReport } from '@/types/aiIntelligence';
+import { ANOMALY_SEVERITY_CLASS, formatAnomalyRatio, formatPercent } from '@/utils/format';
+import { getMetricColorClass } from '@/utils/metricThresholds';
+
+export interface EnhancedCPUBarProps {
+ usage: number;
+ loadAverage?: number;
+ cores?: number;
+ model?: string;
+ resourceId?: string;
+ anomaly?: AnomalyReport | null;
+}
+
+export interface EnhancedCPUBarPresentation {
+ anomalyClass: string;
+ anomalyDescription?: string;
+ anomalyRatio: string;
+ barClass: string;
+ barWidth: string;
+ displayLoadAverage?: string;
+ displayUsage: string;
+ hasAnomaly: boolean;
+ tooltipUsageClass: string;
+}
+
+export function buildEnhancedCPUBarPresentation(
+ props: EnhancedCPUBarProps,
+): EnhancedCPUBarPresentation {
+ const anomalyRatio = formatAnomalyRatio(props.anomaly);
+
+ return {
+ anomalyClass: props.anomaly
+ ? (ANOMALY_SEVERITY_CLASS[props.anomaly.severity] ?? 'text-yellow-400')
+ : 'text-yellow-400',
+ anomalyDescription: props.anomaly?.description,
+ anomalyRatio,
+ barClass: getMetricColorClass(props.usage, 'cpu'),
+ barWidth: `${Math.min(props.usage, 100)}%`,
+ displayLoadAverage:
+ props.loadAverage !== undefined ? props.loadAverage.toFixed(2) : undefined,
+ displayUsage: formatPercent(props.usage),
+ hasAnomaly: Boolean(props.anomaly && anomalyRatio),
+ tooltipUsageClass: props.usage > 90 ? 'text-red-400' : 'text-base-content',
+ };
+}
+
diff --git a/frontend-modern/src/components/Dashboard/useEnhancedCPUBarState.ts b/frontend-modern/src/components/Dashboard/useEnhancedCPUBarState.ts
new file mode 100644
index 0000000000..585953e0b7
--- /dev/null
+++ b/frontend-modern/src/components/Dashboard/useEnhancedCPUBarState.ts
@@ -0,0 +1,20 @@
+import { createMemo } from 'solid-js';
+import { useTooltip } from '@/hooks/useTooltip';
+import {
+ buildEnhancedCPUBarPresentation,
+ type EnhancedCPUBarProps,
+} from './enhancedCpuBarModel';
+
+export function useEnhancedCPUBarState(props: EnhancedCPUBarProps) {
+ const tip = useTooltip();
+ const presentation = createMemo(() => buildEnhancedCPUBarPresentation(props));
+
+ return {
+ handleMouseEnter: tip.onMouseEnter,
+ handleMouseLeave: tip.onMouseLeave,
+ presentation,
+ tip,
+ tooltipVisible: createMemo(() => tip.show()),
+ };
+}
+
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index a150d1e44b..11371fc62a 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -85,6 +85,9 @@ import dashboardStateSource from '@/components/Dashboard/useDashboardState.ts?ra
import dashboardFilterStateSource from '@/components/Dashboard/useDashboardFilterState.ts?raw';
import thresholdSliderModelSource from '@/components/Dashboard/thresholdSliderModel.ts?raw';
import thresholdSliderStateSource from '@/components/Dashboard/useThresholdSliderState.ts?raw';
+import enhancedCpuBarSource from '@/components/Dashboard/EnhancedCPUBar.tsx?raw';
+import enhancedCpuBarModelSource from '@/components/Dashboard/enhancedCpuBarModel.ts?raw';
+import enhancedCpuBarStateSource from '@/components/Dashboard/useEnhancedCPUBarState.ts?raw';
import stackedDiskBarSource from '@/components/Dashboard/StackedDiskBar.tsx?raw';
import stackedDiskBarModelSource from '@/components/Dashboard/stackedDiskBarModel.ts?raw';
import stackedDiskBarStateSource from '@/components/Dashboard/useStackedDiskBarState.ts?raw';
@@ -558,6 +561,13 @@ describe('frontend resource type boundaries', () => {
expect(metricBarStateSource).toContain('new ResizeObserver');
expect(metricBarModelSource).toContain('export function buildMetricBarPresentation');
expect(metricBarModelSource).toContain('estimateTextWidth');
+ expect(enhancedCpuBarSource).toContain('useEnhancedCPUBarState');
+ expect(enhancedCpuBarSource).not.toContain('const tip = useTooltip()');
+ expect(enhancedCpuBarSource).not.toContain('const barColor = createMemo(() =>');
+ expect(enhancedCpuBarSource).not.toContain('const anomalyRatio = createMemo(() =>');
+ expect(enhancedCpuBarStateSource).toContain('useTooltip');
+ expect(enhancedCpuBarModelSource).toContain('export function buildEnhancedCPUBarPresentation');
+ expect(enhancedCpuBarModelSource).toContain('tooltipUsageClass');
expect(workloadsSummarySource).toContain('normalizeOrgScope(getOrgID())');
expect(workloadsSummarySource).not.toContain("const DEFAULT_ORG_SCOPE = 'default'");
expect(workloadsSummarySource).not.toContain('const normalizeOrgScope =');
diff --git a/scripts/release_control/subsystem_lookup_test.py b/scripts/release_control/subsystem_lookup_test.py
index bf399c0d6e..18253fef77 100644
--- a/scripts/release_control/subsystem_lookup_test.py
+++ b/scripts/release_control/subsystem_lookup_test.py
@@ -2011,6 +2011,36 @@ class SubsystemLookupTest(unittest.TestCase):
"dashboard-workload-hot-path",
)
+ def test_lookup_paths_assigns_dashboard_enhanced_cpu_bar_runtime_to_performance_and_scalability(self) -> None:
+ result = lookup_paths(
+ [
+ "frontend-modern/src/components/Dashboard/EnhancedCPUBar.tsx",
+ "frontend-modern/src/components/Dashboard/enhancedCpuBarModel.ts",
+ "frontend-modern/src/components/Dashboard/useEnhancedCPUBarState.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"], [])