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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Fix alert threshold metric coloring
rcourtman361f289485cc
diff --git a/docs/release-control/v6/internal/records/known-rc-issue-closure-for-ga-metric-threshold-coloring-2026-05-01.md b/docs/release-control/v6/internal/records/known-rc-issue-closure-for-ga-metric-threshold-coloring-2026-05-01.mdnew file mode 100644index 0000000000..92250891d0--- /dev/null+++ b/docs/release-control/v6/internal/records/known-rc-issue-closure-for-ga-metric-threshold-coloring-2026-05-01.md@@ -0,0 +1,52 @@+# Known RC Issue Closure For GA Metric Threshold Coloring Record++- Date: `2026-05-01`+- Gate: `known-rc-issue-closure-for-ga`+- Result: `passed`++## Context++The v5 maintenance delta audit found that `#1358` was not fully carried into+v6. Pulse v5 had been fixed so metric color bands respected configured alert+thresholds, but the v6 Workloads, Infrastructure, and Storage display helpers+still colored CPU, memory, and disk bars from static display constants.++That meant an operator could lower, raise, or disable alert thresholds in the+alert configuration and still see v6 runtime metric bars use the old hard-coded+color bands.++## Disposition++The v6 candidate now resolves display metric colors through the alert+configuration path:++- `frontend-modern/src/utils/metricThresholds.ts` resolves display thresholds+ from alert defaults, hysteresis trigger/clear pairs, disabled thresholds, and+ resource overrides.+- `frontend-modern/src/stores/alertsActivation.ts` exposes that resolver to+ frontend consumers through the active alert configuration.+- Workloads route guest rows and drawers through guest/Docker scope identity+ candidates before coloring CPU, memory, and disk bars.+- Infrastructure and Storage consumers pass alert-backed threshold props into+ their existing metric bar models instead of selecting thresholds locally.+- The legacy static `METRIC_THRESHOLDS` path remains only as fallback display+ behavior for callers that do not have alert configuration in scope.++## Proof++- `npm --prefix frontend-modern run type-check`+- From `frontend-modern`: `npm exec vitest run src/utils/__tests__/metricThresholds.test.ts src/components/Workloads/MetricBar.test.tsx src/components/Workloads/__tests__/EnhancedCPUBar.test.tsx src/components/Workloads/__tests__/GuestRow.test.tsx src/components/Workloads/__tests__/WorkloadsSurface.performance.contract.test.tsx src/components/Workloads/__tests__/WorkloadsSurface.k8s.test.tsx src/components/shared/__tests__/InfrastructureSummaryTable.test.tsx src/components/Storage/__tests__/Storage.test.tsx src/components/Storage/__tests__/useEnhancedStorageBarModel.test.ts`+- Browser proof on `http://127.0.0.1:5173/workloads`: page loaded after reload,+ Workloads table rendered with metric bars, backend/live data showed connected,+ and browser console error count was `0`.+- Local threshold sanity check:+ `curl -s http://127.0.0.1:7655/api/alerts/config | jq '{activationState, hysteresisMargin, guestDefaults: .guestDefaults, dockerDefaults: .dockerDefaults}'`+ showed active guest thresholds and Docker CPU/memory/disk triggers set to+ `0`, matching the neutral high-CPU Docker row observed in-browser.++## Outcome++The v6 candidate no longer knowingly regresses v5 `#1358`. Runtime metric+colors now respect configured alert thresholds, including disabled Docker+thresholds, while keeping static display constants as a compatibility fallback+for threshold-unaware callers.diff --git a/docs/release-control/v6/internal/status.json b/docs/release-control/v6/internal/status.jsonindex 2422e6aa1c..00904a5eb6 100644--- a/docs/release-control/v6/internal/status.json+++ b/docs/release-control/v6/internal/status.json@@ -4439,6 +4439,12 @@"kind": "file","evidence_tier": "managed-runtime-exercise"},+ {+ "repo": "pulse",+ "path": "docs/release-control/v6/internal/records/known-rc-issue-closure-for-ga-metric-threshold-coloring-2026-05-01.md",+ "kind": "file",+ "evidence_tier": "managed-runtime-exercise"+ },{"repo": "pulse","path": "docs/release-control/v6/internal/records/known-rc-issue-closure-for-ga-rc3-followup-2026-05-01.md",diff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.mdindex 2cf7507df2..98c7774677 100644--- a/docs/release-control/v6/internal/subsystems/alerts.md+++ b/docs/release-control/v6/internal/subsystems/alerts.md@@ -46,6 +46,9 @@ operator-facing alert routing behavior for live runtime alerts.24. `frontend-modern/src/utils/alertThresholdsPresentation.ts`25. `frontend-modern/src/utils/alertThresholdsSectionPresentation.ts`26. `internal/alerts/history.go`+27. `frontend-modern/src/stores/alertsActivation.ts`+28. `frontend-modern/src/utils/alertThresholdDefaults.ts`+29. `frontend-modern/src/utils/metricThresholds.ts`## Shared Boundaries@@ -62,6 +65,12 @@ operator-facing alert routing behavior for live runtime alerts.preserving the shared upgrade-navigation contract; the alert surface mayroute to the canonical destination, but must not emit browser-local upgrademetrics or present Pro-required copy when prompt suppression applies.+6. Add or change frontend metric color thresholds through+ `frontend-modern/src/utils/metricThresholds.ts`,+ `frontend-modern/src/utils/alertThresholdDefaults.ts`, and+ `frontend-modern/src/stores/alertsActivation.ts` so browser display colors+ consume the same configured alert thresholds and override identity chain as+ the alert runtime instead of hard-coded per-surface thresholds.## Forbidden Paths@@ -130,6 +139,15 @@ incidents. ZFS device alert labels must preserve raw device names such asdevice paths can already begin with `/`; browser alert surfaces consume theruntime `resourceName` as authored rather than patching storage labels locally.+Browser metric severity colors are also alert-backed. Workloads,+Infrastructure, and Storage may pass resolved display thresholds into their+local bars, but threshold selection must flow through the shared alert activation+store and `frontend-modern/src/utils/metricThresholds.ts`, including configured+hysteresis, disabled thresholds, storage usage defaults, and guest/Docker+override identity candidates. Static metric-color defaults are only fallback+presentation behavior for callers that do not have alert configuration in+scope.+Alert history persistence is also part of that canonical boundary. The historymanager may choose the owned runtime data directory, but it must normalize thatdirectory once and then resolve only the fixed `alert-history.json` anddiff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex 8608ad702b..ed3ebad9da 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -1396,6 +1396,11 @@ owns sorting, count, identity-alias, and linked-agent derivation, andowns the per-row render/runtime surface. Future work should extend thoseowners instead of pushing websocket, alert, or identity plumbing back into theshared table shell.+The shared infrastructure summary row may consume alert-backed metric+thresholds from the table state, but threshold selection itself remains+alerts-owned through `frontend-modern/src/stores/alertsActivation.ts` and+`frontend-modern/src/utils/metricThresholds.ts`; shared primitive cells and rows+must only pass resolved warning/critical values into metric presentation.The shared infrastructure selector now follows that same owner split.`frontend-modern/src/components/shared/InfrastructureSelector.tsx` stays therender shell, `frontend-modern/src/components/shared/useInfrastructureSelectorState.ts`diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.mdindex b3d89c1894..57f7baba1f 100644--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md@@ -202,6 +202,11 @@ regression protection.21. Extend stacked memory-bar capacity math, balloon/swap derivation, and resize-observer runtime through `frontend-modern/src/components/Workloads/stackedMemoryBarModel.ts` and `frontend-modern/src/components/Workloads/useStackedMemoryBarState.ts` rather than rebuilding memory-bar-local state, tooltip shaping, and label-fit logic inside `frontend-modern/src/components/Workloads/StackedMemoryBar.tsx`22. Extend metric-bar width, label-fit logic, and resize-observer runtime through `frontend-modern/src/components/Workloads/metricBarModel.ts` and `frontend-modern/src/components/Workloads/useMetricBarState.ts` rather than rebuilding metric-local state and threshold mapping inside `frontend-modern/src/components/Workloads/MetricBar.tsx`23. Extend enhanced CPU bar usage/anomaly presentation and tooltip runtime through `frontend-modern/src/components/Workloads/enhancedCpuBarModel.ts` and `frontend-modern/src/components/Workloads/useEnhancedCPUBarState.ts` rather than rebuilding tooltip-local state and CPU-threshold formatting inside `frontend-modern/src/components/Workloads/EnhancedCPUBar.tsx`+ Workload and unified-resource metric bars may accept resolved alert display+ threshold props, but they must not choose alert thresholds locally. Scope and+ override resolution belongs to the alerts-owned activation store and+ `frontend-modern/src/utils/metricThresholds.ts`, while the hot-path bar+ models remain presentation-only consumers.23. Extend grouped workload row windowing, reveal-index clamping, overscan math, and per-group visible-slice derivation through `frontend-modern/src/components/Workloads/useGroupedTableWindowing.ts`, and extend viewport event wiring through `frontend-modern/src/components/Workloads/useWorkloadViewportSync.ts` rather than rebuilding scroll handlers, mounted-row budgets, viewport listeners, or group-slice math inside `frontend-modern/src/components/Workloads/useWorkloadsDerivedState.ts`24. Extend Workloads shell rendering through `frontend-modern/src/components/Workloads/WorkloadsStateCards.tsx`, `frontend-modern/src/components/Workloads/WorkloadsTable.tsx`, and `frontend-modern/src/components/Workloads/WorkloadsStatsStrip.tsx` rather than accreting loading cards, workload table markup, or stats-strip presentation back into `frontend-modern/src/components/Workloads/WorkloadsSurface.tsx`25. Extend workload table shell ownership through `frontend-modern/src/components/Workloads/WorkloadTableHeader.tsx` and `frontend-modern/src/components/Workloads/WorkloadPanel.tsx` rather than rebuilding sortable header markup, grouped node rows, row expansion, or guest-drawer rendering inside `frontend-modern/src/components/Workloads/WorkloadsTable.tsx`diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.jsonindex 0680497989..efe81795b6 100644--- a/docs/release-control/v6/internal/subsystems/registry.json+++ b/docs/release-control/v6/internal/subsystems/registry.json@@ -1291,6 +1291,7 @@],"owned_files": ["frontend-modern/src/pages/Alerts.tsx",+ "frontend-modern/src/stores/alertsActivation.ts","frontend-modern/src/utils/alertActivationPresentation.ts","frontend-modern/src/utils/alertAdministrationPresentation.ts","frontend-modern/src/utils/alertBulkEditPresentation.ts",@@ -1306,9 +1307,11 @@"frontend-modern/src/utils/alertSchedulePresentation.ts","frontend-modern/src/utils/alertSeverityPresentation.ts","frontend-modern/src/utils/alertTabsPresentation.ts",+ "frontend-modern/src/utils/alertThresholdDefaults.ts","frontend-modern/src/utils/alertThresholdsPresentation.ts","frontend-modern/src/utils/alertThresholdsSectionPresentation.ts",- "frontend-modern/src/utils/alertWebhookPresentation.ts"+ "frontend-modern/src/utils/alertWebhookPresentation.ts",+ "frontend-modern/src/utils/metricThresholds.ts"],"verification": {"allow_same_subsystem_tests": true,@@ -1377,6 +1380,7 @@"frontend-modern/src/components/Alerts/Thresholds/hooks/__tests__/useCollapsedSections.test.ts","frontend-modern/src/components/Alerts/Thresholds/sections/__tests__/CollapsibleSection.test.tsx","frontend-modern/src/components/Alerts/WebhookConfig.test.tsx",+ "frontend-modern/src/features/alerts/__tests__/alertsConfigurationModel.test.ts","frontend-modern/src/features/alerts/__tests__/helpers.test.ts","frontend-modern/src/features/alerts/__tests__/OverviewTab.emptystate.test.tsx","frontend-modern/src/features/alerts/__tests__/OverviewTab.timelineerror.test.tsx",@@ -1423,6 +1427,21 @@"frontend-modern/src/utils/__tests__/alertThresholdsSectionPresentation.test.ts"]},+ {+ "id": "alert-display-threshold-resolution",+ "label": "alert display threshold proof",+ "match_prefixes": [],+ "match_files": [+ "frontend-modern/src/stores/alertsActivation.ts",+ "frontend-modern/src/utils/alertThresholdDefaults.ts",+ "frontend-modern/src/utils/metricThresholds.ts"+ ],+ "allow_same_subsystem_tests": false,+ "test_prefixes": [],+ "exact_files": [+ "frontend-modern/src/utils/__tests__/metricThresholds.test.ts"+ ]+ },{"id": "alert-resource-table-presentation-helper","label": "alert resource table presentation helper proof",diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex 81ce46ce1e..700a0dccf0 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -131,6 +131,11 @@ state.columns and rows, but horizontal overflow and scrollbar hiding must routethrough the shared `Table` wrapper rather than page-local scroll divs orinline overflow styles.+ Storage capacity bars may consume alert-backed disk thresholds, but storage+ surfaces do not own threshold selection. `EnhancedStorageBar` and its model+ must pass resolved thresholds from the alerts activation boundary into the+ shared metric-color helper instead of carrying storage-local usage color+ bands.4. Route transport changes for storage and recovery endpoints through `internal/api/` and the owning `api-contracts` proof routesShared setup-script transport may be reused by storage and recovery-linkedsetup flows, but it remains API/lifecycle-owned: generated PVE scripts mustdiff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.mdindex 7ef6b510e5..344dd6111e 100644--- a/docs/release-control/v6/internal/subsystems/unified-resources.md+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md@@ -168,6 +168,12 @@ cross-source deduplication.infrastructure tables must use the shared `Table` primitive's scroll framedirectly instead of reintroducing page-local `overflow-x-auto` wrappersinside the canonical card shell.+ Unified resource host metric cells may consume alert-backed agent+ thresholds, but resource consumers must not resolve alert defaults or+ overrides locally. Host table state exposes the alerts-owned threshold+ resolver and row renderers pass the resolved values into metric bars while+ preserving unified-resource ownership over identity, rows, grouping, and+ detail presentation.Docker Swarm service, Kubernetes namespace/deployment, and PMG detailtables follow that same shell boundary: their platform-specific rows andactions are unified-resource-owned, while horizontal overflow is owned bydiff --git a/frontend-modern/src/components/Infrastructure/UnifiedResourceHostTableCard.tsx b/frontend-modern/src/components/Infrastructure/UnifiedResourceHostTableCard.tsxindex 723eeab19f..a9700b1d3a 100644--- a/frontend-modern/src/components/Infrastructure/UnifiedResourceHostTableCard.tsx+++ b/frontend-modern/src/components/Infrastructure/UnifiedResourceHostTableCard.tsx@@ -11,6 +11,7 @@ import {} from '@/components/shared/groupedTableRowPresentation';import { TableCardHeader } from '@/components/shared/TableCardHeader';import { TableCard } from '@/components/shared/TableCard';+import { hostOverrideIdCandidates } from '@/features/alerts/alertOverridesModel';import {Table,TableBody,@@ -237,6 +238,18 @@ export const UnifiedResourceHostTableCard: Component<UnifiedResourceHostTableCargetAgentStatusIndicator({ status: resource.status }),);const metricsKey = createMemo(() => buildMetricKeyForUnifiedResource(resource));+ const alertResourceIdCandidates = createMemo(() =>+ hostOverrideIdCandidates(resource),+ );+ const cpuThresholds = createMemo(() =>+ table.getMetricThresholds('agent', 'cpu', alertResourceIdCandidates()),+ );+ const memoryThresholds = createMemo(() =>+ table.getMetricThresholds('agent', 'memory', alertResourceIdCandidates()),+ );+ const diskThresholds = createMemo(() =>+ table.getMetricThresholds('agent', 'disk', alertResourceIdCandidates()),+ );const detailControlsId = createMemo(() =>buildSummaryDisclosureControlsId(resource.id),);@@ -436,6 +449,7 @@ export const UnifiedResourceHostTableCard: Component<UnifiedResourceHostTableCarresourceId={table.isMobile() ? undefined : metricsKey()}isRunning={isResourceOnline(resource)}showMobile={false}+ thresholds={cpuThresholds()}/></Show></TableCell>@@ -460,6 +474,7 @@ export const UnifiedResourceHostTableCard: Component<UnifiedResourceHostTableCar}swapUsed={resource.agent?.memory?.swapUsed ?? 0}swapTotal={resource.agent?.memory?.swapTotal ?? 0}+ thresholds={memoryThresholds()}/></div></Show>@@ -487,6 +502,7 @@ export const UnifiedResourceHostTableCard: Component<UnifiedResourceHostTableCar} as Disk): undefined}+ thresholds={diskThresholds()}/></div></Show>diff --git a/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx b/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsxindex 440e9034f9..8025b36955 100644--- a/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx+++ b/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx@@ -394,9 +394,23 @@ describe('UnifiedResourceTable performance contract', () => {expect(unifiedResourceTableStateSource).toContain('clearPinnedSummaryScope?: () => void;');expect(unifiedResourceTableStateSource).toContain('showHostClearAction');expect(unifiedResourceTableStateSource).toContain('showServiceClearAction');+ expect(unifiedResourceTableStateSource).toContain('useAlertsActivation');+ expect(unifiedResourceTableStateSource).toContain('getMetricThresholds');expect(unifiedResourceTableStateSource).not.toContain('const resourceColumnStyle = createMemo(() =>',);+ expect(unifiedResourceHostTableCardSource).toContain(+ "table.getMetricThresholds('agent', 'cpu', alertResourceIdCandidates())",+ );+ expect(unifiedResourceHostTableCardSource).toContain(+ "table.getMetricThresholds('agent', 'memory', alertResourceIdCandidates())",+ );+ expect(unifiedResourceHostTableCardSource).toContain(+ "table.getMetricThresholds('agent', 'disk', alertResourceIdCandidates())",+ );+ expect(unifiedResourceHostTableCardSource).toContain('thresholds={cpuThresholds()}');+ expect(unifiedResourceHostTableCardSource).toContain('thresholds={memoryThresholds()}');+ expect(unifiedResourceHostTableCardSource).toContain('thresholds={diskThresholds()}');expect(unifiedResourceHostTableCardSource).not.toContain('style={');expect(unifiedResourcePBSTableSectionSource).not.toContain('style={');expect(unifiedResourcePMGTableSectionSource).not.toContain('style={');diff --git a/frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts b/frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.tsindex 88f39003f5..b8006f13c2 100644--- a/frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts+++ b/frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts@@ -2,6 +2,8 @@ import { createEffect, createMemo, createSignal, onCleanup } from 'solid-js';import type { Resource } from '@/types/resource';import type { ColumnPriority } from '@/hooks/useBreakpoint';import { useBreakpoint } from '@/hooks/useBreakpoint';+import { useAlertsActivation } from '@/stores/alertsActivation';+import type { AlertThresholdScope, DisplayMetricType } from '@/utils/metricThresholds';import {buildInfrastructureSummaryGroupScope,splitPrimaryAndServiceResources,@@ -61,6 +63,7 @@ export interface UnifiedResourceTableProps {export function useUnifiedResourceTableState(props: UnifiedResourceTableProps) {const breakpoint = useBreakpoint();+ const alertsActivation = useAlertsActivation();const [tableContainerWidth, setTableContainerWidth] = createSignal<number | null>(null);const [tableRootElement, setTableRootElement] = createSignal<HTMLDivElement | null>(null);const [sortKey, setSortKey] = createSignal<SortKey>('default');@@ -191,6 +194,12 @@ export function useUnifiedResourceTableState(props: UnifiedResourceTableProps) {const renderSortIndicator = (key: SortKey) =>getUnifiedResourceTableSortIndicator(sortKey(), sortDirection(), key);+ const getMetricThresholds = (+ scope: AlertThresholdScope,+ metric: DisplayMetricType,+ resourceIds?: string | string[],+ ) => alertsActivation.getMetricThresholds(scope, metric, resourceIds);+const toggleExpand = (resourceId: string) => {props.onExpandedResourceChange(props.expandedResourceId === resourceId ? null : resourceId);};@@ -219,6 +228,7 @@ export function useUnifiedResourceTableState(props: UnifiedResourceTableProps) {isHostDiskIoVisible,isVisible,isServiceVisible,+ getMetricThresholds,handleSort,renderSortIndicator,resolveResourceLabel,diff --git a/frontend-modern/src/components/Storage/EnhancedStorageBar.tsx b/frontend-modern/src/components/Storage/EnhancedStorageBar.tsxindex 590da81671..71ea29ccef 100644--- a/frontend-modern/src/components/Storage/EnhancedStorageBar.tsx+++ b/frontend-modern/src/components/Storage/EnhancedStorageBar.tsx@@ -28,6 +28,7 @@ import {import { useTooltip } from '@/hooks/useTooltip';import { ProgressBar } from '@/components/shared/ProgressBar';import { TooltipPortal } from '@/components/shared/TooltipPortal';+import { useAlertsActivation } from '@/stores/alertsActivation';import type { ZFSPool } from '@/types/api';import { useEnhancedStorageBarModel } from './useEnhancedStorageBarModel';@@ -40,11 +41,13 @@ interface EnhancedStorageBarProps {export function EnhancedStorageBar(props: EnhancedStorageBarProps) {const tip = useTooltip();+ const alertsActivation = useAlertsActivation();const { usagePercent, barColor, label, tooltipRows, zfsSummary } = useEnhancedStorageBarModel({used: () => props.used,total: () => props.total,free: () => props.free,zfsPool: () => props.zfsPool,+ thresholds: () => alertsActivation.getMetricThresholds('storage', 'disk'),});return (@@ -68,9 +71,7 @@ export function EnhancedStorageBar(props: EnhancedStorageBarProps) {}label={<span class={STORAGE_BAR_LABEL_WRAP_CLASS}>- <span class={STORAGE_BAR_LABEL_TEXT_CLASS}>- {label()}- </span>+ <span class={STORAGE_BAR_LABEL_TEXT_CLASS}>{label()}</span></span>}/>@@ -78,9 +79,7 @@ export function EnhancedStorageBar(props: EnhancedStorageBarProps) {{/* Tooltip */}<TooltipPortal when={tip.show()} x={tip.pos().x} y={tip.pos().y}><div class={STORAGE_BAR_TOOLTIP_WRAP_CLASS}>- <div class={STORAGE_BAR_TOOLTIP_TITLE_CLASS}>- {getStorageBarTooltipTitle()}- </div>+ <div class={STORAGE_BAR_TOOLTIP_TITLE_CLASS}>{getStorageBarTooltipTitle()}</div><For each={tooltipRows()}>{(row) => (@@ -106,9 +105,7 @@ export function EnhancedStorageBar(props: EnhancedStorageBarProps) {</div></Show><Show when={zfsSummary()?.errorSummary}>- <div class={`${getZfsErrorTextClass()} mt-0.5`}>- {zfsSummary()?.errorSummary}- </div>+ <div class={`${getZfsErrorTextClass()} mt-0.5`}>{zfsSummary()?.errorSummary}</div></Show></div></Show>diff --git a/frontend-modern/src/components/Storage/__tests__/Storage.test.tsx b/frontend-modern/src/components/Storage/__tests__/Storage.test.tsxindex 01b7211866..6ea40ea523 100644--- a/frontend-modern/src/components/Storage/__tests__/Storage.test.tsx+++ b/frontend-modern/src/components/Storage/__tests__/Storage.test.tsx@@ -301,6 +301,7 @@ vi.mock('@/contexts/appRuntime', () => ({vi.mock('@/stores/alertsActivation', () => ({useAlertsActivation: () => ({activationState: () => alertsActivationState,+ getMetricThresholds: () => ({ warning: 80, critical: 85 }),}),}));@@ -1747,9 +1748,7 @@ describe('Storage', () => {fireEvent.click(screen.getByRole('button', { name: 'Filter' }));fireEvent.click(screen.getByRole('menuitem', { name: 'Node' }));const nodeMenu = screen.getByRole('menu');- const optionLabels = Array.from(- nodeMenu.querySelectorAll<HTMLButtonElement>('button'),- )+ const optionLabels = Array.from(nodeMenu.querySelectorAll<HTMLButtonElement>('button')).map((button) => (button.textContent || '').trim()).filter((text) => text.length > 0 && !text.startsWith('Node'));expect(optionLabels).toContain('pve1');diff --git a/frontend-modern/src/components/Storage/useEnhancedStorageBarModel.ts b/frontend-modern/src/components/Storage/useEnhancedStorageBarModel.tsindex badb807418..ddb6f141e7 100644--- a/frontend-modern/src/components/Storage/useEnhancedStorageBarModel.ts+++ b/frontend-modern/src/components/Storage/useEnhancedStorageBarModel.ts@@ -1,6 +1,7 @@import { Accessor, createMemo } from 'solid-js';import type { ZFSPool } from '@/types/api';import { getMetricColorClass } from '@/utils/metricThresholds';+import type { MetricDisplayThresholds } from '@/utils/metricThresholds';import {getStorageBarLabel,getStorageBarTooltipRows,@@ -13,13 +14,14 @@ type UseEnhancedStorageBarModelOptions = {total: Accessor<number>;free: Accessor<number>;zfsPool: Accessor<ZFSPool | undefined>;+ thresholds?: Accessor<MetricDisplayThresholds | null | undefined>;};export const useEnhancedStorageBarModel = (options: UseEnhancedStorageBarModelOptions) => {- const usagePercent = createMemo(() =>- getStorageBarUsagePercent(options.used(), options.total()),+ const usagePercent = createMemo(() => getStorageBarUsagePercent(options.used(), options.total()));+ const barColor = createMemo(() =>+ getMetricColorClass(usagePercent(), 'disk', options.thresholds?.()),);- const barColor = createMemo(() => getMetricColorClass(usagePercent(), 'disk'));const label = createMemo(() => getStorageBarLabel(options.used(), options.total()));const tooltipRows = createMemo(() =>getStorageBarTooltipRows(options.used(), options.free(), options.total()),diff --git a/frontend-modern/src/components/Workloads/GuestDrawer.tsx b/frontend-modern/src/components/Workloads/GuestDrawer.tsxindex a77c6bac6d..ba8499657d 100644--- a/frontend-modern/src/components/Workloads/GuestDrawer.tsx+++ b/frontend-modern/src/components/Workloads/GuestDrawer.tsx@@ -16,6 +16,7 @@ export const GuestDrawer: Component<GuestDrawerProps> = (props) => {discoveryLoadingState,discoveryResourceId,discoveryResourceType,+ diskThresholds,guestId,hasAgentInfo,hasDiscoverySupport,@@ -51,9 +52,7 @@ export const GuestDrawer: Component<GuestDrawerProps> = (props) => {<buttononClick={() => switchTab('discovery')}class={`pb-2 text-sm font-medium transition-colors relative ${- activeTab() === 'discovery'- ? 'text-blue-600 dark:text-blue-400'- : ' hover:text-muted'+ activeTab() === 'discovery' ? 'text-blue-600 dark:text-blue-400' : ' hover:text-muted'}`}>Discovery@@ -93,6 +92,7 @@ export const GuestDrawer: Component<GuestDrawerProps> = (props) => {onCustomUrlChange={props.onCustomUrlChange}customUrl={props.customUrl}backupPresentation={backupPresentation()}+ diskThresholds={diskThresholds()}webInterfaceTargetLabel={webInterfaceTargetLabel()}/></div>diff --git a/frontend-modern/src/components/Workloads/GuestDrawerOverview.tsx b/frontend-modern/src/components/Workloads/GuestDrawerOverview.tsxindex 1df84c96cb..077bc9d250 100644--- a/frontend-modern/src/components/Workloads/GuestDrawerOverview.tsx+++ b/frontend-modern/src/components/Workloads/GuestDrawerOverview.tsx@@ -2,6 +2,7 @@ import { For, Show } from 'solid-js';import { WebInterfaceUrlField } from '@/components/shared/WebInterfaceUrlField';import { formatBytes, formatUptime } from '@/utils/format';+import type { MetricDisplayThresholds } from '@/utils/metricThresholds';import { DiskList } from './DiskList';import { isGuestDrawerVM } from './guestDrawerModel';@@ -29,6 +30,7 @@ interface GuestDrawerOverviewProps {ageLabel: string;dateLabel: string;} | null;+ diskThresholds?: MetricDisplayThresholds | null;webInterfaceTargetLabel: string;}@@ -50,7 +52,9 @@ export function GuestDrawerOverview(props: GuestDrawerOverviewProps) {<Show when={props.guest.uptime > 0}><div class="flex items-center justify-between"><span class="text-muted">Uptime</span>- <span class="font-medium text-base-content">{formatUptime(props.guest.uptime)}</span>+ <span class="font-medium text-base-content">+ {formatUptime(props.guest.uptime)}+ </span></div></Show><Show when={props.guest.node}>@@ -82,7 +86,10 @@ export function GuestDrawerOverview(props: GuestDrawerOverviewProps) {<span class="font-medium">{props.guest.osName}</span></Show><Show- when={(props.guest.osName?.length ?? 0) > 0 && (props.guest.osVersion?.length ?? 0) > 0}+ when={+ (props.guest.osName?.length ?? 0) > 0 &&+ (props.guest.osVersion?.length ?? 0) > 0+ }><span class="text-muted mx-1">•</span></Show>@@ -160,7 +167,9 @@ export function GuestDrawerOverview(props: GuestDrawerOverviewProps) {</div></Show>- <Show when={props.hasFilesystemDetails && props.guest.disks && props.guest.disks.length > 0}>+ <Show+ when={props.hasFilesystemDetails && props.guest.disks && props.guest.disks.length > 0}+ ><div class="rounded border border-border bg-surface p-3 shadow-sm"><div class="text-[11px] font-medium uppercase tracking-wide text-base-content mb-2">Filesystems@@ -171,6 +180,7 @@ export function GuestDrawerOverview(props: GuestDrawerOverviewProps) {diskStatusReason={isGuestDrawerVM(props.guest) ? (props.guest as any).diskStatusReason : undefined}+ thresholds={props.diskThresholds}/></div></div>diff --git a/frontend-modern/src/components/Workloads/GuestRow.tsx b/frontend-modern/src/components/Workloads/GuestRow.tsxindex ad207a9bcd..1e7575ed76 100644--- a/frontend-modern/src/components/Workloads/GuestRow.tsx+++ b/frontend-modern/src/components/Workloads/GuestRow.tsx@@ -46,10 +46,12 @@ export function GuestRow(props: GuestRowProps) {clusterName,contextLabel,cpuAnomaly,+ cpuThresholds,customUrl,diskAnomaly,diskIOEmphasis,diskRead,+ diskThresholds,diskWrite,displayId,dockerHostId,@@ -71,6 +73,7 @@ export function GuestRow(props: GuestRowProps) {lockLabel,memoryAnomaly,memoryPercentOnly,+ memoryThresholds,memoryTooltip,metricsKey,namespace,@@ -227,6 +230,7 @@ export function GuestRow(props: GuestRowProps) {cores={isMobile() ? undefined : props.guest.cpus}resourceId={metricsKey()}anomaly={cpuAnomaly()}+ thresholds={cpuThresholds()}/></div></td>@@ -245,6 +249,7 @@ export function GuestRow(props: GuestRowProps) {swapTotal={props.guest.memory?.swapTotal || 0}resourceId={metricsKey()}anomaly={memoryAnomaly()}+ thresholds={memoryThresholds()}/></div></td>@@ -267,6 +272,7 @@ export function GuestRow(props: GuestRowProps) {disks={props.guest.disks}aggregateDisk={props.guest.disk}anomaly={diskAnomaly()}+ thresholds={diskThresholds()}/></Show></td>@@ -538,9 +544,7 @@ export function GuestRow(props: GuestRowProps) {<Show when={isColVisible('update')}><td class="px-1.5 sm:px-2 py-0.5 align-middle"><div class="flex justify-center">- <Show- when={workloadType() === 'app-container' && dockerHostId()}- >+ <Show when={workloadType() === 'app-container' && dockerHostId()}><UpdateButtonupdateStatus={props.guest.updateStatus}agentId={dockerHostId()}diff --git a/frontend-modern/src/components/Workloads/MetricBar.test.tsx b/frontend-modern/src/components/Workloads/MetricBar.test.tsxindex 773e633db0..0e6ab6d051 100644--- a/frontend-modern/src/components/Workloads/MetricBar.test.tsx+++ b/frontend-modern/src/components/Workloads/MetricBar.test.tsx@@ -104,6 +104,22 @@ describe('MetricBar', () => {result.unmount();});+ it('uses resolved alert thresholds when provided', () => {+ let result = render(() => (+ <MetricBar value={80} label="val" type="cpu" thresholds={{ warning: 70, critical: 85 }} />+ ));+ let bar = result.container.querySelector('.bg-metric-warning-bg');+ expect(bar).toBeInTheDocument();+ result.unmount();++ result = render(() => (+ <MetricBar value={85} label="val" type="cpu" thresholds={{ warning: 70, critical: 85 }} />+ ));+ bar = result.container.querySelector('.bg-metric-critical-bg');+ expect(bar).toBeInTheDocument();+ result.unmount();+ });+it('shows sublabel when space permits', () => {render(() => <MetricBar value={50} label="val" sublabel="sub" />);expect(screen.getByText('(sub)')).toBeInTheDocument();diff --git a/frontend-modern/src/components/Workloads/__tests__/EnhancedCPUBar.test.tsx b/frontend-modern/src/components/Workloads/__tests__/EnhancedCPUBar.test.tsxindex b794adba62..69401f4eae 100644--- a/frontend-modern/src/components/Workloads/__tests__/EnhancedCPUBar.test.tsx+++ b/frontend-modern/src/components/Workloads/__tests__/EnhancedCPUBar.test.tsx@@ -118,6 +118,14 @@ describe('EnhancedCPUBar', () => {expect(bar?.getAttribute('fill')).toContain('239, 68, 68');});+ it('uses resolved alert thresholds when provided', () => {+ const { container } = render(() => (+ <EnhancedCPUBar usage={82} thresholds={{ warning: 70, critical: 85 }} />+ ));+ const bar = getBarFill(container);+ expect(bar?.getAttribute('fill')).toContain('234, 179, 8');+ });+it('uses critical color class well above critical threshold', () => {const { container } = render(() => <EnhancedCPUBar usage={99} />);const bar = getBarFill(container);@@ -309,7 +317,7 @@ describe('EnhancedCPUBar', () => {expect(tooltipValue!).toHaveTextContent('95%');});- it('does not apply red text to usage <=90% in tooltip', async () => {+ it('does not apply red text below the critical threshold in tooltip', async () => {const { container } = render(() => <EnhancedCPUBar usage={85} />);await fireEvent.mouseEnter(getBarTrigger(container));const tooltipValue = getTooltipUsageValue();@@ -318,13 +326,12 @@ describe('EnhancedCPUBar', () => {expect(tooltipValue!).toHaveClass('text-base-content');});- it('uses text-base-content for usage exactly 90% in tooltip', async () => {+ it('applies red text at the critical threshold in tooltip', async () => {const { container } = render(() => <EnhancedCPUBar usage={90} />);await fireEvent.mouseEnter(getBarTrigger(container));const tooltipValue = getTooltipUsageValue();expect(tooltipValue).not.toBeNull();- expect(tooltipValue!).toHaveClass('text-base-content');- expect(tooltipValue!).not.toHaveClass('text-red-400');+ expect(tooltipValue!).toHaveClass('text-red-400');});it('applies red text at usage boundary (91%)', async () => {diff --git a/frontend-modern/src/components/Workloads/__tests__/GuestRow.test.tsx b/frontend-modern/src/components/Workloads/__tests__/GuestRow.test.tsxindex d53656dd13..f1ed6fdafc 100644--- a/frontend-modern/src/components/Workloads/__tests__/GuestRow.test.tsx+++ b/frontend-modern/src/components/Workloads/__tests__/GuestRow.test.tsx@@ -52,6 +52,7 @@ vi.mock('@/stores/alertsActivation', () => ({isPastObservationWindow: () => true,getBackupThresholds: () => ({ staleHours: 48, criticalHours: 168 }),getTemperatureThreshold: () => null,+ getMetricThresholds: () => ({ warning: 70, critical: 85 }),refreshConfig: vi.fn(),refreshActiveAlerts: vi.fn(),activate: vi.fn(),@@ -104,9 +105,8 @@ vi.mock('@/components/shared/workloadTypeBadges', () => ({}));vi.mock('@/routing/resourceLinks', async () => {- const actual = await vi.importActual<typeof import('@/routing/resourceLinks')>(- '@/routing/resourceLinks',- );+ const actual =+ await vi.importActual<typeof import('@/routing/resourceLinks')>('@/routing/resourceLinks');return {...actual,buildInfrastructureHrefForWorkload: () => '/infrastructure/node1',@@ -114,6 +114,9 @@ vi.mock('@/routing/resourceLinks', async () => {});vi.mock('../workloadTopology', () => ({+ getWorkloadAlertResourceIdCandidates: (guest: WorkloadGuest) => [guest.id],+ getWorkloadAlertThresholdScope: (guest: WorkloadGuest) =>+ guest.workloadType === 'app-container' ? 'docker' : 'guest',getWorkloadDockerHostId: (guest: WorkloadGuest) => guest.dockerHostId || '',}));@@ -1051,9 +1054,7 @@ describe('OCI container handling', () => {});const badge = screen.getByText('SYSTEM-CONTAINER');expect(badge).toBeTruthy();- expect(badge.getAttribute('title')).toBe(- 'OCI Container • docker.io/library/alpine:3.18',- );+ expect(badge.getAttribute('title')).toBe('OCI Container • docker.io/library/alpine:3.18');});});diff --git a/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.k8s.test.tsx b/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.k8s.test.tsxindex c41e6f9bf3..9017aea8fa 100644--- a/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.k8s.test.tsx+++ b/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.k8s.test.tsx@@ -94,6 +94,8 @@ vi.mock('@/api/guestMetadata', () => ({vi.mock('@/stores/alertsActivation', () => ({useAlertsActivation: () => ({activationState: () => 'active',+ getMetricThresholds: () => ({ warning: 70, critical: 85 }),+ getBackupThresholds: () => ({ freshHours: 24, staleHours: 72 }),}),}));diff --git a/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.performance.contract.test.tsx b/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.performance.contract.test.tsxindex e0278712c9..c027d26cd8 100644--- a/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.performance.contract.test.tsx+++ b/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.performance.contract.test.tsx@@ -161,7 +161,11 @@ vi.mock('@/api/guestMetadata', () => ({}));vi.mock('@/stores/alertsActivation', () => ({- useAlertsActivation: () => ({ activationState: () => 'active' }),+ useAlertsActivation: () => ({+ activationState: () => 'active',+ getMetricThresholds: () => ({ warning: 70, critical: 85 }),+ getBackupThresholds: () => ({ freshHours: 24, staleHours: 72 }),+ }),}));vi.mock('@/stores/aiChat', () => ({@@ -916,6 +920,11 @@ describe('Workloads performance contract', () => {expect(guestRowSource).not.toContain('function NetworkInfoCell(');expect(guestRowSource).not.toContain('function OSInfoCell(');expect(guestRowSource).not.toContain('function BackupStatusCell(');+ expect(guestRowSource).toContain('thresholds={cpuThresholds()}');+ expect(guestRowSource).toContain('thresholds={memoryThresholds()}');+ expect(guestRowSource).toContain('thresholds={diskThresholds()}');+ expect(guestRowStateSource).toContain('getWorkloadAlertThresholdScope');+ expect(guestRowStateSource).toContain('getMetricThresholds');expect(guestRowModelSource).toContain('export const GUEST_COLUMNS');expect(guestRowModelSource).toContain('export const VIEW_MODE_COLUMNS');expect(guestRowStateSource).toContain('getCanonicalWorkloadId');diff --git a/frontend-modern/src/components/Workloads/diskListModel.ts b/frontend-modern/src/components/Workloads/diskListModel.tsindex d3ff81dce4..0308db94e1 100644--- a/frontend-modern/src/components/Workloads/diskListModel.ts+++ b/frontend-modern/src/components/Workloads/diskListModel.ts@@ -2,10 +2,12 @@ import type { Disk } from '@/types/api';import { formatBytes } from '@/utils/format';import { getMetricColorClass } from '@/utils/metricThresholds';+import type { MetricDisplayThresholds } from '@/utils/metricThresholds';export interface DiskListProps {disks: Disk[];diskStatusReason?: string;+ thresholds?: MetricDisplayThresholds | null;}export interface WorkloadsDiskPresentation {@@ -44,8 +46,10 @@ export const getWorkloadsDiskUsageText = (disk: Disk): string =>export const getWorkloadsDiskUsagePercentLabel = (disk: Disk): string =>hasWorkloadsDiskCapacity(disk) ? `${getWorkloadsDiskUsagePercent(disk).toFixed(0)}%` : '—';-export const getWorkloadsDiskProgressClass = (disk: Disk): string =>- getMetricColorClass(getWorkloadsDiskUsagePercent(disk), 'disk');+export const getWorkloadsDiskProgressClass = (+ disk: Disk,+ thresholds?: MetricDisplayThresholds | null,+): string => getMetricColorClass(getWorkloadsDiskUsagePercent(disk), 'disk', thresholds);export const getWorkloadsDiskProgressWidth = (disk: Disk): string =>`${Math.min(getWorkloadsDiskUsagePercent(disk), 100)}%`;@@ -55,6 +59,7 @@ export const getWorkloadsDiskTypeLabel = (disk: Disk): string => disk.type?.toUpexport const buildWorkloadsDiskPresentation = (disk: Disk,index: number,+ thresholds?: MetricDisplayThresholds | null,): WorkloadsDiskPresentation => {const label = getWorkloadsDiskLabel(disk);@@ -62,7 +67,7 @@ export const buildWorkloadsDiskPresentation = (key: `${disk.mountpoint ?? ''}:${disk.device ?? ''}:${index}`,label,labelTitle: getWorkloadsDiskLabelTitle(label),- progressClass: getWorkloadsDiskProgressClass(disk),+ progressClass: getWorkloadsDiskProgressClass(disk, thresholds),progressWidth: getWorkloadsDiskProgressWidth(disk),typeLabel: getWorkloadsDiskTypeLabel(disk),usageText: getWorkloadsDiskUsageText(disk),diff --git a/frontend-modern/src/components/Workloads/enhancedCpuBarModel.ts b/frontend-modern/src/components/Workloads/enhancedCpuBarModel.tsindex 51134197ea..9da70a7e6a 100644--- a/frontend-modern/src/components/Workloads/enhancedCpuBarModel.ts+++ b/frontend-modern/src/components/Workloads/enhancedCpuBarModel.ts@@ -1,6 +1,7 @@import type { AnomalyReport } from '@/types/aiIntelligence';import { ANOMALY_SEVERITY_CLASS, formatAnomalyRatio, formatPercent } from '@/utils/format';import { getMetricColorClass, getMetricColorRgba } from '@/utils/metricThresholds';+import type { MetricDisplayThresholds } from '@/utils/metricThresholds';export interface EnhancedCPUBarProps {usage: number;@@ -9,6 +10,7 @@ export interface EnhancedCPUBarProps {model?: string;resourceId?: string;anomaly?: AnomalyReport | null;+ thresholds?: MetricDisplayThresholds | null;}export interface EnhancedCPUBarPresentation {@@ -35,13 +37,13 @@ export function buildEnhancedCPUBarPresentation(: 'text-yellow-400',anomalyDescription: props.anomaly?.description,anomalyRatio,- barClass: getMetricColorClass(props.usage, 'cpu'),- barFill: getMetricColorRgba(props.usage, 'cpu'),+ barClass: getMetricColorClass(props.usage, 'cpu', props.thresholds),+ barFill: getMetricColorRgba(props.usage, 'cpu', props.thresholds),barWidth: `${Math.min(props.usage, 100)}%`,- displayLoadAverage:- props.loadAverage !== undefined ? props.loadAverage.toFixed(2) : undefined,+ 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',+ tooltipUsageClass:+ props.usage >= (props.thresholds?.critical ?? 90) ? 'text-red-400' : 'text-base-content',};}diff --git a/frontend-modern/src/components/Workloads/metricBarModel.ts b/frontend-modern/src/components/Workloads/metricBarModel.tsindex 36a0fc7da1..b31b251596 100644--- a/frontend-modern/src/components/Workloads/metricBarModel.ts+++ b/frontend-modern/src/components/Workloads/metricBarModel.ts@@ -1,6 +1,6 @@import { estimateTextWidth } from '@/utils/format';import { getMetricColorClass } from '@/utils/metricThresholds';-import type { MetricType } from '@/utils/metricThresholds';+import type { MetricDisplayThresholds, MetricType } from '@/utils/metricThresholds';export interface MetricBarProps {value: number;@@ -8,6 +8,7 @@ export interface MetricBarProps {sublabel?: string;showLabel?: boolean;type?: 'cpu' | 'memory' | 'disk' | 'generic';+ thresholds?: MetricDisplayThresholds | null;resourceId?: string;class?: string;}@@ -33,10 +34,9 @@ export function buildMetricBarPresentation(const metricType: MetricType = metric === 'generic' ? 'cpu' : metric;return {- progressColorClass: getMetricColorClass(props.value, metricType),+ progressColorClass: getMetricColorClass(props.value, metricType, props.thresholds),showLabel,showSublabel,width,};}-diff --git a/frontend-modern/src/components/Workloads/stackedDiskBarModel.ts b/frontend-modern/src/components/Workloads/stackedDiskBarModel.tsindex 0ef4b86989..eee8799234 100644--- a/frontend-modern/src/components/Workloads/stackedDiskBarModel.ts+++ b/frontend-modern/src/components/Workloads/stackedDiskBarModel.ts@@ -8,12 +8,14 @@ import {formatPercent,} from '@/utils/format';import { getMetricColorRgba } from '@/utils/metricThresholds';+import type { MetricDisplayThresholds } from '@/utils/metricThresholds';export interface StackedDiskBarProps {disks?: Disk[];aggregateDisk?: Disk;mode?: 'stacked' | 'aggregate' | 'mini';anomaly?: AnomalyReport | null;+ thresholds?: MetricDisplayThresholds | null;}export interface StackedDiskSegment {@@ -85,12 +87,18 @@ function getDiskLabel(disk: Disk, index: number): string {return disk.mountpoint || disk.device || `Disk ${index + 1}`;}-function getStackedDiskColor(percent: number, index: number): string {- if (percent >= 90) {- return getMetricColorRgba(90, 'disk');+function getStackedDiskColor(+ percent: number,+ index: number,+ thresholds?: MetricDisplayThresholds | null,+): string {+ const critical = thresholds?.critical ?? 90;+ const warning = thresholds?.warning ?? 80;+ if (percent >= critical) {+ return getMetricColorRgba(percent, 'disk', thresholds);}- if (percent >= 80) {- return getMetricColorRgba(80, 'disk');+ if (percent >= warning) {+ return getMetricColorRgba(percent, 'disk', thresholds);}return SEGMENT_COLORS[index % SEGMENT_COLORS.length];}@@ -101,6 +109,7 @@ function buildTooltipContent(aggregateDisk: Disk | undefined;aggregateMode: boolean;miniMode: boolean;+ thresholds?: MetricDisplayThresholds | null;},): StackedDiskTooltipItem[] {const useUsageColors = options.aggregateMode || options.miniMode;@@ -109,8 +118,8 @@ function buildTooltipContent(const percentValue = getDiskUsagePercent(disk);return {color: useUsageColors- ? getMetricColorRgba(percentValue, 'disk')- : getStackedDiskColor(percentValue, index),+ ? getMetricColorRgba(percentValue, 'disk', options.thresholds)+ : getStackedDiskColor(percentValue, index, options.thresholds),label: getDiskLabel(disk, index),percent: formatPercent(percentValue),total: formatBytes(disk.total),@@ -123,7 +132,7 @@ function buildTooltipContent(const percentValue = getDiskUsagePercent(options.aggregateDisk);return [{- color: getMetricColorRgba(percentValue, 'disk'),+ color: getMetricColorRgba(percentValue, 'disk', options.thresholds),label: 'Total',percent: formatPercent(percentValue),total: formatBytes(options.aggregateDisk.total),@@ -174,9 +183,7 @@ export function buildStackedDiskBarPresentation(const anomalyRatio = formatAnomalyRatio(props.anomaly) ?? '';const maxInfo = getMaxDiskInfo(disks);const maxLabelShort = maxInfo ? `max ${formatPercent(maxInfo.percent)}` : '';- const maxLabelFull = maxInfo- ? `Max ${formatPercent(maxInfo.percent)} (${maxInfo.label})`- : '';+ const maxLabelFull = maxInfo ? `Max ${formatPercent(maxInfo.percent)} (${maxInfo.label})` : '';const displayLabel = formatPercent(overallPercent);const displaySublabel = `${formatBytes(totalUsed)}/${formatBytes(totalCapacity)}`;const showMaxLabel =@@ -191,14 +198,14 @@ export function buildStackedDiskBarPresentation();const barColor =aggregateMode && hasMultipleDisks && maxInfo- ? getMetricColorRgba(maxInfo.percent, 'disk')- : getMetricColorRgba(overallPercent, 'disk');+ ? getMetricColorRgba(maxInfo.percent, 'disk', props.thresholds)+ : getMetricColorRgba(overallPercent, 'disk', props.thresholds);const segments =useStackedSegments && totalCapacity > 0? disks.map((disk, index) => {const diskUsagePercent = getDiskUsagePercent(disk);return {- color: getStackedDiskColor(diskUsagePercent, index),+ color: getStackedDiskColor(diskUsagePercent, index, props.thresholds),disk,diskUsagePercent,index,@@ -209,7 +216,7 @@ export function buildStackedDiskBarPresentation(const miniDisks = disks.map((disk, index) => {const percent = getDiskUsagePercent(disk);return {- color: getMetricColorRgba(percent, 'disk'),+ color: getMetricColorRgba(percent, 'disk', props.thresholds),label: getDiskLabel(disk, index),percent,};@@ -218,6 +225,7 @@ export function buildStackedDiskBarPresentation(aggregateDisk: props.aggregateDisk,aggregateMode,miniMode,+ thresholds: props.thresholds,});return {@@ -230,7 +238,9 @@ export function buildStackedDiskBarPresentation(barColor,barPercent,containerClass:- miniMode && hasDisks ? 'metric-text w-full' : 'metric-text w-full h-4 flex items-center justify-center',+ miniMode && hasDisks+ ? 'metric-text w-full'+ : 'metric-text w-full h-4 flex items-center justify-center',displayLabel,displaySublabel,hasDisks,diff --git a/frontend-modern/src/components/Workloads/stackedMemoryBarModel.ts b/frontend-modern/src/components/Workloads/stackedMemoryBarModel.tsindex d49e1099af..f47386bcc8 100644--- a/frontend-modern/src/components/Workloads/stackedMemoryBarModel.ts+++ b/frontend-modern/src/components/Workloads/stackedMemoryBarModel.ts@@ -7,6 +7,7 @@ import {formatPercent,} from '@/utils/format';import { getMetricColorRgba } from '@/utils/metricThresholds';+import type { MetricDisplayThresholds } from '@/utils/metricThresholds';export interface StackedMemoryBarProps {used: number;@@ -17,6 +18,7 @@ export interface StackedMemoryBarProps {balloon?: number;resourceId?: string;anomaly?: AnomalyReport | null;+ thresholds?: MetricDisplayThresholds | null;}export interface StackedMemorySegment {@@ -63,14 +65,17 @@ function getUtilizationPercent(props: StackedMemoryBarProps): number {return 0;}-function getSegments(props: StackedMemoryBarProps, utilizationPercent: number): StackedMemorySegment[] {+function getSegments(+ props: StackedMemoryBarProps,+ utilizationPercent: number,+): StackedMemorySegment[] {if (props.total <= 0) {if (utilizationPercent <= 0) {return [];}return [{- color: getMetricColorRgba(utilizationPercent, 'memory'),+ color: getMetricColorRgba(utilizationPercent, 'memory', props.thresholds),label: 'Utilization',leftPercent: 0,widthPercent: utilizationPercent,@@ -88,7 +93,7 @@ function getSegments(props: StackedMemoryBarProps, utilizationPercent: number):}return [{- color: getMetricColorRgba(usedPercent, 'memory'),+ color: getMetricColorRgba(usedPercent, 'memory', props.thresholds),label: 'Active',leftPercent: 0,widthPercent: usedPercent,@@ -99,7 +104,7 @@ function getSegments(props: StackedMemoryBarProps, utilizationPercent: number):const segments: StackedMemorySegment[] = [];if (props.used > 0) {segments.push({- color: getMetricColorRgba(usedPercent, 'memory'),+ color: getMetricColorRgba(usedPercent, 'memory', props.thresholds),label: 'Active',leftPercent: 0,widthPercent: usedPercent,diff --git a/frontend-modern/src/components/Workloads/useDiskListState.ts b/frontend-modern/src/components/Workloads/useDiskListState.tsindex ef38bec9e2..b699d0e697 100644--- a/frontend-modern/src/components/Workloads/useDiskListState.ts+++ b/frontend-modern/src/components/Workloads/useDiskListState.ts@@ -10,7 +10,7 @@ export function useDiskListState(props: DiskListProps) {getWorkloadGuestDiskStatusMessage(props.diskStatusReason),);const diskPresentation = createMemo(() =>- props.disks.map((disk, index) => buildWorkloadsDiskPresentation(disk, index)),+ props.disks.map((disk, index) => buildWorkloadsDiskPresentation(disk, index, props.thresholds)),);return {diff --git a/frontend-modern/src/components/Workloads/useGuestDrawerState.ts b/frontend-modern/src/components/Workloads/useGuestDrawerState.tsindex c258a96810..cac563e2e8 100644--- a/frontend-modern/src/components/Workloads/useGuestDrawerState.ts+++ b/frontend-modern/src/components/Workloads/useGuestDrawerState.ts@@ -1,6 +1,8 @@import { createEffect, createMemo, createSignal } from 'solid-js';+import { useAlertsActivation } from '@/stores/alertsActivation';import { getDiscoveryLoadingState } from '@/utils/discoveryPresentation';+import type { DisplayMetricType } from '@/utils/metricThresholds';import {getCanonicalWorkloadId,getDiscoveryResourceTypeForWorkload,@@ -12,6 +14,8 @@ import { buildInfrastructureHrefForWorkload } from '@/routing/resourceLinks';import {getDiscoveryHostIdForWorkload,getDiscoveryResourceIdForWorkload,+ getWorkloadAlertResourceIdCandidates,+ getWorkloadAlertThresholdScope,} from './workloadTopology';import {getGuestDrawerAgentLabel,@@ -27,9 +31,23 @@ import {} from './guestDrawerModel';export function useGuestDrawerState(props: GuestDrawerProps) {+ const alertsActivation = useAlertsActivation();const [activeTab, setActiveTab] = createSignal<GuestDrawerTab>('overview');const guestId = createMemo(() => getCanonicalWorkloadId(props.guest));+ const alertThresholdScope = createMemo(() => getWorkloadAlertThresholdScope(props.guest));+ const alertResourceIdCandidates = createMemo(() =>+ getWorkloadAlertResourceIdCandidates(props.guest),+ );+ const metricThresholds = (metric: DisplayMetricType) =>+ createMemo(() =>+ alertsActivation.getMetricThresholds(+ alertThresholdScope(),+ metric,+ alertResourceIdCandidates(),+ ),+ );+ const diskThresholds = metricThresholds('disk');const infrastructureHref = createMemo(() => buildInfrastructureHrefForWorkload(props.guest));const osName = createMemo(() => props.guest.osName || '');const osVersion = createMemo(() => props.guest.osVersion || '');@@ -55,9 +73,7 @@ export function useGuestDrawerState(props: GuestDrawerProps) {const hasDiscoverySupport = createMemo(() => hasDiscoverySupportForWorkload(props.guest));const discoveryAgentId = createMemo(() => getDiscoveryHostIdForWorkload(props.guest));const discoveryResourceId = createMemo(() => getDiscoveryResourceIdForWorkload(props.guest));- const discoveryResourceType = createMemo(() =>- getDiscoveryResourceTypeForWorkload(props.guest),- );+ const discoveryResourceType = createMemo(() => getDiscoveryResourceTypeForWorkload(props.guest));const webInterfaceTargetLabel = createMemo(() =>getWebInterfaceTargetLabelForWorkload(props.guest),);@@ -81,6 +97,7 @@ export function useGuestDrawerState(props: GuestDrawerProps) {discoveryLoadingState: getDiscoveryLoadingState(),discoveryResourceId,discoveryResourceType,+ diskThresholds,guestId,guestOsSummary,hasAgentInfo,diff --git a/frontend-modern/src/components/Workloads/useGuestRowState.ts b/frontend-modern/src/components/Workloads/useGuestRowState.tsindex 4fae2932fc..820ed827e0 100644--- a/frontend-modern/src/components/Workloads/useGuestRowState.ts+++ b/frontend-modern/src/components/Workloads/useGuestRowState.ts@@ -2,7 +2,9 @@ import { createMemo } from 'solid-js';import { useBreakpoint } from '@/hooks/useBreakpoint';import { useAnomalyForMetric } from '@/hooks/useAnomalies';+import { useAlertsActivation } from '@/stores/alertsActivation';import type { Container } from '@/types/api';+import type { DisplayMetricType } from '@/utils/metricThresholds';import { buildMetricKey } from '@/utils/metricsKeys';import { getGuestPowerIndicator, isGuestRunning } from '@/utils/status';import { getShortImageName, formatBytes } from '@/utils/format';@@ -15,7 +17,11 @@ import {import { buildInfrastructureHrefForWorkload } from '@/routing/resourceLinks';import { getWorkloadTypeBadge } from '@/components/shared/workloadTypeBadges';-import { getWorkloadDockerHostId } from './workloadTopology';+import {+ getWorkloadAlertResourceIdCandidates,+ getWorkloadAlertThresholdScope,+ getWorkloadDockerHostId,+} from './workloadTopology';import {DEFAULT_FIRST_CELL_INDENT,EMPTY_IO_EMPHASIS,@@ -26,6 +32,7 @@ import {export function useGuestRowState(props: GuestRowProps) {const { isMobile } = useBreakpoint();+ const alertsActivation = useAlertsActivation();const guestId = createMemo(() => getCanonicalWorkloadId(props.guest));const infrastructureHref = createMemo(() => buildInfrastructureHrefForWorkload(props.guest));@@ -44,6 +51,21 @@ export function useGuestRowState(props: GuestRowProps) {const metricsKey = createMemo(() =>buildMetricKey(getWorkloadMetricsKind(props.guest), guestId()),);+ const alertThresholdScope = createMemo(() => getWorkloadAlertThresholdScope(props.guest));+ const alertResourceIdCandidates = createMemo(() =>+ getWorkloadAlertResourceIdCandidates(props.guest),+ );+ const metricThresholds = (metric: DisplayMetricType) =>+ createMemo(() =>+ alertsActivation.getMetricThresholds(+ alertThresholdScope(),+ metric,+ alertResourceIdCandidates(),+ ),+ );+ const cpuThresholds = metricThresholds('cpu');+ const memoryThresholds = metricThresholds('memory');+ const diskThresholds = metricThresholds('disk');const cpuAnomaly = useAnomalyForMetric(guestId, () => 'cpu');const memoryAnomaly = useAnomalyForMetric(guestId, () => 'memory');@@ -256,11 +278,13 @@ export function useGuestRowState(props: GuestRowProps) {return {appContainerRuntimeLabel,cpuAnomaly,+ cpuThresholds,customUrl,diskAnomaly,diskIOEmphasis,diskPercent,diskRead,+ diskThresholds,diskWrite,displayId,dockerHostId,@@ -283,6 +307,7 @@ export function useGuestRowState(props: GuestRowProps) {lockLabel,memoryAnomaly,memoryPercentOnly,+ memoryThresholds,memoryTooltip,metricsKey,namespace,diff --git a/frontend-modern/src/components/Workloads/workloadTopology.ts b/frontend-modern/src/components/Workloads/workloadTopology.tsindex 85915e48ae..c1264f028b 100644--- a/frontend-modern/src/components/Workloads/workloadTopology.ts+++ b/frontend-modern/src/components/Workloads/workloadTopology.ts@@ -1,10 +1,12 @@import type { Node } from '@/types/api';import type { WorkloadGuest } from '@/types/workloads';+import { guestOverrideIdCandidates } from '@/features/alerts/guestOverrideIdentity';import {getCanonicalWorkloadId,resolveDiscoveryTargetForWorkload,resolveWorkloadType,} from '@/utils/workloads';+import type { AlertThresholdScope } from '@/utils/metricThresholds';const firstTrimmed = (values: Array<string | null | undefined>): string => {for (const value of values) {@@ -48,6 +50,43 @@ export const getWorkloadDockerHostId = (guest: WorkloadGuest): string => {return (guest.dockerHostId || '').trim();};+export const getWorkloadAlertThresholdScope = (guest: WorkloadGuest): AlertThresholdScope => {+ const type = resolveWorkloadType(guest);+ return type === 'app-container' ? 'docker' : 'guest';+};++export const getWorkloadAlertResourceIdCandidates = (guest: WorkloadGuest): string[] => {+ const type = resolveWorkloadType(guest);+ if (type === 'vm' || type === 'system-container') {+ return guestOverrideIdCandidates(guest);+ }++ if (type === 'app-container') {+ const discoveryTarget = resolveDiscoveryTargetForWorkload(guest);+ const hostCandidates = dedupeTrimmed([+ discoveryTarget?.agentId,+ guest.dockerHostId,+ guest.contextLabel,+ guest.node,+ guest.instance,+ ]);+ const idSegments = guest.id.split(/[:/]/).filter(Boolean);+ const shortId = idSegments[idSegments.length - 1] || guest.id;+ const containerIds = dedupeTrimmed([+ discoveryTarget?.resourceId,+ guest.containerId,+ shortId,+ guest.id,+ ]);+ const dockerOverrideIds = hostCandidates.flatMap((hostId) =>+ containerIds.map((containerId) => `docker:${hostId}/${containerId}`),+ );+ return dedupeTrimmed([...dockerOverrideIds, guest.id]);+ }++ return dedupeTrimmed([getCanonicalWorkloadId(guest), guest.id]);+};+export const getWorkloadContainerHostId = (guest: WorkloadGuest): string => {const type = resolveWorkloadType(guest);if (type !== 'app-container') return '';diff --git a/frontend-modern/src/components/shared/InfrastructureSummaryTableRow.tsx b/frontend-modern/src/components/shared/InfrastructureSummaryTableRow.tsxindex d97f6822f2..f1776515f1 100644--- a/frontend-modern/src/components/shared/InfrastructureSummaryTableRow.tsx+++ b/frontend-modern/src/components/shared/InfrastructureSummaryTableRow.tsx@@ -59,13 +59,17 @@ export const InfrastructureSummaryTableRow: Component<InfrastructureSummaryTableconst isExpanded = createMemo(() => props.table.isExpandedNode(nodeId()));const statusIndicator = createMemo(() =>- isPVEItem ? getNodeStatusIndicator(node() as Node) : getPBSStatusIndicator(pbs() as PBSInstance),+ isPVEItem+ ? getNodeStatusIndicator(node() as Node)+ : getPBSStatusIndicator(pbs() as PBSInstance),);const cpuPercentValue = createMemo(() => getInfrastructureSummaryCpuPercent(props.item));const memoryPercentValue = createMemo(() => getInfrastructureSummaryMemoryPercent(props.item));const diskPercentValue = createMemo(() => getInfrastructureSummaryDiskPercent(props.item));const diskSublabel = createMemo(() => getInfrastructureSummaryDiskSublabel(props.item));- const cpuTemperatureValue = createMemo(() => getInfrastructureSummaryCpuTemperatureValue(props.item));+ const cpuTemperatureValue = createMemo(() =>+ getInfrastructureSummaryCpuTemperatureValue(props.item),+ );const uptimeValue = createMemo(() => props.item.uptime ?? 0);const displayName = () => (isPVEItem ? getNodeDisplayName(node() as Node) : pbs()!.name);const showActualName = () => isPVEItem && hasAlternateDisplayName(node() as Node);@@ -74,12 +78,23 @@ export const InfrastructureSummaryTableRow: Component<InfrastructureSummaryTable? resolveInfrastructureSummaryLinkedAgent(node() as Node, props.tableProps.agents): undefined;const metricsKey = createMemo(() => getInfrastructureSummaryMetricsKey(props.item));+ const alertThresholdScope = createMemo((): 'node' | 'pbs' => (isPVEItem ? 'node' : 'pbs'));+ const cpuThresholds = createMemo(() =>+ props.table.getMetricThresholds(alertThresholdScope(), 'cpu', resourceId()),+ );+ const memoryThresholds = createMemo(() =>+ props.table.getMetricThresholds(alertThresholdScope(), 'memory', resourceId()),+ );+ const diskThresholds = createMemo(() =>+ props.table.getMetricThresholds(alertThresholdScope(), 'disk', resourceId()),+ );+ const temperatureThresholds = createMemo(() =>+ isPVEItem ? props.table.getMetricThresholds('node', 'temperature', resourceId()) : null,+ );const alertStyles = createMemo(() =>getAlertStyles(resourceId(), props.table.activeAlerts, props.table.alertsEnabled()),);- const showAlertHighlight = createMemo(- () => alertStyles().hasUnacknowledgedAlert && online(),- );+ const showAlertHighlight = createMemo(() => alertStyles().hasUnacknowledgedAlert && online());const rowStyle = createMemo(() => {const styles: Record<string, string> = {};@@ -103,8 +118,7 @@ export const InfrastructureSummaryTableRow: Component<InfrastructureSummaryTable});const rowClass = createMemo(() => {- const baseHover =- 'cursor-pointer transition-all duration-200 relative hover:shadow-sm group';+ const baseHover = 'cursor-pointer transition-all duration-200 relative hover:shadow-sm group';if (isSelected()) {return `${baseHover} z-10 bg-blue-50 dark:bg-blue-900`;@@ -259,9 +273,12 @@ export const InfrastructureSummaryTableRow: Component<InfrastructureSummaryTable<EnhancedCPUBarusage={cpuPercentValue()}loadAverage={isPVEItem ? node()!.loadAverage?.[0] : undefined}- cores={props.table.isMobile() ? undefined : isPVEItem ? node()!.cpuInfo?.cores : undefined}+ cores={+ props.table.isMobile() ? undefined : isPVEItem ? node()!.cpuInfo?.cores : undefined+ }model={isPVEItem ? node()!.cpuInfo?.model : undefined}resourceId={metricsKey()}+ thresholds={cpuThresholds()}/></div></TableCell>@@ -285,6 +302,7 @@ export const InfrastructureSummaryTableRow: Component<InfrastructureSummaryTable}isRunning={online()}showMobile={false}+ thresholds={memoryThresholds()}/>}>@@ -295,6 +313,7 @@ export const InfrastructureSummaryTableRow: Component<InfrastructureSummaryTableswapUsed={node()!.memory?.swapUsed || 0}swapTotal={node()!.memory?.swapTotal || 0}resourceId={metricsKey()}+ thresholds={memoryThresholds()}/></Show></div>@@ -315,6 +334,7 @@ export const InfrastructureSummaryTableRow: Component<InfrastructureSummaryTablesublabel={diskSublabel()}isRunning={online()}showMobile={false}+ thresholds={diskThresholds()}/>}>@@ -325,6 +345,7 @@ export const InfrastructureSummaryTableRow: Component<InfrastructureSummaryTablefree: (node()!.disk?.total || 0) - (node()!.disk?.used || 0),usage: node()!.disk?.total ? node()!.disk!.used / node()!.disk!.total : 0,}}+ thresholds={diskThresholds()}/></Show></div>@@ -374,8 +395,13 @@ export const InfrastructureSummaryTableRow: Component<InfrastructureSummaryTablevalue={value}min={min}max={max}- critical={props.table.temperatureThreshold()}- warning={Math.max(0, props.table.temperatureThreshold() - 5)}+ critical={+ temperatureThresholds()?.critical ?? props.table.temperatureThreshold()+ }+ warning={+ temperatureThresholds()?.warning ??+ Math.max(0, props.table.temperatureThreshold() - 5)+ }/></div>);@@ -384,8 +410,13 @@ export const InfrastructureSummaryTableRow: Component<InfrastructureSummaryTablereturn (<TemperatureGaugevalue={value}- critical={props.table.temperatureThreshold()}- warning={Math.max(0, props.table.temperatureThreshold() - 5)}+ critical={+ temperatureThresholds()?.critical ?? props.table.temperatureThreshold()+ }+ warning={+ temperatureThresholds()?.warning ??+ Math.max(0, props.table.temperatureThreshold() - 5)+ }/>);})()}@@ -438,8 +469,11 @@ export const InfrastructureSummaryTableRow: Component<InfrastructureSummaryTable<div class="flex justify-center"><span class={online() ? 'text-xs text-base-content' : 'text-xs text-muted'}>{online()- ? (getInfrastructureSummaryCountValue(props.item, 'diskCount', props.tableProps) ??- '-')+ ? (getInfrastructureSummaryCountValue(+ props.item,+ 'diskCount',+ props.tableProps,+ ) ?? '-'): '-'}</span></div>@@ -463,7 +497,9 @@ export const InfrastructureSummaryTableRow: Component<InfrastructureSummaryTable</Show><TableCell class="px-0 py-1 align-middle text-center">- <Show when={isPVEItem ? node()!.guestURL || node()!.host : pbs()!.guestURL || pbs()!.host}>+ <Show+ when={isPVEItem ? node()!.guestURL || node()!.host : pbs()!.guestURL || pbs()!.host}+ ><ahref={isPVEItemdiff --git a/frontend-modern/src/components/shared/__tests__/InfrastructureSummaryTable.test.tsx b/frontend-modern/src/components/shared/__tests__/InfrastructureSummaryTable.test.tsxindex 477bc5327c..f70be646be 100644--- a/frontend-modern/src/components/shared/__tests__/InfrastructureSummaryTable.test.tsx+++ b/frontend-modern/src/components/shared/__tests__/InfrastructureSummaryTable.test.tsx@@ -29,6 +29,7 @@ vi.mock('@/stores/alertsActivation', () => ({useAlertsActivation: () => ({activationState: () => 'active',getTemperatureThreshold: () => 80,+ getMetricThresholds: () => ({ warning: 75, critical: 80 }),}),}));diff --git a/frontend-modern/src/components/shared/responsive/ResponsiveMetricCell.tsx b/frontend-modern/src/components/shared/responsive/ResponsiveMetricCell.tsxindex 627325b4af..faf5b54d49 100644--- a/frontend-modern/src/components/shared/responsive/ResponsiveMetricCell.tsx+++ b/frontend-modern/src/components/shared/responsive/ResponsiveMetricCell.tsx@@ -3,7 +3,7 @@ import { MetricBar } from '@/components/Workloads/MetricBar';import { useBreakpoint } from '@/hooks/useBreakpoint';import { formatPercent } from '@/utils/format';import { getMetricSeverity } from '@/utils/metricThresholds';-import type { MetricSeverity } from '@/utils/metricThresholds';+import type { MetricDisplayThresholds, MetricSeverity } from '@/utils/metricThresholds';export interface ResponsiveMetricCellProps {/** Metric value (0-100 percentage) */@@ -32,6 +32,9 @@ export interface ResponsiveMetricCellProps {/** Additional CSS classes for container */class?: string;++ /** Resolved warning/critical thresholds for alert-aligned coloring. */+ thresholds?: MetricDisplayThresholds | null;}/** Map metric severity to text color + weight for compact metric display */@@ -41,8 +44,12 @@ const METRIC_TEXT_STYLES: Record<MetricSeverity, string> = {normal: 'text-muted',};-function metricTextClass(value: number, type: 'cpu' | 'memory' | 'disk'): string {- return METRIC_TEXT_STYLES[getMetricSeverity(value, type)];+function metricTextClass(+ value: number,+ type: 'cpu' | 'memory' | 'disk',+ thresholds?: MetricDisplayThresholds | null,+): string {+ return METRIC_TEXT_STYLES[getMetricSeverity(value, type, thresholds)];}function compactCapacityLabel(sublabel?: string): string | undefined {@@ -91,7 +98,7 @@ function compactCapacityLabel(sublabel?: string): string | undefined {export const ResponsiveMetricCell: Component<ResponsiveMetricCellProps> = (props) => {const { isAtLeast, isBelow } = useBreakpoint();const displayLabel = createMemo(() => props.label ?? formatPercent(props.value));- const colorClass = createMemo(() => metricTextClass(props.value, props.type));+ const colorClass = createMemo(() => metricTextClass(props.value, props.type, props.thresholds));const isRunning = () => props.isRunning !== false; // Default to true if not specifiedconst isVeryNarrow = createMemo(() => isBelow('xs'));@@ -135,6 +142,7 @@ export const ResponsiveMetricCell: Component<ResponsiveMetricCellProps> = (propsshowLabel={showLabel()}type={props.type}resourceId={props.resourceId}+ thresholds={props.thresholds}/></div></div>@@ -151,9 +159,10 @@ export const MetricText: Component<{type: 'cpu' | 'memory' | 'disk';label?: string;class?: string;+ thresholds?: MetricDisplayThresholds | null;}> = (props) => {const displayLabel = createMemo(() => props.label ?? formatPercent(props.value));- const colorClass = createMemo(() => metricTextClass(props.value, props.type));+ const colorClass = createMemo(() => metricTextClass(props.value, props.type, props.thresholds));return (<span class={`text-xs text-center ${colorClass()} ${props.class || ''}`}>{displayLabel()}</span>@@ -176,9 +185,10 @@ export const DualMetricCell: Component<{desktopContent?: JSX.Element;fallback?: JSX.Element;class?: string;+ thresholds?: MetricDisplayThresholds | null;}> = (props) => {const displayLabel = createMemo(() => props.label ?? formatPercent(props.value));- const colorClass = createMemo(() => metricTextClass(props.value, props.type));+ const colorClass = createMemo(() => metricTextClass(props.value, props.type, props.thresholds));const isRunning = () => props.isRunning !== false;const defaultFallback = (@@ -198,6 +208,7 @@ export const DualMetricCell: Component<{sublabel={props.sublabel}type={props.type}resourceId={props.resourceId}+ thresholds={props.thresholds}/>);diff --git a/frontend-modern/src/components/shared/useInfrastructureSummaryTableState.ts b/frontend-modern/src/components/shared/useInfrastructureSummaryTableState.tsindex 02b031578f..f6db1320b0 100644--- a/frontend-modern/src/components/shared/useInfrastructureSummaryTableState.ts+++ b/frontend-modern/src/components/shared/useInfrastructureSummaryTableState.ts@@ -2,6 +2,7 @@ import { createMemo, createSignal } from 'solid-js';import { useWebSocket } from '@/contexts/appRuntime';import { useBreakpoint } from '@/hooks/useBreakpoint';import { useAlertsActivation } from '@/stores/alertsActivation';+import type { AlertThresholdScope, DisplayMetricType } from '@/utils/metricThresholds';import {getInfrastructureSummaryDefaultSortDirection,isTemperatureMonitoringEnabled,@@ -16,6 +17,11 @@ export function useInfrastructureSummaryTableState(props: InfrastructureSummaryTconst alertsEnabled = createMemo(() => alertsActivation.activationState() === 'active');const { isMobile } = useBreakpoint();const temperatureThreshold = createMemo(() => alertsActivation.getTemperatureThreshold());+ const getMetricThresholds = (+ scope: AlertThresholdScope,+ metric: DisplayMetricType,+ resourceIds?: string | string[],+ ) => alertsActivation.getMetricThresholds(scope, metric, resourceIds);const [sortKey, setSortKey] = createSignal<InfrastructureSummarySortKey>('default');const [sortDirection, setSortDirection] = createSignal<'asc' | 'desc'>('asc');@@ -73,6 +79,7 @@ export function useInfrastructureSummaryTableState(props: InfrastructureSummaryTalertsEnabled,handleSort,hasAnyTemperatureData,+ getMetricThresholds,isExpandedNode: (nodeId: string) => expandedNodeId() === nodeId,isMobile,isTemperatureMonitoringEnabled: (node: Parameters<typeof isTemperatureMonitoringEnabled>[0]) =>diff --git a/frontend-modern/src/features/alerts/__tests__/alertsConfigurationModel.test.ts b/frontend-modern/src/features/alerts/__tests__/alertsConfigurationModel.test.tsindex 62cc942503..432acba4ed 100644--- a/frontend-modern/src/features/alerts/__tests__/alertsConfigurationModel.test.ts+++ b/frontend-modern/src/features/alerts/__tests__/alertsConfigurationModel.test.ts@@ -6,6 +6,9 @@ import {ALERT_DOCKER_GAP_VALIDATION_ERROR,buildAlertsConfigurationPayload,createDefaultAlertsConfigurationSnapshot,+ FACTORY_DOCKER_DEFAULTS,+ FACTORY_GUEST_DEFAULTS,+ FACTORY_STORAGE_DEFAULT,readAlertsConfigurationSnapshot,} from '../alertsConfigurationModel';@@ -13,8 +16,11 @@ describe('alertsConfigurationModel', () => {it('creates the canonical default snapshot', () => {const snapshot = createDefaultAlertsConfigurationSnapshot();- expect(snapshot.guestDefaults.cpu).toBe(80);- expect(snapshot.dockerDefaults.serviceWarnGapPercent).toBe(10);+ expect(snapshot.guestDefaults.cpu).toBe(FACTORY_GUEST_DEFAULTS.cpu);+ expect(snapshot.dockerDefaults.serviceWarnGapPercent).toBe(+ FACTORY_DOCKER_DEFAULTS.serviceWarnGapPercent,+ );+ expect(snapshot.storageDefault).toBe(FACTORY_STORAGE_DEFAULT);expect(snapshot.timeThresholds.guest).toBe(5);expect(snapshot.scheduleCooldown.enabled).toBe(true);expect(snapshot.backupDefaults.ignoreVMIDs).toEqual([]);diff --git a/frontend-modern/src/features/alerts/alertsConfigurationModel.ts b/frontend-modern/src/features/alerts/alertsConfigurationModel.tsindex 8c8974c359..70fb03ec36 100644--- a/frontend-modern/src/features/alerts/alertsConfigurationModel.ts+++ b/frontend-modern/src/features/alerts/alertsConfigurationModel.ts@@ -1,4 +1,21 @@-import type { AlertConfig, ActivationState, BackupAlertConfig, SnapshotAlertConfig } from '@/types/alerts';+import type {+ AlertConfig,+ ActivationState,+ BackupAlertConfig,+ SnapshotAlertConfig,+} from '@/types/alerts';+import {+ FACTORY_AGENT_DEFAULTS,+ FACTORY_BACKUP_DEFAULTS,+ FACTORY_DOCKER_DEFAULTS,+ FACTORY_DOCKER_STATE_DISABLE_CONNECTIVITY,+ FACTORY_DOCKER_STATE_SEVERITY,+ FACTORY_GUEST_DEFAULTS,+ FACTORY_NODE_DEFAULTS,+ FACTORY_PBS_DEFAULTS,+ FACTORY_SNAPSHOT_DEFAULTS,+ FACTORY_STORAGE_DEFAULT,+} from '@/utils/alertThresholdDefaults';import {clampMaxAlertsPerHour,@@ -21,64 +38,18 @@ import type {} from './types';import { GROUPING_WINDOW_DEFAULT_SECONDS, clampCooldownMinutes } from './types';-export const FACTORY_GUEST_DEFAULTS = {- cpu: 80,- memory: 85,- disk: 90,- diskRead: -1,- diskWrite: -1,- networkIn: -1,- networkOut: -1,-};--export const FACTORY_NODE_DEFAULTS = {- cpu: 80,- memory: 85,- disk: 90,- temperature: 80,-};--export const FACTORY_PBS_DEFAULTS = {- cpu: 80,- memory: 85,-};--export const FACTORY_AGENT_DEFAULTS = {- cpu: 80,- memory: 85,- disk: 90,- diskTemperature: 55,-};--export const FACTORY_DOCKER_DEFAULTS = {- cpu: 80,- memory: 85,- disk: 85,- restartCount: 3,- restartWindow: 300,- memoryWarnPct: 90,- memoryCriticalPct: 95,- serviceWarnGapPercent: 10,- serviceCriticalGapPercent: 50,-};--export const FACTORY_DOCKER_STATE_DISABLE_CONNECTIVITY = false;-export const FACTORY_DOCKER_STATE_SEVERITY: 'warning' | 'critical' = 'warning';-export const FACTORY_STORAGE_DEFAULT = 85;-export const FACTORY_SNAPSHOT_DEFAULTS: SnapshotAlertConfig = {- enabled: false,- warningDays: 30,- criticalDays: 45,-};-export const FACTORY_BACKUP_DEFAULTS: BackupAlertConfig = {- enabled: false,- warningDays: 7,- criticalDays: 14,- freshHours: 24,- staleHours: 72,- alertOrphaned: true,- ignoreVMIDs: [],-};+export {+ FACTORY_AGENT_DEFAULTS,+ FACTORY_BACKUP_DEFAULTS,+ FACTORY_DOCKER_DEFAULTS,+ FACTORY_DOCKER_STATE_DISABLE_CONNECTIVITY,+ FACTORY_DOCKER_STATE_SEVERITY,+ FACTORY_GUEST_DEFAULTS,+ FACTORY_NODE_DEFAULTS,+ FACTORY_PBS_DEFAULTS,+ FACTORY_SNAPSHOT_DEFAULTS,+ FACTORY_STORAGE_DEFAULT,+} from '@/utils/alertThresholdDefaults';export interface AlertsConfigurationSnapshot {scheduleQuietHours: QuietHoursConfig;@@ -452,13 +423,12 @@ export function readAlertsConfigurationSnapshot(config: AlertConfig): AlertsConffriday: quietHours.days.includes(5),saturday: quietHours.days.includes(6),}- : ((quietHours.days as Record<string, boolean>) || createDefaultQuietHours().days);+ : (quietHours.days as Record<string, boolean>) || createDefaultQuietHours().days;snapshot.scheduleQuietHours = {enabled: quietHours.enabled || false,start: quietHours.start || '22:00',end: quietHours.end || '08:00',- timezone:- quietHours.timezone || Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC',+ timezone: quietHours.timezone || Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC',days,suppress: {performance: quietHours.suppress?.performance ?? false,@@ -525,7 +495,8 @@ export function buildAlertsConfigurationPayload({} {if (snapshot.dockerDefaults.serviceCriticalGapPercent > 0 &&- snapshot.dockerDefaults.serviceWarnGapPercent > snapshot.dockerDefaults.serviceCriticalGapPercent+ snapshot.dockerDefaults.serviceWarnGapPercent >+ snapshot.dockerDefaults.serviceCriticalGapPercent) {return {dockerValidationError: ALERT_DOCKER_GAP_VALIDATION_ERROR,diff --git a/frontend-modern/src/stores/alertsActivation.ts b/frontend-modern/src/stores/alertsActivation.tsindex 21de3e53ec..0f8b3fcd67 100644--- a/frontend-modern/src/stores/alertsActivation.ts+++ b/frontend-modern/src/stores/alertsActivation.ts@@ -3,7 +3,13 @@ import { AlertsAPI } from '@/api/alerts';import type { AlertConfig, ActivationState as ActivationStateType } from '@/types/alerts';import type { Alert } from '@/types/api';import { setGlobalActivationState } from '@/utils/alertsActivation';+import { FACTORY_NODE_DEFAULTS } from '@/utils/alertThresholdDefaults';import { logger } from '@/utils/logger';+import {+ type AlertThresholdScope,+ type DisplayMetricType,+ resolveMetricDisplayThresholds,+} from '@/utils/metricThresholds';// Create signals for activation stateconst [config, setConfig] = createSignal<AlertConfig | null>(null);@@ -129,14 +135,15 @@ const getBackupThresholds = (): { freshHours: number; staleHours: number } => {// Get temperature threshold from config (for display coloring)const getTemperatureThreshold = (): number => {- const cfg = config();- // nodeDefaults.temperature is a HysteresisThreshold with trigger/clear- const tempConfig = cfg?.nodeDefaults?.temperature;- if (typeof tempConfig === 'object' && tempConfig !== null && 'trigger' in tempConfig) {- return (tempConfig as { trigger: number }).trigger;- }- // Fallback to default 80°C- return 80;+ return getMetricThresholds('node', 'temperature')?.critical ?? FACTORY_NODE_DEFAULTS.temperature;+};++const getMetricThresholds = (+ scope: AlertThresholdScope,+ metric: DisplayMetricType,+ resourceIds?: string | string[],+) => {+ return resolveMetricDisplayThresholds(config(), scope, metric, resourceIds);};// Export the store@@ -152,6 +159,7 @@ export const useAlertsActivation = () => ({isPastObservationWindow,getBackupThresholds,getTemperatureThreshold,+ getMetricThresholds,// ActionsrefreshConfig,diff --git a/frontend-modern/src/utils/__tests__/metricThresholds.test.ts b/frontend-modern/src/utils/__tests__/metricThresholds.test.tsindex 74715f3881..cf7412069c 100644--- a/frontend-modern/src/utils/__tests__/metricThresholds.test.ts+++ b/frontend-modern/src/utils/__tests__/metricThresholds.test.ts@@ -5,9 +5,12 @@ import {getMetricColorRgba,getMetricColorHex,getMetricTextColorClass,+ getDefaultMetricDisplayThresholds,+ resolveMetricDisplayThresholds,METRIC_THRESHOLDS,type MetricType,} from '@/utils/metricThresholds';+import type { AlertConfig } from '@/types/alerts';describe('metricThresholds', () => {describe('getMetricSeverity', () => {@@ -153,4 +156,86 @@ describe('metricThresholds', () => {expect(METRIC_THRESHOLDS.disk).toEqual({ warning: 80, critical: 90 });});});++ describe('alert-backed display thresholds', () => {+ it('derives guest display thresholds from alert trigger and clear defaults', () => {+ expect(getDefaultMetricDisplayThresholds('cpu')).toEqual({ warning: 75, critical: 80 });+ expect(getDefaultMetricDisplayThresholds('memory')).toEqual({ warning: 80, critical: 85 });+ expect(getDefaultMetricDisplayThresholds('disk')).toEqual({ warning: 85, critical: 90 });+ expect(getDefaultMetricDisplayThresholds('generic')).toEqual({+ warning: 75,+ critical: 90,+ });+ });++ it('resolves configured defaults and resource override candidates', () => {+ const config = {+ enabled: true,+ guestDefaults: {+ cpu: { trigger: 82, clear: 77 },+ },+ nodeDefaults: {},+ storageDefault: { trigger: 85, clear: 80 },+ overrides: {+ 'guest:cluster-a:100': {+ cpu: { trigger: 95, clear: 90 },+ },+ },+ } as AlertConfig;++ expect(resolveMetricDisplayThresholds(config, 'guest', 'cpu', 'missing')).toEqual({+ warning: 77,+ critical: 82,+ });+ expect(+ resolveMetricDisplayThresholds(config, 'guest', 'cpu', [+ 'cluster-a:node-a:100',+ 'guest:cluster-a:100',+ ]),+ ).toEqual({+ warning: 90,+ critical: 95,+ });+ });++ it('treats disabled thresholds as normal display coloring', () => {+ const config = {+ enabled: true,+ guestDefaults: {},+ nodeDefaults: {},+ storageDefault: { trigger: 85, clear: 80 },+ overrides: {+ 'guest:cluster-a:100': {+ disk: { trigger: -1, clear: 0 },+ },+ },+ } as AlertConfig;++ expect(+ resolveMetricDisplayThresholds(config, 'guest', 'disk', 'guest:cluster-a:100'),+ ).toBeNull();+ expect(getMetricColorClass(99, 'disk', null)).toContain('bg-metric-normal-bg');+ });++ it('honors disabled docker defaults and storage usage aliases', () => {+ const config = {+ enabled: true,+ guestDefaults: {},+ nodeDefaults: {},+ dockerDefaults: {+ cpu: { trigger: 0, clear: 0 },+ memory: { trigger: 0, clear: 0 },+ disk: { trigger: 0, clear: 0 },+ },+ storageDefault: { trigger: 92, clear: 86 },+ overrides: {},+ } as AlertConfig;++ expect(resolveMetricDisplayThresholds(config, 'docker', 'cpu')).toBeNull();+ expect(resolveMetricDisplayThresholds(config, 'storage', 'usage')).toEqual({+ warning: 86,+ critical: 92,+ });+ });+ });});diff --git a/frontend-modern/src/utils/alertThresholdDefaults.ts b/frontend-modern/src/utils/alertThresholdDefaults.tsnew file mode 100644index 0000000000..ac1b1d09fd--- /dev/null+++ b/frontend-modern/src/utils/alertThresholdDefaults.ts@@ -0,0 +1,62 @@+import type { BackupAlertConfig, SnapshotAlertConfig } from '@/types/alerts';++export const FACTORY_GUEST_DEFAULTS = {+ cpu: 80,+ memory: 85,+ disk: 90,+ diskRead: -1,+ diskWrite: -1,+ networkIn: -1,+ networkOut: -1,+};++export const FACTORY_NODE_DEFAULTS = {+ cpu: 80,+ memory: 85,+ disk: 90,+ temperature: 80,+};++export const FACTORY_PBS_DEFAULTS = {+ cpu: 80,+ memory: 85,+};++export const FACTORY_AGENT_DEFAULTS = {+ cpu: 80,+ memory: 85,+ disk: 90,+ diskTemperature: 55,+};++export const FACTORY_DOCKER_DEFAULTS = {+ cpu: 80,+ memory: 85,+ disk: 85,+ restartCount: 3,+ restartWindow: 300,+ memoryWarnPct: 90,+ memoryCriticalPct: 95,+ serviceWarnGapPercent: 10,+ serviceCriticalGapPercent: 50,+};++export const FACTORY_DOCKER_STATE_DISABLE_CONNECTIVITY = false;+export const FACTORY_DOCKER_STATE_SEVERITY: 'warning' | 'critical' = 'warning';+export const FACTORY_STORAGE_DEFAULT = 85;++export const FACTORY_SNAPSHOT_DEFAULTS: SnapshotAlertConfig = {+ enabled: false,+ warningDays: 30,+ criticalDays: 45,+};++export const FACTORY_BACKUP_DEFAULTS: BackupAlertConfig = {+ enabled: false,+ warningDays: 7,+ criticalDays: 14,+ freshHours: 24,+ staleHours: 72,+ alertOrphaned: true,+ ignoreVMIDs: [],+};diff --git a/frontend-modern/src/utils/metricThresholds.ts b/frontend-modern/src/utils/metricThresholds.tsindex 0f52a341ef..00ae217ab9 100644--- a/frontend-modern/src/utils/metricThresholds.ts+++ b/frontend-modern/src/utils/metricThresholds.ts@@ -6,9 +6,33 @@* in components — import from this module instead.*/+import type {+ AlertConfig,+ AlertThresholds,+ DockerThresholdConfig,+ HysteresisThreshold,+ RawOverrideConfig,+} from '@/types/alerts';+import {+ FACTORY_AGENT_DEFAULTS,+ FACTORY_DOCKER_DEFAULTS,+ FACTORY_GUEST_DEFAULTS,+ FACTORY_NODE_DEFAULTS,+ FACTORY_PBS_DEFAULTS,+ FACTORY_STORAGE_DEFAULT,+} from '@/utils/alertThresholdDefaults';+export type MetricType = 'cpu' | 'memory' | 'disk';+export type DisplayMetricType = MetricType | 'temperature' | 'diskTemperature' | 'usage';+export type DisplayMetricBarType = MetricType | 'generic';+export type AlertThresholdScope = 'guest' | 'node' | 'pbs' | 'agent' | 'docker' | 'storage';++export interface MetricDisplayThresholds {+ warning: number;+ critical: number;+}-export const METRIC_THRESHOLDS: Record<MetricType, { warning: number; critical: number }> = {+export const METRIC_THRESHOLDS: Record<MetricType, MetricDisplayThresholds> = {cpu: { warning: 80, critical: 90 },memory: { warning: 75, critical: 85 },disk: { warning: 80, critical: 90 },@@ -16,9 +40,212 @@ export const METRIC_THRESHOLDS: Record<MetricType, { warning: number; critical:export type MetricSeverity = 'normal' | 'warning' | 'critical';+const DEFAULT_GENERIC_THRESHOLDS: MetricDisplayThresholds = {+ warning: 75,+ critical: 90,+};++const DEFAULT_HYSTERESIS_MARGIN = 5;++const SCOPE_DEFAULTS: Record<+ Exclude<AlertThresholdScope, 'storage'>,+ Partial<Record<DisplayMetricType, number>>+> = {+ guest: FACTORY_GUEST_DEFAULTS,+ node: FACTORY_NODE_DEFAULTS,+ pbs: FACTORY_PBS_DEFAULTS,+ agent: FACTORY_AGENT_DEFAULTS,+ docker: FACTORY_DOCKER_DEFAULTS,+};++const toFiniteNumber = (value: unknown): number | null => {+ if (typeof value !== 'number' || !Number.isFinite(value)) {+ return null;+ }+ return value;+};++const normalizeMargin = (value: number | undefined): number => {+ const numeric = toFiniteNumber(value);+ if (numeric === null) {+ return DEFAULT_HYSTERESIS_MARGIN;+ }+ return Math.max(0, numeric);+};++const isHysteresisThreshold = (value: unknown): value is HysteresisThreshold => {+ return value !== null && typeof value === 'object' && 'trigger' in value;+};++const getScopeThresholds = (+ config: AlertConfig | null,+ scope: AlertThresholdScope,+): AlertThresholds | DockerThresholdConfig | HysteresisThreshold | undefined => {+ switch (scope) {+ case 'guest':+ return config?.guestDefaults;+ case 'node':+ return config?.nodeDefaults;+ case 'pbs':+ return config?.pbsDefaults;+ case 'agent':+ return config?.agentDefaults;+ case 'docker':+ return config?.dockerDefaults;+ case 'storage':+ return config?.storageDefault;+ }+};++const normalizeResourceIds = (resourceIds?: string | string[]): string[] => {+ const ids = Array.isArray(resourceIds) ? resourceIds : [resourceIds];+ const result: string[] = [];+ const seen = new Set<string>();+ ids.forEach((value) => {+ const normalized = (value || '').trim();+ if (!normalized || seen.has(normalized)) return;+ seen.add(normalized);+ result.push(normalized);+ });+ return result;+};++const findOverride = (+ overrides: AlertConfig['overrides'] | undefined,+ resourceIds?: string | string[],+): RawOverrideConfig | undefined => {+ if (!overrides) {+ return undefined;+ }+ for (const resourceId of normalizeResourceIds(resourceIds)) {+ const override = overrides[resourceId];+ if (override) {+ return override;+ }+ }+ return undefined;+};++const getOverrideValue = (+ override: RawOverrideConfig | undefined,+ metric: DisplayMetricType,+): number | HysteresisThreshold | undefined => {+ const value = override?.[metric];+ if (typeof value === 'number' || isHysteresisThreshold(value)) {+ return value;+ }+ if (metric === 'disk') {+ const usageValue = override?.usage;+ if (typeof usageValue === 'number' || isHysteresisThreshold(usageValue)) {+ return usageValue;+ }+ }+ return undefined;+};++const getBaseThresholdValue = (+ thresholds: AlertThresholds | DockerThresholdConfig | HysteresisThreshold | undefined,+ metric: DisplayMetricType,+): number | HysteresisThreshold | undefined => {+ if (!thresholds) {+ return undefined;+ }+ if (isHysteresisThreshold(thresholds)) {+ return metric === 'disk' || metric === 'usage' ? thresholds : undefined;+ }+ const value = (thresholds as Partial<Record<DisplayMetricType, number | HysteresisThreshold>>)[+ metric+ ];+ if (typeof value === 'number' || isHysteresisThreshold(value)) {+ return value;+ }+ return undefined;+};++const getFallbackCritical = (+ scope: AlertThresholdScope,+ metric: DisplayMetricType,+): number | undefined => {+ if (scope === 'storage') {+ return metric === 'disk' || metric === 'usage' ? FACTORY_STORAGE_DEFAULT : undefined;+ }+ return SCOPE_DEFAULTS[scope][metric];+};++const resolveThreshold = (+ value: number | HysteresisThreshold | undefined,+ fallbackCritical: number | undefined,+ margin: number,+): MetricDisplayThresholds | null => {+ if (isHysteresisThreshold(value)) {+ const critical = toFiniteNumber(value.trigger);+ if (critical === null || critical <= 0) {+ return null;+ }+ const clear = toFiniteNumber(value.clear);+ const warning =+ clear === null ? Math.max(0, critical - margin) : Math.max(0, Math.min(clear, critical));+ return { warning, critical };+ }++ const numeric = toFiniteNumber(value);+ if (numeric !== null) {+ if (numeric <= 0) {+ return null;+ }+ return {+ warning: Math.max(0, numeric - margin),+ critical: numeric,+ };+ }++ if (!fallbackCritical || fallbackCritical <= 0) {+ return null;+ }++ return {+ warning: Math.max(0, fallbackCritical - margin),+ critical: fallbackCritical,+ };+};++export const getDefaultMetricDisplayThresholds = (+ metric: DisplayMetricBarType,+): MetricDisplayThresholds => {+ if (metric === 'generic') {+ return DEFAULT_GENERIC_THRESHOLDS;+ }++ return (+ resolveThreshold(undefined, SCOPE_DEFAULTS.guest[metric], DEFAULT_HYSTERESIS_MARGIN) ??+ METRIC_THRESHOLDS[metric]+ );+};++export const resolveMetricDisplayThresholds = (+ config: AlertConfig | null,+ scope: AlertThresholdScope,+ metric: DisplayMetricType,+ resourceIds?: string | string[],+): MetricDisplayThresholds | null => {+ const margin = normalizeMargin(config?.hysteresisMargin);+ const scopeThresholds = getScopeThresholds(config, scope);+ const override = findOverride(config?.overrides, resourceIds);+ const overrideValue = getOverrideValue(override, metric);+ const baseValue = getBaseThresholdValue(scopeThresholds, metric);+ return resolveThreshold(overrideValue ?? baseValue, getFallbackCritical(scope, metric), margin);+};+/** Determine severity level from a percentage value and metric type. */-export function getMetricSeverity(value: number, metric: MetricType): MetricSeverity {- const t = METRIC_THRESHOLDS[metric];+export function getMetricSeverity(+ value: number,+ metric: MetricType,+ thresholds?: MetricDisplayThresholds | null,+): MetricSeverity {+ const t = thresholds === undefined ? METRIC_THRESHOLDS[metric] : thresholds;+ if (!t) {+ return 'normal';+ }if (value >= t.critical) return 'critical';if (value >= t.warning) return 'warning';return 'normal';@@ -32,8 +259,12 @@ const BG_CLASSES: Record<MetricSeverity, string> = {normal: 'bg-metric-normal-bg dark:bg-metric-normal-bg',};-export function getMetricColorClass(value: number, metric: MetricType): string {- return BG_CLASSES[getMetricSeverity(value, metric)];+export function getMetricColorClass(+ value: number,+ metric: MetricType,+ thresholds?: MetricDisplayThresholds | null,+): string {+ return BG_CLASSES[getMetricSeverity(value, metric, thresholds)];}// -- RGBA colors (canvas rendering, inline styles) --@@ -44,8 +275,12 @@ const RGBA_COLORS: Record<MetricSeverity, string> = {normal: 'rgba(34, 197, 94, 0.6)',};-export function getMetricColorRgba(value: number, metric: MetricType): string {- return RGBA_COLORS[getMetricSeverity(value, metric)];+export function getMetricColorRgba(+ value: number,+ metric: MetricType,+ thresholds?: MetricDisplayThresholds | null,+): string {+ return RGBA_COLORS[getMetricSeverity(value, metric, thresholds)];}// -- Hex colors (sparkline canvas) --@@ -56,8 +291,12 @@ const HEX_COLORS: Record<MetricSeverity, string> = {normal: '#22c55e',};-export function getMetricColorHex(value: number, metric: MetricType): string {- return HEX_COLORS[getMetricSeverity(value, metric)];+export function getMetricColorHex(+ value: number,+ metric: MetricType,+ thresholds?: MetricDisplayThresholds | null,+): string {+ return HEX_COLORS[getMetricSeverity(value, metric, thresholds)];}// -- Text color classes (labels, percentage text) --@@ -68,6 +307,10 @@ const TEXT_CLASSES: Record<MetricSeverity, string> = {normal: 'text-muted',};-export function getMetricTextColorClass(value: number, metric: MetricType): string {- return TEXT_CLASSES[getMetricSeverity(value, metric)];+export function getMetricTextColorClass(+ value: number,+ metric: MetricType,+ thresholds?: MetricDisplayThresholds | null,+): string {+ return TEXT_CLASSES[getMetricSeverity(value, metric, thresholds)];}diff --git a/scripts/release_control/canonical_completion_guard_test.py b/scripts/release_control/canonical_completion_guard_test.pyindex 3dae631e74..53579394d4 100644--- a/scripts/release_control/canonical_completion_guard_test.py+++ b/scripts/release_control/canonical_completion_guard_test.py@@ -2843,6 +2843,7 @@ index 1111111..2222222 100644"frontend-modern/src/features/alerts/__tests__/OverviewTab.emptystate.test.tsx","frontend-modern/src/features/alerts/__tests__/OverviewTab.timelineerror.test.tsx","frontend-modern/src/features/alerts/__tests__/OverviewTab.total24h.test.tsx",+ "frontend-modern/src/features/alerts/__tests__/alertsConfigurationModel.test.ts","frontend-modern/src/features/alerts/__tests__/helpers.test.ts","frontend-modern/src/features/alerts/identity.test.ts","frontend-modern/src/features/alerts/thresholds/__tests__/helpers.test.ts",