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
Surface saved Patrol readiness issues
rcourtmanf12efba419e3
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 1e31a97740..215f24cdfa 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -924,8 +924,12 @@ the canonical monitored-system blocked payload.`/api/settings/ai/update` may save a selected Patrol provider/model evenwhen that model is not ready for tool-backed Patrol execution, but it mustecho `patrol_readiness` with stable `cause` metadata and execution routes- must continue to fail closed before model calls- and the structured investigation-record contract, so unified findings may+ must continue to fail closed before model calls. Frontend Patrol settings+ consumers must surface that saved-but-not-ready response as a saved+ configuration issue with the echoed provider, model, cause, and summary+ instead of reporting the successful save as a failed save or hiding the+ readiness blocker behind a generic notification; and the structured+ investigation-record contract, so unified findings mayexpose `investigation_record` only through the shared`aicontracts.InvestigationRecord` payload shape, with frontend API typesand backend contract tests updated in the same slice as any field changediff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex f2a38f7d24..57510a011b 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -764,7 +764,11 @@ prompt explain the same operator-facing priority.copy. When the failure includes Patrol readiness context, the inline statemust expose the provider, model, and readiness summary next to a directprovider-settings action instead of hiding that diagnosis behind Assistant- alone. When safe remediation is locked, the same popover state owner must+ alone. 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+ state owner mustclear stale full-mode unlock state before Apply Configuration submits themonitor-only autonomy payload, so disabled paid controls cannot leak stalepermission into a save. If that inline state opens Assistant, the Patroldiff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.mdindex a271d5a602..67d7bfeb40 100644--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md@@ -395,6 +395,12 @@ must send safe `handoff_metadata.kind=patrol_configuration_failure` plus onlythe runtime-failure boolean needed for drawer/session presentation, so thesaved session restores as a Patrol configuration issue without carrying rawprovider, credential, command, or retry payloads into the browser.+Successful provider-model saves that return+`patrol_readiness.status=not_ready` are still configuration issues, not silent+successes: the Patrol popover must keep the saved provider/model visible,+render a `Patrol configuration needs attention` inline state with the returned+readiness cause and summary, and hand off to Assistant as a model-only Patrol+configuration issue rather than as a save failure.The readiness contract now applies before Patrol work is admitted, not onlyafter a page render: recoverable Patrol provider/model settings saves mustpersist and echo structured readiness cause metadata, manual run requests mustdiff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsxindex 53eff0ad81..52fa0ba87e 100644--- a/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx@@ -433,7 +433,11 @@ export function PatrolIntelligenceHeader(props: { state: PatrolIntelligenceStatedata-testid="patrol-configuration-error"class="mb-3 rounded-md border border-red-300 bg-red-50 px-3 py-2.5 text-red-950 dark:border-red-800 dark:bg-red-950/30 dark:text-red-100">- <p class="text-xs font-semibold">Patrol configuration was not saved</p>+ <p class="text-xs font-semibold">+ {failure().saved+ ? 'Patrol configuration needs attention'+ : 'Patrol configuration was not saved'}+ </p><p class="mt-1 text-xs leading-relaxed">{failure().message}</p><Showwhen={diff --git a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsxindex e7a146cee5..d3b69812e4 100644--- a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx+++ b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx@@ -142,12 +142,29 @@ describe('PatrolIntelligenceSummary', () => {correlationTotal: () => 0,correlations: () => [],intelligenceSummary: () => ({+ timestamp: '2026-05-06T12:15:00Z',overall_health: {grade: 'C',score: 65,- factors: [{ category: 'coverage' }],+ trend: 'stable',+ factors: [+ {+ category: 'coverage',+ name: 'Coverage',+ impact: -10,+ description: 'Patrol coverage is incomplete.',+ },+ ],prediction: 'Patrol coverage is incomplete.',},+ findings_count: {+ critical: 0,+ warning: 0,+ watch: 0,+ info: 0,+ total: 0,+ },+ predictions_count: 0,recent_changes_count: 0,recent_changes: [],policy_posture: {@@ -155,10 +172,28 @@ describe('PatrolIntelligenceSummary', () => {sensitivity_counts: {},routing_counts: {},},+ learning: {+ resources_with_knowledge: 0,+ total_notes: 0,+ resources_with_baselines: 0,+ patterns_detected: 0,+ correlations_learned: 0,+ incidents_tracked: 0,+ },}),manualRunRequested: () => false,patrolStream: {+ phase: () => 'Running',+ currentTool: () => '',+ tokens: () => 0,+ resynced: () => false,+ resyncReason: () => '',+ bufferStartSeq: () => 0,+ bufferEndSeq: () => 0,+ outputTruncated: () => false,+ reconnectCount: () => 0,isStreaming: () => true,+ errorMessage: () => '',},runtimeState: () => 'running',summaryStats: () => ({diff --git a/frontend-modern/src/features/patrol/__tests__/patrolCommercialBoundary.test.ts b/frontend-modern/src/features/patrol/__tests__/patrolCommercialBoundary.test.tsindex 779463644d..09c5610dcd 100644--- a/frontend-modern/src/features/patrol/__tests__/patrolCommercialBoundary.test.ts+++ b/frontend-modern/src/features/patrol/__tests__/patrolCommercialBoundary.test.ts@@ -32,7 +32,7 @@ describe('patrol commercial boundary', () => {it('keeps the patrol configuration panel above lower page actions', () => {expect(patrolIntelligenceHeaderSource).toContain('fixed right-4 top-32 z-[9999] isolate');expect(patrolIntelligenceHeaderSource).toContain('max-h-[calc(100vh-10rem)]');- expect(patrolIntelligenceHeaderSource).toContain('sm:max-h-[36rem]');+ expect(patrolIntelligenceHeaderSource).toContain('sm:max-h-[calc(100vh-14rem)]');expect(patrolIntelligenceHeaderSource).toContain('overflow-y-auto');expect(patrolIntelligenceHeaderSource).toContain('sm:top-[13rem]');expect(patrolIntelligenceHeaderSource).not.toContain('sm:top-[17.5rem]');diff --git a/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts b/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.tsindex f84cba38ed..0d286b822a 100644--- a/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts+++ b/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts@@ -668,6 +668,27 @@ describe('patrolInvestigationContextModel', () => {expect(JSON.stringify(handoff)).not.toContain('systemctl restart pulse.service');});+ it('labels saved Patrol configuration readiness issues separately from save failures', () => {+ const handoff = buildPatrolConfigurationFailureHandoff({+ saved: true,+ message: 'Patrol was saved, but the selected model cannot run Patrol tools yet.',+ code: 'patrol_readiness_not_ready',+ readiness: {+ status: 'not_ready',+ cause: 'model_unsupported_tools',+ summary: 'The selected Patrol model cannot run tools.',+ provider: 'ollama',+ model: 'ollama:deepseek-r1:7b',+ },+ });++ expect(handoff.prompt).toContain('Discuss this Pulse Patrol configuration issue');+ expect(handoff.context.briefing).toMatchObject({+ title: 'Patrol configuration issue attached',+ actionLabel: 'Review Patrol configuration issue',+ });+ });+it('builds operator-facing Patrol record presentation without exposing raw commands', () => {const presentation = buildPatrolInvestigationRecordPresentation({id: 'record-1',diff --git a/frontend-modern/src/features/patrol/__tests__/usePatrolIntelligenceState.test.ts b/frontend-modern/src/features/patrol/__tests__/usePatrolIntelligenceState.test.tsindex 8965cb3c80..03d7bf48b0 100644--- a/frontend-modern/src/features/patrol/__tests__/usePatrolIntelligenceState.test.ts+++ b/frontend-modern/src/features/patrol/__tests__/usePatrolIntelligenceState.test.ts@@ -1,9 +1,29 @@import { describe, expect, it } from 'vitest';import {+ buildPatrolSettingsReadinessFailure,resolvePatrolAutonomyLevelForSave,resolvePatrolAutonomySettingsForSave,} from '../usePatrolIntelligenceState';+import type { AISettings, PatrolReadiness } from '@/types/ai';++const settingsWithReadiness = (patrolReadiness: PatrolReadiness): AISettings => ({+ enabled: true,+ model: 'ollama:llama3',+ configured: true,+ custom_context: '',+ auth_method: 'api_key',+ oauth_connected: false,+ anthropic_configured: false,+ openai_configured: false,+ openrouter_configured: false,+ deepseek_configured: false,+ gemini_configured: false,+ ollama_configured: true,+ ollama_base_url: 'http://127.0.0.1:11434',+ configured_providers: ['ollama'],+ patrol_readiness: patrolReadiness,+});describe('usePatrolIntelligenceState', () => {describe('resolvePatrolAutonomyLevelForSave', () => {@@ -67,4 +87,67 @@ describe('usePatrolIntelligenceState', () => {).toEqual({ autonomyLevel: 'assisted', fullModeUnlocked: false });});});++ describe('buildPatrolSettingsReadinessFailure', () => {+ it('ignores settings snapshots that do not block Patrol readiness', () => {+ expect(+ buildPatrolSettingsReadinessFailure({+ settings: settingsWithReadiness({+ status: 'warning',+ ready: true,+ summary: 'Patrol can run with reduced confidence.',+ checks: [],+ }),+ }),+ ).toBeNull();+ });++ it('builds a saved configuration issue from a not-ready settings response', () => {+ expect(+ buildPatrolSettingsReadinessFailure({+ settings: settingsWithReadiness({+ status: 'not_ready',+ ready: false,+ cause: 'model_unsupported_tools',+ summary: 'The selected model cannot run Patrol tools.',+ provider: 'ollama',+ model: 'ollama:deepseek-r1:7b',+ checks: [],+ }),+ autonomyLevel: 'monitor',+ fullModeUnlocked: false,+ investigationBudget: 15,+ investigationTimeoutSec: 300,+ runtimeState: 'blocked',+ blockedReason: 'Connect a tool-capable Patrol model.',+ }),+ ).toEqual({+ message: 'The selected model cannot run Patrol tools.',+ code: 'patrol_readiness_not_ready',+ status: 409,+ saved: true,+ details: {+ status: 'not_ready',+ cause: 'model_unsupported_tools',+ summary: 'The selected model cannot run Patrol tools.',+ provider: 'ollama',+ model: 'ollama:deepseek-r1:7b',+ },+ autonomyLevel: 'monitor',+ fullModeUnlocked: false,+ investigationBudget: 15,+ investigationTimeoutSec: 300,+ readiness: {+ status: 'not_ready',+ cause: 'model_unsupported_tools',+ summary: 'The selected model cannot run Patrol tools.',+ provider: 'ollama',+ model: 'ollama:deepseek-r1:7b',+ },+ runtimeState: 'blocked',+ blockedReason: 'Connect a tool-capable Patrol model.',+ blockedCause: undefined,+ });+ });+ });});diff --git a/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts b/frontend-modern/src/features/patrol/patrolInvestigationContextModel.tsindex 301a893f1e..097343a227 100644--- a/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts+++ b/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts@@ -277,6 +277,7 @@ export interface PatrolConfigurationFailureInput {message: string;code?: string;status?: number;+ saved?: boolean;details?: Record<string, string>;autonomyLevel?: string;fullModeUnlocked?: boolean;@@ -690,6 +691,7 @@ export function buildPatrolConfigurationFailureHandoff(): PatrolConfigurationFailureHandoff {const message = normalizeText(input.message) || 'Patrol configuration could not be saved.';const code = normalizeText(input.code);+ const issueLabel = input.saved ? 'Patrol configuration issue' : 'Patrol configuration failure';const readinessSummary = normalizeText(input.readiness?.summary);const cause = normalizeText(input.readiness?.cause) || normalizeText(input.blockedCause);const provider = normalizeText(input.readiness?.provider);@@ -715,7 +717,7 @@ export function buildPatrolConfigurationFailureHandoff(},briefing: {sourceLabel: 'Pulse Patrol',- title: 'Patrol configuration failure attached',+ title: `${issueLabel.charAt(0).toUpperCase()}${issueLabel.slice(1)} attached`,subject: code ? `${code}: ${message}` : message,statusLabel:[input.status ? `HTTP ${input.status}` : undefined, cause]@@ -723,7 +725,7 @@ export function buildPatrolConfigurationFailureHandoff(.join(' · ') || undefined,detailLines: detailLines.slice(0, 4),evidence: formatConfigurationFailureDetails(input.details).slice(0, 4),- actionLabel: 'Review Patrol configuration failure',+ actionLabel: `Review ${issueLabel}`,safetyNote:'Assistant can explain the configuration state; provider changes, retries, and remediation remain operator-controlled.',suggestedPrompts: formatPatrolSuggestedPrompts([@@ -1245,8 +1247,9 @@ function buildPatrolConfigurationFailurePrompt(detailLines: string[],): string {const code = normalizeText(input.code);+ const issueLabel = input.saved ? 'configuration issue' : 'configuration failure';return [- 'Discuss this Pulse Patrol configuration failure.',+ `Discuss this Pulse Patrol ${issueLabel}.`,code ? `Server code: ${code}.` : undefined,`Start by explaining this failure: ${truncateContextText(message, 220)}.`,detailLines.length > 0 ? `Attached details: ${detailLines.join('; ')}.` : undefined,diff --git a/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts b/frontend-modern/src/features/patrol/usePatrolIntelligenceState.tsindex 5047e5cb92..be40594f36 100644--- a/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts+++ b/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts@@ -45,6 +45,19 @@ type PatrolAPIError = Error & {const patrolErrorMessage = (error: unknown, fallback: string) =>error instanceof Error && error.message.trim() ? error.message : fallback;+const buildReadinessDetails = (+ readiness: NonNullable<AISettings['patrol_readiness']>,+): Record<string, string> => {+ const details: Record<string, string> = {+ status: readiness.status,+ };+ if (readiness.cause?.trim()) details.cause = readiness.cause.trim();+ if (readiness.summary?.trim()) details.summary = readiness.summary.trim();+ if (readiness.provider?.trim()) details.provider = readiness.provider.trim();+ if (readiness.model?.trim()) details.model = readiness.model.trim();+ return details;+};+export function resolvePatrolAutonomyLevelForSave(level: PatrolAutonomyLevel,fullModeUnlocked: boolean,@@ -75,6 +88,54 @@ export function resolvePatrolAutonomySettingsForSave({};}+export function buildPatrolSettingsReadinessFailure({+ settings,+ message,+ autonomyLevel,+ fullModeUnlocked,+ investigationBudget,+ investigationTimeoutSec,+ runtimeState,+ blockedReason,+ blockedCause,+}: {+ settings: AISettings | null | undefined;+ message?: string;+ autonomyLevel?: string;+ fullModeUnlocked?: boolean;+ investigationBudget?: number;+ investigationTimeoutSec?: number;+ runtimeState?: string;+ blockedReason?: string;+ blockedCause?: string;+}): PatrolConfigurationFailureInput | null {+ const readiness = settings?.patrol_readiness;+ if (!readiness || readiness.status !== 'not_ready') return null;++ return {+ message:+ message || readiness.summary || 'Patrol settings were saved, but Patrol is not ready to run.',+ code: 'patrol_readiness_not_ready',+ status: 409,+ saved: true,+ details: buildReadinessDetails(readiness),+ autonomyLevel,+ fullModeUnlocked,+ investigationBudget,+ investigationTimeoutSec,+ readiness: {+ status: readiness.status,+ cause: readiness.cause,+ summary: readiness.summary,+ provider: readiness.provider,+ model: readiness.model,+ },+ runtimeState,+ blockedReason,+ blockedCause,+ };+}+export function usePatrolIntelligenceState() {const [initialSurfaceReady, setInitialSurfaceReady] = createSignal(false);const [activeTab, setActiveTab] = createSignal<PatrolTab>('findings');@@ -211,9 +272,28 @@ export function usePatrolIntelligenceState() {applyPatrolAISettings(aiRuntimeSettings());});+ const surfaceSavedPatrolReadinessIssue = (+ settings: AISettings | null | undefined,+ message?: string,+ ) => {+ const failure = buildPatrolSettingsReadinessFailure({+ settings,+ message,+ autonomyLevel: autonomyLevel(),+ fullModeUnlocked: fullModeUnlocked(),+ investigationBudget: investigationBudget(),+ investigationTimeoutSec: investigationTimeout(),+ runtimeState: runtimeState(),+ blockedReason: blockedReason(),+ blockedCause: patrolStatus()?.blocked_cause,+ });+ setAdvancedSettingsError(failure);+ };+async function handleTogglePatrol() {if (isTogglingPatrol()) return;setIsTogglingPatrol(true);+ setAdvancedSettingsError(null);const previousValue = patrolEnabledLocal();const newValue = !previousValue;setPatrolEnabledLocal(newValue);@@ -232,6 +312,10 @@ export function usePatrolIntelligenceState() {if (typeof data?.patrol_interval_minutes === 'number') {setPatrolInterval(data.patrol_interval_minutes);}+ surfaceSavedPatrolReadinessIssue(+ data,+ 'Patrol setting was saved, but Patrol is not ready to run.',+ );if (refetchPatrolStatus) {refetchPatrolStatus();}@@ -281,13 +365,19 @@ export function usePatrolIntelligenceState() {async function handleModelChange(modelId: string) {if (isUpdatingSettings()) return;setIsUpdatingSettings(true);+ setAdvancedSettingsError(null);try {const updated = await AIAPI.updateSettings({ patrol_model: modelId });syncAIRuntimeSettings(updated);setPatrolModel(updated.patrol_model || modelId);+ surfaceSavedPatrolReadinessIssue(+ updated,+ 'Patrol model was saved, but Patrol is not ready to run.',+ );await refetchPatrolStatus();} catch (err) {console.error('Failed to update patrol model:', err);+ setAdvancedSettingsError(buildAdvancedSettingsFailure(err, 'Failed to update Patrol model'));notificationStore.error(patrolErrorMessage(err, 'Failed to update patrol model'));} finally {setIsUpdatingSettings(false);@@ -297,11 +387,16 @@ export function usePatrolIntelligenceState() {async function handleIntervalChange(minutes: number) {if (isUpdatingSettings()) return;setIsUpdatingSettings(true);+ setAdvancedSettingsError(null);try {const updated = await AIAPI.updateSettings({ patrol_interval_minutes: minutes });syncAIRuntimeSettings(updated);setPatrolInterval(updated.patrol_interval_minutes ?? minutes);setPatrolEnabledLocal((updated.patrol_interval_minutes ?? minutes) > 0);+ surfaceSavedPatrolReadinessIssue(+ updated,+ 'Patrol schedule was saved, but Patrol is not ready to run.',+ );refetchPatrolStatus();} catch (err) {console.error('Failed to update patrol interval:', err);@@ -314,11 +409,16 @@ export function usePatrolIntelligenceState() {async function handleAlertTriggeredAnalysisChange(enabled: boolean) {if (isUpdatingSettings()) return;setIsUpdatingSettings(true);+ setAdvancedSettingsError(null);const previous = alertTriggeredAnalysis();setAlertTriggeredAnalysis(enabled);try {const updated = await AIAPI.updateSettings({ alert_triggered_analysis: enabled });syncAIRuntimeSettings(updated);+ surfaceSavedPatrolReadinessIssue(+ updated,+ 'Patrol setting was saved, but Patrol is not ready to run.',+ );} catch (err) {console.error('Failed to update alert-triggered analysis:', err);setAlertTriggeredAnalysis(previous);@@ -331,11 +431,16 @@ export function usePatrolIntelligenceState() {async function handlePatrolAlertTriggersChange(enabled: boolean) {if (isUpdatingSettings()) return;setIsUpdatingSettings(true);+ setAdvancedSettingsError(null);const previous = patrolAlertTriggers();setPatrolAlertTriggers(enabled);try {const updated = await AIAPI.updateSettings({ patrol_alert_triggers_enabled: enabled });syncAIRuntimeSettings(updated);+ surfaceSavedPatrolReadinessIssue(+ updated,+ 'Patrol trigger setting was saved, but Patrol is not ready to run.',+ );} catch (err) {console.error('Failed to update alert-triggered patrols:', err);setPatrolAlertTriggers(previous);@@ -350,11 +455,16 @@ export function usePatrolIntelligenceState() {async function handlePatrolAnomalyTriggersChange(enabled: boolean) {if (isUpdatingSettings()) return;setIsUpdatingSettings(true);+ setAdvancedSettingsError(null);const previous = patrolAnomalyTriggers();setPatrolAnomalyTriggers(enabled);try {const updated = await AIAPI.updateSettings({ patrol_anomaly_triggers_enabled: enabled });syncAIRuntimeSettings(updated);+ surfaceSavedPatrolReadinessIssue(+ updated,+ 'Patrol trigger setting was saved, but Patrol is not ready to run.',+ );} catch (err) {console.error('Failed to update anomaly-triggered patrols:', err);setPatrolAnomalyTriggers(previous);@@ -557,9 +667,12 @@ export function usePatrolIntelligenceState() {}}- const buildAdvancedSettingsFailure = (err: unknown): PatrolConfigurationFailureInput => {+ const buildAdvancedSettingsFailure = (+ err: unknown,+ fallback = 'Failed to save Patrol configuration',+ ): PatrolConfigurationFailureInput => {const apiError = err as PatrolAPIError;- const message = patrolErrorMessage(err, 'Failed to save Patrol configuration');+ const message = patrolErrorMessage(err, fallback);const readiness = patrolReadiness();const apiDetails = apiError.details ?? {};const hasReadinessDetails =diff --git a/tests/integration/tests/18-patrol-runtime-state.spec.ts b/tests/integration/tests/18-patrol-runtime-state.spec.tsindex 52ad9f74b5..c5841edce5 100644--- a/tests/integration/tests/18-patrol-runtime-state.spec.ts+++ b/tests/integration/tests/18-patrol-runtime-state.spec.ts@@ -232,6 +232,12 @@ async function mockBlockedPatrolRuntimeState(page: Page,options: {autonomyRoute?: (route: Route) => Promise<void>;+ models?: Array<{+ id: string;+ name: string;+ description?: string;+ notable?: boolean;+ }>;status?: Record<string, unknown>;} = {},): Promise<void> {@@ -272,7 +278,7 @@ async function mockBlockedPatrolRuntimeState(await route.fulfill({status: 200,contentType: "application/json",- body: JSON.stringify({ models: [] }),+ body: JSON.stringify({ models: options.models ?? [] }),});});@@ -691,6 +697,121 @@ test.describe("Patrol runtime-state browser contract", () => {).toHaveCount(0);});+ test("surfaces model readiness blocker after Patrol provider-model save", async ({+ page,+ }, testInfo) => {+ test.skip(+ testInfo.project.name.startsWith("mobile-"),+ "Desktop-only Patrol configuration coverage",+ );++ let settingsUpdatePayload: Record<string, unknown> | null = null;+ const unsupportedModel = "ollama:deepseek-r1:7b";++ await mockRuntimeCapabilities(page, ["ai_patrol", "ai_alerts"]);+ await ensureAuthenticated(page);+ await page.route("**/api/settings/ai/update", async (route) => {+ settingsUpdatePayload = route.request().postDataJSON() as Record<+ string,+ unknown+ >;+ await route.fulfill({+ status: 200,+ contentType: "application/json",+ body: JSON.stringify({+ enabled: true,+ configured: true,+ model: "ollama:llama3",+ chat_model: "ollama:llama3",+ patrol_model: unsupportedModel,+ patrol_interval_minutes: 360,+ patrol_enabled: true,+ alert_triggered_analysis: false,+ patrol_alert_triggers_enabled: true,+ patrol_anomaly_triggers_enabled: true,+ patrol_event_triggers_enabled: true,+ patrol_auto_fix: false,+ anthropic_configured: false,+ openai_configured: false,+ openrouter_configured: false,+ deepseek_configured: false,+ gemini_configured: false,+ ollama_configured: true,+ ollama_base_url: "http://127.0.0.1:11434",+ configured_providers: ["ollama"],+ custom_context: "",+ auth_method: "api_key",+ oauth_connected: false,+ request_timeout_seconds: 300,+ control_level: "read_only",+ protected_guests: [],+ discovery_enabled: false,+ discovery_interval_hours: 0,+ patrol_readiness: {+ status: "not_ready",+ ready: false,+ cause: "model_unsupported_tools",+ summary: PATROL_REASONING_ONLY_REJECTION,+ provider: "ollama",+ model: unsupportedModel,+ checks: [+ {+ id: "tools",+ status: "not_ready",+ cause: "model_unsupported_tools",+ label: "Patrol tools",+ message: PATROL_REASONING_ONLY_REJECTION,+ action: "open_provider_settings",+ },+ ],+ },+ }),+ });+ });+ await mockBlockedPatrolRuntimeState(page, {+ models: [{ id: unsupportedModel, name: "DeepSeek R1" }],+ });++ await page.goto("/patrol", { waitUntil: "domcontentloaded" });+ await page.getByRole("button", { name: "Configure Patrol" }).click();+ const configPanel = page.getByRole("dialog", {+ name: "Patrol Configuration",+ });++ await configPanel+ .getByLabel("Provider model")+ .selectOption(unsupportedModel);+ await expect+ .poll(() => settingsUpdatePayload)+ .toMatchObject({ patrol_model: unsupportedModel });++ const inlineError = configPanel.getByTestId("patrol-configuration-error");+ await expect(inlineError).toBeVisible();+ await expect(inlineError).toContainText(+ "Patrol configuration needs attention",+ );+ await expect(inlineError).toContainText(+ "Patrol model was saved, but Patrol is not ready to run.",+ );+ await expect(inlineError).toContainText(PATROL_REASONING_ONLY_REJECTION);+ await expect(inlineError).toContainText(+ "patrol_readiness_not_ready · model_unsupported_tools",+ );+ await expect(inlineError).toContainText("Provider: ollama");+ await expect(inlineError).toContainText(`Model: ${unsupportedModel}`);+ await expect(page.getByText("Failed to update patrol model")).toHaveCount(+ 0,+ );++ await inlineError+ .getByTestId("patrol-configuration-error-assistant-button")+ .click();+ await expect(configPanel).toBeHidden();+ await expect(page.getByLabel("Assistant context")).toContainText(+ "Patrol configuration issue attached",+ );+ });+test("clamps stale full-mode state before monitor-only Patrol configuration save", async ({page,}, testInfo) => {@@ -855,7 +976,11 @@ test.describe("Patrol runtime-state browser contract", () => {await expect(page.getByText("Selected model does not support Patrol tools"),).toBeVisible();- await expect(page.getByText(/tool_choice/)).toBeVisible();+ await expect(+ page.getByText("Provider rejected Patrol tool calls"),+ ).toBeVisible();+ await expect(page.getByText(/tool_choice/)).toHaveCount(0);+ await expect(page.getByText(/No endpoints found/)).toHaveCount(0);await expect(page.getByRole("link", { name: "Open Patrol provider settings" }),).toHaveAttribute("href", "/settings/system-ai");