Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Align dashboard runtime finding actions

rcourtman0bac4b393705
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 2d4ff2a7a9..e370e5c75c 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -601,6 +601,14 @@ of drifting back into a page-local dashboard panel cluster.
that same dashboard overview boundary so the problem-resource severity contract
stays shared with `ProblemResourcesTable.tsx` instead of floating as an
unowned helper.
+That same dashboard overview boundary must consume the governed Patrol finding
+presentation helpers when it surfaces Patrol findings in compact form. In
+`frontend-modern/src/features/dashboardOverview/ActionRequiredPanel.tsx`,
+Patrol-owned runtime findings must use the shared compact badge, title, and
+primary-action/manual-control contracts from
+`frontend-modern/src/utils/aiFindingPresentation.ts` rather than rendering raw
+`Pulse Patrol:` titles or generic snooze/dismiss controls that the Patrol
+runtime lifecycle rejects.
Feature-owned alert shells under `frontend-modern/src/features/alerts/` now
also treat shared action runtime as a first-class feature owner instead of
diff --git a/frontend-modern/src/features/dashboardOverview/ActionRequiredPanel.tsx b/frontend-modern/src/features/dashboardOverview/ActionRequiredPanel.tsx
index 7a2f033e7e..4201051cbf 100644
--- a/frontend-modern/src/features/dashboardOverview/ActionRequiredPanel.tsx
+++ b/frontend-modern/src/features/dashboardOverview/ActionRequiredPanel.tsx
@@ -6,10 +6,12 @@ import { notificationStore } from '@/stores/notifications';
import { AlertsAPI } from '@/api/alerts';
import { hasFeature } from '@/stores/license';
import { formatRelativeTime } from '@/utils/format';
-import { getAlertSeverityBadgeClass } from '@/utils/alertSeverityPresentation';
import { getApprovalRiskPresentation } from '@/utils/approvalRiskPresentation';
import {
- getFindingSeverityCompactLabel,
+ getFindingCompactBadgePresentation,
+ getFindingManualControlsPresentation,
+ getFindingPrimaryActionPresentation,
+ getFindingTitlePresentation,
getInvestigationOutcomeBadgeClasses,
getInvestigationOutcomeLabel,
} from '@/utils/aiFindingPresentation';
@@ -265,60 +267,80 @@ function FindingsAttentionRows(props: { findings: UnifiedFinding[] }) {
</p>
<ul class="space-y-1" role="list">
<For each={props.findings}>
- {(finding) => (
- <li class="flex items-center gap-2 py-1.5 px-2 -mx-2 rounded hover:bg-surface-hover transition-colors">
- <span class={getAlertSeverityBadgeClass(finding.severity)}>
- {getFindingSeverityCompactLabel(finding.severity)}
- </span>
- <p
- class="min-w-0 text-xs font-medium text-base-content truncate flex-1"
- title={finding.title}
- >
- {finding.title}
- </p>
- <Show when={finding.investigationOutcome}>
- {(outcome) => (
- <span
- class={`shrink-0 inline-flex items-center rounded border px-1.5 py-0.5 text-[10px] font-medium ${getInvestigationOutcomeBadgeClasses(outcome())}`}
+ {(finding) => {
+ const compactBadge = getFindingCompactBadgePresentation(finding);
+ const title = getFindingTitlePresentation(finding).label;
+ const primaryAction = getFindingPrimaryActionPresentation(finding);
+ const manualControls = getFindingManualControlsPresentation(finding);
+
+ return (
+ <li class="flex items-center gap-2 py-1.5 px-2 -mx-2 rounded hover:bg-surface-hover transition-colors">
+ <span class={compactBadge.badgeClasses}>{compactBadge.label}</span>
+ <p class="min-w-0 text-xs font-medium text-base-content truncate flex-1" title={title}>
+ {title}
+ </p>
+ <Show when={finding.investigationOutcome}>
+ {(outcome) => (
+ <span
+ class={`shrink-0 inline-flex items-center rounded border px-1.5 py-0.5 text-[10px] font-medium ${getInvestigationOutcomeBadgeClasses(outcome())}`}
+ >
+ {getInvestigationOutcomeLabel(outcome())}
+ </span>
+ )}
+ </Show>
+ <div class="shrink-0 flex items-center gap-1">
+ <Show
+ when={primaryAction}
+ fallback={
+ <button
+ type="button"
+ onClick={() => handleReinvestigate(finding)}
+ disabled={actionLoading() === finding.id}
+ class="flex items-center gap-1 px-2 py-1 text-[10px] font-medium text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900 rounded transition-colors disabled:opacity-50"
+ title="Re-investigate this finding"
+ >
+ <RefreshCwIcon
+ class={`w-3 h-3 ${actionLoading() === finding.id ? 'animate-spin' : ''}`}
+ />
+ Retry
+ </button>
+ }
>
- {getInvestigationOutcomeLabel(outcome())}
- </span>
- )}
- </Show>
- <div class="shrink-0 flex items-center gap-1">
- <button
- type="button"
- onClick={() => handleReinvestigate(finding)}
- disabled={actionLoading() === finding.id}
- class="flex items-center gap-1 px-2 py-1 text-[10px] font-medium text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900 rounded transition-colors disabled:opacity-50"
- title="Re-investigate this finding"
- >
- <RefreshCwIcon
- class={`w-3 h-3 ${actionLoading() === finding.id ? 'animate-spin' : ''}`}
- />
- Retry
- </button>
- <button
- type="button"
- onClick={() => handleSnooze(finding)}
- disabled={actionLoading() === finding.id}
- class="px-2 py-1 text-[10px] font-medium text-muted hover:bg-surface-hover rounded transition-colors disabled:opacity-50"
- title="Snooze for 24 hours"
- >
- Snooze
- </button>
- <button
- type="button"
- onClick={() => handleDismiss(finding)}
- disabled={actionLoading() === finding.id}
- class="px-2 py-1 text-[10px] font-medium text-muted hover:bg-surface-hover rounded transition-colors disabled:opacity-50"
- title="Dismiss this finding"
- >
- Dismiss
- </button>
- </div>
- </li>
- )}
+ {(action) => (
+ <a
+ href={action().href}
+ class="px-2 py-1 text-[10px] font-medium text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900 rounded transition-colors"
+ >
+ {action().label}
+ </a>
+ )}
+ </Show>
+ <Show when={manualControls.snooze}>
+ <button
+ type="button"
+ onClick={() => handleSnooze(finding)}
+ disabled={actionLoading() === finding.id}
+ class="px-2 py-1 text-[10px] font-medium text-muted hover:bg-surface-hover rounded transition-colors disabled:opacity-50"
+ title="Snooze for 24 hours"
+ >
+ Snooze
+ </button>
+ </Show>
+ <Show when={manualControls.dismiss}>
+ <button
+ type="button"
+ onClick={() => handleDismiss(finding)}
+ disabled={actionLoading() === finding.id}
+ class="px-2 py-1 text-[10px] font-medium text-muted hover:bg-surface-hover rounded transition-colors disabled:opacity-50"
+ title="Dismiss this finding"
+ >
+ Dismiss
+ </button>
+ </Show>
+ </div>
+ </li>
+ );
+ }}
</For>
</ul>
<Show when={props.findings.length > 5}>
diff --git a/frontend-modern/src/features/dashboardOverview/__tests__/ActionRequiredPanel.test.tsx b/frontend-modern/src/features/dashboardOverview/__tests__/ActionRequiredPanel.test.tsx
new file mode 100644
index 0000000000..b0d438c802
--- /dev/null
+++ b/frontend-modern/src/features/dashboardOverview/__tests__/ActionRequiredPanel.test.tsx
@@ -0,0 +1,101 @@
+import { readFileSync } from 'node:fs';
+import { resolve } from 'node:path';
+import { describe, expect, it } from 'vitest';
+import {
+ getFindingCompactBadgePresentation,
+ getFindingManualControlsPresentation,
+ getFindingPrimaryActionPresentation,
+ getFindingTitlePresentation,
+} from '@/utils/aiFindingPresentation';
+
+const actionRequiredPanelSource = readFileSync(
+ resolve(__dirname, '..', 'ActionRequiredPanel.tsx'),
+ 'utf-8',
+);
+
+describe('ActionRequiredPanel', () => {
+ it('uses runtime-qualified compact badges for Patrol runtime findings', () => {
+ expect(
+ getFindingCompactBadgePresentation({
+ severity: 'warning',
+ resourceId: 'ai-service',
+ resourceName: 'Pulse Patrol Service',
+ title: 'Pulse Patrol: Insufficient API credits',
+ }),
+ ).toEqual({
+ label: 'Runtime issue',
+ badgeClasses:
+ 'border-sky-200 bg-sky-50 text-sky-700 dark:border-sky-800 dark:bg-sky-900 dark:text-sky-300',
+ });
+ });
+
+ it('keeps compact severity labels for infrastructure findings', () => {
+ expect(
+ getFindingCompactBadgePresentation({
+ severity: 'warning',
+ resourceId: 'vm-101',
+ resourceName: 'db-01',
+ title: 'Disk nearly full',
+ }),
+ ).toEqual({
+ label: 'WARN',
+ badgeClasses:
+ 'border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-800 dark:bg-amber-900 dark:text-amber-300',
+ });
+ });
+
+ it('routes dashboard finding rows through the shared Patrol title and action helpers', () => {
+ expect(actionRequiredPanelSource).toContain(
+ 'const compactBadge = getFindingCompactBadgePresentation(finding);',
+ );
+ expect(actionRequiredPanelSource).toContain(
+ 'const title = getFindingTitlePresentation(finding).label;',
+ );
+ expect(actionRequiredPanelSource).toContain(
+ 'const primaryAction = getFindingPrimaryActionPresentation(finding);',
+ );
+ expect(actionRequiredPanelSource).toContain(
+ 'const manualControls = getFindingManualControlsPresentation(finding);',
+ );
+ expect(actionRequiredPanelSource).toContain('{compactBadge.label}');
+ expect(actionRequiredPanelSource).toContain('title={title}');
+ expect(actionRequiredPanelSource).toContain('{title}');
+ });
+
+ it('uses Open AI Settings instead of rejected generic controls for Patrol runtime findings', () => {
+ expect(
+ getFindingTitlePresentation({
+ resourceId: 'ai-service',
+ resourceName: 'Pulse Patrol Service',
+ title: 'Pulse Patrol: Insufficient API credits',
+ }),
+ ).toEqual({
+ label: 'Insufficient API credits',
+ });
+ expect(
+ getFindingPrimaryActionPresentation({
+ resourceId: 'ai-service',
+ resourceName: 'Pulse Patrol Service',
+ title: 'Pulse Patrol: Insufficient API credits',
+ }),
+ ).toEqual({
+ label: 'Open AI Settings',
+ href: '/settings/system-ai',
+ });
+ expect(
+ getFindingManualControlsPresentation({
+ resourceId: 'ai-service',
+ resourceName: 'Pulse Patrol Service',
+ title: 'Pulse Patrol: Insufficient API credits',
+ }),
+ ).toEqual({
+ acknowledge: false,
+ snooze: false,
+ dismiss: false,
+ });
+ expect(actionRequiredPanelSource).toContain('when={primaryAction}');
+ expect(actionRequiredPanelSource).toContain('{action().label}');
+ expect(actionRequiredPanelSource).toContain('manualControls.snooze');
+ expect(actionRequiredPanelSource).toContain('manualControls.dismiss');
+ });
+});
diff --git a/frontend-modern/src/utils/aiFindingPresentation.ts b/frontend-modern/src/utils/aiFindingPresentation.ts
index e7fdf4ca56..c748ea4484 100644
--- a/frontend-modern/src/utils/aiFindingPresentation.ts
+++ b/frontend-modern/src/utils/aiFindingPresentation.ts
@@ -236,6 +236,11 @@ export interface FindingSeverityPresentation {
uppercase: boolean;
}
+export interface FindingCompactBadgePresentation {
+ label: string;
+ badgeClasses: string;
+}
+
export const getFindingSourceLabel = (source: UnifiedFinding['source'] | string): string =>
FINDING_SOURCE_LABELS[source] || source;
@@ -320,6 +325,23 @@ export const getFindingSeverityCompactLabel = (
severity: UnifiedFinding['severity'] | string,
): string => FINDING_SEVERITY_COMPACT_LABELS[severity] || String(severity).toUpperCase();
+export const getFindingCompactBadgePresentation = (
+ finding: Pick<UnifiedFinding, 'severity' | 'resourceId' | 'resourceName' | 'title'>,
+): FindingCompactBadgePresentation => {
+ if (isPatrolRuntimeFinding(finding)) {
+ const severityPresentation = getFindingSeverityPresentation(finding);
+ return {
+ label: severityPresentation.label,
+ badgeClasses: severityPresentation.badgeClasses,
+ };
+ }
+
+ return {
+ label: getFindingSeverityCompactLabel(finding.severity),
+ badgeClasses: getFindingSeverityBadgeClasses(finding.severity),
+ };
+};
+
export const isPatrolRuntimeFinding = (
finding: Pick<UnifiedFinding, 'resourceId' | 'resourceName' | 'title'>,
): boolean => {