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: persist finding dismissal state across restarts
rcourtman59a4843f208c
diff --git a/internal/ai/findings_persistence.go b/internal/ai/findings_persistence.goindex 134abe3d5b..e541bb1ec1 100644--- a/internal/ai/findings_persistence.go+++ b/internal/ai/findings_persistence.go@@ -21,25 +21,30 @@ func (a *FindingsPersistenceAdapter) SaveFindings(findings map[string]*Finding)records := make(map[string]*config.AIFindingRecord, len(findings))for id, f := range findings {records[id] = &config.AIFindingRecord{- ID: f.ID,- Key: f.Key,- Severity: string(f.Severity),- Category: string(f.Category),- ResourceID: f.ResourceID,- ResourceName: f.ResourceName,- ResourceType: f.ResourceType,- Node: f.Node,- Title: f.Title,- Description: f.Description,- Recommendation: f.Recommendation,- Evidence: f.Evidence,- DetectedAt: f.DetectedAt,- LastSeenAt: f.LastSeenAt,- ResolvedAt: f.ResolvedAt,- AutoResolved: f.AutoResolved,- AcknowledgedAt: f.AcknowledgedAt,- SnoozedUntil: f.SnoozedUntil,- AlertID: f.AlertID,+ ID: f.ID,+ Key: f.Key,+ Severity: string(f.Severity),+ Category: string(f.Category),+ ResourceID: f.ResourceID,+ ResourceName: f.ResourceName,+ ResourceType: f.ResourceType,+ Node: f.Node,+ Title: f.Title,+ Description: f.Description,+ Recommendation: f.Recommendation,+ Evidence: f.Evidence,+ Source: f.Source,+ DetectedAt: f.DetectedAt,+ LastSeenAt: f.LastSeenAt,+ ResolvedAt: f.ResolvedAt,+ AutoResolved: f.AutoResolved,+ AcknowledgedAt: f.AcknowledgedAt,+ SnoozedUntil: f.SnoozedUntil,+ AlertID: f.AlertID,+ DismissedReason: f.DismissedReason,+ UserNote: f.UserNote,+ TimesRaised: f.TimesRaised,+ Suppressed: f.Suppressed,}}return a.config.SaveAIFindings(records)@@ -56,26 +61,32 @@ func (a *FindingsPersistenceAdapter) LoadFindings() (map[string]*Finding, error)findings := make(map[string]*Finding, len(data.Findings))for id, r := range data.Findings {findings[id] = &Finding{- ID: r.ID,- Key: r.Key,- Severity: FindingSeverity(r.Severity),- Category: FindingCategory(r.Category),- ResourceID: r.ResourceID,- ResourceName: r.ResourceName,- ResourceType: r.ResourceType,- Node: r.Node,- Title: r.Title,- Description: r.Description,- Recommendation: r.Recommendation,- Evidence: r.Evidence,- DetectedAt: r.DetectedAt,- LastSeenAt: r.LastSeenAt,- ResolvedAt: r.ResolvedAt,- AutoResolved: r.AutoResolved,- AcknowledgedAt: r.AcknowledgedAt,- SnoozedUntil: r.SnoozedUntil,- AlertID: r.AlertID,+ ID: r.ID,+ Key: r.Key,+ Severity: FindingSeverity(r.Severity),+ Category: FindingCategory(r.Category),+ ResourceID: r.ResourceID,+ ResourceName: r.ResourceName,+ ResourceType: r.ResourceType,+ Node: r.Node,+ Title: r.Title,+ Description: r.Description,+ Recommendation: r.Recommendation,+ Evidence: r.Evidence,+ Source: r.Source,+ DetectedAt: r.DetectedAt,+ LastSeenAt: r.LastSeenAt,+ ResolvedAt: r.ResolvedAt,+ AutoResolved: r.AutoResolved,+ AcknowledgedAt: r.AcknowledgedAt,+ SnoozedUntil: r.SnoozedUntil,+ AlertID: r.AlertID,+ DismissedReason: r.DismissedReason,+ UserNote: r.UserNote,+ TimesRaised: r.TimesRaised,+ Suppressed: r.Suppressed,}}return findings, nil}+diff --git a/internal/ai/findings_persistence_test.go b/internal/ai/findings_persistence_test.goindex 75ac9a31b4..b8e4c29a6c 100644--- a/internal/ai/findings_persistence_test.go+++ b/internal/ai/findings_persistence_test.go@@ -144,25 +144,30 @@ func TestFindingsPersistenceAdapter_PreservesAllFields(t *testing.T) {snoozed := now.Add(24 * time.Hour)originalFinding := &Finding{- ID: "test-finding",- Key: "test-key",- Severity: FindingSeverityCritical,- Category: FindingCategorySecurity,- ResourceID: "resource-123",- ResourceName: "Test Resource",- ResourceType: "vm",- Node: "node1",- Title: "Test Title",- Description: "Test Description",- Recommendation: "Test Recommendation",- Evidence: "Test Evidence",- DetectedAt: now,- LastSeenAt: now,- ResolvedAt: &resolved,- AutoResolved: true,- AcknowledgedAt: &acked,- SnoozedUntil: &snoozed,- AlertID: "alert-456",+ ID: "test-finding",+ Key: "test-key",+ Severity: FindingSeverityCritical,+ Category: FindingCategorySecurity,+ ResourceID: "resource-123",+ ResourceName: "Test Resource",+ ResourceType: "vm",+ Node: "node1",+ Title: "Test Title",+ Description: "Test Description",+ Recommendation: "Test Recommendation",+ Evidence: "Test Evidence",+ Source: "ai-analysis",+ DetectedAt: now,+ LastSeenAt: now,+ ResolvedAt: &resolved,+ AutoResolved: true,+ AcknowledgedAt: &acked,+ SnoozedUntil: &snoozed,+ AlertID: "alert-456",+ DismissedReason: "expected_behavior",+ UserNote: "This is intentional for Frigate recordings",+ TimesRaised: 5,+ Suppressed: false,}findings := map[string]*Finding{"test-finding": originalFinding}@@ -213,4 +218,132 @@ func TestFindingsPersistenceAdapter_PreservesAllFields(t *testing.T) {if f.SnoozedUntil == nil {t.Error("SnoozedUntil should not be nil")}++ // Verify user feedback fields are preserved (these were missing before the fix)+ if f.Source != originalFinding.Source {+ t.Errorf("Source mismatch: got %q, want %q", f.Source, originalFinding.Source)+ }+ if f.DismissedReason != originalFinding.DismissedReason {+ t.Errorf("DismissedReason mismatch: got %q, want %q", f.DismissedReason, originalFinding.DismissedReason)+ }+ if f.UserNote != originalFinding.UserNote {+ t.Errorf("UserNote mismatch: got %q, want %q", f.UserNote, originalFinding.UserNote)+ }+ if f.TimesRaised != originalFinding.TimesRaised {+ t.Errorf("TimesRaised mismatch: got %d, want %d", f.TimesRaised, originalFinding.TimesRaised)+ }+ if f.Suppressed != originalFinding.Suppressed {+ t.Errorf("Suppressed mismatch: got %v, want %v", f.Suppressed, originalFinding.Suppressed)+ }+}++// TestFindingsPersistenceAdapter_PreservesDismissals specifically tests that dismissed findings+// are properly persisted across restarts. This was a bug where DismissedReason, UserNote,+// TimesRaised, and Suppressed fields were not being saved to disk.+func TestFindingsPersistenceAdapter_PreservesDismissals(t *testing.T) {+ tmp := t.TempDir()+ persistence := config.NewConfigPersistence(tmp)+ adapter := NewFindingsPersistenceAdapter(persistence)++ now := time.Now()+ acked := now.Add(-1 * time.Hour)++ // Simulate a finding that was dismissed as "expected_behavior"+ dismissedFinding := &Finding{+ ID: "frigate-storage-123",+ Key: "storage-growth-high",+ Severity: FindingSeverityWarning,+ Category: FindingCategoryCapacity,+ ResourceID: "delly-frigate-storage",+ ResourceName: "frigate-storage",+ ResourceType: "storage",+ Node: "delly",+ Title: "Frigate storage growing at 56GB/day",+ Description: "Storage will be full in 13 days",+ Recommendation: "Reduce retention policy",+ Evidence: "6.0% per day growth rate",+ Source: "ai-analysis",+ DetectedAt: now.Add(-5 * time.Hour),+ LastSeenAt: now,+ DismissedReason: "expected_behavior",+ UserNote: "24/7 recording is intentional, storage is sized for this",+ TimesRaised: 3,+ Suppressed: false,+ AcknowledgedAt: &acked,+ }++ // Also test a suppressed finding+ suppressedFinding := &Finding{+ ID: "dev-vm-hot",+ Key: "cpu-high",+ Severity: FindingSeverityInfo,+ Category: FindingCategoryPerformance,+ ResourceID: "node1-105",+ ResourceName: "dev-vm",+ ResourceType: "vm",+ Node: "node1",+ Title: "Dev VM running hot",+ Description: "CPU at 80%",+ Source: "ai-analysis",+ DetectedAt: now.Add(-24 * time.Hour),+ LastSeenAt: now,+ DismissedReason: "suppressed",+ UserNote: "Development workload, expected",+ TimesRaised: 10,+ Suppressed: true,+ AcknowledgedAt: &acked,+ }++ findings := map[string]*Finding{+ dismissedFinding.ID: dismissedFinding,+ suppressedFinding.ID: suppressedFinding,+ }++ // Save+ if err := adapter.SaveFindings(findings); err != nil {+ t.Fatalf("failed to save findings: %v", err)+ }++ // Load (simulating restart)+ loaded, err := adapter.LoadFindings()+ if err != nil {+ t.Fatalf("failed to load findings: %v", err)+ }++ // Verify dismissed finding+ df := loaded[dismissedFinding.ID]+ if df == nil {+ t.Fatal("dismissed finding not found after load")+ }+ if df.DismissedReason != "expected_behavior" {+ t.Errorf("DismissedReason not preserved: got %q, want 'expected_behavior'", df.DismissedReason)+ }+ if df.UserNote != dismissedFinding.UserNote {+ t.Errorf("UserNote not preserved: got %q", df.UserNote)+ }+ if df.TimesRaised != 3 {+ t.Errorf("TimesRaised not preserved: got %d, want 3", df.TimesRaised)+ }+ if df.IsActive() {+ t.Error("dismissed finding should not be active")+ }++ // Verify suppressed finding+ sf := loaded[suppressedFinding.ID]+ if sf == nil {+ t.Fatal("suppressed finding not found after load")+ }+ if !sf.Suppressed {+ t.Error("Suppressed not preserved: should be true")+ }+ if sf.DismissedReason != "suppressed" {+ t.Errorf("DismissedReason not preserved for suppressed: got %q", sf.DismissedReason)+ }+ if sf.TimesRaised != 10 {+ t.Errorf("TimesRaised not preserved: got %d, want 10", sf.TimesRaised)+ }+ if sf.IsActive() {+ t.Error("suppressed finding should not be active")+ }}+diff --git a/internal/config/persistence.go b/internal/config/persistence.goindex 6d6938af44..ed4f65c193 100644--- a/internal/config/persistence.go+++ b/internal/config/persistence.go@@ -1480,6 +1480,7 @@ type AIFindingRecord struct {Description string `json:"description"`Recommendation string `json:"recommendation,omitempty"`Evidence string `json:"evidence,omitempty"`+ Source string `json:"source,omitempty"`DetectedAt time.Time `json:"detected_at"`LastSeenAt time.Time `json:"last_seen_at"`ResolvedAt *time.Time `json:"resolved_at,omitempty"`@@ -1487,6 +1488,11 @@ type AIFindingRecord struct {AcknowledgedAt *time.Time `json:"acknowledged_at,omitempty"`SnoozedUntil *time.Time `json:"snoozed_until,omitempty"`AlertID string `json:"alert_id,omitempty"`+ // User feedback fields - enables persistence of dismissal state+ DismissedReason string `json:"dismissed_reason,omitempty"`+ UserNote string `json:"user_note,omitempty"`+ TimesRaised int `json:"times_raised"`+ Suppressed bool `json:"suppressed"`}// SaveAIFindings persists AI findings to disk