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 Patrol configuration readiness
rcourtman4e56f006e7b3
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 4159d847fa..576226ff26 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -845,7 +845,10 @@ the canonical monitored-system blocked payload.and the Patrol autonomy save contract, so Community/free runtime payloadsmay persist only `monitor` autonomy settings through`/api/ai/patrol/autonomy`, while `approval`, `assisted`, and `full` return- the canonical license-required response instead of a generic save failure+ the canonical license-required response instead of a generic save failure,+ and Patrol frontend state owners must clamp stale paid autonomy to `monitor`+ before submitting that endpoint when the safe-remediation entitlement is not+ effectiveand the Patrol settings-save readiness contract, so`/api/settings/ai/update` may save a selected Patrol provider/model evenwhen that model is not ready for tool-backed Patrol execution, but it must@@ -3777,4 +3780,8 @@ configuration from paid remediation autonomy. `GET /api/ai/patrol/autonomy`continues to clamp effective Community autonomy to `monitor`, and`PUT /api/ai/patrol/autonomy` in the open-source/free adapter must accept andpersist only `monitor` settings while returning the canonical license-required-payload for investigation or remediation autonomy levels.+payload for investigation or remediation autonomy levels. Frontend Patrol state+owners must not rely on that 402 as normal control flow for stale local state:+when the current entitlement locks safe remediation, they submit `monitor` even+if older persisted settings or a previous entitlement left `approval`,+`assisted`, or `full` in memory.diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex fba47a0402..2ba06c8009 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -716,7 +716,10 @@ frontend primitive boundary.of that shared feature-presentation boundary: it must stay viewport-bounded,expose an accessible dialog label, and pass backend save rejection reasonsthrough as inline dialog state instead of replacing them with generic toast- copy. If that inline state opens Assistant, the Patrol feature must hand off+ 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. If that inline state opens Assistant, the Patrol feature must hand offa source-named, model-only briefing and close the popover so the sharedAssistant drawer is not visually hidden behind feature chrome.19. Keep the shared `system-ai` settings shell product-first.diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.mdindex 7c9ff8d30c..24a115edd5 100644--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md@@ -369,7 +369,15 @@ after a page render: recoverable Patrol provider/model settings saves mustpersist and echo structured readiness cause metadata, manual run requests mustreturn the structured readiness reason if a stale UI still submits, andscheduled or scoped alert/anomaly runs must skip before calling the model while-preserving the blocked reason and cause in Patrol status.+preserving the blocked reason and cause in Patrol status. The Patrol+configuration state owner must also clamp stale investigation/remediation+autonomy back to findings-only `monitor` before submitting Apply Configuration+when the safe-remediation entitlement is not effective, so an expired or+downgraded plan cannot turn a recoverable configuration review into a Pro-only+save failure. The same inline error surface must render any Patrol readiness+provider, model, and summary carried by the failure object, and keep the+provider-settings action immediately available before the operator chooses to+open the Assistant handoff.That same Patrol-owned presentation rule also applies to the findings emptystate: `frontend-modern/src/components/AI/FindingsPanel.tsx` must not treat`0 active findings` as equivalent to "your infrastructure looks healthy" whendiff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsxindex c512c2ac2e..53eff0ad81 100644--- a/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx@@ -17,8 +17,29 @@ import { getPatrolPageHeaderMeta } from '@/utils/patrolPagePresentation';import { buildPatrolScheduleOptions } from '@/utils/aiPatrolSchedulePresentation';import { getPatrolRuntimePresentation } from '@/utils/patrolRuntimePresentation';import { getPatrolRecencyPresentation } from '@/utils/patrolSummaryPresentation';+import { PATROL_PROVIDER_SETTINGS_ACTION } from '@/utils/patrolRuntimeActions';+import type { PatrolConfigurationFailureInput } from './patrolInvestigationContextModel';import type { PatrolIntelligenceState } from './usePatrolIntelligenceState';+const isNonEmptyConfigurationDetail = (value?: string | null): value is string =>+ Boolean(value?.trim());++export function getPatrolConfigurationFailureInlineDetails(+ failure: PatrolConfigurationFailureInput,+): string[] {+ const readiness = failure.readiness ?? null;+ const codeAndCause = [failure.code, readiness?.cause || failure.blockedCause]+ .filter(isNonEmptyConfigurationDetail)+ .join(' · ');++ return [+ codeAndCause || undefined,+ readiness?.summary ? `Readiness: ${readiness.summary}` : undefined,+ readiness?.provider ? `Provider: ${readiness.provider}` : undefined,+ readiness?.model ? `Model: ${readiness.model}` : undefined,+ ].filter(isNonEmptyConfigurationDetail);+}+export function PatrolIntelligenceHeader(props: { state: PatrolIntelligenceState }) {const state = props.state;const headerMeta = getPatrolPageHeaderMeta();@@ -414,22 +435,36 @@ export function PatrolIntelligenceHeader(props: { state: PatrolIntelligenceState><p class="text-xs font-semibold">Patrol configuration was not saved</p><p class="mt-1 text-xs leading-relaxed">{failure().message}</p>- <Show when={failure().code || failure().readiness?.cause}>- <p class="mt-1 text-[11px] leading-relaxed opacity-80">- {[failure().code, failure().readiness?.cause]- .filter(Boolean)- .join(' · ')}- </p>- </Show>- <button- type="button"- data-testid="patrol-configuration-error-assistant-button"- onClick={state.openAdvancedSettingsErrorInAssistant}- class="mt-2 inline-flex items-center gap-1.5 rounded-md border border-red-300 bg-white/80 px-2 py-1 text-xs font-medium text-red-950 transition-colors hover:bg-white dark:border-red-700 dark:bg-red-950/40 dark:text-red-100 dark:hover:bg-red-900/50"+ <Show+ when={+ getPatrolConfigurationFailureInlineDetails(failure()).length > 0+ }>- <MessageSquareIcon class="h-3.5 w-3.5" />- Discuss with Assistant- </button>+ <ul class="mt-1 space-y-0.5 text-[11px] leading-relaxed opacity-80">+ <For each={getPatrolConfigurationFailureInlineDetails(failure())}>+ {(detail) => <li>{detail}</li>}+ </For>+ </ul>+ </Show>+ <div class="mt-2 flex flex-wrap items-center gap-2">+ <button+ type="button"+ data-testid="patrol-configuration-error-assistant-button"+ onClick={state.openAdvancedSettingsErrorInAssistant}+ class="inline-flex items-center gap-1.5 rounded-md border border-red-300 bg-white/80 px-2 py-1 text-xs font-medium text-red-950 transition-colors hover:bg-white dark:border-red-700 dark:bg-red-950/40 dark:text-red-100 dark:hover:bg-red-900/50"+ >+ <MessageSquareIcon class="h-3.5 w-3.5" />+ Discuss with Assistant+ </button>+ <a+ href={PATROL_PROVIDER_SETTINGS_ACTION.href}+ data-testid="patrol-configuration-error-settings-link"+ class="inline-flex items-center gap-1.5 rounded-md border border-red-300 bg-white/80 px-2 py-1 text-xs font-medium text-red-950 transition-colors hover:bg-white dark:border-red-700 dark:bg-red-950/40 dark:text-red-100 dark:hover:bg-red-900/50"+ >+ <SettingsIcon class="h-3.5 w-3.5" />+ {PATROL_PROVIDER_SETTINGS_ACTION.label}+ </a>+ </div></div>)}</Show>diff --git a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceHeader.test.ts b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceHeader.test.tsnew file mode 100644index 0000000000..359105fd31--- /dev/null+++ b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceHeader.test.ts@@ -0,0 +1,37 @@+import { describe, expect, it } from 'vitest';++import { getPatrolConfigurationFailureInlineDetails } from '../PatrolIntelligenceHeader';++describe('PatrolIntelligenceHeader', () => {+ it('keeps Patrol configuration readiness context visible inline', () => {+ expect(+ getPatrolConfigurationFailureInlineDetails({+ message: 'Patrol configuration could not be saved.',+ code: 'patrol_readiness_not_ready',+ readiness: {+ status: 'not_ready',+ cause: 'model_unsupported_tools',+ summary:+ 'The selected Patrol model is a reasoning-only model family that commonly does not emit tool calls.',+ provider: 'openrouter',+ model: 'openrouter:deepseek/deepseek-r1',+ },+ }),+ ).toEqual([+ 'patrol_readiness_not_ready · model_unsupported_tools',+ 'Readiness: The selected Patrol model is a reasoning-only model family that commonly does not emit tool calls.',+ 'Provider: openrouter',+ 'Model: openrouter:deepseek/deepseek-r1',+ ]);+ });++ it('falls back to the blocked cause when readiness cause is absent', () => {+ expect(+ getPatrolConfigurationFailureInlineDetails({+ message: 'Patrol configuration could not be saved.',+ code: 'patrol_autonomy_pro_required',+ blockedCause: 'license_required',+ }),+ ).toEqual(['patrol_autonomy_pro_required · license_required']);+ });+});diff --git a/frontend-modern/src/features/patrol/__tests__/usePatrolIntelligenceState.test.ts b/frontend-modern/src/features/patrol/__tests__/usePatrolIntelligenceState.test.tsnew file mode 100644index 0000000000..8c8754a204--- /dev/null+++ b/frontend-modern/src/features/patrol/__tests__/usePatrolIntelligenceState.test.ts@@ -0,0 +1,19 @@+import { describe, expect, it } from 'vitest';++import { resolvePatrolAutonomyLevelForSave } from '../usePatrolIntelligenceState';++describe('usePatrolIntelligenceState', () => {+ describe('resolvePatrolAutonomyLevelForSave', () => {+ it('clamps stale paid autonomy to monitor when safe remediation is locked', () => {+ expect(resolvePatrolAutonomyLevelForSave('full', true, true)).toBe('monitor');+ expect(resolvePatrolAutonomyLevelForSave('assisted', false, true)).toBe('monitor');+ expect(resolvePatrolAutonomyLevelForSave('approval', false, true)).toBe('monitor');+ });++ it('preserves paid autonomy choices when safe remediation is available', () => {+ expect(resolvePatrolAutonomyLevelForSave('assisted', false, false)).toBe('assisted');+ expect(resolvePatrolAutonomyLevelForSave('assisted', true, false)).toBe('full');+ expect(resolvePatrolAutonomyLevelForSave('approval', false, false)).toBe('approval');+ });+ });+});diff --git a/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts b/frontend-modern/src/features/patrol/usePatrolIntelligenceState.tsindex 073b2ac43e..c57c75945b 100644--- a/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts+++ b/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts@@ -45,6 +45,18 @@ type PatrolAPIError = Error & {const patrolErrorMessage = (error: unknown, fallback: string) =>error instanceof Error && error.message.trim() ? error.message : fallback;+export function resolvePatrolAutonomyLevelForSave(+ level: PatrolAutonomyLevel,+ fullModeUnlocked: boolean,+ autoFixLocked: boolean,+): PatrolAutonomyLevel {+ if (autoFixLocked) return 'monitor';+ if (level === 'assisted' || level === 'full') {+ return fullModeUnlocked ? 'full' : 'assisted';+ }+ return level;+}+export function usePatrolIntelligenceState() {const [initialSurfaceReady, setInitialSurfaceReady] = createSignal(false);const [activeTab, setActiveTab] = createSignal<PatrolTab>('findings');@@ -496,10 +508,14 @@ export function usePatrolIntelligenceState() {async function handleAutonomyChange(level: PatrolAutonomyLevel) {if (isUpdatingAutonomy()) return;- if (autoFixLocked() && (level === 'approval' || level === 'assisted')) return;+ if (autoFixLocked() && level !== 'monitor') return;const previousLevel = autonomyLevel();- const effectiveLevel = level === 'assisted' && fullModeUnlocked() ? 'full' : level;+ const effectiveLevel = resolvePatrolAutonomyLevelForSave(+ level,+ fullModeUnlocked(),+ autoFixLocked(),+ );setAutonomyLevel(effectiveLevel);setIsUpdatingAutonomy(true);@@ -523,6 +539,11 @@ export function usePatrolIntelligenceState() {const apiError = err as PatrolAPIError;const message = patrolErrorMessage(err, 'Failed to save Patrol configuration');const readiness = patrolReadiness();+ const apiDetails = apiError.details ?? {};+ const hasReadinessDetails =+ Boolean(apiDetails.status || apiDetails.provider || apiDetails.model) ||+ apiError.code === 'patrol_readiness_not_ready';+ const readinessSummary = apiDetails.readiness_summary ?? apiDetails.summary;return {message,code: apiError.code,@@ -540,7 +561,17 @@ export function usePatrolIntelligenceState() {provider: readiness.provider,model: readiness.model,}- : null,+ : hasReadinessDetails+ ? {+ status: apiDetails.status,+ cause: apiDetails.cause,+ summary:+ readinessSummary ||+ (apiError.code === 'patrol_readiness_not_ready' ? message : undefined),+ provider: apiDetails.provider,+ model: apiDetails.model,+ }+ : null,runtimeState: runtimeState(),blockedReason: blockedReason(),blockedCause: patrolStatus()?.blocked_cause,@@ -551,11 +582,11 @@ export function usePatrolIntelligenceState() {setIsSavingAdvanced(true);setAdvancedSettingsError(null);try {- let effectiveLevel = autonomyLevel();- const inAutoFix = effectiveLevel === 'assisted' || effectiveLevel === 'full';- if (inAutoFix) {- effectiveLevel = fullModeUnlocked() ? 'full' : 'assisted';- }+ const effectiveLevel = resolvePatrolAutonomyLevelForSave(+ autonomyLevel(),+ fullModeUnlocked(),+ autoFixLocked(),+ );const result = await updatePatrolAutonomySettings({autonomy_level: effectiveLevel,diff --git a/tests/integration/tests/18-patrol-runtime-state.spec.ts b/tests/integration/tests/18-patrol-runtime-state.spec.tsindex 9b1dfa2469..740aaec4c9 100644--- a/tests/integration/tests/18-patrol-runtime-state.spec.ts+++ b/tests/integration/tests/18-patrol-runtime-state.spec.ts@@ -230,13 +230,16 @@ const scopedTriggerPatrolStatus = {async function mockBlockedPatrolRuntimeState(page: Page,- options: { autonomyRoute?: (route: Route) => Promise<void> } = {},+ options: {+ autonomyRoute?: (route: Route) => Promise<void>;+ status?: Record<string, unknown>;+ } = {},): Promise<void> {await page.route("**/api/ai/patrol/status", async (route) => {await route.fulfill({status: 200,contentType: "application/json",- body: JSON.stringify(blockedPatrolStatus),+ body: JSON.stringify(options.status ?? blockedPatrolStatus),});});@@ -562,6 +565,18 @@ test.describe("Patrol runtime-state browser contract", () => {]);await ensureAuthenticated(page);await mockBlockedPatrolRuntimeState(page, {+ status: {+ ...blockedPatrolStatus,+ readiness: {+ status: "not_ready",+ ready: false,+ cause: "model_unsupported_tools",+ summary: PATROL_REASONING_ONLY_REJECTION,+ provider: "openrouter",+ model: "openrouter:deepseek/deepseek-r1",+ checks: [],+ },+ },autonomyRoute: async (route) => {if (route.request().method() !== "PUT") {await route.fulfill({@@ -645,6 +660,14 @@ test.describe("Patrol runtime-state browser contract", () => {await expect(inlineError).toBeVisible();await expect(inlineError).toContainText(PATROL_AUTONOMY_PRO_REQUIRED);await expect(inlineError).toContainText("patrol_autonomy_pro_required");+ await expect(inlineError).toContainText(PATROL_REASONING_ONLY_REJECTION);+ await expect(inlineError).toContainText("Provider: openrouter");+ await expect(inlineError).toContainText(+ "Model: openrouter:deepseek/deepseek-r1",+ );+ await expect(+ inlineError.getByRole("link", { name: "Open Patrol provider settings" }),+ ).toHaveAttribute("href", "/settings/system-ai");await inlineError.getByTestId("patrol-configuration-error-assistant-button").click();