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: finding drawer actions (notes persist, acknowledge visual, discuss context)
rcourtmand1f76982ec3f
diff --git a/frontend-modern/src/api/aiChat.ts b/frontend-modern/src/api/aiChat.tsindex cbc890ebc8..f84dfca6ed 100644--- a/frontend-modern/src/api/aiChat.ts+++ b/frontend-modern/src/api/aiChat.ts@@ -176,7 +176,8 @@ export class AIChatAPI {model: string | undefined,onEvent: (event: StreamEvent) => void,signal?: AbortSignal,- mentions?: Array<{ id: string; name: string; type: string; node?: string }>+ mentions?: Array<{ id: string; name: string; type: string; node?: string }>,+ findingId?: string): Promise<void> {logger.debug('[AI Chat] Starting chat stream', { prompt: prompt.substring(0, 50) });@@ -188,6 +189,9 @@ export class AIChatAPI {if (mentions && mentions.length > 0) {body.mentions = mentions;}+ if (findingId) {+ body.finding_id = findingId;+ }const response = await apiFetch(`${this.baseUrl}/chat`, {method: 'POST',diff --git a/frontend-modern/src/components/AI/Chat/hooks/useChat.ts b/frontend-modern/src/components/AI/Chat/hooks/useChat.tsindex 7e2c52ff5d..df8ac6d15f 100644--- a/frontend-modern/src/components/AI/Chat/hooks/useChat.ts+++ b/frontend-modern/src/components/AI/Chat/hooks/useChat.ts@@ -322,7 +322,7 @@ export function useChat(options: UseChatOptions = {}) {};// Send a message - allows sending mid-stream (aborts current response like Pulse AI TUI)- const sendMessage = async (prompt: string, mentions?: Array<{ id: string; name: string; type: string; node?: string }>) => {+ const sendMessage = async (prompt: string, mentions?: Array<{ id: string; name: string; type: string; node?: string }>, findingId?: string) => {if (!prompt.trim()) return;// If already streaming, abort the current request first@@ -391,7 +391,8 @@ export function useChat(options: UseChatOptions = {}) {processEvent(assistantId, event);},abortControllerRef?.signal,- mentions+ mentions,+ findingId);} catch (error) {if (error instanceof Error && error.name === 'AbortError') {diff --git a/frontend-modern/src/components/AI/Chat/index.tsx b/frontend-modern/src/components/AI/Chat/index.tsxindex e9c2584b81..f6ba466fc7 100644--- a/frontend-modern/src/components/AI/Chat/index.tsx+++ b/frontend-modern/src/components/AI/Chat/index.tsx@@ -410,7 +410,15 @@ export const AIChat: Component<AIChatProps> = (props) => {const prompt = input().trim();if (!prompt) return;const mentions = accumulatedMentions();- chat.sendMessage(prompt, mentions.length > 0 ? mentions : undefined);+ // Pass findingId from context on the first message, clear after success+ const ctx = aiChatStore.context;+ const findingId = ctx.findingId;+ chat.sendMessage(prompt, mentions.length > 0 ? mentions : undefined, findingId)+ .then(() => {+ if (findingId) {+ aiChatStore.clearFindingId?.();+ }+ });setInput('');setAccumulatedMentions([]);setMentionActive(false);diff --git a/frontend-modern/src/components/AI/FindingsPanel.tsx b/frontend-modern/src/components/AI/FindingsPanel.tsxindex 1807a70f30..29b534d190 100644--- a/frontend-modern/src/components/AI/FindingsPanel.tsx+++ b/frontend-modern/src/components/AI/FindingsPanel.tsx@@ -216,7 +216,13 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {const aPriority = severityOrder[a.severity] ?? 4;const bPriority = severityOrder[b.severity] ?? 4;if (aPriority !== bPriority) return aPriority - bPriority;++ // Within same severity, sort acknowledged findings below unacknowledged+ const aAcked = a.acknowledgedAt ? 1 : 0;+ const bAcked = b.acknowledgedAt ? 1 : 0;+ if (aAcked !== bAcked) return aAcked - bAcked;}+return new Date(b.detectedAt).getTime() - new Date(a.detectedAt).getTime();});@@ -450,7 +456,9 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {<divid={`finding-${finding.id}`}class={`p-3 cursor-pointer transition-colors ${finding.status === 'active'- ? 'hover:bg-gray-50 dark:hover:bg-gray-800/50'+ ? finding.acknowledgedAt+ ? 'opacity-60 hover:opacity-80 bg-gray-50/30 dark:bg-gray-800/20'+ : 'hover:bg-gray-50 dark:hover:bg-gray-800/50': 'opacity-60 bg-gray-50/50 dark:bg-gray-800/30 hover:opacity-80'}`}onClick={() => {@@ -496,6 +504,11 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {Alert-triggered</span></Show>+ <Show when={finding.acknowledgedAt && finding.status === 'active'}>+ <span class="px-1.5 py-0.5 text-[10px] font-medium rounded bg-gray-200 text-gray-600 dark:bg-gray-600 dark:text-gray-300">+ Acknowledged+ </span>+ </Show><Show when={isOutOfScope(finding)}><spanclass="px-1.5 py-0.5 text-[10px] font-medium rounded bg-amber-200 text-amber-900 dark:bg-amber-900/60 dark:text-amber-100"@@ -563,17 +576,19 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {{/* Actions */}<div class="flex items-center gap-1 shrink-0"><Show when={finding.status === 'active'}>- <button- type="button"- onClick={(e) => handleAcknowledge(finding, e)}- class="p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300"- title="Acknowledge"- disabled={actionLoading() === finding.id}- >- <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4" />- </svg>- </button>+ <Show when={!finding.acknowledgedAt}>+ <button+ type="button"+ onClick={(e) => handleAcknowledge(finding, e)}+ class="p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300"+ title="Acknowledge"+ disabled={actionLoading() === finding.id}+ >+ <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4" />+ </svg>+ </button>+ </Show><buttontype="button"onClick={(e) => handleSnooze(finding, 24, e)}@@ -709,14 +724,16 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {<Show when={finding.status === 'active'}><div class="mt-3 flex flex-wrap gap-2 text-xs">- <button- type="button"- onClick={(e) => handleAcknowledge(finding, e)}- class="px-2 py-1 rounded border border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-700"- disabled={actionLoading() === finding.id}- >- Acknowledge- </button>+ <Show when={!finding.acknowledgedAt}>+ <button+ type="button"+ onClick={(e) => handleAcknowledge(finding, e)}+ class="px-2 py-1 rounded border border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-700"+ disabled={actionLoading() === finding.id}+ >+ Acknowledge+ </button>+ </Show><buttontype="button"onClick={(e) => handleSnooze(finding, 1, e)}diff --git a/frontend-modern/src/stores/aiChat.ts b/frontend-modern/src/stores/aiChat.tsindex 44a999f73f..a85bab68bc 100644--- a/frontend-modern/src/stores/aiChat.ts+++ b/frontend-modern/src/stores/aiChat.ts@@ -421,6 +421,15 @@ export const aiChatStore = {});},+ // Clear the findingId after first message is sent+ clearFindingId() {+ setAIChatContext(prev => {+ if (!prev.findingId) return prev;+ const { findingId: _, ...rest } = prev;+ return rest;+ });+ },+// Register the AI input element (called by AIChat component)registerInput(ref: HTMLTextAreaElement | null) {aiInputRef = ref;diff --git a/internal/ai/chat/types.go b/internal/ai/chat/types.goindex 9c4b84265c..08fc92731b 100644--- a/internal/ai/chat/types.go+++ b/internal/ai/chat/types.go@@ -71,6 +71,7 @@ type ExecuteRequest struct {SessionID string `json:"session_id,omitempty"`Model string `json:"model,omitempty"`Mentions []StructuredMention `json:"mentions,omitempty"`+ FindingID string `json:"finding_id,omitempty"` // Pre-populate finding context for "Discuss" flowMaxTurns int `json:"max_turns,omitempty"` // Override max agentic turns (0 = use default)AutonomousMode *bool `json:"autonomous_mode,omitempty"` // Per-request autonomous override (nil = use service default)}diff --git a/internal/ai/unified/alerts.go b/internal/ai/unified/alerts.goindex 339bfc7437..027cd8473e 100644--- a/internal/ai/unified/alerts.go+++ b/internal/ai/unified/alerts.go@@ -713,6 +713,23 @@ func (s *UnifiedStore) Acknowledge(findingID string) bool {return true}+// SetUserNote sets or updates the user note on a finding+func (s *UnifiedStore) SetUserNote(findingID string, note string) bool {+ s.mu.Lock()++ f, ok := s.findings[findingID]+ if !ok {+ s.mu.Unlock()+ return false+ }++ f.UserNote = note++ s.mu.Unlock()+ s.scheduleSave()+ return true+}+// Resolve marks a finding as resolvedfunc (s *UnifiedStore) Resolve(findingID string) bool {s.mu.Lock()diff --git a/internal/api/ai_handler.go b/internal/api/ai_handler.goindex 9dff355f41..fb1ff67e91 100644--- a/internal/api/ai_handler.go+++ b/internal/api/ai_handler.go@@ -8,9 +8,12 @@ import ("sync/atomic""time"+ "fmt"+"github.com/rcourtman/pulse-go-rewrite/internal/agentexec""github.com/rcourtman/pulse-go-rewrite/internal/ai/approval""github.com/rcourtman/pulse-go-rewrite/internal/ai/chat"+ "github.com/rcourtman/pulse-go-rewrite/internal/ai/unified""github.com/rcourtman/pulse-go-rewrite/internal/config""github.com/rcourtman/pulse-go-rewrite/internal/models""github.com/rcourtman/pulse-go-rewrite/internal/monitoring"@@ -77,6 +80,8 @@ type AIHandler struct {servicesMu sync.RWMutexstateProviders map[string]AIStateProviderstateProvidersMu sync.RWMutex+ unifiedStoreMu sync.RWMutex+ unifiedStore *unified.UnifiedStore}// newChatService is the factory function for creating the AI service.@@ -112,6 +117,13 @@ func NewAIHandler(mtp *config.MultiTenantPersistence, mtm *monitoring.MultiTenan}}+// SetUnifiedStore sets the unified store for finding context lookup in the "Discuss" flow+func (h *AIHandler) SetUnifiedStore(store *unified.UnifiedStore) {+ h.unifiedStoreMu.Lock()+ h.unifiedStore = store+ h.unifiedStoreMu.Unlock()+}+// GetService returns the AI service for the current contextfunc (h *AIHandler) GetService(ctx context.Context) AIService {orgID := GetOrgID(ctx)@@ -380,6 +392,7 @@ type ChatRequest struct {SessionID string `json:"session_id,omitempty"`Model string `json:"model,omitempty"`Mentions []ChatMention `json:"mentions,omitempty"`+ FindingID string `json:"finding_id,omitempty"`}// HandleChat handles POST /api/ai/chat - streaming chat@@ -510,12 +523,49 @@ func (h *AIHandler) HandleChat(w http.ResponseWriter, r *http.Request) {})}+ // Augment prompt with finding context when discussing a specific finding+ prompt := req.Prompt+ if req.FindingID != "" {+ h.unifiedStoreMu.RLock()+ store := h.unifiedStore+ h.unifiedStoreMu.RUnlock()+ if store != nil {+ if f := store.Get(req.FindingID); f != nil {+ findingCtx := fmt.Sprintf("[Finding Context]\nID: %s\nTitle: %s\nSeverity: %s\nCategory: %s\nResource: %s (%s)\nDescription: %s",+ f.ID, f.Title, f.Severity, f.Category, f.ResourceName, f.ResourceType, f.Description)+ if f.Recommendation != "" {+ findingCtx += fmt.Sprintf("\nRecommendation: %s", f.Recommendation)+ }+ if f.Evidence != "" {+ findingCtx += fmt.Sprintf("\nEvidence: %s", f.Evidence)+ }+ if f.InvestigationStatus != "" {+ findingCtx += fmt.Sprintf("\nInvestigation Status: %s", f.InvestigationStatus)+ }+ if f.InvestigationOutcome != "" {+ findingCtx += fmt.Sprintf("\nInvestigation Outcome: %s", f.InvestigationOutcome)+ }+ if f.UserNote != "" {+ findingCtx += fmt.Sprintf("\nUser Note: %s", f.UserNote)+ }+ if f.AcknowledgedAt != nil {+ findingCtx += fmt.Sprintf("\nAcknowledged At: %s", f.AcknowledgedAt.Format(time.RFC3339))+ }+ if f.Node != "" {+ findingCtx += fmt.Sprintf("\nNode: %s", f.Node)+ }+ prompt = findingCtx + "\n\n---\nUser message: " + prompt+ }+ }+ }+// Stream from AI chat serviceerr := svc.ExecuteStream(ctx, chat.ExecuteRequest{- Prompt: req.Prompt,+ Prompt: prompt,SessionID: req.SessionID,Model: req.Model,Mentions: chatMentions,+ FindingID: req.FindingID,}, func(event chat.StreamEvent) {writeEvent(event)})diff --git a/internal/api/ai_handlers.go b/internal/api/ai_handlers.goindex b2fa0d4a06..407a0df450 100644--- a/internal/api/ai_handlers.go+++ b/internal/api/ai_handlers.go@@ -3664,6 +3664,12 @@ func (h *AISettingsHandler) HandleSetFindingNote(w http.ResponseWriter, r *http.return}+ // Mirror the note to the unified store immediately so it's visible+ // without waiting for the next patrol sync cycle+ if unifiedStore := h.GetUnifiedStore(); unifiedStore != nil {+ unifiedStore.SetUserNote(req.FindingID, req.Note)+ }+response := map[string]interface{}{"success": true,"message": "Note updated",diff --git a/internal/api/router.go b/internal/api/router.goindex a786511767..c861d4401d 100644--- a/internal/api/router.go+++ b/internal/api/router.go@@ -2120,6 +2120,12 @@ func (r *Router) StartPatrol(ctx context.Context) {InvestigationOutcome: f.InvestigationOutcome,LastInvestigatedAt: f.LastInvestigatedAt,InvestigationAttempts: f.InvestigationAttempts,+ AcknowledgedAt: f.AcknowledgedAt,+ SnoozedUntil: f.SnoozedUntil,+ DismissedReason: f.DismissedReason,+ UserNote: f.UserNote,+ Suppressed: f.Suppressed,+ TimesRaised: f.TimesRaised,}_, isNew := unifiedStore.AddFromAI(uf)return isNew@@ -2157,6 +2163,12 @@ func (r *Router) StartPatrol(ctx context.Context) {InvestigationOutcome: f.InvestigationOutcome,LastInvestigatedAt: f.LastInvestigatedAt,InvestigationAttempts: f.InvestigationAttempts,+ AcknowledgedAt: f.AcknowledgedAt,+ SnoozedUntil: f.SnoozedUntil,+ DismissedReason: f.DismissedReason,+ UserNote: f.UserNote,+ Suppressed: f.Suppressed,+ TimesRaised: f.TimesRaised,}// Copy resolution timestamp if resolvedif f.ResolvedAt != nil || f.AutoResolved {@@ -2171,6 +2183,9 @@ func (r *Router) StartPatrol(ctx context.Context) {}log.Info().Int("count", len(existingFindings)).Msg("AI Intelligence: Synced existing patrol findings to unified store")}++ // Wire unified store for "Discuss with Assistant" finding context lookup+ r.aiHandler.SetUnifiedStore(unifiedStore)}}