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.

Fix AI investigation context and UI settings

rcourtman3d8374e52792
diff --git a/frontend-modern/src/pages/AIIntelligence.tsx b/frontend-modern/src/pages/AIIntelligence.tsx
index e4d9672a69..324002edab 100644
--- a/frontend-modern/src/pages/AIIntelligence.tsx
+++ b/frontend-modern/src/pages/AIIntelligence.tsx
@@ -742,9 +742,8 @@ export function AIIntelligence() {
</div>
</div>
- {/* Advanced Settings Gear — hidden for free users since all settings are Pro-only */}
- <Show when={!autoFixLocked() || !alertAnalysisLocked()}>
- <div class="relative" ref={advancedSettingsRef}>
+ {/* Advanced Settings Gear — visible to all users with gentle Pro upgrade hints */}
+ <div class="relative" ref={advancedSettingsRef}>
<button
onClick={() => setShowAdvancedSettings(!showAdvancedSettings())}
disabled={!patrolEnabledLocal()}
@@ -847,7 +846,6 @@ export function AIIntelligence() {
</div>
</Show>
</div>
- </Show>
</div>
</div>
</div>
diff --git a/internal/ai/investigation/adapters_test.go b/internal/ai/investigation/adapters_test.go
index 167205612d..474660cb68 100644
--- a/internal/ai/investigation/adapters_test.go
+++ b/internal/ai/investigation/adapters_test.go
@@ -197,6 +197,7 @@ func newTestChatService(t *testing.T) *chat.Service {
setServiceField(t, svc, "sessions", sessions)
setServiceField(t, svc, "agenticLoop", agentic)
setServiceField(t, svc, "executor", executor)
+ setServiceField(t, svc, "provider", provider)
setServiceField(t, svc, "started", true)
return svc
diff --git a/internal/api/ai_handlers.go b/internal/api/ai_handlers.go
index 407a0df450..b722b705f5 100644
--- a/internal/api/ai_handlers.go
+++ b/internal/api/ai_handlers.go
@@ -749,8 +749,8 @@ func (h *AISettingsHandler) setupInvestigationOrchestrator(orgID string, svc *ai
}
h.investigationMu.Unlock()
- // Get chat service for this org
- ctx := context.Background()
+ // Get chat service for this org using org-scoped context
+ ctx := context.WithValue(context.Background(), OrgIDContextKey, orgID)
chatSvc := h.chatHandler.GetService(ctx)
if chatSvc == nil {
log.Warn().Str("orgID", orgID).Msg("Chat service not available for orchestrator")
@@ -2705,13 +2705,27 @@ func (h *AISettingsHandler) HandleInvestigateAlert(w http.ResponseWriter, r *htt
}
// SetAlertProvider sets the alert provider for AI context
+// Sets on both the legacy service and all tenant services to ensure multi-tenant support.
func (h *AISettingsHandler) SetAlertProvider(ap ai.AlertProvider) {
- h.GetAIService(context.Background()).SetAlertProvider(ap)
+ h.legacyAIService.SetAlertProvider(ap)
+
+ h.aiServicesMu.RLock()
+ defer h.aiServicesMu.RUnlock()
+ for _, svc := range h.aiServices {
+ svc.SetAlertProvider(ap)
+ }
}
// SetAlertResolver sets the alert resolver for AI Patrol autonomous alert management
+// Sets on both the legacy service and all tenant services to ensure multi-tenant support.
func (h *AISettingsHandler) SetAlertResolver(resolver ai.AlertResolver) {
- h.GetAIService(context.Background()).SetAlertResolver(resolver)
+ h.legacyAIService.SetAlertResolver(resolver)
+
+ h.aiServicesMu.RLock()
+ defer h.aiServicesMu.RUnlock()
+ for _, svc := range h.aiServices {
+ svc.SetAlertResolver(resolver)
+ }
}
// oauthSessions stores active OAuth sessions (state -> session)