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(api): add POST /api/ai/patrol/undismiss endpoint to revert suppressed findings (#1300)

rcourtman2fcddecf8081
diff --git a/internal/ai/findings.go b/internal/ai/findings.go
index efd2c9ec66..1d651e1956 100644
--- a/internal/ai/findings.go
+++ b/internal/ai/findings.go
@@ -743,6 +743,16 @@ func (s *FindingsStore) Undismiss(id string) bool {
return false
}
+ // Remove any explicit suppression rules that were created for this finding's
+ // resource+category (from Suppress()), so future findings aren't blocked.
+ if f.Suppressed && f.ResourceID != "" {
+ for ruleID, rule := range s.suppressionRules {
+ if rule.ResourceID == f.ResourceID && rule.Category == f.Category {
+ delete(s.suppressionRules, ruleID)
+ }
+ }
+ }
+
// Clear dismissal state
f.DismissedReason = ""
f.Suppressed = false
diff --git a/internal/ai/unified/alerts.go b/internal/ai/unified/alerts.go
index 027cd8473e..4380bea940 100644
--- a/internal/ai/unified/alerts.go
+++ b/internal/ai/unified/alerts.go
@@ -677,6 +677,30 @@ func (s *UnifiedStore) Dismiss(findingID, reason, note string) bool {
return true
}
+// Undismiss reverts a dismissed finding back to active state
+func (s *UnifiedStore) Undismiss(findingID string) bool {
+ s.mu.Lock()
+
+ f, ok := s.findings[findingID]
+ if !ok {
+ s.mu.Unlock()
+ return false
+ }
+
+ if f.DismissedReason == "" && !f.Suppressed {
+ s.mu.Unlock()
+ return false
+ }
+
+ f.DismissedReason = ""
+ f.Suppressed = false
+ f.AcknowledgedAt = nil
+
+ s.mu.Unlock()
+ s.scheduleSave()
+ return true
+}
+
// Snooze snoozes a finding for the specified duration
func (s *UnifiedStore) Snooze(findingID string, duration time.Duration) bool {
s.mu.Lock()
diff --git a/internal/api/ai_handlers.go b/internal/api/ai_handlers.go
index 0838930ab4..602da2a1ab 100644
--- a/internal/api/ai_handlers.go
+++ b/internal/api/ai_handlers.go
@@ -3874,6 +3874,57 @@ func (h *AISettingsHandler) HandleDismissFinding(w http.ResponseWriter, r *http.
}
}
+// HandleUndismissFinding reverts a dismissed/suppressed finding back to active state (POST /api/ai/patrol/undismiss)
+func (h *AISettingsHandler) HandleUndismissFinding(w http.ResponseWriter, r *http.Request) {
+ if r.Method != http.MethodPost {
+ http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
+ return
+ }
+
+ if !CheckAuth(h.getConfig(r.Context()), w, r) {
+ return
+ }
+
+ patrol := h.GetAIService(r.Context()).GetPatrolService()
+ if patrol == nil {
+ http.Error(w, "Patrol service not available", http.StatusServiceUnavailable)
+ return
+ }
+
+ var req struct {
+ FindingID string `json:"finding_id"`
+ }
+ if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
+ http.Error(w, "Invalid request body", http.StatusBadRequest)
+ return
+ }
+
+ if req.FindingID == "" {
+ http.Error(w, "finding_id is required", http.StatusBadRequest)
+ return
+ }
+
+ findings := patrol.GetFindings()
+ findings.Undismiss(req.FindingID)
+
+ if store := h.GetUnifiedStore(); store != nil {
+ store.Undismiss(req.FindingID)
+ }
+
+ log.Info().
+ Str("finding_id", req.FindingID).
+ Msg("AI Patrol: Finding undismissed by user")
+
+ response := map[string]interface{}{
+ "success": true,
+ "message": "Finding undismissed",
+ }
+
+ if err := utils.WriteJSONResponse(w, response); err != nil {
+ log.Error().Err(err).Msg("Failed to write undismiss response")
+ }
+}
+
// HandleSuppressFinding permanently suppresses similar findings for a resource (POST /api/ai/patrol/suppress)
// The LLM will be told never to re-raise findings of this type for this resource
func (h *AISettingsHandler) HandleSuppressFinding(w http.ResponseWriter, r *http.Request) {
diff --git a/internal/api/route_inventory_test.go b/internal/api/route_inventory_test.go
index df76d4acc7..ece6cd9ac1 100644
--- a/internal/api/route_inventory_test.go
+++ b/internal/api/route_inventory_test.go
@@ -436,6 +436,7 @@ var allRouteAllowlist = []string{
"/api/ai/patrol/run",
"/api/ai/patrol/acknowledge",
"/api/ai/patrol/dismiss",
+ "/api/ai/patrol/undismiss",
"/api/ai/patrol/findings/note",
"/api/ai/patrol/suppress",
"/api/ai/patrol/snooze",
diff --git a/internal/api/router.go b/internal/api/router.go
index ff07772878..e9b6023021 100644
--- a/internal/api/router.go
+++ b/internal/api/router.go
@@ -1567,6 +1567,7 @@ func (r *Router) setupRoutes() {
// Dismiss and resolve don't require Pro license - users should be able to clear findings they can see
// This is especially important for users who accumulated findings before fixing the patrol-without-AI bug
r.mux.HandleFunc("/api/ai/patrol/dismiss", RequireAuth(r.config, RequireScope(config.ScopeAIExecute, r.aiSettingsHandler.HandleDismissFinding)))
+ r.mux.HandleFunc("/api/ai/patrol/undismiss", RequireAuth(r.config, RequireScope(config.ScopeAIExecute, r.aiSettingsHandler.HandleUndismissFinding)))
r.mux.HandleFunc("/api/ai/patrol/findings/note", RequireAuth(r.config, RequireScope(config.ScopeAIExecute, r.aiSettingsHandler.HandleSetFindingNote)))
r.mux.HandleFunc("/api/ai/patrol/suppress", RequireAuth(r.config, RequireScope(config.ScopeAIExecute, r.aiSettingsHandler.HandleSuppressFinding)))
r.mux.HandleFunc("/api/ai/patrol/snooze", RequireAuth(r.config, RequireScope(config.ScopeAIExecute, r.aiSettingsHandler.HandleSnoozeFinding)))