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.

Distinguish auto-suppressed dismissals from manual operator dismissals on the row

rcourtman3f783a7d983e
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index c271d7001b..b8f20c0819 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -1222,7 +1222,21 @@ auto-dismissed under `operator_state_cause` re-detects after the
suppression has lifted (maintenance window passed,
`IntentionallyOffline` cleared, or provider unwired), the
new-finding path wakes it with a `suppression_lifted` lifecycle
-event carrying the previous cause. Time-bounded operator
+event carrying the previous cause.
+
+The operator-facing FindingsPanel must also distinguish
+auto-suppressed dismissals from manual operator dismissals on the
+row. Both serialize as `DismissedReason="expected_behavior"`, but
+the auto-dismiss carries `operator_state_cause` lifecycle metadata.
+A parallel "auto: maintenance" / "auto: intentionally offline"
+badge sits next to the existing dismissed-reason badge so the
+operator sees who closed the loop — Pulse on their behalf vs their
+own decision. The badge routes through the canonical
+`getOperatorStateDismissCause` and
+`formatOperatorStateDismissCauseLabel` helpers; the lifecycle scan
+mirrors the Go-side helper's newest-first contract so a manual
+dismissal that supersedes an earlier auto-dismiss is reported as
+manual. Time-bounded operator
commitments do not silently turn into permanent dismissals; manual
operator dismissals (no `operator_state_cause` metadata) are
unaffected by this wake path because the helper that detects the
diff --git a/frontend-modern/src/components/AI/FindingsPanel.tsx b/frontend-modern/src/components/AI/FindingsPanel.tsx
index e5904c0c4d..2c42644c85 100644
--- a/frontend-modern/src/components/AI/FindingsPanel.tsx
+++ b/frontend-modern/src/components/AI/FindingsPanel.tsx
@@ -47,6 +47,8 @@ import {
buildFindingFilterOptions,
formatFindingForClipboard,
formatFindingLifecycleType,
+ formatOperatorStateDismissCauseLabel,
+ getOperatorStateDismissCause,
formatFindingLoopState,
getFindingActiveRuntimeSortOrder,
getFindingSeverityPresentation,
@@ -818,6 +820,26 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
{' · '}({formatIdentifierLabel(finding.dismissedReason)})
</span>
</Show>
+ {/* Distinguish Pulse-auto-suppressed dismissals from operator
+ decisions — both serialize as DismissedReason=
+ 'expected_behavior' on the wire, but the auto-dismiss
+ carries `operator_state_cause` lifecycle metadata. The
+ badge attributes the suppression so the operator sees
+ "Pulse stayed quiet because of my maintenance window"
+ vs "I decided this was expected." */}
+ <Show
+ when={(() => {
+ const cause = getOperatorStateDismissCause(finding);
+ return cause && formatOperatorStateDismissCauseLabel(cause);
+ })()}
+ >
+ <span
+ class="ml-2 text-blue-600 dark:text-blue-400"
+ title="Auto-suppressed by Pulse based on operator-set state for this resource."
+ >
+ {' · '}auto: {formatOperatorStateDismissCauseLabel(getOperatorStateDismissCause(finding))}
+ </span>
+ </Show>
<Show when={finding.dismissedReason === 'will_fix_later' && finding.remindAt}>
<span class="ml-2 text-amber-600 dark:text-amber-400" title="Pulse will surface this finding again on this date if it is still tripping.">
{' · '}Reminding {formatTime(finding.remindAt!)}
diff --git a/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts b/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
index 551ebb008c..d2e985b6d6 100644
--- a/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
+++ b/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
@@ -5,6 +5,8 @@ import {
buildFindingFilterOptions,
formatFindingForClipboard,
formatFindingLifecycleType,
+ formatOperatorStateDismissCauseLabel,
+ getOperatorStateDismissCause,
formatFindingLoopState,
getFindingActiveRuntimeSortOrder,
getFindingEmptyStateCopy,
@@ -1106,4 +1108,84 @@ describe('aiFindingPresentation', () => {
).toBe('Fixed by Patrol 2h ago');
});
});
+
+ describe('operator-state dismiss cause attribution', () => {
+ it('reports the most recent operator_state_cause from the lifecycle', () => {
+ // Lifecycle scan must be newest-first so a later auto-dismiss
+ // overrides an older manual one. Mirror the Go-side helper's
+ // contract — the rendering branch depends on it for the badge.
+ expect(
+ getOperatorStateDismissCause({
+ lifecycle: [
+ { at: '2026-04-01T00:00:00Z', type: 'dismissed', metadata: { reason: 'expected_behavior' } },
+ { at: '2026-04-02T00:00:00Z', type: 'undismissed' },
+ {
+ at: '2026-04-03T00:00:00Z',
+ type: 'dismissed',
+ metadata: { operator_state_cause: 'maintenance_window' },
+ },
+ ],
+ } as never),
+ ).toBe('maintenance_window');
+ });
+
+ it('returns empty when the most recent dismissed event is a manual operator dismissal', () => {
+ // A manual dismiss that supersedes an earlier auto-dismiss must
+ // NOT report the stale auto-dismiss cause — that would falsely
+ // badge the finding as auto-suppressed when the operator
+ // overrode it.
+ expect(
+ getOperatorStateDismissCause({
+ lifecycle: [
+ {
+ at: '2026-04-01T00:00:00Z',
+ type: 'dismissed',
+ metadata: { operator_state_cause: 'maintenance_window' },
+ },
+ { at: '2026-04-02T00:00:00Z', type: 'undismissed' },
+ { at: '2026-04-03T00:00:00Z', type: 'dismissed', metadata: { reason: 'expected_behavior' } },
+ ],
+ } as never),
+ ).toBe('');
+ });
+
+ it('returns empty for findings without lifecycle entries', () => {
+ expect(getOperatorStateDismissCause({ lifecycle: undefined } as never)).toBe('');
+ expect(getOperatorStateDismissCause({ lifecycle: [] } as never)).toBe('');
+ });
+
+ it('formats canonical operator-state causes as human labels', () => {
+ expect(formatOperatorStateDismissCauseLabel('maintenance_window')).toBe('maintenance');
+ expect(formatOperatorStateDismissCauseLabel('intentionally_offline')).toBe(
+ 'intentionally offline',
+ );
+ // Unknown causes return empty so render code can gate cleanly
+ // and not show a bogus "auto: <unknown>" badge.
+ expect(formatOperatorStateDismissCauseLabel('something_new')).toBe('');
+ expect(formatOperatorStateDismissCauseLabel('')).toBe('');
+ });
+ });
+
+ describe('FindingsPanel operator-state dismiss badge wiring', () => {
+ it('renders an "auto: <cause>" badge for operator-state-driven dismissals', () => {
+ // Both manual and auto-dismissed findings show DismissedReason=
+ // expected_behavior; the auto-dismiss is distinguished by the
+ // operator_state_cause lifecycle metadata. Pin the wiring so the
+ // FindingsPanel renders the parallel badge through the canonical
+ // helper, not by re-implementing the lifecycle scan inline.
+ expect(findingsPanelSource).toContain('getOperatorStateDismissCause(finding)');
+ expect(findingsPanelSource).toContain('formatOperatorStateDismissCauseLabel(');
+ expect(findingsPanelSource).toMatch(/auto: \{formatOperatorStateDismissCauseLabel/);
+ // The badge sits next to the existing dismissed-reason badge in
+ // source order so the two pieces of information read together
+ // (the reason and the attribution).
+ const dismissedReasonIndex = findingsPanelSource.indexOf(
+ '({formatIdentifierLabel(finding.dismissedReason)})',
+ );
+ const autoBadgeIndex = findingsPanelSource.indexOf('auto: {formatOperatorStateDismissCauseLabel');
+ expect(dismissedReasonIndex).toBeGreaterThan(0);
+ expect(autoBadgeIndex).toBeGreaterThan(0);
+ expect(autoBadgeIndex).toBeGreaterThan(dismissedReasonIndex);
+ });
+ });
});
diff --git a/frontend-modern/src/utils/aiFindingPresentation.ts b/frontend-modern/src/utils/aiFindingPresentation.ts
index e3d58252d0..224953c191 100644
--- a/frontend-modern/src/utils/aiFindingPresentation.ts
+++ b/frontend-modern/src/utils/aiFindingPresentation.ts
@@ -811,3 +811,52 @@ export const formatFindingForClipboard = (
}
return lines.join('\n');
};
+
+/**
+ * Returns the canonical `operator_state_cause` for a finding's most
+ * recent dismissed lifecycle event, or "" when the finding has not been
+ * auto-dismissed by operator-state suppression. Scans newest-first and
+ * stops at the first `dismissed` event so a manual operator dismissal
+ * that supersedes an earlier auto-dismiss is reported as manual (no
+ * stale cause leaks through). Mirrors the Go-side
+ * `findOperatorStateDismissCause` helper from
+ * `internal/ai/findings.go`.
+ *
+ * Used by render code to badge auto-dismissed findings differently
+ * from manual operator dismissals — both show DismissedReason=
+ * 'expected_behavior' on the wire but tell different stories: Pulse
+ * auto-handled vs operator decided.
+ */
+export const getOperatorStateDismissCause = (
+ finding: Pick<UnifiedFinding, 'lifecycle'>,
+): string => {
+ const lifecycle = finding.lifecycle;
+ if (!lifecycle || lifecycle.length === 0) return '';
+ for (let i = lifecycle.length - 1; i >= 0; i -= 1) {
+ const ev = lifecycle[i];
+ if (ev.type !== 'dismissed') continue;
+ const cause = ev.metadata?.operator_state_cause;
+ if (cause) return cause;
+ // First dismissed event without cause is a manual dismissal that
+ // supersedes any earlier auto-dismiss — stop scanning so a stale
+ // earlier cause does not falsely badge the finding as
+ // auto-suppressed.
+ return '';
+ }
+ return '';
+};
+
+/**
+ * Human-readable label for an `operator_state_cause` value. Returns
+ * empty string for unknown values so render code can gate cleanly.
+ */
+export const formatOperatorStateDismissCauseLabel = (cause: string): string => {
+ switch (cause) {
+ case 'maintenance_window':
+ return 'maintenance';
+ case 'intentionally_offline':
+ return 'intentionally offline';
+ default:
+ return '';
+ }
+};