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.

Keep retained guest memory from signalling live pressure

pulse-triage[bot]72ef65ea0f1c
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 6e21bcf283..905a5ea6a6 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -2997,6 +2997,28 @@ hot paths. The shell keeps its fitted percentage/capacity label on a
semi-opaque surface scrim with base-content contrast so segment colors cannot
make the small readout illegible; this remains CSS presentation only and adds
no measurement or per-row runtime work.
+The Workloads memory bar consumes the same already-classified observation as
+the row's freshness cue (`memoryObservation.ts`), without deriving freshness
+from capacity, Last seen, another metric or a host-relative denominator.
+Only a current observation may colour memory as live pressure or show its
+anomaly badge. Last-known and unknown observations keep their percentage,
+composition, balloon and swap geometry for inspection, in a neutral tone;
+their composition tooltip carries the original source/time caveat. A current
+linked-agent memory observation remains current while QEMU disk reads defer.
+Tooltip headings, numeric values and neutral labels use theme-aware text so
+the source caveat and composition remain readable on both light and dark surfaces.
+An unavailable reading, including the shared bar's explicit unavailable input,
+emits no swap indicator, swap usage tooltip or anomaly badge even when retained
+numeric carriers are present. Known capacity may still explain that absence.
+Unannotated unrelated-platform callers keep current behaviour and measured
+zero remains zero. Alert records, thresholds, evaluation and historical series
+are unchanged: withholding a live decoration neither dismisses an alert nor
+establishes guest recovery. `stackedMemoryBarModel.test.ts`,
+`StackedMemoryBar.test.tsx` and `GuestRow.test.tsx` verify neutral retention,
+unavailable carriers, current controls, host/percentage-only paths and reactive
+same-guest replacement. Browser acceptance uses the canonical Workloads mapper
+and surface at desktop and phone widths, with source-owned memory independent
+of QEMU disk deferral; it is not native guest or installed acceptance.
The dashboard metric bar now follows that same pattern: the shell stays in
`frontend-modern/src/components/Workloads/MetricBar.tsx`, while width,
show-label, sublabel-fit, and threshold-color derivation live in
diff --git a/frontend-modern/browser-verification/1004ce45c414bd0b.json b/frontend-modern/browser-verification/1004ce45c414bd0b.json
new file mode 100644
index 0000000000..8fd812dcfe
--- /dev/null
+++ b/frontend-modern/browser-verification/1004ce45c414bd0b.json
@@ -0,0 +1,54 @@
+{
+ "version": 1,
+ "result": "passed",
+ "base_sha": "a308c3fa9dcae201645e7e3dcfc2a18c8ca6aa15",
+ "changed_paths": [
+ "frontend-modern/src/components/Workloads/GuestRow.tsx",
+ "frontend-modern/src/components/Workloads/StackedMemoryBar.tsx",
+ "frontend-modern/src/components/Workloads/stackedMemoryBarModel.ts"
+ ],
+ "content_sha256": {
+ "frontend-modern/src/components/Workloads/GuestRow.tsx": "58c385c741b67805df7323283479c99ec8a46043c8f308d135fbe6bed8fed7d3",
+ "frontend-modern/src/components/Workloads/StackedMemoryBar.tsx": "63f6516204e473c3183f6e0ea5310af03d99c5462b7d7ed08b52356cb3252273",
+ "frontend-modern/src/components/Workloads/stackedMemoryBarModel.ts": "27c8bbef0075df9df8cec5e13ac49b06b731cdfebed828e8ace8ddbfd2f107f8"
+ },
+ "routes": [
+ "/proxmox?tab=workloads (synthetic canonical snapshot through production useWorkloads/useWorkloadsState/WorkloadsSurface/GuestRow at /tmp/memory-bars/index.html)"
+ ],
+ "states": [
+ "Current, last-known, unavailable, unannotated legacy and future-dated Proxmox memory, measured zero and independent current linked-agent memory while QEMU disk reads defer",
+ "Guest/host memory bases, light/dark themes, retained swap/balloon/cache, synthetic anomaly carriers and same-identity replacement"
+ ],
+ "interactions": [
+ "Hover the real memory composition tooltip: source/age caveat, neutral legend and readable numbers; caveat/numeric text contrast checked at least 4.5:1 in both themes",
+ "Phone visible Prior/Unknown/N/A cues and complete screen-reader provenance without hover",
+ "Change Guest/Host basis and refresh Last seen without reviving a retained reading; replace with current and unavailable observations without removing the guest"
+ ],
+ "viewports": [
+ {
+ "width": 1365,
+ "height": 900
+ },
+ {
+ "width": 390,
+ "height": 844
+ }
+ ],
+ "verified_at": "2026-10-09T17:33:20.358Z",
+ "browsers": [
+ {
+ "engine": "desktop",
+ "version": "141.0.7390.37"
+ },
+ {
+ "engine": "phone",
+ "version": "26.0"
+ }
+ ],
+ "playwright_version": "1.56.1",
+ "evidence": {
+ "result": "Retained lane evidence/browser-result.json",
+ "screenshots": "Ten inspected desktop Chromium/phone WebKit captures in evidence/BROWSER.tar.xz",
+ "limits": "Synthetic canonical snapshot and intercepted synthetic anomalies, production useWorkloads mapper/useWorkloadsState/WorkloadsSurface/GuestRow/StackedMemoryBar and CSS. Memory-basis/theme controls and observation replacement are fixture inputs. No authenticated full App, backend/native guest, thaw, installed/released or physical-device acceptance."
+ }
+}
diff --git a/frontend-modern/src/components/Workloads/GuestRow.tsx b/frontend-modern/src/components/Workloads/GuestRow.tsx
index 0528b23e6f..f5e9902a20 100644
--- a/frontend-modern/src/components/Workloads/GuestRow.tsx
+++ b/frontend-modern/src/components/Workloads/GuestRow.tsx
@@ -604,6 +604,7 @@ export function GuestRow(props: GuestRowProps) {
used={props.guest.memory?.used || 0}
total={memoryDisplayTotal()}
unavailable={memoryDisplayUnavailable()}
+ reading={memoryReading()}
percentOnly={isHostMemoryBasis() ? undefined : memoryPercentOnly()}
cache={isHostMemoryBasis() ? 0 : (props.guest.memory?.cache ?? 0)}
cacheInclusiveLabel={isHostMemoryBasis() ? undefined : 'Shown in Proxmox'}
diff --git a/frontend-modern/src/components/Workloads/StackedMemoryBar.test.tsx b/frontend-modern/src/components/Workloads/StackedMemoryBar.test.tsx
index 938a9b5383..2761f3c0fa 100644
--- a/frontend-modern/src/components/Workloads/StackedMemoryBar.test.tsx
+++ b/frontend-modern/src/components/Workloads/StackedMemoryBar.test.tsx
@@ -1,5 +1,7 @@
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { render, screen, cleanup } from '@solidjs/testing-library';
+import { createSignal } from 'solid-js';
+import type { MemoryObservationPresentation } from '@/utils/memoryObservation';
import { StackedMemoryBar } from './StackedMemoryBar';
let resizeCallback: ResizeObserverCallback | undefined;
@@ -53,6 +55,57 @@ describe('StackedMemoryBar', () => {
expect(getSegments(container)).toHaveLength(0);
});
+ it.each(['last-known', 'unknown'] as const)(
+ 'uses neutral %s bars and restores live decoration only with a current reading',
+ (state) => {
+ const [reading, setReading] = createSignal<MemoryObservationPresentation>({
+ state,
+ summary: 'Retained reading',
+ message: 'Not a current measurement.',
+ });
+ const { container } = render(() => (
+ <StackedMemoryBar
+ used={90}
+ total={100}
+ swapUsed={10}
+ swapTotal={20}
+ reading={reading()}
+ anomaly={{
+ resource_id: 'vm-100',
+ resource_name: 'test-vm',
+ resource_type: 'vm',
+ metric: 'memory',
+ current_value: 90,
+ baseline_mean: 30,
+ baseline_std_dev: 5,
+ z_score: 12,
+ severity: 'critical',
+ description: 'Memory usage 3x above baseline',
+ }}
+ />
+ ));
+ const bar = getSegments(container)[0];
+ const shell = container.firstElementChild;
+ expect(screen.getByText('90%')).toBeInTheDocument();
+ expect(bar).toHaveAttribute('fill', 'rgba(148, 163, 184, 0.5)');
+ expect(getSwapBar(container)).toHaveAttribute('fill', 'rgba(148, 163, 184, 0.5)');
+ expect(screen.queryByText('3.0x')).not.toBeInTheDocument();
+
+ setReading({ ...reading(), state: 'current', message: 'Current.' });
+ expect(container.firstElementChild).toBe(shell);
+ expect(getSegments(container)[0]).toHaveAttribute('fill', 'rgba(239, 68, 68, 0.6)');
+ expect(getSwapBar(container)).toHaveAttribute('fill', 'rgb(168 85 247)');
+ expect(screen.getByText('3.0x')).toBeInTheDocument();
+
+ setReading({ ...reading(), state: 'unavailable', message: 'Unavailable.' });
+ expect(screen.getByText('N/A')).toBeInTheDocument();
+ expect(screen.queryByText('90%')).not.toBeInTheDocument();
+ expect(screen.queryByText('3.0x')).not.toBeInTheDocument();
+ expect(getSwapBar(container)).toBeNull();
+ expect(getSegments(container)).toEqual([]);
+ },
+ );
+
it('renders 0% when both used and total are 0', () => {
render(() => <StackedMemoryBar used={0} total={0} />);
expect(screen.getByText('0%')).toBeInTheDocument();
diff --git a/frontend-modern/src/components/Workloads/StackedMemoryBar.tsx b/frontend-modern/src/components/Workloads/StackedMemoryBar.tsx
index d4fd470e9a..a049d0c2fa 100644
--- a/frontend-modern/src/components/Workloads/StackedMemoryBar.tsx
+++ b/frontend-modern/src/components/Workloads/StackedMemoryBar.tsx
@@ -64,7 +64,7 @@ export function StackedMemoryBar(props: StackedMemoryBarProps) {
width={swapBarWidth()}
height="18"
rx="2"
- fill="rgb(168 85 247)"
+ fill={presentation().swapBarColor}
/>
</Show>
</svg>
@@ -96,9 +96,12 @@ export function StackedMemoryBar(props: StackedMemoryBarProps) {
<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">
+ <div class="font-medium mb-1 text-base-content border-b border-border pb-1">
{presentation().tooltipTitle}
</div>
+ <Show when={presentation().tooltipMessage}>
+ <p class="mb-2 max-w-xs text-xs text-muted">{presentation().tooltipMessage}</p>
+ </Show>
<For each={presentation().tooltipRows}>
{(row) => (
<div
@@ -106,7 +109,7 @@ export function StackedMemoryBar(props: StackedMemoryBarProps) {
classList={{ 'border-t border-border': row.borderTop }}
>
<span class={row.labelClass}>{row.label}</span>
- <span class="whitespace-nowrap text-slate-300">{row.value}</span>
+ <span class="whitespace-nowrap text-base-content">{row.value}</span>
</div>
)}
</For>
diff --git a/frontend-modern/src/components/Workloads/__tests__/GuestRow.test.tsx b/frontend-modern/src/components/Workloads/__tests__/GuestRow.test.tsx
index 370ea46ca7..392d6ce976 100644
--- a/frontend-modern/src/components/Workloads/__tests__/GuestRow.test.tsx
+++ b/frontend-modern/src/components/Workloads/__tests__/GuestRow.test.tsx
@@ -86,6 +86,7 @@ vi.mock('../StackedMemoryBar', () => ({
used: number;
total: number;
unavailable?: boolean;
+ reading?: { state: string; message: string } | null;
comparisonTotalLabel?: string;
tooltipTitle?: string;
}) => (
@@ -94,6 +95,8 @@ vi.mock('../StackedMemoryBar', () => ({
data-used={props.used}
data-total={props.total}
data-unavailable={props.unavailable}
+ data-reading-state={props.reading?.state}
+ data-reading-message={props.reading?.message}
data-comparison-total-label={props.comparisonTotalLabel}
data-tooltip-title={props.tooltipTitle}
/>
@@ -1180,6 +1183,14 @@ describe('GuestRow', () => {
expect(screen.queryByRole('img', { name: /current/ })).not.toBeInTheDocument();
} else {
expect(screen.getByTestId('memory-bar')).toHaveAttribute('data-unavailable', 'false');
+ expect(screen.getByTestId('memory-bar')).toHaveAttribute(
+ 'data-reading-state',
+ 'last-known',
+ );
+ expect(screen.getByTestId('memory-bar')).toHaveAttribute(
+ 'data-reading-message',
+ 'Last known. Source: QEMU guest agent. Observed: 2026-09-30 11:00:00 UTC. Not a current measurement.',
+ );
}
});
@@ -1199,6 +1210,11 @@ describe('GuestRow', () => {
expect(
screen.getByRole('img', { name: 'test-vm memory history, freshness unknown 50%' }),
).toBeInTheDocument();
+ } else {
+ expect(screen.getByTestId('memory-bar')).toHaveAttribute(
+ 'data-reading-state',
+ 'unknown',
+ );
}
},
);
@@ -1237,6 +1253,10 @@ describe('GuestRow', () => {
expect(screen.queryByText('50%')).not.toBeInTheDocument();
} else {
expect(screen.getByTestId('memory-bar')).toHaveAttribute('data-unavailable', 'true');
+ expect(screen.getByTestId('memory-bar')).toHaveAttribute(
+ 'data-reading-state',
+ 'unavailable',
+ );
}
});
@@ -1264,6 +1284,9 @@ describe('GuestRow', () => {
setGuest({ ...guest(), memory: observation('current') });
expect(container.querySelector('tr')).toBe(row);
expect(container.querySelector(noticeSelector)).toBeNull();
+ if (mode === 'bars') {
+ expect(screen.getByTestId('memory-bar')).not.toHaveAttribute('data-reading-state');
+ }
if (mode === 'sparklines') {
expect(
screen.getByRole('img', { name: 'test-vm memory history, current 50%' }),
diff --git a/frontend-modern/src/components/Workloads/__tests__/stackedMemoryBarModel.test.ts b/frontend-modern/src/components/Workloads/__tests__/stackedMemoryBarModel.test.ts
index 476c1228e7..7886bca130 100644
--- a/frontend-modern/src/components/Workloads/__tests__/stackedMemoryBarModel.test.ts
+++ b/frontend-modern/src/components/Workloads/__tests__/stackedMemoryBarModel.test.ts
@@ -1,9 +1,152 @@
import { describe, expect, it } from 'vitest';
import { buildStackedMemoryBarPresentation } from '../stackedMemoryBarModel';
+import type { AnomalyReport } from '@/types/aiIntelligence';
const GiB = 1024 ** 3;
+const anomaly: AnomalyReport = {
+ resource_id: 'vm-100',
+ resource_name: 'test-vm',
+ resource_type: 'vm',
+ metric: 'memory',
+ current_value: 90,
+ baseline_mean: 30,
+ baseline_std_dev: 5,
+ z_score: 12,
+ severity: 'critical',
+ description: 'Memory usage 3x above baseline',
+};
+
+describe('source-owned memory decorations', () => {
+ const props = {
+ used: 90,
+ total: 100,
+ cache: 2,
+ balloon: 98,
+ swapUsed: 10,
+ swapTotal: 20,
+ anomaly,
+ };
+
+ it.each(['last-known', 'unknown'] as const)(
+ 'keeps %s composition inspectable without a live severity or anomaly',
+ (state) => {
+ const message = `${state}. Source: QEMU guest agent. Not a current measurement.`;
+ const current = buildStackedMemoryBarPresentation(props, 400);
+ const retained = buildStackedMemoryBarPresentation(
+ { ...props, reading: { state, message } },
+ 400,
+ );
+
+ expect(retained.displayPercentValue).toBe(90);
+ expect(retained.displaySublabel).toBe(current.displaySublabel);
+ expect(
+ retained.segments.map(({ label, leftPercent, widthPercent }) => ({
+ label,
+ leftPercent,
+ widthPercent,
+ })),
+ ).toEqual(
+ current.segments.map(({ label, leftPercent, widthPercent }) => ({
+ label,
+ leftPercent,
+ widthPercent,
+ })),
+ );
+ expect(retained.segments.every(({ color }) => color === 'rgba(148, 163, 184, 0.5)')).toBe(
+ true,
+ );
+ expect(retained.tooltipRows.map(({ label, value }) => ({ label, value }))).toEqual(
+ current.tooltipRows.map(({ label, value }) => ({ label, value })),
+ );
+ expect(retained.tooltipRows.every(({ labelClass }) => labelClass === 'text-muted')).toBe(
+ true,
+ );
+ expect(retained.tooltipMessage).toBe(message);
+ expect(retained.showSwapBar).toBe(true);
+ expect(retained.swapBarPercent).toBe(50);
+ expect(retained.swapBarColor).toBe('rgba(148, 163, 184, 0.5)');
+ expect(retained.anomalyDescription).toBeUndefined();
+ expect(retained.anomalyRatio).toBe('');
+ },
+ );
+
+ it.each(['last-known', 'unknown'] as const)(
+ 'does not colour a %s percentage-only or host-share value as current pressure',
+ (state) => {
+ const reading = { state, message: 'Not a current measurement.' };
+ const percentOnly = buildStackedMemoryBarPresentation(
+ { used: 0, total: 0, percentOnly: 95, reading, anomaly },
+ 400,
+ );
+ const hostShare = buildStackedMemoryBarPresentation(
+ {
+ used: 10,
+ total: 100,
+ severityPercent: 95,
+ comparisonTotalLabel: 'Host total',
+ reading,
+ anomaly,
+ },
+ 400,
+ );
+ for (const presentation of [percentOnly, hostShare]) {
+ expect(presentation.segments[0].color).toBe('rgba(148, 163, 184, 0.5)');
+ expect(presentation.anomalyDescription).toBeUndefined();
+ expect(presentation.tooltipMessage).toBe(reading.message);
+ }
+ expect(percentOnly.displayPercentValue).toBe(95);
+ expect(hostShare.displayPercentValue).toBe(10);
+ expect(hostShare.tooltipRows.map(({ label }) => label)).toEqual(['Used', 'Host total']);
+ },
+ );
+
+ it.each([
+ { unavailable: true },
+ { reading: { state: 'unavailable' as const, message: 'Reading unavailable.' } },
+ { unavailable: true, reading: { state: 'last-known' as const, message: 'Last known.' } },
+ ])('withholds every live decoration for unavailable usage (%j)', (availability) => {
+ const presentation = buildStackedMemoryBarPresentation({ ...props, ...availability }, 400);
+ expect(presentation.unavailable).toBe(true);
+ expect(presentation.segments).toEqual([]);
+ expect(presentation.showSwapBar).toBe(false);
+ expect(presentation.swapBarPercent).toBe(0);
+ expect(presentation.showSublabel).toBe(false);
+ expect(presentation.tooltipRows.map(({ label }) => label)).toEqual(['Usage', 'Total']);
+ expect(presentation.anomalyDescription).toBeUndefined();
+ expect(presentation.anomalyRatio).toBe('');
+ });
+
+ it('preserves current and unannotated-platform severity, swap and anomaly behaviour', () => {
+ const legacy = buildStackedMemoryBarPresentation(props, 400);
+ const current = buildStackedMemoryBarPresentation(
+ { ...props, reading: { state: 'current', message: 'Current. Source: Pulse Agent.' } },
+ 400,
+ );
+ for (const presentation of [current, legacy]) {
+ expect(presentation.segments[0].color).toBe('rgba(239, 68, 68, 0.6)');
+ expect(presentation.tooltipRows[0].labelClass).toBe('text-red-400');
+ expect(presentation.showSwapBar).toBe(true);
+ expect(presentation.swapBarColor).toBe('rgb(168 85 247)');
+ expect(presentation.anomalyDescription).toBe(anomaly.description);
+ expect(presentation.anomalyRatio).toBe('3.0x');
+ }
+ expect(legacy.tooltipMessage).toBeUndefined();
+ });
+
+ it('keeps a retained measured zero as zero rather than unavailable', () => {
+ const presentation = buildStackedMemoryBarPresentation(
+ { used: 0, total: 100, reading: { state: 'last-known', message: 'Last known zero.' } },
+ 400,
+ );
+ expect(presentation.unavailable).toBe(false);
+ expect(presentation.displayLabel).toBe('0%');
+ expect(presentation.tooltipRows[0].value).toBe('0 B');
+ expect(presentation.tooltipMessage).toBe('Last known zero.');
+ });
+});
+
describe('buildStackedMemoryBarPresentation', () => {
it('renders unavailable usage without inventing a zero-percent segment', () => {
const presentation = buildStackedMemoryBarPresentation(
@@ -19,13 +162,13 @@ describe('buildStackedMemoryBarPresentation', () => {
{
borderTop: false,
label: 'Usage',
- labelClass: 'text-slate-400',
+ labelClass: 'text-muted',
value: 'Unavailable',
},
{
borderTop: true,
label: 'Total',
- labelClass: 'text-slate-400',
+ labelClass: 'text-muted',
value: '8.00 GB',
},
]);
diff --git a/frontend-modern/src/components/Workloads/stackedMemoryBarModel.ts b/frontend-modern/src/components/Workloads/stackedMemoryBarModel.ts
index a5a02eb298..cae008ad2b 100644
--- a/frontend-modern/src/components/Workloads/stackedMemoryBarModel.ts
+++ b/frontend-modern/src/components/Workloads/stackedMemoryBarModel.ts
@@ -8,11 +8,14 @@ import {
} from '@/utils/format';
import { getMetricColorRgba, getMetricSeverity } from '@/utils/metricThresholds';
import type { MetricDisplayThresholds, MetricSeverity } from '@/utils/metricThresholds';
+import type { MemoryObservationPresentation } from '@/utils/memoryObservation';
export interface StackedMemoryBarProps {
used: number;
total: number;
unavailable?: boolean;
+ /** Already classified by the owning surface; never infer freshness from capacity. */
+ reading?: Pick<MemoryObservationPresentation, 'state' | 'message'> | null;
percentOnly?: number;
/** Reclaimable buff/cache (available - truly free); used + cache + free ≈ total. */
cache?: number;
@@ -55,7 +58,9 @@ export interface StackedMemoryBarPresentation {
showSublabel: boolean;
showSwapBar: boolean;
swapBarPercent: number;
+ swapBarColor: string;
tooltipRows: StackedMemoryTooltipRow[];
+ tooltipMessage?: string;
tooltipTitle: string;
unavailable: boolean;
}
@@ -76,6 +81,16 @@ const MEMORY_COLORS = {
swap: 'rgba(168, 85, 247, 0.6)',
};
+const RETAINED_MEMORY_COLOR = 'rgba(148, 163, 184, 0.5)';
+
+const isMemoryUnavailable = (props: StackedMemoryBarProps): boolean =>
+ props.unavailable === true || props.reading?.state === 'unavailable';
+
+// A retained value can still explain the last report, but it cannot assert
+// today's pressure or anomaly. Unannotated platform bars keep their behaviour.
+const isMemoryCurrent = (props: StackedMemoryBarProps): boolean =>
+ !isMemoryUnavailable(props) && (!props.reading || props.reading.state === 'current');
+
// Cache can never exceed the non-used pages; clamp so a momentarily
// inconsistent snapshot (used drifting past total - cache) cannot push the
// segments or the reconciliation row past 100%.
@@ -86,7 +101,7 @@ function getEffectiveCache(props: StackedMemoryBarProps): number {
}
function getUtilizationPercent(props: StackedMemoryBarProps): number {
- if (props.unavailable) return 0;
+ if (isMemoryUnavailable(props)) return 0;
if (props.total > 0) {
return (props.used / props.total) * 100;
}
@@ -100,7 +115,7 @@ function getSegments(
props: StackedMemoryBarProps,
utilizationPercent: number,
): StackedMemorySegment[] {
- if (props.unavailable) {
+ if (isMemoryUnavailable(props)) {
return [];
}
if (props.total <= 0) {
@@ -109,7 +124,9 @@ function getSegments(
}
return [
{
- color: getMetricColorRgba(utilizationPercent, 'memory', props.thresholds),
+ color: isMemoryCurrent(props)
+ ? getMetricColorRgba(utilizationPercent, 'memory', props.thresholds)
+ : RETAINED_MEMORY_COLOR,
label: 'Utilization',
leftPercent: 0,
widthPercent: utilizationPercent,
@@ -129,7 +146,9 @@ function getSegments(
const segments: StackedMemorySegment[] = [];
if (props.used > 0) {
segments.push({
- color: getMetricColorRgba(severityPercent, 'memory', props.thresholds),
+ color: isMemoryCurrent(props)
+ ? getMetricColorRgba(severityPercent, 'memory', props.thresholds)
+ : RETAINED_MEMORY_COLOR,
label: 'Active',
leftPercent: 0,
widthPercent: usedPercent,
@@ -139,7 +158,7 @@ function getSegments(
// Reclaimable buff/cache rides between active and the balloon limit, like v5.
if (cache > 0) {
segments.push({
- color: MEMORY_COLORS.cache,
+ color: isMemoryCurrent(props) ? MEMORY_COLORS.cache : RETAINED_MEMORY_COLOR,
label: 'Reclaimable',
leftPercent: usedPercent,
widthPercent: cachePercent,
@@ -154,7 +173,7 @@ function getSegments(
);
if (balloonLimitPercent > 0 && balloon > usedPlusCache) {
segments.push({
- color: MEMORY_COLORS.balloon,
+ color: isMemoryCurrent(props) ? MEMORY_COLORS.balloon : RETAINED_MEMORY_COLOR,
label: 'Balloon',
leftPercent: usedPercent + cachePercent,
widthPercent: balloonLimitPercent,
@@ -175,18 +194,18 @@ function getTooltipRows(
const hasActiveBallooning = props.total > 0 && balloon > 0 && balloon < props.total;
const hasSwap = (props.swapTotal || 0) > 0;
- if (props.unavailable) {
+ if (isMemoryUnavailable(props)) {
rows.push({
borderTop: false,
label: 'Usage',
- labelClass: 'text-slate-400',
+ labelClass: 'text-muted',
value: 'Unavailable',
});
if (props.total > 0) {
rows.push({
borderTop: true,
label: 'Total',
- labelClass: 'text-slate-400',
+ labelClass: 'text-muted',
value: formatBytes(props.total),
});
}
@@ -198,7 +217,9 @@ function getTooltipRows(
rows.push({
borderTop: false,
label: 'Used',
- labelClass: USED_LABEL_CLASS[getMetricSeverity(severityPercent, 'memory', props.thresholds)],
+ labelClass: isMemoryCurrent(props)
+ ? USED_LABEL_CLASS[getMetricSeverity(severityPercent, 'memory', props.thresholds)]
+ : 'text-muted',
value: formatBytes(props.used),
});
@@ -206,7 +227,7 @@ function getTooltipRows(
rows.push({
borderTop: true,
label: props.comparisonTotalLabel,
- labelClass: 'text-slate-400',
+ labelClass: 'text-muted',
value: formatBytes(props.total),
});
return rows;
@@ -216,7 +237,7 @@ function getTooltipRows(
rows.push({
borderTop: true,
label: 'Reclaimable cache',
- labelClass: 'text-amber-400',
+ labelClass: isMemoryCurrent(props) ? 'text-amber-400' : 'text-muted',
value: formatBytes(cache),
});
}
@@ -225,7 +246,7 @@ function getTooltipRows(
rows.push({
borderTop: true,
label: 'Balloon Limit',
- labelClass: 'text-blue-400',
+ labelClass: isMemoryCurrent(props) ? 'text-blue-400' : 'text-muted',
value: formatBytes(balloon),
});
}
@@ -236,7 +257,7 @@ function getTooltipRows(
rows.push({
borderTop: true,
label: 'Free',
- labelClass: 'text-slate-400',
+ labelClass: 'text-muted',
value: formatBytes(Math.max(0, ceiling - props.used - cache)),
});
@@ -246,7 +267,7 @@ function getTooltipRows(
rows.push({
borderTop: true,
label: props.cacheInclusiveLabel ?? 'Used with cache',
- labelClass: 'text-slate-500 italic',
+ labelClass: isMemoryCurrent(props) ? 'text-slate-500 italic' : 'text-muted',
value: formatPercent(((props.used + cache) / props.total) * 100),
});
}
@@ -254,16 +275,16 @@ function getTooltipRows(
rows.push({
borderTop: true,
label: 'Utilization',
- labelClass: 'text-blue-300',
+ labelClass: isMemoryCurrent(props) ? 'text-blue-300' : 'text-muted',
value: displayLabel,
});
}
- if (props.total > 0 && hasSwap) {
+ if (!isMemoryUnavailable(props) && props.total > 0 && hasSwap) {
rows.push({
borderTop: true,
label: 'Swap',
- labelClass: 'text-amber-400',
+ labelClass: isMemoryCurrent(props) ? 'text-amber-400' : 'text-muted',
value: `${formatBytes(props.swapUsed || 0)} / ${formatBytes(props.swapTotal || 0)}`,
});
}
@@ -278,15 +299,16 @@ export function buildStackedMemoryBarPresentation(
props: StackedMemoryBarProps,
containerWidth: number,
): StackedMemoryBarPresentation {
+ const unavailable = isMemoryUnavailable(props);
+ const current = isMemoryCurrent(props);
+ const anomaly = current ? props.anomaly : undefined;
const utilizationPercent = getUtilizationPercent(props);
const displayLabel = formatPercent(utilizationPercent);
const displaySublabel =
- !props.unavailable && props.total > 0
- ? `${formatBytes(props.used)}/${formatBytes(props.total)}`
- : '';
- const anomalyRatio = formatAnomalyRatio(props.anomaly) ?? '';
+ !unavailable && props.total > 0 ? `${formatBytes(props.used)}/${formatBytes(props.total)}` : '';
+ const anomalyRatio = formatAnomalyRatio(anomaly) ?? '';
// The anomaly marker shares the label's line whenever it renders.
- const anomalyMarker = props.anomaly?.description && anomalyRatio ? ` ${anomalyRatio}` : '';
+ const anomalyMarker = anomaly?.description && anomalyRatio ? ` ${anomalyRatio}` : '';
const showSublabel =
displaySublabel.length > 0 &&
containerWidth >=
@@ -294,23 +316,25 @@ export function buildStackedMemoryBarPresentation(
LABEL_PADDING_PX;
return {
- anomalyClass: props.anomaly
- ? (ANOMALY_SEVERITY_CLASS[props.anomaly.severity] ?? 'text-yellow-400')
+ anomalyClass: anomaly
+ ? (ANOMALY_SEVERITY_CLASS[anomaly.severity] ?? 'text-yellow-400')
: 'text-yellow-400',
- anomalyDescription: props.anomaly?.description,
+ anomalyDescription: anomaly?.description,
anomalyRatio,
displayLabel,
displayPercentValue: utilizationPercent,
displaySublabel,
segments: getSegments(props, utilizationPercent),
showSublabel,
- showSwapBar: (props.swapTotal || 0) > 0 && (props.swapUsed || 0) > 0,
+ showSwapBar: !unavailable && (props.swapTotal || 0) > 0 && (props.swapUsed || 0) > 0,
swapBarPercent:
- props.swapTotal && props.swapTotal > 0
+ !unavailable && props.swapTotal && props.swapTotal > 0
? Math.min(((props.swapUsed || 0) / props.swapTotal) * 100, 100)
: 0,
+ swapBarColor: current ? 'rgb(168 85 247)' : RETAINED_MEMORY_COLOR,
tooltipRows: getTooltipRows(props, displayLabel),
+ tooltipMessage: props.reading?.message,
tooltipTitle: props.tooltipTitle ?? 'Memory Composition',
- unavailable: props.unavailable === true,
+ unavailable,
};
}