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.

feat: Allow reverting dismissed AI alerts from suppression rules

rcourtman545990e48f8d
diff --git a/frontend-modern/src/api/patrol.ts b/frontend-modern/src/api/patrol.ts
index 3f08b2e5e7..fa527d98ce 100644
--- a/frontend-modern/src/api/patrol.ts
+++ b/frontend-modern/src/api/patrol.ts
@@ -345,8 +345,9 @@ export interface SuppressionRule {
resource_name?: string; // Human-readable name
category?: FindingCategory; // Empty means "any category"
description: string; // User's reason
+ dismissed_reason?: 'not_an_issue' | 'expected_behavior' | 'will_fix_later'; // Why it was dismissed
created_at: string;
- created_from: 'finding' | 'manual';
+ created_from: 'finding' | 'dismissed' | 'manual'; // 'finding' = suppressed, 'dismissed' = just dismissed
finding_id?: string; // Original finding ID if created from dismissal
}
diff --git a/frontend-modern/src/pages/Alerts.tsx b/frontend-modern/src/pages/Alerts.tsx
index 048f41d433..1ac752bb6e 100644
--- a/frontend-modern/src/pages/Alerts.tsx
+++ b/frontend-modern/src/pages/Alerts.tsx
@@ -3248,7 +3248,7 @@ function OverviewTab(props: {
{(rule) => (
<div class="flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-800/50 rounded-lg border border-gray-200 dark:border-gray-700">
<div class="flex-1 min-w-0">
- <div class="flex items-center gap-2 text-sm">
+ <div class="flex items-center gap-2 text-sm flex-wrap">
<span class="font-medium text-gray-800 dark:text-gray-200">
{rule.resource_name || rule.resource_id || 'Any resource'}
</span>
@@ -3262,28 +3262,49 @@ function OverviewTab(props: {
Any category
</span>
</Show>
- <span class="px-1.5 py-0.5 text-xs rounded bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300">
- {rule.created_from === 'finding' ? 'From Finding' : 'Manual'}
- </span>
+ {/* Show dismissal type with appropriate styling */}
+ <Show when={rule.created_from === 'finding'}>
+ <span class="px-1.5 py-0.5 text-xs rounded bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-300">
+ 🔇 Suppressed
+ </span>
+ </Show>
+ <Show when={rule.created_from === 'dismissed'}>
+ <span class={`px-1.5 py-0.5 text-xs rounded ${rule.dismissed_reason === 'expected_behavior'
+ ? 'bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300'
+ : rule.dismissed_reason === 'will_fix_later'
+ ? 'bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-300'
+ : 'bg-gray-200 dark:bg-gray-700 text-gray-600 dark:text-gray-400'
+ }`}>
+ {rule.dismissed_reason === 'expected_behavior' && '✓ Expected'}
+ {rule.dismissed_reason === 'will_fix_later' && '⏱ Noted'}
+ {rule.dismissed_reason === 'not_an_issue' && '✓ Not an Issue'}
+ {!rule.dismissed_reason && 'Dismissed'}
+ </span>
+ </Show>
+ <Show when={rule.created_from === 'manual'}>
+ <span class="px-1.5 py-0.5 text-xs rounded bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300">
+ Manual
+ </span>
+ </Show>
</div>
<p class="text-xs text-gray-500 dark:text-gray-500 mt-1 truncate">
{rule.description || 'No description'}
</p>
</div>
<button
- class="ml-3 px-2 py-1 text-xs text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/30 rounded transition-colors"
+ class="ml-3 px-2 py-1 text-xs text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/30 rounded transition-colors flex-shrink-0"
onClick={async () => {
try {
await deleteSuppressionRule(rule.id);
- notificationStore.success('Rule deleted');
+ notificationStore.success(rule.created_from === 'manual' ? 'Rule deleted' : 'Finding reactivated');
fetchAiData();
} catch (_err) {
notificationStore.error('Failed to delete rule');
}
}}
- title="Delete this rule"
+ title={rule.created_from === 'manual' ? 'Delete this rule' : 'Reactivate this finding'}
>
- Delete
+ {rule.created_from === 'manual' ? 'Delete' : 'Reactivate'}
</button>
</div>
)}
diff --git a/internal/ai/findings.go b/internal/ai/findings.go
index cb28133369..931ffd3144 100644
--- a/internal/ai/findings.go
+++ b/internal/ai/findings.go
@@ -89,14 +89,15 @@ func (f *Finding) IsResolved() bool {
// SuppressionRule represents a user-defined rule to suppress certain AI findings
// Users can create these manually to prevent alerts before they happen
type SuppressionRule struct {
- ID string `json:"id"`
- ResourceID string `json:"resource_id,omitempty"` // Empty means "any resource"
- ResourceName string `json:"resource_name,omitempty"` // Human-readable name for display
- Category FindingCategory `json:"category,omitempty"` // Empty means "any category"
- Description string `json:"description"` // User's reason, e.g., "dev VM runs hot"
- CreatedAt time.Time `json:"created_at"`
- CreatedFrom string `json:"created_from,omitempty"` // "finding" if created from a dismissed finding, "manual" if user-created
- FindingID string `json:"finding_id,omitempty"` // Original finding ID if created from dismissal
+ ID string `json:"id"`
+ ResourceID string `json:"resource_id,omitempty"` // Empty means "any resource"
+ ResourceName string `json:"resource_name,omitempty"` // Human-readable name for display
+ Category FindingCategory `json:"category,omitempty"` // Empty means "any category"
+ Description string `json:"description"` // User's reason, e.g., "dev VM runs hot"
+ DismissedReason string `json:"dismissed_reason,omitempty"` // "not_an_issue", "expected_behavior", "will_fix_later"
+ CreatedAt time.Time `json:"created_at"`
+ CreatedFrom string `json:"created_from,omitempty"` // "finding" if suppressed, "dismissed" if just dismissed, "manual" if user-created
+ FindingID string `json:"finding_id,omitempty"` // Original finding ID if created from dismissal
}
// FindingsPersistence interface for saving/loading findings (avoids circular imports)
@@ -415,6 +416,41 @@ func (s *FindingsStore) Dismiss(id, reason, note string) bool {
return true
}
+// Undismiss reverts a dismissed finding back to active state
+// This clears DismissedReason, Suppressed, and AcknowledgedAt
+// allowing the finding to be raised again
+func (s *FindingsStore) Undismiss(id string) bool {
+ s.mu.Lock()
+
+ f, exists := s.findings[id]
+ if !exists {
+ s.mu.Unlock()
+ return false
+ }
+
+ // Check if it was actually dismissed
+ if f.DismissedReason == "" && !f.Suppressed {
+ s.mu.Unlock()
+ return false
+ }
+
+ // Clear dismissal state
+ f.DismissedReason = ""
+ f.Suppressed = false
+ f.AcknowledgedAt = nil
+ // Keep UserNote in case user wants to see their notes
+
+ // If it was resolved, don't reactivate - user should manually reopen
+ // But if it's not resolved, it becomes active again
+ if f.ResolvedAt == nil && !f.IsSnoozed() {
+ s.activeCounts[f.Severity]++
+ }
+
+ s.mu.Unlock()
+ s.scheduleSave()
+ return true
+}
+
// SetUserNote updates the user note on a finding
func (s *FindingsStore) SetUserNote(id, note string) bool {
s.mu.Lock()
@@ -765,18 +801,30 @@ func (s *FindingsStore) GetSuppressionRules() []*SuppressionRule {
rules = append(rules, rule)
}
- // Also include suppressed findings as rules (for visibility)
+ // Include all dismissed findings as rules (for visibility and to allow reverting)
+ // This covers both suppressed ("not_an_issue") and acknowledged ("expected_behavior", "will_fix_later")
for _, f := range s.findings {
- if f.Suppressed {
+ if f.Suppressed || f.DismissedReason != "" {
+ createdFrom := "finding"
+ if !f.Suppressed && f.DismissedReason != "" {
+ // Mark as "dismissed" type to distinguish from permanent suppression
+ createdFrom = "dismissed"
+ }
+ // Handle nil AcknowledgedAt (shouldn't happen but be safe)
+ createdAt := f.LastSeenAt
+ if f.AcknowledgedAt != nil {
+ createdAt = *f.AcknowledgedAt
+ }
rules = append(rules, &SuppressionRule{
- ID: "finding_" + f.ID,
- ResourceID: f.ResourceID,
- ResourceName: f.ResourceName,
- Category: f.Category,
- Description: f.UserNote,
- CreatedAt: *f.AcknowledgedAt,
- CreatedFrom: "finding",
- FindingID: f.ID,
+ ID: "finding_" + f.ID,
+ ResourceID: f.ResourceID,
+ ResourceName: f.ResourceName,
+ Category: f.Category,
+ Description: f.UserNote,
+ DismissedReason: f.DismissedReason,
+ CreatedAt: createdAt,
+ CreatedFrom: createdFrom,
+ FindingID: f.ID,
})
}
}
@@ -799,10 +847,16 @@ func (s *FindingsStore) DeleteSuppressionRule(ruleID string) bool {
// Check if it's a finding-based rule (e.g., "finding_abc123")
if strings.HasPrefix(ruleID, "finding_") {
findingID := strings.TrimPrefix(ruleID, "finding_")
- if f, exists := s.findings[findingID]; exists && f.Suppressed {
- // Un-suppress the finding
+ if f, exists := s.findings[findingID]; exists && (f.Suppressed || f.DismissedReason != "") {
+ // Un-suppress/undismiss the finding
+ wasActive := f.IsActive()
f.Suppressed = false
f.DismissedReason = ""
+ f.AcknowledgedAt = nil
+ // If it wasn't active before but is now, increment count
+ if !wasActive && f.IsActive() {
+ s.activeCounts[f.Severity]++
+ }
s.scheduleSave()
return true
}