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
Tint Docker host and Machines rows for their drawer's alerts
rcourtman15dc868c7e3a
diff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.mdindex c270dc70d3..362f48ba9a 100644--- a/docs/release-control/v6/internal/subsystems/alerts.md+++ b/docs/release-control/v6/internal/subsystems/alerts.md@@ -3464,3 +3464,12 @@ metrics target, and for agent and Docker hosts `agent:<id>` andorders them most severe first. The Machines/Infrastructure and Docker hostdrawers build their "Needs attention" rows from it; resources no longer embedan alert list, so no drawer can silently read an always-empty copy.+`getUnifiedResourceAlertStyles` computes row highlighting from that same set,+so the Docker hosts and Machines table rows tint for exactly the unacknowledged+alerts their drawers list. Docker host rows previously matched the row id and+display name against `getAlertStyles`; Docker alerts are keyed+`docker:<host source id>` and carry the hostname as their node, so a host whose+display name differs from its hostname was never highlighted, and Machines rows+had no alert highlighting at all. `getAlertStyles` keeps its+id-plus-node-name matching for the platform tables whose alerts are keyed that+way.diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex 61544b1e06..63f02af058 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -4990,7 +4990,10 @@ name, so it keeps the shared single-line rhythm. Drawers for unified resourceswebsocket `activeAlerts` map through `getAlertsForUnifiedResource`(`frontend-modern/src/utils/alerts.ts`), most severe first, never from aresource-embedded list, and show each alert's resource name and metric beside-its text like the other drawers. The remaining Overview rows are additive+its text like the other drawers. Their table rows take the platform host rows'+red (critical) or yellow tint from the same set through+`getUnifiedResourceAlertStyles`, only for unacknowledged alerts and never on+an expanded row, so a row and its drawer agree. The remaining Overview rows are additiveoperator context that the parent table row cannot carry, such as OS/runtime,Pulse observation or action coverage, primary reachability, protection gaps,pending updates, or an identified service. Routine health, placement, anddiff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.mdindex b91304e4d5..9a954da020 100644--- a/docs/release-control/v6/internal/subsystems/unified-resources.md+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md@@ -2225,7 +2225,12 @@ storage); agent and Docker hosts also answer to `agent:<id>` andstated when it is a whole sentence of an open alert's text, because a unifiedincident alert on storage with consumers joins the incident summary and itsimpact ("... above threshold. Affects 2 dependent resources: ...") and neither-may repeat beside it.+may repeat beside it. The Docker hosts (`DockerHostsTable.tsx`) and Machines+(`AgentsMachinesTable.tsx`) table rows tint from the same set through+`getUnifiedResourceAlertStyles`, so a collapsed row never looks healthy while+its drawer lists an unacknowledged alert (an expanded row drops the tint while+its drawer shows the alerts); acknowledged alerts stay in the drawer without+tinting the row.Machine and host overview cards that render compact system, hardware, disk,and temperature facts must also compose the frontend-primitives`InfoCardKeyValueRow`. Mobile rows retain their condensed endpoint layout;diff --git a/frontend-modern/browser-verification/18ad64507908105c.json b/frontend-modern/browser-verification/18ad64507908105c.jsonnew file mode 100644index 0000000000..6f9f942724--- /dev/null+++ b/frontend-modern/browser-verification/18ad64507908105c.json@@ -0,0 +1,43 @@+{+ "version": 1,+ "base_sha": "362ab2f235ca1f82e51cbe960d1ce04219ffb62b",+ "verified_at": "2026-10-06T14:05:00Z",+ "result": "passed",+ "changed_paths": [+ "frontend-modern/src/features/docker/DockerHostsTable.tsx",+ "frontend-modern/src/features/standalone/AgentsMachinesTable.tsx",+ "frontend-modern/src/utils/alerts.ts"+ ],+ "content_sha256": {+ "frontend-modern/src/features/docker/DockerHostsTable.tsx": "2084327e67ed183015dcae2f3b6594896f265a1afc3e5b8a288e54ae51ff2b72",+ "frontend-modern/src/features/standalone/AgentsMachinesTable.tsx": "dc45b46be78052d29b0560dce529d5368cd3100df277dd555f3acbf7ef7d83d4",+ "frontend-modern/src/utils/alerts.ts": "65f4d4c09dea426255c394cb5d0713212f80abb1076ffae16d418c0e7ee0e061"+ },+ "routes": ["/docker/overview", "/standalone/machines", "/alerts"],+ "viewports": [+ {+ "width": 1440,+ "height": 900+ },+ {+ "width": 390,+ "height": 844+ }+ ],+ "states": [+ "Private mock stack serving an embedded build of this tree (base da3fcf69f7, PR 2575; rebased unchanged onto its merge 362ab2f235) on its own port; mock mode skips CheckHost, so the private binary added that call through a go build overlay of internal/monitoring/monitor_alerts.go that is not part of this commit",+ "Docker hosts: Ops Services 01 (hostname ops-services-01, Docker host source orion-2-mock) row tinted red with three open docker-service-health alerts (two critical, one warning) that its drawer lists; the previous id + display-name match tinted nothing for this host",+ "Docker hosts: auth-service-01 row red with the one container-health alert its drawer lists; Edge Apps 01 and edge-proxy-01 untinted with no Needs attention section in their drawers",+ "Machines: Apollo-114 row tinted red for a backend-raised agent:host-linux-1 memory alert (per-host memory trigger lowered to 5% on the private stack) that its drawer lists; Spectrum-709 untinted with no drawer alerts",+ "Every Docker host and machine row checked against its own drawer: tinted exactly when the drawer lists an unacknowledged alert",+ "After acknowledging the Apollo-114 alert, its row is untinted while its drawer still lists the alert as Acknowledged",+ "Light and dark themes at 1440px and 390px: red-50 / red-950/25 row backgrounds on the alerted rows only",+ "No page errors"+ ],+ "interactions": [+ "Open Docker overview and expand then collapse each host row drawer, reading its Needs attention list",+ "Open Machines and expand then collapse each machine row drawer, reading its Needs attention list",+ "Acknowledge the Apollo-114 memory alert from its Alerts page card, return to Machines and expand its drawer",+ "Repeat the row tint checks at the 390px viewport and in dark mode"+ ]+}diff --git a/frontend-modern/src/features/docker/DockerHostsTable.tsx b/frontend-modern/src/features/docker/DockerHostsTable.tsxindex cad5f8ad5e..fbaa7b0858 100644--- a/frontend-modern/src/features/docker/DockerHostsTable.tsx+++ b/frontend-modern/src/features/docker/DockerHostsTable.tsx@@ -10,7 +10,7 @@ import { StackedMemoryBar } from '@/components/Workloads/StackedMemoryBar';import { StackedDiskBar } from '@/components/Workloads/StackedDiskBar';import { TableCell, TableRow } from '@/components/shared/Table';import { getSimpleStatusIndicator } from '@/utils/status';-import { getAlertStyles } from '@/utils/alerts';+import { getUnifiedResourceAlertStyles } from '@/utils/alerts';import { useWebSocket } from '@/contexts/appRuntime';import { useAlertsActivation } from '@/stores/alertsActivation';import { hostOverrideIdCandidates } from '@/features/alerts/alertOverridesModel';@@ -374,8 +374,11 @@ export const DockerHostsTable: Component<{const isSelected = () => selectedHostId() === host.id;const toggleDrawer = () =>setSelectedHostId((current) => (current === host.id ? null : host.id));+ // The same open alerts the host's drawer lists: Docker alerts+ // are keyed on the Docker host id and carry the hostname, so+ // matching the row's id or display name finds none of them.const hostAlertStyles = createMemo(() =>- getAlertStyles(host.id, activeAlerts, alertsEnabled(), name()),+ getUnifiedResourceAlertStyles(host, activeAlerts, alertsEnabled()),);// Metrics from a host that stopped reporting are its last// values, not live readings; say so instead of showing themdiff --git a/frontend-modern/src/features/docker/__tests__/DockerHostsTable.test.tsx b/frontend-modern/src/features/docker/__tests__/DockerHostsTable.test.tsxindex f3f231e4a4..f5a4d1b7d3 100644--- a/frontend-modern/src/features/docker/__tests__/DockerHostsTable.test.tsx+++ b/frontend-modern/src/features/docker/__tests__/DockerHostsTable.test.tsx@@ -1,7 +1,7 @@import { cleanup, fireEvent, render, screen, within } from '@solidjs/testing-library';import { afterEach, describe, expect, it, vi } from 'vitest';-import type { Disk } from '@/types/api';+import type { Alert, Disk } from '@/types/api';import type { Resource } from '@/types/resource';import type { MetricDisplayThresholds } from '@/utils/metricThresholds';import { DockerHostsTable } from '../DockerHostsTable';@@ -38,8 +38,10 @@ vi.mock('@/components/shared/responsive', () => ({),}));+const activeAlertsMock = vi.hoisted(() => ({}) as Record<string, Alert>);+vi.mock('@/contexts/appRuntime', () => ({- useWebSocket: () => ({ activeAlerts: {} as Record<string, never> }),+ useWebSocket: () => ({ activeAlerts: activeAlertsMock }),}));vi.mock('@/stores/alertsActivation', () => ({useAlertsActivation: () => ({@@ -125,6 +127,7 @@ const makeDockerHost = (overrides: Partial<Resource> = {}): Resource => ({afterEach(() => {cleanup();vi.clearAllMocks();+ for (const key of Object.keys(activeAlertsMock)) delete activeAlertsMock[key];});describe('DockerHostsTable', () => {@@ -214,6 +217,64 @@ describe('DockerHostsTable', () => {);});+ it('tints a host row for the Docker alerts its drawer lists, not by display name', () => {+ // Docker alerts are keyed on the Docker host id and carry the hostname+ // as their node; neither is the row's id or its display name.+ const dockerAlert = (id: string, resourceId: string, level: Alert['level']): Alert => ({+ id,+ type: 'docker-service-health',+ level,+ resourceId,+ resourceName: id,+ node: 'ops-services-01',+ instance: '',+ message: id,+ value: 0,+ threshold: 0,+ startTime: '2026-10-06T10:00:00Z',+ acknowledged: false,+ });+ Object.assign(activeAlertsMock, {+ service: dockerAlert('service', 'docker:orion-2-mock/service/svc-backend-1', 'warning'),+ offline: dockerAlert('offline', 'docker:orion-20-mock', 'critical'),+ });+ const hostWithSource = (id: string, name: string, hostSourceId: string) =>+ makeDockerHost({+ id,+ name,+ displayName: name,+ docker: { hostSourceId, hostname: name.toLowerCase().replaceAll(' ', '-') },+ });++ render(() => (+ <DockerHostsTable+ resources={[+ hostWithSource('agent-aa22ff2b2bc3257d', 'Ops Services 01', 'orion-2-mock'),+ hostWithSource('agent-bb33', 'Ops Services 20', 'orion-20-mock'),+ hostWithSource('agent-cc44', 'Quiet Host', 'quiet-mock'),+ ]}+ emptyIcon={<span />}+ emptyTitle="No Docker hosts"+ emptyDescription="No hosts"+ showToolbar={false}+ />+ ));++ const row = (id: string) => document.querySelector(`[data-docker-host-row="${id}"]`)!;+ expect(row('agent-aa22ff2b2bc3257d')).toHaveClass('bg-yellow-50');+ expect(row('agent-bb33')).toHaveClass('bg-red-50');+ expect(row('agent-cc44')).not.toHaveClass('bg-yellow-50');+ expect(row('agent-cc44')).not.toHaveClass('bg-red-50');++ // The tinted row's drawer lists the same alert; the quiet host's lists none.+ fireEvent.click(row('agent-aa22ff2b2bc3257d').querySelector('button[aria-controls]')!);+ const attention = screen.getByTestId('drawer-attention-section');+ expect(within(attention).getAllByRole('listitem')).toHaveLength(1);+ expect(attention).toHaveTextContent('service');+ fireEvent.click(row('agent-cc44').querySelector('button[aria-controls]')!);+ expect(screen.queryByTestId('drawer-attention-section')).toBeNull();+ });+it('colors row metric bars from alert-configured thresholds, not display defaults', () => {render(() => (<DockerHostsTablediff --git a/frontend-modern/src/features/standalone/AgentsMachinesTable.tsx b/frontend-modern/src/features/standalone/AgentsMachinesTable.tsxindex 4b99ca84a0..ddd6920a84 100644--- a/frontend-modern/src/features/standalone/AgentsMachinesTable.tsx+++ b/frontend-modern/src/features/standalone/AgentsMachinesTable.tsx@@ -25,6 +25,7 @@ import { TemperatureGauge } from '@/components/shared/TemperatureGauge';import { ResourceNameWithWebInterfaceLink } from '@/components/shared/WebInterfaceLink';import { TableCell, TableHead, TableRow } from '@/components/shared/Table';import { TooltipPortal } from '@/components/shared/TooltipPortal';+import { useWebSocket } from '@/contexts/appRuntime';import { hostOverrideIdCandidates } from '@/features/alerts/alertOverridesModel';import {compareAgentVersions,@@ -61,6 +62,7 @@ import type { Disk } from '@/types/api';import type { Resource, ResourceAvailabilityMeta } from '@/types/resource';import type { MetricDisplayThresholds } from '@/utils/metricThresholds';import { getActionableAgentIdFromResource } from '@/utils/agentResources';+import { getUnifiedResourceAlertStyles } from '@/utils/alerts';import { formatBytes, formatSpeed, formatObservedSpeed, normalizeDiskArray } from '@/utils/format';import { STORAGE_KEYS } from '@/utils/localStorage';import { useAlertsActivation } from '@/stores/alertsActivation';@@ -1196,6 +1198,7 @@ export const AgentsMachinesTable: Component<{}tableState.resetFilters();};+ const { activeAlerts } = useWebSocket();const alertsActivation = useAlertsActivation();const [sortKey, setSortKey] = createSignal<AgentMachineSortKey>('name');const [sortDirection, setSortDirection] = createSignal<'asc' | 'desc'>('asc');@@ -1577,6 +1580,22 @@ export const AgentsMachinesTable: Component<{getAgentMachineThermalPressurePresentation(machine);const isExpanded = () => drawer.isExpanded(machine);const detailRowId = () => drawer.detailRowId(machine);+ // Tint the row for the open alerts its drawer lists, so a+ // machine over a threshold stands out without opening it.+ const machineAlertStyles = createMemo(() =>+ getUnifiedResourceAlertStyles(+ machine,+ activeAlerts,+ alertsActivation.detectionEnabled(),+ ),+ );+ const machineAlertBg = () => {+ const s = machineAlertStyles();+ if (!s.hasUnacknowledgedAlert) return '';+ return s.severity === 'critical'+ ? 'bg-red-50 dark:bg-red-950/25'+ : 'bg-yellow-50 dark:bg-yellow-950/25';+ };const agentMetadataId = () => agentMetadataIdFor(machine);const agentRemovalId = () => agentRemovalIdFor(machine);const savedWebInterfaceUrl = () => savedAgentCustomUrlFor(agentMetadataId());@@ -1587,7 +1606,9 @@ export const AgentsMachinesTable: Component<{return (<><TableRow- class={`${getPlatformResourceDetailRowClass(isExpanded())} text-[11px] sm:text-xs`}+ class={`${getPlatformResourceDetailRowClass(isExpanded())} text-[11px] sm:text-xs ${+ isExpanded() ? '' : machineAlertBg()+ }`}data-agents-machine-row={machine.id}onClick={toggleDetails}>diff --git a/frontend-modern/src/features/standalone/__tests__/AgentsMachinesTable.test.tsx b/frontend-modern/src/features/standalone/__tests__/AgentsMachinesTable.test.tsxindex 723f0ff3c0..09e91f4919 100644--- a/frontend-modern/src/features/standalone/__tests__/AgentsMachinesTable.test.tsx+++ b/frontend-modern/src/features/standalone/__tests__/AgentsMachinesTable.test.tsx@@ -1,7 +1,9 @@import { cleanup, fireEvent, render, screen, waitFor, within } from '@solidjs/testing-library';+import { createStore, reconcile } from 'solid-js/store';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import { AgentMetadataAPI } from '@/api/agentMetadata';import { MonitoringAPI } from '@/api/monitoring';+import type { Alert } from '@/types/api';import type { Resource } from '@/types/resource';import { STORAGE_KEYS } from '@/utils/localStorage';import { RESOURCE_METADATA_CHANGED_EVENT } from '@/utils/resourceMetadataEvents';@@ -33,6 +35,13 @@ vi.mock('@/api/monitoring', () => ({},}));+// The websocket's activeAlerts is a Solid store, so rows must follow it live.+const activeAlertsRef = vi.hoisted(() => ({ current: {} as Record<string, Alert> }));++vi.mock('@/contexts/appRuntime', () => ({+ useWebSocket: () => ({ activeAlerts: activeAlertsRef.current }),+}));+vi.mock('@/stores/notifications', () => ({notificationStore: {success: vi.fn(),@@ -111,6 +120,9 @@ const resource = (overrides: Partial<Resource>): Resource =>...overrides,}) as Resource;+const [activeAlerts, setActiveAlerts] = createStore<Record<string, Alert>>({});+activeAlertsRef.current = activeAlerts;+const emptyIcon = <span data-testid="empty-icon" />;const getAllAgentMetadataMock = vi.mocked(AgentMetadataAPI.getAllMetadata);const deleteAgentMetadataMock = vi.mocked(AgentMetadataAPI.deleteMetadata);@@ -140,6 +152,7 @@ beforeEach(() => {afterEach(() => {cleanup();+ setActiveAlerts(reconcile({}));window.localStorage.clear();vi.unstubAllGlobals();vi.clearAllMocks();@@ -190,6 +203,65 @@ describe('AgentsMachinesTable', () => {expect(onExternalStatusChange).not.toHaveBeenCalled();});+ it('tints a machine row for the open alerts its drawer lists', () => {+ const agentAlert = (id: string, resourceId: string, overrides: Partial<Alert> = {}): Alert => ({+ id,+ type: 'memory',+ level: 'warning',+ resourceId,+ resourceName: id,+ node: id,+ instance: '',+ message: id,+ value: 91,+ threshold: 85,+ startTime: '2026-10-06T10:00:00Z',+ acknowledged: false,+ ...overrides,+ });+ // Agent alerts are keyed "agent:<agentId>", never the row's resource id.+ setActiveAlerts({+ memory: agentAlert('memory', 'agent:host-tower'),+ disk: agentAlert('disk', 'agent:host-nas/disk:data', { type: 'disk', level: 'critical' }),+ acked: agentAlert('acked', 'agent:host-pi', { acknowledged: true }),+ });+ const machine = (id: string, agentId: string) =>+ resource({ id, name: id, agent: { agentId } } as Partial<Resource>);++ render(() => (+ <AgentsMachinesTable+ resources={[+ machine('tower', 'host-tower'),+ machine('nas', 'host-nas'),+ machine('pi', 'host-pi'),+ machine('laptop', 'host-laptop'),+ ]}+ emptyIcon={emptyIcon}+ emptyTitle="No machines"+ emptyDescription="Install Pulse Agent."+ />+ ));++ const row = (id: string) => document.querySelector(`[data-agents-machine-row="${id}"]`)!;+ expect(row('tower')).toHaveClass('bg-yellow-50');+ expect(row('nas')).toHaveClass('bg-red-50');+ // An acknowledged alert stays in the drawer but no longer tints the row.+ for (const id of ['pi', 'laptop']) {+ expect(row(id)).not.toHaveClass('bg-yellow-50');+ expect(row(id)).not.toHaveClass('bg-red-50');+ }++ // The tint follows the live alert store without a re-render: acknowledging+ // clears it, escalation turns it red, and resolution clears it.+ setActiveAlerts('memory', 'acknowledged', true);+ expect(row('tower')).not.toHaveClass('bg-yellow-50');+ setActiveAlerts('memory', { acknowledged: false, level: 'critical' });+ expect(row('tower')).toHaveClass('bg-red-50');+ setActiveAlerts(reconcile({}));+ expect(row('tower')).not.toHaveClass('bg-red-50');+ expect(row('nas')).not.toHaveClass('bg-red-50');+ });+it('keeps the column picker inside the shared View preferences disclosure', async () => {render(() => (<AgentsMachinesTablediff --git a/frontend-modern/src/utils/__tests__/alerts.test.ts b/frontend-modern/src/utils/__tests__/alerts.test.tsindex 5ef3a4c6aa..f57a32613a 100644--- a/frontend-modern/src/utils/__tests__/alerts.test.ts+++ b/frontend-modern/src/utils/__tests__/alerts.test.ts@@ -1,5 +1,10 @@import { describe, expect, it } from 'vitest';-import { getAlertsForResource, getAlertsForUnifiedResource, getAlertStyles } from '@/utils/alerts';+import {+ getAlertsForResource,+ getAlertsForUnifiedResource,+ getAlertStyles,+ getUnifiedResourceAlertStyles,+} from '@/utils/alerts';import type { Alert } from '@/types/api';import type { Resource } from '@/types/resource';@@ -375,4 +380,70 @@ describe('getAlertsForUnifiedResource', () => {expect(ids(getAlertsForUnifiedResource(pod, active, true))).toEqual(['pod-incident']);});++ describe('getUnifiedResourceAlertStyles', () => {+ // Mock "Ops Services 01": the Docker alerts carry the hostname as their+ // node, which is neither the row's id nor its display name.+ const dockerHost = resource({+ id: 'agent-aa22ff2b2bc3257d',+ type: 'docker-host',+ name: 'Ops Services 01',+ displayName: 'Ops Services 01',+ platformType: 'docker',+ docker: { hostSourceId: 'orion-2-mock', hostname: 'ops-services-01' },+ canonicalIdentity: {+ displayName: 'Ops Services 01',+ primaryId: 'docker-host:orion-2-mock',+ aliases: ['docker-host:orion-2-mock', 'orion-2-mock'],+ },+ } as Partial<Resource>);+ const serviceAlert = (id: string, overrides: Partial<Alert> = {}) =>+ alert(id, `docker:orion-2-mock/service/${id}`, {+ type: 'docker-service-health',+ node: 'ops-services-01',+ ...overrides,+ });++ it('tints a Docker host row for the service alerts its drawer lists', () => {+ const active = byId(serviceAlert('svc-1'), serviceAlert('svc-2'), serviceAlert('svc-3'));++ const styles = getUnifiedResourceAlertStyles(dockerHost, active, true);+ expect(styles.hasUnacknowledgedAlert).toBe(true);+ expect(styles.severity).toBe('warning');+ expect(styles.unacknowledgedCount).toBe(3);+ // The row's previous id + display-name match found none of them.+ expect(getAlertStyles(dockerHost.id, active, true, 'Ops Services 01').hasAlert).toBe(false);+ });++ it('tints a machine row for an alert on its agent key', () => {+ const machine = resource({+ id: 'agent-acdfdee2953587fb',+ name: 'Apollo-114',+ agent: { agentId: 'host-linux-1' },+ } as Partial<Resource>);+ const active = byId(+ alert('memory', 'agent:host-linux-1', { type: 'memory' }),+ alert('disk', 'agent:host-linux-1/disk:data', { level: 'critical' }),+ );++ const styles = getUnifiedResourceAlertStyles(machine, active, true);+ expect(styles.severity).toBe('critical');+ expect(styles.alertCount).toBe(2);+ });++ it('leaves the row untinted when every open alert is acknowledged', () => {+ const active = byId(serviceAlert('svc-1', { acknowledged: true, level: 'critical' }));++ const styles = getUnifiedResourceAlertStyles(dockerHost, active, true);+ expect(styles.hasUnacknowledgedAlert).toBe(false);+ expect(styles.hasAcknowledgedOnlyAlert).toBe(true);+ expect(styles.severity).toBeNull();+ });++ it('reports nothing while alert detection is off', () => {+ const styles = getUnifiedResourceAlertStyles(dockerHost, byId(serviceAlert('svc-1')), false);+ expect(styles.hasAlert).toBe(false);+ expect(styles.rowClass).toBe('');+ });+ });});diff --git a/frontend-modern/src/utils/alerts.ts b/frontend-modern/src/utils/alerts.tsindex e6e92993f1..b292e10c40 100644--- a/frontend-modern/src/utils/alerts.ts+++ b/frontend-modern/src/utils/alerts.ts@@ -32,13 +32,36 @@ export const getAlertStyles = (return noAlertStyles;}- const alertsForResource = getAlertsForResource(- Array.isArray(resourceId) ? resourceId : [resourceId],- activeAlerts,- alertsEnabled,- nodeMatch,+ return getAlertStylesForAlerts(+ getAlertsForResource(+ Array.isArray(resourceId) ? resourceId : [resourceId],+ activeAlerts,+ alertsEnabled,+ nodeMatch,+ ),);+};++// Alert highlighting for a unified resource's row, from the open alerts its+// drawer lists under "Needs attention" (getAlertsForUnifiedResource). Matching+// by display name misses machines whose alerts are keyed on the agent or+// Docker host id, and a row that disagrees with its own drawer hides the+// problem until someone opens it.+export const getUnifiedResourceAlertStyles = (+ resource: Resource,+ activeAlerts: Record<string, Alert>,+ alertsEnabled: boolean | undefined = isAlertsDetectionEnabled(),+) => {+ if (!alertsEnabled) {+ return noAlertStyles;+ }+ return getAlertStylesForAlerts(+ getAlertsForUnifiedResource(resource, activeAlerts, alertsEnabled),+ );+};++function getAlertStylesForAlerts(alertsForResource: Alert[]) {const unacknowledgedAlerts = alertsForResource.filter((alert) => !alert.acknowledged);const acknowledgedAlerts = alertsForResource.filter((alert) => alert.acknowledged);@@ -134,7 +157,7 @@ export const getAlertStyles = (acknowledgedCount,hasAcknowledgedOnlyAlert: !hasUnacknowledgedAlert && acknowledgedCount > 0,};-};+}export function getAlertsForResource(resourceIds: string[],