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): complete wiring on first-time configure; guard Ollama fallback

rcourtmanae2edbde204f
diff --git a/frontend-modern/public/install-host-agent.ps1 b/frontend-modern/public/install-host-agent.ps1
index c0c14509c3..d212c1c651 100644
--- a/frontend-modern/public/install-host-agent.ps1
+++ b/frontend-modern/public/install-host-agent.ps1
@@ -473,7 +473,7 @@ if (-not $NoService) {
for ($i = 1; $i -le $maxRetries; $i++) {
Start-Sleep -Seconds $retryDelay
- $hostname = $env:COMPUTERNAME
+ $hostname = if ($Hostname) { $Hostname } else { $env:COMPUTERNAME }
$lookupHost = Test-AgentRegistration -PulseUrl $PulseUrl -Hostname $hostname -Token $Token
if ($lookupHost) {
diff --git a/internal/ai/chat/service.go b/internal/ai/chat/service.go
index 3a5f3309e4..6b69080a72 100644
--- a/internal/ai/chat/service.go
+++ b/internal/ai/chat/service.go
@@ -773,10 +773,9 @@ 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 != "" {
+ // Only fall back for bare/unrecognized model names (no explicit "ollama:" prefix).
+ // An explicit "ollama:llama3" must not be silently rerouted to a different provider.
+ if !strings.HasPrefix(modelStr, "ollama:") && s.cfg.OpenAIAPIKey != "" && s.cfg.OpenAIBaseURL != "" {
return providers.NewOpenAIClient(s.cfg.OpenAIAPIKey, modelName, s.cfg.OpenAIBaseURL, timeout), nil
}
baseURL = "http://localhost:11434"
diff --git a/internal/api/router.go b/internal/api/router.go
index 0181da78e3..62e6abaa6f 100644
--- a/internal/api/router.go
+++ b/internal/api/router.go
@@ -3447,11 +3447,26 @@ func (r *Router) StopAIChat(ctx context.Context) {
// RestartAIChat restarts the AI chat service with updated configuration
// Call this when AI settings change that affect the service (e.g., model selection)
func (r *Router) RestartAIChat(ctx context.Context) {
- if r.aiHandler != nil {
- if err := r.aiHandler.Restart(ctx); err != nil {
- log.Error().Err(err).Msg("Failed to restart AI chat service")
- } else {
- log.Info().Msg("AI chat service restarted with new configuration")
+ if r.aiHandler == nil {
+ return
+ }
+
+ wasRunning := r.aiHandler.IsRunning(ctx)
+
+ if err := r.aiHandler.Restart(ctx); err != nil {
+ log.Error().Err(err).Msg("Failed to restart AI chat service")
+ return
+ }
+
+ log.Info().Msg("AI chat service restarted with new configuration")
+
+ // If the service just started for the first time (was not running before),
+ // perform the full post-start wiring that StartAIChat normally handles.
+ if !wasRunning && r.aiHandler.IsRunning(ctx) {
+ r.wireAIChatProviders()
+ r.wireChatServiceToAI()
+ if r.aiSettingsHandler != nil {
+ r.aiSettingsHandler.WireOrchestratorAfterChatStart()
}
}
}