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 stacked memory bar runtime owners

rcourtman5117ed0abc6a
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 feb24fff3d..e1a60a8ea4 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -36,31 +36,36 @@ regression protection.
14. `frontend-modern/src/components/Dashboard/StackedDiskBar.tsx`
15. `frontend-modern/src/components/Dashboard/stackedDiskBarModel.ts`
16. `frontend-modern/src/components/Dashboard/useStackedDiskBarState.ts`
-17. `frontend-modern/src/components/Dashboard/DiskList.tsx`
-18. `frontend-modern/src/components/Dashboard/diskListModel.ts`
-19. `frontend-modern/src/components/Dashboard/useDiskListState.ts`
-20. `frontend-modern/src/components/Dashboard/GuestRow.tsx`
-21. `frontend-modern/src/components/Dashboard/guestRowModel.tsx`
-22. `frontend-modern/src/components/Dashboard/useGuestRowState.ts`
-23. `frontend-modern/src/components/Dashboard/GuestDrawer.tsx`
-24. `frontend-modern/src/components/Dashboard/guestDrawerModel.ts`
-25. `frontend-modern/src/components/Dashboard/useGuestDrawerState.ts`
-26. `frontend-modern/src/components/Dashboard/workloadSelectors.ts`
-27. `frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx`
-28. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts`
-29. `frontend-modern/src/components/Infrastructure/infrastructureSelectors.ts`
-30. `frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts`
-31. `frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx`
-32. `frontend-modern/src/components/Dashboard/__tests__/DashboardFilter.test.tsx`
-33. `frontend-modern/src/components/Dashboard/__tests__/useDashboardFilterState.test.ts`
-34. `frontend-modern/src/components/Dashboard/ThresholdSlider.test.tsx`
-35. `frontend-modern/src/components/Dashboard/__tests__/useThresholdSliderState.test.ts`
-36. `frontend-modern/src/components/Dashboard/__tests__/StackedDiskBar.test.tsx`
-37. `frontend-modern/src/components/Dashboard/__tests__/useStackedDiskBarState.test.tsx`
-38. `frontend-modern/src/components/Dashboard/__tests__/DiskList.test.tsx`
-39. `frontend-modern/src/components/Dashboard/__tests__/GuestRow.test.tsx`
-40. `frontend-modern/src/components/Dashboard/GuestDrawer.test.tsx`
-41. `frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx`
+17. `frontend-modern/src/components/Dashboard/StackedMemoryBar.tsx`
+18. `frontend-modern/src/components/Dashboard/stackedMemoryBarModel.ts`
+19. `frontend-modern/src/components/Dashboard/useStackedMemoryBarState.ts`
+20. `frontend-modern/src/components/Dashboard/DiskList.tsx`
+21. `frontend-modern/src/components/Dashboard/diskListModel.ts`
+22. `frontend-modern/src/components/Dashboard/useDiskListState.ts`
+23. `frontend-modern/src/components/Dashboard/GuestRow.tsx`
+24. `frontend-modern/src/components/Dashboard/guestRowModel.tsx`
+25. `frontend-modern/src/components/Dashboard/useGuestRowState.ts`
+26. `frontend-modern/src/components/Dashboard/GuestDrawer.tsx`
+27. `frontend-modern/src/components/Dashboard/guestDrawerModel.ts`
+28. `frontend-modern/src/components/Dashboard/useGuestDrawerState.ts`
+29. `frontend-modern/src/components/Dashboard/workloadSelectors.ts`
+30. `frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx`
+31. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts`
+32. `frontend-modern/src/components/Infrastructure/infrastructureSelectors.ts`
+33. `frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts`
+34. `frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx`
+35. `frontend-modern/src/components/Dashboard/__tests__/DashboardFilter.test.tsx`
+36. `frontend-modern/src/components/Dashboard/__tests__/useDashboardFilterState.test.ts`
+37. `frontend-modern/src/components/Dashboard/ThresholdSlider.test.tsx`
+38. `frontend-modern/src/components/Dashboard/__tests__/useThresholdSliderState.test.ts`
+39. `frontend-modern/src/components/Dashboard/__tests__/StackedDiskBar.test.tsx`
+40. `frontend-modern/src/components/Dashboard/__tests__/useStackedDiskBarState.test.tsx`
+41. `frontend-modern/src/components/Dashboard/StackedMemoryBar.test.tsx`
+42. `frontend-modern/src/components/Dashboard/__tests__/useStackedMemoryBarState.test.tsx`
+43. `frontend-modern/src/components/Dashboard/__tests__/DiskList.test.tsx`
+44. `frontend-modern/src/components/Dashboard/__tests__/GuestRow.test.tsx`
+45. `frontend-modern/src/components/Dashboard/GuestDrawer.test.tsx`
+46. `frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx`
## Shared Boundaries
@@ -86,6 +91,7 @@ regression protection.
12. Extend dashboard filter defaults, active-filter counting, reset semantics, and mobile toolbar state through `frontend-modern/src/components/Dashboard/dashboardFilterModel.ts` and `frontend-modern/src/components/Dashboard/useDashboardFilterState.ts`, and keep dashboard-owned filter-config assembly in `frontend-modern/src/components/Dashboard/useDashboardState.ts`, rather than rebuilding filter-local state inside `frontend-modern/src/components/Dashboard/DashboardFilter.tsx` or inline config IIFEs in `frontend-modern/src/components/Dashboard/Dashboard.tsx`
13. Extend threshold-slider value-position math, title/label derivation, and drag scroll-lock runtime through `frontend-modern/src/components/Dashboard/thresholdSliderModel.ts` and `frontend-modern/src/components/Dashboard/useThresholdSliderState.ts` rather than rebuilding slider-local state and pointer lifecycle inside `frontend-modern/src/components/Dashboard/ThresholdSlider.tsx`
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`
## Forbidden Paths
@@ -167,6 +173,16 @@ resize-observer plus tooltip lifecycle live in
`frontend-modern/src/components/Dashboard/useStackedDiskBarState.ts`.
Future disk-bar runtime changes must extend through those owners instead of
reintroducing mixed resize state and presentation branching into the shell.
+The dashboard stacked memory bar now follows that same pattern: the shell
+stays in `frontend-modern/src/components/Dashboard/StackedMemoryBar.tsx`,
+while memory-capacity math, balloon/swap tooltip derivation, anomaly label
+presentation, and sublabel-fit logic live in
+`frontend-modern/src/components/Dashboard/stackedMemoryBarModel.ts` and
+resize-observer plus tooltip lifecycle live in
+`frontend-modern/src/components/Dashboard/useStackedMemoryBarState.ts`.
+Future memory-bar runtime changes must extend through those owners instead of
+reintroducing mixed resize state, balloon branching, and tooltip shaping 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 50a1312a03..2ac0aa61a7 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -2528,6 +2528,8 @@
"frontend-modern/src/components/Dashboard/guestRowModel.tsx",
"frontend-modern/src/components/Dashboard/StackedDiskBar.tsx",
"frontend-modern/src/components/Dashboard/stackedDiskBarModel.ts",
+ "frontend-modern/src/components/Dashboard/StackedMemoryBar.tsx",
+ "frontend-modern/src/components/Dashboard/stackedMemoryBarModel.ts",
"frontend-modern/src/components/Dashboard/ThresholdSlider.tsx",
"frontend-modern/src/components/Dashboard/thresholdSliderModel.ts",
"frontend-modern/src/components/Dashboard/useDashboardFilterState.ts",
@@ -2536,6 +2538,7 @@
"frontend-modern/src/components/Dashboard/useGuestDrawerState.ts",
"frontend-modern/src/components/Dashboard/useGuestRowState.ts",
"frontend-modern/src/components/Dashboard/useStackedDiskBarState.ts",
+ "frontend-modern/src/components/Dashboard/useStackedMemoryBarState.ts",
"frontend-modern/src/components/Dashboard/useThresholdSliderState.ts",
"frontend-modern/src/components/Dashboard/workloadSelectors.ts",
"frontend-modern/src/components/Infrastructure/infrastructureSelectors.ts",
@@ -2556,7 +2559,9 @@
"frontend-modern/src/components/Dashboard/__tests__/StackedDiskBar.test.tsx",
"frontend-modern/src/components/Dashboard/__tests__/useDashboardFilterState.test.ts",
"frontend-modern/src/components/Dashboard/__tests__/useStackedDiskBarState.test.tsx",
+ "frontend-modern/src/components/Dashboard/__tests__/useStackedMemoryBarState.test.tsx",
"frontend-modern/src/components/Dashboard/__tests__/useThresholdSliderState.test.ts",
+ "frontend-modern/src/components/Dashboard/StackedMemoryBar.test.tsx",
"frontend-modern/src/components/Dashboard/ThresholdSlider.test.tsx",
"internal/api/router_bench_test.go",
"internal/api/slo_bench_test.go",
@@ -2598,6 +2603,8 @@
"frontend-modern/src/components/Dashboard/guestRowModel.tsx",
"frontend-modern/src/components/Dashboard/StackedDiskBar.tsx",
"frontend-modern/src/components/Dashboard/stackedDiskBarModel.ts",
+ "frontend-modern/src/components/Dashboard/StackedMemoryBar.tsx",
+ "frontend-modern/src/components/Dashboard/stackedMemoryBarModel.ts",
"frontend-modern/src/components/Dashboard/ThresholdSlider.tsx",
"frontend-modern/src/components/Dashboard/thresholdSliderModel.ts",
"frontend-modern/src/components/Dashboard/useDashboardFilterState.ts",
@@ -2606,6 +2613,7 @@
"frontend-modern/src/components/Dashboard/useGuestDrawerState.ts",
"frontend-modern/src/components/Dashboard/useGuestRowState.ts",
"frontend-modern/src/components/Dashboard/useStackedDiskBarState.ts",
+ "frontend-modern/src/components/Dashboard/useStackedMemoryBarState.ts",
"frontend-modern/src/components/Dashboard/useThresholdSliderState.ts",
"frontend-modern/src/components/Dashboard/workloadSelectors.ts",
"frontend-modern/src/components/Infrastructure/infrastructureSelectors.ts",
@@ -2623,9 +2631,11 @@
"frontend-modern/src/components/Dashboard/__tests__/StackedDiskBar.test.tsx",
"frontend-modern/src/components/Dashboard/__tests__/useDashboardFilterState.test.ts",
"frontend-modern/src/components/Dashboard/__tests__/useStackedDiskBarState.test.tsx",
+ "frontend-modern/src/components/Dashboard/__tests__/useStackedMemoryBarState.test.tsx",
"frontend-modern/src/components/Dashboard/__tests__/useThresholdSliderState.test.ts",
"frontend-modern/src/components/Dashboard/__tests__/workloadSelectors.test.ts",
"frontend-modern/src/components/Dashboard/GuestDrawer.test.tsx",
+ "frontend-modern/src/components/Dashboard/StackedMemoryBar.test.tsx",
"frontend-modern/src/components/Dashboard/ThresholdSlider.test.tsx",
"frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx"
]
diff --git a/frontend-modern/src/components/Dashboard/StackedMemoryBar.tsx b/frontend-modern/src/components/Dashboard/StackedMemoryBar.tsx
index 67e536256f..182aab6ca4 100644
--- a/frontend-modern/src/components/Dashboard/StackedMemoryBar.tsx
+++ b/frontend-modern/src/components/Dashboard/StackedMemoryBar.tsx
@@ -1,263 +1,80 @@
-import { Show, For, createMemo, createSignal, onMount, onCleanup } from 'solid-js';
-import { useTooltip } from '@/hooks/useTooltip';
+import { Show, For } from 'solid-js';
import { TooltipPortal } from '@/components/shared/TooltipPortal';
-import {
- formatBytes,
- formatPercent,
- estimateTextWidth,
- formatAnomalyRatio,
- ANOMALY_SEVERITY_CLASS,
-} from '@/utils/format';
-import { getMetricColorRgba } from '@/utils/metricThresholds';
-import type { AnomalyReport } from '@/types/aiIntelligence';
-
-interface StackedMemoryBarProps {
- used: number;
- total: number;
- percentOnly?: number;
- swapUsed?: number;
- swapTotal?: number;
- balloon?: number;
- resourceId?: string;
- anomaly?: AnomalyReport | null; // Baseline anomaly if detected
-}
-
-// Colors for memory segments
-const MEMORY_COLORS = {
- active: 'rgba(34, 197, 94, 0.6)', // green (base, overridden by threshold)
- balloon: 'rgba(59, 130, 246, 0.6)', // blue
- swap: 'rgba(168, 85, 247, 0.6)', // purple
-};
+import { type StackedMemoryBarProps } from './stackedMemoryBarModel';
+import { useStackedMemoryBarState } from './useStackedMemoryBarState';
export function StackedMemoryBar(props: StackedMemoryBarProps) {
- const anomalyRatio = createMemo(() => formatAnomalyRatio(props.anomaly));
- const utilizationPercent = createMemo(() => {
- if (props.total > 0) {
- return (props.used / props.total) * 100;
- }
- if (Number.isFinite(props.percentOnly)) {
- return Math.max(0, Math.min(props.percentOnly as number, 100));
- }
- return 0;
- });
-
- const tip = useTooltip();
- const [containerWidth, setContainerWidth] = createSignal(100);
- let containerRef: HTMLDivElement | undefined;
-
- onMount(() => {
- if (!containerRef) return;
- setContainerWidth(containerRef.offsetWidth);
-
- const observer = new ResizeObserver((entries) => {
- for (const entry of entries) {
- setContainerWidth(entry.contentRect.width);
- }
- });
-
- observer.observe(containerRef);
- onCleanup(() => observer.disconnect());
- });
-
- // Calculate segments
- const segments = createMemo(() => {
- if (props.total <= 0) {
- const percent = utilizationPercent();
- if (percent <= 0) return [];
- return [
- { type: 'Utilization', bytes: 0, percent, color: getMetricColorRgba(percent, 'memory') },
- ];
- }
-
- const balloon = props.balloon || 0;
-
- // Proxmox balloon semantics:
- // - balloon = 0: ballooning not enabled/configured
- // - balloon = total (maxmem): ballooning configured but at max (no actual ballooning)
- // - balloon < total: active ballooning, guest limited to 'balloon' bytes
- //
- // Only show balloon segment when actual ballooning is in effect
- const hasActiveBallooning = balloon > 0 && balloon < props.total;
-
- // Used memory is what the guest is actually consuming
- const usedPercent = (props.used / props.total) * 100;
-
- if (hasActiveBallooning) {
- // With active ballooning:
- // - Green: actual used memory
- // - Yellow: balloon limit marker (shows where the guest is capped)
- // The balloon limit shows as a segment from used to balloon
- const balloonLimitPercent = Math.max(0, (balloon / props.total) * 100 - usedPercent);
-
- const segs = [
- {
- type: 'Active',
- bytes: props.used,
- percent: usedPercent,
- color: getMetricColorRgba(usedPercent, 'memory'),
- },
- ];
-
- // Only show balloon segment if there's room between used and balloon limit
- if (balloonLimitPercent > 0 && balloon > props.used) {
- segs.push({
- type: 'Balloon',
- bytes: balloon - props.used,
- percent: balloonLimitPercent,
- color: MEMORY_COLORS.balloon,
- });
- }
-
- return segs.filter((s) => s.bytes > 0);
- }
-
- // No active ballooning - show used memory with threshold-based coloring
- return [
- {
- type: 'Active',
- bytes: props.used,
- percent: usedPercent,
- color: getMetricColorRgba(usedPercent, 'memory'),
- },
- ].filter((s) => s.bytes > 0);
- });
-
- const swapPercent = createMemo(() => {
- if (!props.swapTotal || props.swapTotal <= 0) return 0;
- return ((props.swapUsed || 0) / props.swapTotal) * 100;
- });
-
- const hasSwap = createMemo(() => (props.swapTotal || 0) > 0);
-
- const displayLabel = createMemo(() => {
- return formatPercent(utilizationPercent());
- });
-
- const displaySublabel = createMemo(() => {
- if (props.total <= 0) return '';
- return `${formatBytes(props.used)}/${formatBytes(props.total)}`;
- });
-
- const showSublabel = createMemo(() => {
- if (!displaySublabel()) return false;
- const fullText = `${displayLabel()} (${displaySublabel()})`;
- return containerWidth() >= estimateTextWidth(fullText);
- });
+ const state = useStackedMemoryBarState(props);
+ const presentation = state.presentation;
return (
- <div ref={containerRef} class="metric-text w-full h-4 flex items-center justify-center">
+ <div ref={state.setContainerRef} 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}
>
- {/* Stacked segments - use absolute positioning like MetricBar for correct width scaling */}
- <For each={segments()}>
- {(segment, idx) => {
- // Calculate left offset as sum of previous segments
- const leftOffset = () => {
- let offset = 0;
- const segs = segments();
- for (let i = 0; i < idx(); i++) {
- offset += segs[i].percent;
- }
- return offset;
- };
- return (
- <div
- class="absolute top-0 h-full transition-all duration-300"
- style={{
- left: `${leftOffset()}%`,
- width: `${segment.percent}%`,
- 'background-color': segment.color,
- 'border-right':
- idx() < segments().length - 1 ? '1px solid rgba(255,255,255,0.3)' : 'none',
- }}
- />
- );
- }}
+ <For each={presentation().segments}>
+ {(segment, idx) => (
+ <div
+ class="absolute top-0 h-full transition-all duration-300"
+ style={{
+ left: `${segment.leftPercent}%`,
+ width: `${segment.widthPercent}%`,
+ 'background-color': segment.color,
+ 'border-right':
+ idx() < presentation().segments.length - 1
+ ? '1px solid rgba(255,255,255,0.3)'
+ : 'none',
+ }}
+ />
+ )}
</For>
- {/* Swap Indicator (Thin line at bottom if swap is used) */}
- <Show when={hasSwap() && (props.swapUsed || 0) > 0}>
+ <Show when={presentation().showSwapBar}>
<div
class="absolute bottom-0 left-0 h-[3px] w-full bg-purple-500"
- style={{ width: `${Math.min(swapPercent(), 100)}%` }}
+ style={{ width: `${presentation().swapBarPercent}%` }}
/>
</Show>
- {/* Label overlay */}
<span class="absolute inset-0 flex items-center justify-center text-[10px] font-semibold text-base-content leading-none pointer-events-none min-w-0 overflow-hidden">
<span class="max-w-full min-w-0 whitespace-nowrap overflow-hidden text-ellipsis px-0.5 text-center">
- <span>{displayLabel()}</span>
- <Show when={showSublabel()}>
- <span class="metric-sublabel font-normal text-muted"> ({displaySublabel()})</span>
+ <span>{presentation().displayLabel}</span>
+ <Show when={presentation().showSublabel}>
+ <span class="metric-sublabel font-normal text-muted">
+ {' '}
+ ({presentation().displaySublabel})
+ </span>
</Show>
- {/* Anomaly indicator */}
- <Show when={props.anomaly && anomalyRatio()}>
+ <Show when={presentation().anomalyDescription && presentation().anomalyRatio}>
<span
- class={`ml-0.5 font-bold animate-pulse ${ANOMALY_SEVERITY_CLASS[props.anomaly!.severity] || 'text-yellow-400'}`}
- title={props.anomaly!.description}
+ class={`ml-0.5 font-bold animate-pulse ${presentation().anomalyClass}`}
+ title={presentation().anomalyDescription}
>
- {anomalyRatio()}
+ {presentation().anomalyRatio}
</span>
</Show>
</span>
</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-[140px]">
<div class="font-medium mb-1 text-slate-300 border-b border-border pb-1">
- Memory Composition
+ {presentation().tooltipTitle}
</div>
-
- <Show when={props.total > 0}>
- <div class="flex justify-between gap-3 py-0.5">
- <span class="text-green-400">Used</span>
- <span class="whitespace-nowrap text-slate-300">{formatBytes(props.used)}</span>
- </div>
- </Show>
-
- <Show
- when={props.total > 0 && (props.balloon || 0) > 0 && (props.balloon || 0) < props.total}
- >
- <div class="flex justify-between gap-3 py-0.5 border-t border-border">
- <span class="text-blue-400">Balloon Limit</span>
- <span class="whitespace-nowrap text-slate-300">
- {formatBytes(props.balloon || 0)}
- </span>
- </div>
- </Show>
-
- <Show
- when={props.total > 0}
- fallback={
- <div class="flex justify-between gap-3 py-0.5 border-t border-border">
- <span class="text-blue-300">Utilization</span>
- <span class="whitespace-nowrap text-slate-300">{displayLabel()}</span>
- </div>
- }
- >
- <div class="flex justify-between gap-3 py-0.5 border-t border-border">
- <span class="text-slate-400">Free</span>
- <span class="whitespace-nowrap text-slate-300">
- {formatBytes(props.total - props.used)}
- </span>
- </div>
- </Show>
-
- <Show when={props.total > 0 && hasSwap()}>
- <div class="mt-1 pt-1 border-t border-slate-600">
- <div class="flex justify-between gap-3 py-0.5">
- <span class="text-purple-400">Swap</span>
- <span class="whitespace-nowrap text-slate-300">
- {formatBytes(props.swapUsed || 0)} / {formatBytes(props.swapTotal || 0)}
- </span>
+ <For each={presentation().tooltipRows}>
+ {(row) => (
+ <div
+ class="flex justify-between gap-3 py-0.5"
+ classList={{ 'border-t border-border': row.borderTop }}
+ >
+ <span class={row.labelClass}>{row.label}</span>
+ <span class="whitespace-nowrap text-slate-300">{row.value}</span>
</div>
- </div>
- </Show>
+ )}
+ </For>
</div>
</TooltipPortal>
</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 f5431ef806..7bfb6ba727 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
@@ -14,6 +14,9 @@ import thresholdSliderStateSource from '../useThresholdSliderState.ts?raw';
import stackedDiskBarSource from '../StackedDiskBar.tsx?raw';
import stackedDiskBarModelSource from '../stackedDiskBarModel.ts?raw';
import stackedDiskBarStateSource from '../useStackedDiskBarState.ts?raw';
+import stackedMemoryBarSource from '../StackedMemoryBar.tsx?raw';
+import stackedMemoryBarModelSource from '../stackedMemoryBarModel.ts?raw';
+import stackedMemoryBarStateSource from '../useStackedMemoryBarState.ts?raw';
import diskListSource from '../DiskList.tsx?raw';
import diskListModelSource from '../diskListModel.ts?raw';
import diskListStateSource from '../useDiskListState.ts?raw';
@@ -525,6 +528,20 @@ describe('Dashboard performance contract', () => {
expect(stackedDiskBarModelSource).toContain('tooltipTitle');
});
+ it('keeps stacked memory bar runtime and derivations in canonical owners', () => {
+ expect(stackedMemoryBarSource).toContain('useStackedMemoryBarState');
+ expect(stackedMemoryBarSource).not.toContain('const [containerWidth, setContainerWidth] =');
+ expect(stackedMemoryBarSource).not.toContain('const segments = createMemo(() => {');
+ expect(stackedMemoryBarSource).not.toContain('const MEMORY_COLORS =');
+ expect(stackedMemoryBarStateSource).toContain('new ResizeObserver');
+ expect(stackedMemoryBarStateSource).toContain('useTooltip');
+ expect(stackedMemoryBarModelSource).toContain(
+ 'export function buildStackedMemoryBarPresentation',
+ );
+ expect(stackedMemoryBarModelSource).toContain('const MEMORY_COLORS');
+ expect(stackedMemoryBarModelSource).toContain('tooltipRows');
+ });
+
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__/useStackedMemoryBarState.test.tsx b/frontend-modern/src/components/Dashboard/__tests__/useStackedMemoryBarState.test.tsx
new file mode 100644
index 0000000000..70b042aff4
--- /dev/null
+++ b/frontend-modern/src/components/Dashboard/__tests__/useStackedMemoryBarState.test.tsx
@@ -0,0 +1,70 @@
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import { cleanup, render } from '@solidjs/testing-library';
+import { useStackedMemoryBarState } from '@/components/Dashboard/useStackedMemoryBarState';
+
+class MockResizeObserver {
+ callback: ResizeObserverCallback;
+ disconnect = vi.fn();
+ observe = vi.fn();
+
+ constructor(callback: ResizeObserverCallback) {
+ this.callback = callback;
+ }
+
+ trigger(width: number) {
+ this.callback(
+ [
+ {
+ contentRect: { width } as DOMRectReadOnly,
+ } as ResizeObserverEntry,
+ ],
+ this as unknown as ResizeObserver,
+ );
+ }
+}
+
+const originalResizeObserver = globalThis.ResizeObserver;
+
+afterEach(() => {
+ cleanup();
+ globalThis.ResizeObserver = originalResizeObserver;
+});
+
+describe('useStackedMemoryBarState', () => {
+ it('centralizes stacked memory derivations and resize observer cleanup', () => {
+ const observers: MockResizeObserver[] = [];
+ globalThis.ResizeObserver = class extends MockResizeObserver {
+ constructor(callback: ResizeObserverCallback) {
+ super(callback);
+ observers.push(this);
+ }
+ } as unknown as typeof ResizeObserver;
+
+ let captured: ReturnType<typeof useStackedMemoryBarState> | undefined;
+
+ const Harness = () => {
+ captured = useStackedMemoryBarState({
+ used: 4 * 1024 ** 3,
+ total: 8 * 1024 ** 3,
+ balloon: 6 * 1024 ** 3,
+ swapUsed: 1 * 1024 ** 3,
+ swapTotal: 2 * 1024 ** 3,
+ });
+ return <div ref={captured.setContainerRef} />;
+ };
+
+ const { unmount } = render(() => <Harness />);
+
+ expect(captured).toBeDefined();
+ expect(observers).toHaveLength(1);
+ expect(observers[0].observe).toHaveBeenCalled();
+ expect(captured!.presentation().segments).toHaveLength(2);
+ expect(captured!.presentation().showSwapBar).toBe(true);
+
+ observers[0].trigger(320);
+ expect(captured!.presentation().showSublabel).toBe(true);
+
+ unmount();
+ expect(observers[0].disconnect).toHaveBeenCalled();
+ });
+});
diff --git a/frontend-modern/src/components/Dashboard/stackedMemoryBarModel.ts b/frontend-modern/src/components/Dashboard/stackedMemoryBarModel.ts
new file mode 100644
index 0000000000..5255c35362
--- /dev/null
+++ b/frontend-modern/src/components/Dashboard/stackedMemoryBarModel.ts
@@ -0,0 +1,206 @@
+import type { AnomalyReport } from '@/types/aiIntelligence';
+import {
+ ANOMALY_SEVERITY_CLASS,
+ estimateTextWidth,
+ formatAnomalyRatio,
+ formatBytes,
+ formatPercent,
+} from '@/utils/format';
+import { getMetricColorRgba } from '@/utils/metricThresholds';
+
+export interface StackedMemoryBarProps {
+ used: number;
+ total: number;
+ percentOnly?: number;
+ swapUsed?: number;
+ swapTotal?: number;
+ balloon?: number;
+ resourceId?: string;
+ anomaly?: AnomalyReport | null;
+}
+
+export interface StackedMemorySegment {
+ color: string;
+ label: string;
+ leftPercent: number;
+ widthPercent: number;
+}
+
+export interface StackedMemoryTooltipRow {
+ borderTop: boolean;
+ label: string;
+ labelClass: string;
+ value: string;
+}
+
+export interface StackedMemoryBarPresentation {
+ anomalyClass: string;
+ anomalyDescription?: string;
+ anomalyRatio: string;
+ displayLabel: string;
+ displaySublabel: string;
+ segments: StackedMemorySegment[];
+ showSublabel: boolean;
+ showSwapBar: boolean;
+ swapBarPercent: number;
+ tooltipRows: StackedMemoryTooltipRow[];
+ tooltipTitle: string;
+}
+
+const MEMORY_COLORS = {
+ active: 'rgba(34, 197, 94, 0.6)',
+ balloon: 'rgba(59, 130, 246, 0.6)',
+ swap: 'rgba(168, 85, 247, 0.6)',
+};
+
+function getUtilizationPercent(props: StackedMemoryBarProps): number {
+ if (props.total > 0) {
+ return (props.used / props.total) * 100;
+ }
+ if (Number.isFinite(props.percentOnly)) {
+ return Math.max(0, Math.min(props.percentOnly as number, 100));
+ }
+ return 0;
+}
+
+function getSegments(props: StackedMemoryBarProps, utilizationPercent: number): StackedMemorySegment[] {
+ if (props.total <= 0) {
+ if (utilizationPercent <= 0) {
+ return [];
+ }
+ return [
+ {
+ color: getMetricColorRgba(utilizationPercent, 'memory'),
+ label: 'Utilization',
+ leftPercent: 0,
+ widthPercent: utilizationPercent,
+ },
+ ];
+ }
+
+ const balloon = props.balloon || 0;
+ const hasActiveBallooning = balloon > 0 && balloon < props.total;
+ const usedPercent = (props.used / props.total) * 100;
+
+ if (!hasActiveBallooning) {
+ if (props.used <= 0) {
+ return [];
+ }
+ return [
+ {
+ color: getMetricColorRgba(usedPercent, 'memory'),
+ label: 'Active',
+ leftPercent: 0,
+ widthPercent: usedPercent,
+ },
+ ];
+ }
+
+ const segments: StackedMemorySegment[] = [];
+ if (props.used > 0) {
+ segments.push({
+ color: getMetricColorRgba(usedPercent, 'memory'),
+ label: 'Active',
+ leftPercent: 0,
+ widthPercent: usedPercent,
+ });
+ }
+
+ const balloonLimitPercent = Math.max(0, (balloon / props.total) * 100 - usedPercent);
+ if (balloonLimitPercent > 0 && balloon > props.used) {
+ segments.push({
+ color: MEMORY_COLORS.balloon,
+ label: 'Balloon',
+ leftPercent: usedPercent,
+ widthPercent: balloonLimitPercent,
+ });
+ }
+
+ return segments;
+}
+
+function getTooltipRows(
+ props: StackedMemoryBarProps,
+ displayLabel: string,
+): StackedMemoryTooltipRow[] {
+ const rows: StackedMemoryTooltipRow[] = [];
+ const balloon = props.balloon || 0;
+ const hasActiveBallooning = props.total > 0 && balloon > 0 && balloon < props.total;
+ const hasSwap = (props.swapTotal || 0) > 0;
+
+ if (props.total > 0) {
+ rows.push({
+ borderTop: false,
+ label: 'Used',
+ labelClass: 'text-green-400',
+ value: formatBytes(props.used),
+ });
+
+ if (hasActiveBallooning) {
+ rows.push({
+ borderTop: true,
+ label: 'Balloon Limit',
+ labelClass: 'text-blue-400',
+ value: formatBytes(balloon),
+ });
+ }
+
+ rows.push({
+ borderTop: true,
+ label: 'Free',
+ labelClass: 'text-slate-400',
+ value: formatBytes(props.total - props.used),
+ });
+ } else {
+ rows.push({
+ borderTop: true,
+ label: 'Utilization',
+ labelClass: 'text-blue-300',
+ value: displayLabel,
+ });
+ }
+
+ if (props.total > 0 && hasSwap) {
+ rows.push({
+ borderTop: true,
+ label: 'Swap',
+ labelClass: 'text-purple-400',
+ value: `${formatBytes(props.swapUsed || 0)} / ${formatBytes(props.swapTotal || 0)}`,
+ });
+ }
+
+ return rows;
+}
+
+export function buildStackedMemoryBarPresentation(
+ props: StackedMemoryBarProps,
+ containerWidth: number,
+): StackedMemoryBarPresentation {
+ const utilizationPercent = getUtilizationPercent(props);
+ const displayLabel = formatPercent(utilizationPercent);
+ const displaySublabel =
+ props.total > 0 ? `${formatBytes(props.used)}/${formatBytes(props.total)}` : '';
+ const showSublabel =
+ displaySublabel.length > 0 &&
+ containerWidth >= estimateTextWidth(`${displayLabel} (${displaySublabel})`);
+
+ return {
+ anomalyClass: props.anomaly
+ ? (ANOMALY_SEVERITY_CLASS[props.anomaly.severity] ?? 'text-yellow-400')
+ : 'text-yellow-400',
+ anomalyDescription: props.anomaly?.description,
+ anomalyRatio: formatAnomalyRatio(props.anomaly),
+ displayLabel,
+ displaySublabel,
+ segments: getSegments(props, utilizationPercent),
+ showSublabel,
+ showSwapBar: (props.swapTotal || 0) > 0 && (props.swapUsed || 0) > 0,
+ swapBarPercent:
+ props.swapTotal && props.swapTotal > 0
+ ? Math.min(((props.swapUsed || 0) / props.swapTotal) * 100, 100)
+ : 0,
+ tooltipRows: getTooltipRows(props, displayLabel),
+ tooltipTitle: 'Memory Composition',
+ };
+}
+
diff --git a/frontend-modern/src/components/Dashboard/useStackedMemoryBarState.ts b/frontend-modern/src/components/Dashboard/useStackedMemoryBarState.ts
new file mode 100644
index 0000000000..56c0437065
--- /dev/null
+++ b/frontend-modern/src/components/Dashboard/useStackedMemoryBarState.ts
@@ -0,0 +1,48 @@
+import { createMemo, createSignal, onCleanup, onMount } from 'solid-js';
+import { useTooltip } from '@/hooks/useTooltip';
+import {
+ buildStackedMemoryBarPresentation,
+ type StackedMemoryBarProps,
+} from './stackedMemoryBarModel';
+
+export function useStackedMemoryBarState(props: StackedMemoryBarProps) {
+ const tip = useTooltip();
+ const [containerWidth, setContainerWidth] = createSignal(100);
+ let containerRef: HTMLDivElement | undefined;
+ let resizeObserver: ResizeObserver | undefined;
+
+ const presentation = createMemo(() =>
+ buildStackedMemoryBarPresentation(props, containerWidth()),
+ );
+
+ onMount(() => {
+ if (!containerRef) {
+ return;
+ }
+
+ setContainerWidth(containerRef.offsetWidth);
+
+ resizeObserver = new ResizeObserver((entries) => {
+ for (const entry of entries) {
+ setContainerWidth(entry.contentRect.width);
+ }
+ });
+ resizeObserver.observe(containerRef);
+ });
+
+ onCleanup(() => {
+ resizeObserver?.disconnect();
+ });
+
+ return {
+ handleMouseEnter: tip.onMouseEnter,
+ handleMouseLeave: tip.onMouseLeave,
+ presentation,
+ setContainerRef: (element: HTMLDivElement) => {
+ containerRef = element;
+ },
+ tip,
+ tooltipVisible: createMemo(() => tip.show() && presentation().tooltipRows.length > 0),
+ };
+}
+
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index 8610e4fe73..0d20effd8c 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -88,6 +88,9 @@ import thresholdSliderStateSource from '@/components/Dashboard/useThresholdSlide
import stackedDiskBarSource from '@/components/Dashboard/StackedDiskBar.tsx?raw';
import stackedDiskBarModelSource from '@/components/Dashboard/stackedDiskBarModel.ts?raw';
import stackedDiskBarStateSource from '@/components/Dashboard/useStackedDiskBarState.ts?raw';
+import stackedMemoryBarSource from '@/components/Dashboard/StackedMemoryBar.tsx?raw';
+import stackedMemoryBarModelSource from '@/components/Dashboard/stackedMemoryBarModel.ts?raw';
+import stackedMemoryBarStateSource from '@/components/Dashboard/useStackedMemoryBarState.ts?raw';
import workloadsSummarySource from '@/components/Workloads/WorkloadsSummary.tsx?raw';
import dashboardRouteSource from '@/pages/Dashboard.tsx?raw';
import dashboardHelpersSource from '@/pages/DashboardPanels/dashboardHelpers.ts?raw';
@@ -535,6 +538,16 @@ describe('frontend resource type boundaries', () => {
expect(stackedDiskBarStateSource).toContain('useTooltip');
expect(stackedDiskBarModelSource).toContain('export function buildStackedDiskBarPresentation');
expect(stackedDiskBarModelSource).toContain('const SEGMENT_COLORS');
+ expect(stackedMemoryBarSource).toContain('useStackedMemoryBarState');
+ expect(stackedMemoryBarSource).not.toContain('const [containerWidth, setContainerWidth] =');
+ expect(stackedMemoryBarSource).not.toContain('const segments = createMemo(() => {');
+ expect(stackedMemoryBarSource).not.toContain('const MEMORY_COLORS =');
+ expect(stackedMemoryBarStateSource).toContain('new ResizeObserver');
+ expect(stackedMemoryBarStateSource).toContain('useTooltip');
+ expect(stackedMemoryBarModelSource).toContain(
+ 'export function buildStackedMemoryBarPresentation',
+ );
+ expect(stackedMemoryBarModelSource).toContain('const MEMORY_COLORS');
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 d77f4524b6..380115abbc 100644
--- a/scripts/release_control/subsystem_lookup_test.py
+++ b/scripts/release_control/subsystem_lookup_test.py
@@ -1951,6 +1951,36 @@ class SubsystemLookupTest(unittest.TestCase):
"dashboard-workload-hot-path",
)
+ def test_lookup_paths_assigns_dashboard_stacked_memory_bar_runtime_to_performance_and_scalability(self) -> None:
+ result = lookup_paths(
+ [
+ "frontend-modern/src/components/Dashboard/StackedMemoryBar.tsx",
+ "frontend-modern/src/components/Dashboard/stackedMemoryBarModel.ts",
+ "frontend-modern/src/components/Dashboard/useStackedMemoryBarState.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"], [])