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.

Keep direct DeepSeek Patrol models selectable

rcourtmand5735a1b9245
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 8ae96f5fb8..8ba42114b4 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -494,6 +494,12 @@ provider-owned fallback must track the current V4 API contract and use
`deepseek-chat` or `deepseek-reasoner`; AI runtime context-window and cost
budgeting must likewise know the V4 Flash/Pro 1M context and distinct pricing
classes before Patrol treats those models as ready.
+The shared `/api/ai/models` catalog must preserve that same direct-provider
+fallback posture for configured DeepSeek paths: when DeepSeek live catalog
+listing fails or omits current V4 entries, the backend catalog must still
+surface direct `deepseek-v4-flash` and `deepseek-v4-pro` options plus clearly
+labelled legacy aliases so saved Patrol or Assistant selections do not render
+as unrelated default models in the browser.
Retired quickstart ownership is now an inert compatibility boundary, not a
self-hosted GA runtime path. The old quickstart provider, bootstrap manager,
and local token-cache persistence API are removed from the Pulse runtime;
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 64882f01f1..549b8c0e22 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -1143,6 +1143,11 @@ the canonical monitored-system blocked payload.
store after an owned settings mutation, but they must not reintroduce
page-local mount loops that fetch `/api/settings/ai` or `/api/ai/models`
separately for chat, Patrol, and cost/budget views.
+ The `/api/ai/models` catalog must also include backend-owned
+ direct-provider fallback entries for configured DeepSeek V4 paths when
+ live provider catalog reads fail, so Patrol and Assistant model selectors
+ keep saved `deepseek:` selections visible without inventing page-local
+ catalog entries or falling back to another provider's model.
26. Keep API-backed first-target onboarding canonical on that same shared
infrastructure-settings boundary:
`frontend-modern/src/components/Settings/infrastructureOperationsModel.tsx`,
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 0f78059a3e..dd88e8daa4 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -771,7 +771,11 @@ prompt explain the same operator-facing priority.
copy. When the failure includes Patrol readiness context, the inline state
must expose the provider, model, and readiness summary next to a direct
provider-settings action instead of hiding that diagnosis behind Assistant
- alone. Successful provider-model saves that return a not-ready Patrol
+ alone. The provider-model selector in that popover must stay bound to the
+ shared runtime settings/model catalog even when the popover mounts after
+ async catalog loading, so a saved direct-provider Patrol model renders as
+ that model instead of visually falling back to the default selection.
+ Successful provider-model saves that return a not-ready Patrol
readiness snapshot must use that same inline surface with `needs attention`
wording, while Assistant receives a saved configuration issue rather than a
failed-save handoff. When safe remediation is locked, the same popover
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index f6717cb075..373f225b3c 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -338,7 +338,12 @@ owns local toggle optimism, run-status orchestration, and Patrol-only copy,
including runtime-availability messaging that stays Patrol-first in
operator-facing shells and uses provider/API-key wording only for the actual
configuration boundary, but the underlying AI runtime catalog must stay shared
-with chat and AI settings.
+with chat and AI settings. The Patrol configuration model selector must remain
+state-driven across async settings/catalog loading: a saved direct-provider
+model such as `deepseek:deepseek-v4-flash` must render as that provider model
+once the shared catalog supplies it, not fall back visually to the default
+model or an unrelated OpenRouter entry because the popover mounted after the
+catalog request completed.
The Patrol page now also treats Patrol runtime availability as a first-class
render contract: the header chip, primary summary card, and status bar must
all route through the shared `frontend-modern/src/utils/patrolRuntimePresentation.ts`
diff --git a/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts b/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts
index 8f162223e3..cfe600ce38 100644
--- a/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts
+++ b/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts
@@ -167,9 +167,10 @@ export function usePatrolIntelligenceState() {
const [patrolAlertTriggers, setPatrolAlertTriggers] = createSignal<boolean>(true);
const [patrolAnomalyTriggers, setPatrolAnomalyTriggers] = createSignal<boolean>(true);
const [selectedRun, setSelectedRun] = createSignal<PatrolRunRecord | null>(null);
+ const [patrolModelSelectElement, setPatrolModelSelectElement] =
+ createSignal<HTMLSelectElement>();
let advancedSettingsRef: HTMLDivElement | undefined;
- let patrolModelSelectRef: HTMLSelectElement | undefined;
let safetyTimerRef: ReturnType<typeof setTimeout> | undefined;
let scrollToFindingTimerRef: ReturnType<typeof setTimeout> | undefined;
let findingScrollTimerRef: ReturnType<typeof setTimeout> | undefined;
@@ -181,7 +182,7 @@ export function usePatrolIntelligenceState() {
};
const setPatrolModelSelectRef = (element: HTMLSelectElement | undefined) => {
- patrolModelSelectRef = element;
+ setPatrolModelSelectElement(() => element);
};
const clearSafetyTimer = () => {
@@ -247,9 +248,12 @@ export function usePatrolIntelligenceState() {
createEffect(() => {
const model = patrolModel();
- const models = availableModels();
- if (patrolModelSelectRef && models.length > 0 && model) {
- patrolModelSelectRef.value = model;
+ const select = patrolModelSelectElement();
+ // Track model catalog changes so a valid selected model is reapplied after
+ // async options are mounted into the configuration popover.
+ availableModels();
+ if (select) {
+ select.value = model;
}
});
diff --git a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
index c3a5ff5b8a..4ee9092ddf 100644
--- a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
+++ b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
@@ -181,6 +181,9 @@ vi.mock('@/stores/aiIntelligence', () => {
get findings() {
return intelligenceState.findings;
},
+ get patrolFindings() {
+ return intelligenceState.findings;
+ },
get intelligenceSummary() {
return intelligenceState.summary;
},
@@ -722,6 +725,50 @@ describe('AIIntelligence entitlement gating', () => {
expect(screen.queryByRole('button', { name: /start free trial/i })).not.toBeInTheDocument();
});
+ it('keeps a saved direct-provider Patrol model selected after the catalog loads', async () => {
+ apiFetchJSONMock.mockImplementation(async (path: string) => {
+ if (path === '/api/ai/models') {
+ return {
+ models: [
+ {
+ id: 'deepseek:deepseek-v4-flash',
+ name: 'DeepSeek V4 Flash',
+ description: 'DeepSeek: current V4 Flash direct API model',
+ },
+ ],
+ };
+ }
+ if (path === '/api/settings/ai') {
+ return {
+ ...defaultAISettings,
+ model: 'openrouter:minimax/minimax-m2.5',
+ patrol_model: 'deepseek:deepseek-v4-flash',
+ };
+ }
+ if (path === '/api/settings/ai/update') {
+ return defaultAISettings;
+ }
+ return {};
+ });
+
+ render(() => <AIIntelligence />);
+
+ await waitFor(() => {
+ expect(screen.getByRole('heading', { name: 'Patrol' })).toBeInTheDocument();
+ });
+ await waitFor(() => {
+ expect(apiFetchJSONMock).toHaveBeenCalledWith('/api/ai/models');
+ });
+
+ fireEvent.click(screen.getByRole('button', { name: 'Configure Patrol' }));
+
+ const select = screen.getByLabelText('Provider model') as HTMLSelectElement;
+ await waitFor(() => {
+ expect(select.value).toBe('deepseek:deepseek-v4-flash');
+ });
+ expect(select.selectedOptions[0]?.textContent).toContain('DeepSeek V4 Flash');
+ });
+
it('unlocks paid patrol controls when the entitlement grants the features', async () => {
hasFeatureMock.mockReturnValue(true);
licenseStatusMock.mockReturnValue({ subscription_state: 'active' });
diff --git a/internal/ai/patrol_readiness.go b/internal/ai/patrol_readiness.go
index 86593df480..7b679d723f 100644
--- a/internal/ai/patrol_readiness.go
+++ b/internal/ai/patrol_readiness.go
@@ -113,12 +113,12 @@ func patrolDeepSeekModelName(normalizedModel string) string {
func patrolDeepSeekModelSupportsTools(normalizedModel string) bool {
model := patrolDeepSeekModelName(normalizedModel)
- return model == "deepseek-v4-flash" || model == "deepseek-v4-pro"
+ return config.IsDeepSeekV4Model(model)
}
func patrolDeepSeekLegacyAlias(normalizedModel string) bool {
model := patrolDeepSeekModelName(normalizedModel)
- return model == "deepseek-chat" || model == "deepseek-reasoner"
+ return config.IsDeepSeekLegacyAliasModel(model)
}
func patrolConfigReadiness(provider, model, status string, cause PatrolFailureCause, summary string) PatrolConfigReadiness {
diff --git a/internal/ai/providers/openai.go b/internal/ai/providers/openai.go
index 100f633140..98ddf35e9d 100644
--- a/internal/ai/providers/openai.go
+++ b/internal/ai/providers/openai.go
@@ -12,6 +12,7 @@ import (
"strings"
"time"
+ "github.com/rcourtman/pulse-go-rewrite/internal/config"
"github.com/rs/zerolog/log"
)
@@ -184,8 +185,9 @@ func (c *OpenAIClient) supportsForcedToolChoice(model string) bool {
if !c.isDeepSeek() {
return true
}
- switch normalizeOpenAICompatibleModelName(model) {
- case "deepseek-v4-flash", "deepseek-v4-pro", "deepseek-chat", "deepseek-reasoner":
+ normalized := normalizeOpenAICompatibleModelName(model)
+ switch {
+ case config.IsDeepSeekV4Model(normalized), config.IsDeepSeekLegacyAliasModel(normalized):
return true
default:
return false
diff --git a/internal/ai/service.go b/internal/ai/service.go
index d1cf51d4ba..4d0e5ad214 100644
--- a/internal/ai/service.go
+++ b/internal/ai/service.go
@@ -4469,20 +4469,22 @@ func (s *Service) ListModelsWithCache(ctx context.Context) ([]providers.ModelInf
log.Warn().Err(err).Str("provider", providerName).Msg("failed to fetch models from provider")
// Keep stale entry (don't overwrite or delete) — the provider's
// previous models remain visible until a successful fetch replaces them.
+ if !hasEntry || len(entry.models) == 0 {
+ if fallbackModels := providerCatalogFallbackModels(providerName); len(fallbackModels) > 0 {
+ s.modelsCache.mu.Lock()
+ s.modelsCache.providers[providerName] = providerModelsEntry{
+ at: time.Now(),
+ models: prefixProviderModels(providerName, fallbackModels),
+ }
+ s.modelsCache.mu.Unlock()
+ }
+ }
continue
}
+ models = mergeProviderCatalogFallbackModels(providerName, models)
// Build prefixed model list for this provider
- prefixed := make([]providers.ModelInfo, 0, len(models))
- for _, m := range models {
- prefixed = append(prefixed, providers.ModelInfo{
- ID: config.FormatModelString(providerName, m.ID),
- Name: m.Name,
- Description: providerDisplayName(providerName) + ": " + m.ID,
- CreatedAt: m.CreatedAt,
- Notable: m.Notable,
- })
- }
+ prefixed := prefixProviderModels(providerName, models)
s.modelsCache.mu.Lock()
s.modelsCache.providers[providerName] = providerModelsEntry{
@@ -4505,6 +4507,87 @@ func (s *Service) ListModelsWithCache(ctx context.Context) ([]providers.ModelInf
return allModels, allCached, nil
}
+func prefixProviderModels(providerName string, models []providers.ModelInfo) []providers.ModelInfo {
+ prefixed := make([]providers.ModelInfo, 0, len(models))
+ for _, m := range models {
+ if strings.TrimSpace(m.ID) == "" {
+ continue
+ }
+ description := strings.TrimSpace(m.Description)
+ if description == "" {
+ description = providerDisplayName(providerName) + ": " + m.ID
+ }
+ prefixed = append(prefixed, providers.ModelInfo{
+ ID: config.FormatModelString(providerName, m.ID),
+ Name: m.Name,
+ Description: description,
+ CreatedAt: m.CreatedAt,
+ Notable: m.Notable,
+ })
+ }
+ return prefixed
+}
+
+func mergeProviderCatalogFallbackModels(providerName string, models []providers.ModelInfo) []providers.ModelInfo {
+ fallbacks := providerCatalogFallbackModels(providerName)
+ if len(fallbacks) == 0 {
+ return models
+ }
+ seen := make(map[string]struct{}, len(models)+len(fallbacks))
+ merged := make([]providers.ModelInfo, 0, len(models)+len(fallbacks))
+ for _, model := range models {
+ id := strings.ToLower(strings.TrimSpace(model.ID))
+ if id == "" {
+ continue
+ }
+ seen[id] = struct{}{}
+ merged = append(merged, model)
+ }
+ for _, fallback := range fallbacks {
+ id := strings.ToLower(strings.TrimSpace(fallback.ID))
+ if id == "" {
+ continue
+ }
+ if _, ok := seen[id]; ok {
+ continue
+ }
+ merged = append(merged, fallback)
+ }
+ return merged
+}
+
+func providerCatalogFallbackModels(providerName string) []providers.ModelInfo {
+ switch providerName {
+ case config.AIProviderDeepSeek:
+ return []providers.ModelInfo{
+ {
+ ID: config.DeepSeekModelV4Flash,
+ Name: "DeepSeek V4 Flash",
+ Description: "DeepSeek: current V4 Flash direct API model",
+ Notable: true,
+ },
+ {
+ ID: config.DeepSeekModelV4Pro,
+ Name: "DeepSeek V4 Pro",
+ Description: "DeepSeek: current V4 Pro direct API model",
+ Notable: true,
+ },
+ {
+ ID: config.DeepSeekModelLegacyChat,
+ Name: "DeepSeek Chat (legacy alias)",
+ Description: "DeepSeek: legacy alias currently routing to V4 Flash",
+ },
+ {
+ ID: config.DeepSeekModelLegacyReasoner,
+ Name: "DeepSeek Reasoner (legacy alias)",
+ Description: "DeepSeek: legacy alias currently routing to V4 Flash",
+ },
+ }
+ default:
+ return nil
+ }
+}
+
func buildModelsCacheKey(cfg *config.AIConfig) string {
if cfg == nil {
return "nil"
diff --git a/internal/ai/service_extended_test.go b/internal/ai/service_extended_test.go
index 2832dac299..30f5e5294d 100644
--- a/internal/ai/service_extended_test.go
+++ b/internal/ai/service_extended_test.go
@@ -2592,6 +2592,49 @@ func TestService_ListModelsWithCache_ProviderErrors(t *testing.T) {
}
}
+func TestService_ListModelsWithCache_DeepSeekCatalogFallback(t *testing.T) {
+ tmpDir := t.TempDir()
+ persistence := config.NewConfigPersistence(tmpDir)
+ if err := persistence.SaveAIConfig(config.AIConfig{
+ Enabled: true,
+ Model: config.DefaultModelForProvider(config.AIProviderDeepSeek),
+ PatrolModel: config.FormatModelString(config.AIProviderDeepSeek, config.DeepSeekModelV4Flash),
+ DeepSeekAPIKey: "test-key",
+ }); err != nil {
+ t.Fatalf("SaveAIConfig: %v", err)
+ }
+
+ svc := NewService(persistence, nil)
+ ctx, cancel := context.WithCancel(context.Background())
+ cancel()
+
+ models, cached, err := svc.ListModelsWithCache(ctx)
+ if err != nil {
+ t.Fatalf("ListModelsWithCache should not fail when DeepSeek catalog fetch fails: %v", err)
+ }
+ if cached {
+ t.Fatal("expected fallback catalog response to be uncached")
+ }
+
+ ids := make(map[string]providers.ModelInfo, len(models))
+ for _, model := range models {
+ ids[model.ID] = model
+ }
+ for _, want := range []string{
+ config.FormatModelString(config.AIProviderDeepSeek, config.DeepSeekModelV4Flash),
+ config.FormatModelString(config.AIProviderDeepSeek, config.DeepSeekModelV4Pro),
+ config.FormatModelString(config.AIProviderDeepSeek, config.DeepSeekModelLegacyChat),
+ config.FormatModelString(config.AIProviderDeepSeek, config.DeepSeekModelLegacyReasoner),
+ } {
+ if _, ok := ids[want]; !ok {
+ t.Fatalf("expected DeepSeek fallback model %q in %+v", want, models)
+ }
+ }
+ if got := ids[config.FormatModelString(config.AIProviderDeepSeek, config.DeepSeekModelV4Flash)].Name; got != "DeepSeek V4 Flash" {
+ t.Fatalf("unexpected DeepSeek V4 Flash display name %q", got)
+ }
+}
+
// ============================================================================
// GetDebugContext - Truncation
// ============================================================================
diff --git a/internal/config/ai.go b/internal/config/ai.go
index b559e5181e..482b0b21f5 100644
--- a/internal/config/ai.go
+++ b/internal/config/ai.go
@@ -145,6 +145,43 @@ const (
DefaultGeminiBaseURL = "https://generativelanguage.googleapis.com/v1beta"
)
+const (
+ DeepSeekModelV4Flash = "deepseek-v4-flash"
+ DeepSeekModelV4Pro = "deepseek-v4-pro"
+ DeepSeekModelLegacyChat = "deepseek-chat"
+ DeepSeekModelLegacyReasoner = "deepseek-reasoner"
+)
+
+// DeepSeekV4ModelIDs returns the current direct DeepSeek model IDs Pulse treats
+// as tool-capable for Assistant and Patrol runtime paths.
+func DeepSeekV4ModelIDs() []string {
+ return []string{DeepSeekModelV4Flash, DeepSeekModelV4Pro}
+}
+
+// DeepSeekLegacyAliasModelIDs returns direct DeepSeek aliases that are still
+// accepted by the provider but should be presented as legacy aliases.
+func DeepSeekLegacyAliasModelIDs() []string {
+ return []string{DeepSeekModelLegacyChat, DeepSeekModelLegacyReasoner}
+}
+
+func IsDeepSeekV4Model(model string) bool {
+ switch strings.ToLower(strings.TrimSpace(model)) {
+ case DeepSeekModelV4Flash, DeepSeekModelV4Pro:
+ return true
+ default:
+ return false
+ }
+}
+
+func IsDeepSeekLegacyAliasModel(model string) bool {
+ switch strings.ToLower(strings.TrimSpace(model)) {
+ case DeepSeekModelLegacyChat, DeepSeekModelLegacyReasoner:
+ return true
+ default:
+ return false
+ }
+}
+
// NewDefaultAIConfig returns an AIConfig with sensible defaults
func NewDefaultAIConfig() *AIConfig {
return &AIConfig{
@@ -353,7 +390,7 @@ func DefaultModelForProvider(provider string) string {
case AIProviderOpenRouter:
return FormatModelString(AIProviderOpenRouter, "openai/gpt-4o-mini")
case AIProviderDeepSeek:
- return FormatModelString(AIProviderDeepSeek, "deepseek-v4-flash")
+ return FormatModelString(AIProviderDeepSeek, DeepSeekModelV4Flash)
case AIProviderGemini:
return FormatModelString(AIProviderGemini, "gemini-1.5-pro")
case AIProviderOllama:
diff --git a/internal/config/ai_config_test.go b/internal/config/ai_config_test.go
index c5aa62ddfa..96fe710b4b 100644
--- a/internal/config/ai_config_test.go
+++ b/internal/config/ai_config_test.go
@@ -250,6 +250,27 @@ func TestDefaultModelForProvider_UsesCanonicalProviderFallbacks(t *testing.T) {
}
}
+func TestDeepSeekModelCatalogHelpers(t *testing.T) {
+ if got := DeepSeekV4ModelIDs(); len(got) != 2 || got[0] != DeepSeekModelV4Flash || got[1] != DeepSeekModelV4Pro {
+ t.Fatalf("DeepSeekV4ModelIDs() = %#v", got)
+ }
+ if got := DeepSeekLegacyAliasModelIDs(); len(got) != 2 || got[0] != DeepSeekModelLegacyChat || got[1] != DeepSeekModelLegacyReasoner {
+ t.Fatalf("DeepSeekLegacyAliasModelIDs() = %#v", got)
+ }
+ if !IsDeepSeekV4Model(" DeepSeek-V4-Flash ") {
+ t.Fatal("expected DeepSeek V4 Flash helper to normalize case and whitespace")
+ }
+ if IsDeepSeekV4Model(DeepSeekModelLegacyChat) {
+ t.Fatal("legacy alias must not be classified as a current V4 model")
+ }
+ if !IsDeepSeekLegacyAliasModel(" DEEPSEEK-REASONER ") {
+ t.Fatal("expected DeepSeek legacy alias helper to normalize case and whitespace")
+ }
+ if IsDeepSeekLegacyAliasModel(DeepSeekModelV4Pro) {
+ t.Fatal("current V4 model must not be classified as a legacy alias")
+ }
+}
+
func TestAIConfig_GetConfiguredProviders(t *testing.T) {
tests := []struct {
name string