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): start chat service on first-time configure without restart

rcourtmane137f3fbf78a
diff --git a/internal/ai/chat/service.go b/internal/ai/chat/service.go
index 3b967f6ab7..3a5f3309e4 100644
--- a/internal/ai/chat/service.go
+++ b/internal/ai/chat/service.go
@@ -773,6 +773,12 @@ func (s *Service) createProviderForModel(modelStr string) (providers.StreamingPr
case "ollama":
baseURL := s.cfg.OllamaBaseURL
if baseURL == "" {
+ // Ollama not explicitly configured. If the user has a custom OpenAI-compatible
+ // base URL set, route there instead — this handles bare model names (e.g.
+ // "qwen3-omni") typed manually for self-hosted OpenAI-compatible endpoints.
+ if s.cfg.OpenAIAPIKey != "" && s.cfg.OpenAIBaseURL != "" {
+ return providers.NewOpenAIClient(s.cfg.OpenAIAPIKey, modelName, s.cfg.OpenAIBaseURL, timeout), nil
+ }
baseURL = "http://localhost:11434"
}
return providers.NewOllamaClient(modelName, baseURL, timeout), nil
diff --git a/internal/api/ai_handler.go b/internal/api/ai_handler.go
index 70fd6ba943..4015dd0e35 100644
--- a/internal/api/ai_handler.go
+++ b/internal/api/ai_handler.go
@@ -349,17 +349,13 @@ func (h *AIHandler) Restart(ctx context.Context) error {
// Load fresh config from persistence to get latest settings
newCfg := h.loadAIConfig(ctx)
- if h.legacyService == nil {
- return nil
- }
-
- if !h.legacyService.IsRunning() {
- // If not running but enabled, try to start
+ // If service was never started (first-time configure) or has stopped, start it
+ // when AI is now enabled. Handles both the nil case (Pulse started before AI
+ // was configured) and the stopped case (previous start failed or was stopped).
+ if h.legacyService == nil || !h.legacyService.IsRunning() {
if newCfg != nil && newCfg.Enabled {
log.Info().Msg("Starting AI service via restart trigger")
- // We need a state provider to start
- // Try to get default state provider from existing map if available
var sp AIStateProvider
h.stateProvidersMu.RLock()
for _, p := range h.stateProviders {
@@ -368,10 +364,9 @@ func (h *AIHandler) Restart(ctx context.Context) error {
}
h.stateProvidersMu.RUnlock()
- // Reuse start logic
return h.Start(ctx, sp)
}
- return nil // Not running and not enabled, nothing to do
+ return nil
}
return h.legacyService.Restart(ctx, newCfg)