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.

Align Patrol empty state with health

rcourtman6461db982bbc
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 433d2d488c..19b3659c8b 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -113,6 +113,7 @@ Own canonical runtime payload shapes between backend and frontend.
6. Route dedicated unified-resource timeline and facet-bundle reads through `frontend-modern/src/api/resources.ts`, `internal/api/resources.go`, and `internal/api/contract_test.go` together so the backend facet contract and the frontend client stay aligned on one timeline-first surface, while capability and relationship detail stays backend-owned for AI correlation and change detection
7. Route canonical AI intelligence summary and resource-intelligence reads through `frontend-modern/src/api/ai.ts`, `frontend-modern/src/stores/aiIntelligence.ts`, `frontend-modern/src/stores/aiIntelligenceSummaryModel.ts`, `frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts`, `frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx`, the Patrol-owned section files under `frontend-modern/src/features/patrol/`, `frontend-modern/src/pages/AIIntelligence.tsx`, `internal/api/ai_handlers.go`, and `internal/api/contract_test.go` together so the summary card, store normalization owner, runtime hook, feature shell, section owners, route shell, and backend payload stay aligned on one governed surface, including the canonical recent-changes slice
while keeping the learning counters backend-only coverage, so the summary page keeps Patrol health and findings primary and renders timeline, correlation, and policy-posture data as secondary investigation context rather than as a separate headline product metric
+ and the Patrol findings empty-state behavior, so `0 active findings` only renders as a healthy frontend conclusion when the same governed AI summary contract still reports healthy overall health; degraded or not-fully-verified health predictions must flow through to the Patrol findings surface instead of being replaced by page-local "looks healthy" copy
and the shared `frontend-modern/src/components/Infrastructure/ResourceChangeSummary.tsx` card, so canonical recent-change timelines stay rendered through one governed frontend card instead of separate page-local list loops
and the shared `frontend-modern/src/utils/resourceChangePresentation.ts` formatter used by the summary page and resource drawer, so canonical change wording does not drift across surfaces
and the `/api/ai/intelligence/changes` route plus `internal/api/contract_test.go`, so the canonical recent-changes endpoint stays on the same intelligence facade and contract snapshot instead of bypassing the shared timeline source
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 90a09e27f8..f4fdf38119 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -182,6 +182,11 @@ Those same feature-owned header badges must also stay aligned to the owning
runtime state instead of surfacing stale auxiliary counters as primary status;
an exhausted quickstart-credit badge cannot override an otherwise active Patrol
runtime unless quickstart exhaustion is the active blocker.
+That same route-owned presentation rule also governs Patrol findings empty
+states: shared section shells under `frontend-modern/src/features/patrol/`
+must not render a green healthy empty state from `0 active findings` alone
+when the owning Patrol runtime or overall-health summary is degraded, blocked,
+or not fully verified.
`frontend-modern/src/components/shared/TagBadges.tsx` is now also the
canonical tag-badge primitive. Dashboard workload rows and the unified-resource
detail drawer must import that shared owner instead of keeping a dashboard-local
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index 4eb9554723..4ee083ea6a 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -112,6 +112,14 @@ reports `runtime_state=blocked`, the real `/ai` route must show Patrol as
paused, keep the blocked reason visible, disable manual Patrol runs, and
suppress stale healthy summary headlines such as `Health A · 100/100` even if
the last summary payload still looks healthy.
+That same Patrol-owned presentation rule also applies to the findings empty
+state: `frontend-modern/src/components/AI/FindingsPanel.tsx` must not treat
+`0 active findings` as equivalent to "your infrastructure looks healthy" when
+the Patrol runtime is blocked, disabled, or unavailable, or when the canonical
+overall-health summary is degraded or not fully verified. The green healthy
+empty state belongs only to an actually healthy Patrol summary, while degraded
+coverage or paused-runtime states must surface the governing warning/error copy
+through `frontend-modern/src/utils/patrolEmptyStatePresentation.ts`.
hook-local fallback logic.
The Patrol header now also has explicit helper ownership for its quickstart and
schedule presentation. `frontend-modern/src/utils/aiQuickstartPresentation.ts`
diff --git a/frontend-modern/src/components/AI/FindingsPanel.tsx b/frontend-modern/src/components/AI/FindingsPanel.tsx
index bba96dcea4..7b025f177b 100644
--- a/frontend-modern/src/components/AI/FindingsPanel.tsx
+++ b/frontend-modern/src/components/AI/FindingsPanel.tsx
@@ -18,17 +18,23 @@ import { notificationStore } from '@/stores/notifications';
import { aiChatStore } from '@/stores/aiChat';
import { InvestigationSection, ApprovalSection } from '@/components/patrol';
import { AIAPI, type RemediationPlan } from '@/api/ai';
+import type { PatrolRuntimeState } from '@/api/patrol';
import { getApprovalRiskPresentation } from '@/utils/approvalRiskPresentation';
import { formatRelativeTime } from '@/utils/format';
import { getFindingAlertIdentifier, hasTriggeringAlert } from '@/utils/findingAlertIdentity';
import { logger } from '@/utils/logger';
import { segmentedButtonClass } from '@/utils/segmentedButton';
+import { getSemanticTonePresentation } from '@/utils/semanticTonePresentation';
import { formatIdentifierLabel } from '@/utils/textPresentation';
+import type { IntelligenceHealthScore } from '@/types/aiIntelligence';
+import { getPatrolFindingsEmptyState } from '@/utils/patrolEmptyStatePresentation';
+import CheckCircleIcon from 'lucide-solid/icons/check-circle';
+import AlertCircleIcon from 'lucide-solid/icons/alert-circle';
+import AlertTriangleIcon from 'lucide-solid/icons/alert-triangle';
import {
buildFindingFilterOptions,
formatFindingLifecycleType,
formatFindingLoopState,
- getFindingEmptyStateCopy,
getFindingSeveritySortOrder,
getFindingResolutionReason,
getFindingLoopStateBadgeClasses,
@@ -59,6 +65,9 @@ interface FindingsPanelProps {
scopeResourceIds?: string[];
scopeResourceTypes?: string[];
showScopeWarnings?: boolean;
+ runtimeState?: PatrolRuntimeState;
+ blockedReason?: string;
+ overallHealth?: IntelligenceHealthScore;
}
export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
@@ -211,7 +220,15 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
pendingApprovalCount: aiIntelligenceStore.pendingApprovalCount,
}),
);
- const emptyStateCopy = createMemo(() => getFindingEmptyStateCopy(filter()));
+ const emptyStateCopy = createMemo(() =>
+ getPatrolFindingsEmptyState({
+ filter: filter(),
+ overallHealth: props.overallHealth,
+ runtimeState: props.runtimeState,
+ blockedReason: props.blockedReason,
+ }),
+ );
+ const emptyStateTone = createMemo(() => getSemanticTonePresentation(emptyStateCopy().tone));
const isOutOfScope = (finding: UnifiedFinding): boolean => {
if (!props.showScopeWarnings) {
@@ -1094,19 +1111,32 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
<div class="p-6 text-sm text-muted text-center">
<Show when={filter() === 'active'}>
<div class="flex flex-col items-center gap-3">
- <svg
- class="w-10 h-10 text-green-500"
- fill="none"
- stroke="currentColor"
- viewBox="0 0 24 24"
+ <Show
+ when={emptyStateCopy().tone === 'success'}
+ fallback={
+ <Show
+ when={emptyStateCopy().tone === 'error'}
+ fallback={
+ <Show
+ when={emptyStateCopy().tone === 'warning'}
+ fallback={
+ <AlertCircleIcon
+ class={`w-10 h-10 ${emptyStateTone().iconClass}`}
+ />
+ }
+ >
+ <AlertTriangleIcon
+ class={`w-10 h-10 ${emptyStateTone().iconClass}`}
+ />
+ </Show>
+ }
+ >
+ <AlertTriangleIcon class={`w-10 h-10 ${emptyStateTone().iconClass}`} />
+ </Show>
+ }
>
- <path
- stroke-linecap="round"
- stroke-linejoin="round"
- stroke-width="2"
- d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
- />
- </svg>
+ <CheckCircleIcon class={`w-10 h-10 ${emptyStateTone().iconClass}`} />
+ </Show>
<div>
<p class="font-medium text-base-content">{emptyStateCopy().title}</p>
<Show when={emptyStateCopy().body}>
diff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx
index 3580275e35..502978d42f 100644
--- a/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx
+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx
@@ -102,6 +102,9 @@ export function PatrolIntelligenceWorkspace(props: { state: PatrolIntelligenceSt
scopeResourceIds={state.selectedRunScopeResourceIds()}
scopeResourceTypes={state.selectedRun()?.scope_resource_types}
showScopeWarnings={Boolean(state.selectedRun())}
+ runtimeState={state.runtimeState()}
+ blockedReason={state.blockedReason()}
+ overallHealth={state.intelligenceSummary()?.overall_health}
/>
</Show>
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index dc7901c064..df525a724a 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -4471,6 +4471,9 @@ describe('frontend resource type boundaries', () => {
'export function getInvestigationSectionState',
);
expect(patrolEmptyStatePresentationSource).toContain('export function getRunHistoryEmptyState');
+ expect(patrolEmptyStatePresentationSource).toContain(
+ 'export function getPatrolFindingsEmptyState',
+ );
expect(patrolRunPresentationSource).toContain('export function getRunHistoryLoadingState');
expect(patrolRunPresentationSource).toContain('export function getToolCallsLoadingState');
expect(patrolRunPresentationSource).toContain('export function getToolCallsUnavailableState');
diff --git a/frontend-modern/src/utils/__tests__/patrolEmptyStatePresentation.test.ts b/frontend-modern/src/utils/__tests__/patrolEmptyStatePresentation.test.ts
index 834746d900..a55abac342 100644
--- a/frontend-modern/src/utils/__tests__/patrolEmptyStatePresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/patrolEmptyStatePresentation.test.ts
@@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest';
import {
getInvestigationMessagesState,
getInvestigationSectionState,
+ getPatrolFindingsEmptyState,
getRunHistoryEmptyState,
} from '@/utils/patrolEmptyStatePresentation';
@@ -33,4 +34,67 @@ describe('patrolEmptyStatePresentation', () => {
empty: true,
});
});
+
+ it('suppresses the healthy findings empty state when patrol health is not fully verified', () => {
+ expect(
+ getPatrolFindingsEmptyState({
+ filter: 'active',
+ overallHealth: {
+ score: 70,
+ grade: 'C',
+ trend: 'stable',
+ factors: [
+ {
+ name: 'Patrol coverage incomplete',
+ impact: -0.35,
+ description:
+ 'Patrol coverage is incomplete: recent activity was limited to scoped runs and ended with errors, so overall health is not fully verified.',
+ category: 'coverage',
+ },
+ ],
+ prediction:
+ 'Patrol coverage is incomplete: recent activity was limited to scoped runs and ended with errors, so overall health is not fully verified.',
+ },
+ runtimeState: 'active',
+ }),
+ ).toEqual({
+ title: 'No active findings',
+ body: 'Patrol coverage is incomplete: recent activity was limited to scoped runs and ended with errors, so overall health is not fully verified.',
+ tone: 'warning',
+ });
+ });
+
+ it('returns the patrol runtime explanation when the runtime is blocked', () => {
+ expect(
+ getPatrolFindingsEmptyState({
+ filter: 'active',
+ runtimeState: 'blocked',
+ blockedReason: 'Quickstart credits exhausted. Connect your API key to continue using AI Patrol.',
+ }),
+ ).toEqual({
+ title: 'Patrol paused',
+ body: 'Quickstart credits exhausted. Connect your API key to continue using AI Patrol.',
+ tone: 'warning',
+ });
+ });
+
+ it('keeps the healthy findings empty state when patrol health is fully healthy', () => {
+ expect(
+ getPatrolFindingsEmptyState({
+ filter: 'active',
+ overallHealth: {
+ score: 100,
+ grade: 'A',
+ trend: 'stable',
+ factors: [],
+ prediction: 'Infrastructure is healthy with no significant issues detected.',
+ },
+ runtimeState: 'active',
+ }),
+ ).toEqual({
+ title: 'No active findings',
+ body: 'Your infrastructure looks healthy!',
+ tone: 'success',
+ });
+ });
});
diff --git a/frontend-modern/src/utils/patrolEmptyStatePresentation.ts b/frontend-modern/src/utils/patrolEmptyStatePresentation.ts
index d6170c2bbb..f8c0ed8922 100644
--- a/frontend-modern/src/utils/patrolEmptyStatePresentation.ts
+++ b/frontend-modern/src/utils/patrolEmptyStatePresentation.ts
@@ -1,3 +1,10 @@
+import type { PatrolRuntimeState } from '@/api/patrol';
+import type { FindingsFilter } from '@/utils/aiFindingPresentation';
+import { getFindingEmptyStateCopy } from '@/utils/aiFindingPresentation';
+import { getPatrolRuntimePresentation } from '@/utils/patrolRuntimePresentation';
+import type { SemanticTone } from '@/utils/semanticTonePresentation';
+import type { IntelligenceHealthScore } from '@/types/aiIntelligence';
+
export function getInvestigationMessagesState(loading: boolean, hasMessages: boolean) {
if (loading) {
return {
@@ -45,3 +52,70 @@ export function getInvestigationSectionState(loading: boolean, hasInvestigation:
empty: false,
} as const;
}
+
+export interface PatrolFindingsEmptyStateCopy {
+ title: string;
+ body?: string;
+ tone: SemanticTone;
+}
+
+const HEALTHY_PATROL_EMPTY_STATE_BODY = 'Your infrastructure looks healthy!';
+
+function getHealthDegradedTone(overallHealth: IntelligenceHealthScore): SemanticTone {
+ return overallHealth.grade === 'D' || overallHealth.grade === 'F' ? 'error' : 'warning';
+}
+
+function shouldSuppressHealthyEmptyState(overallHealth: IntelligenceHealthScore | undefined): boolean {
+ if (!overallHealth) {
+ return false;
+ }
+
+ if (overallHealth.factors.some((factor) => factor.category === 'coverage')) {
+ return true;
+ }
+
+ return overallHealth.grade !== 'A';
+}
+
+export function getPatrolFindingsEmptyState(args: {
+ filter: FindingsFilter;
+ overallHealth?: IntelligenceHealthScore;
+ runtimeState?: PatrolRuntimeState;
+ blockedReason?: string;
+}): PatrolFindingsEmptyStateCopy {
+ if (args.filter !== 'active') {
+ return {
+ ...getFindingEmptyStateCopy(args.filter),
+ tone: 'info',
+ };
+ }
+
+ if (
+ args.runtimeState === 'blocked' ||
+ args.runtimeState === 'disabled' ||
+ args.runtimeState === 'unavailable'
+ ) {
+ const runtime = getPatrolRuntimePresentation(args.runtimeState, args.blockedReason);
+ return {
+ title: runtime.title,
+ body: runtime.description,
+ tone: runtime.tone,
+ };
+ }
+
+ if (shouldSuppressHealthyEmptyState(args.overallHealth)) {
+ return {
+ title: 'No active findings',
+ body:
+ args.overallHealth?.prediction?.trim() ||
+ 'Patrol has not surfaced active findings, but overall infrastructure health is not fully verified.',
+ tone: getHealthDegradedTone(args.overallHealth!),
+ };
+ }
+
+ return {
+ title: 'No active findings',
+ body: HEALTHY_PATROL_EMPTY_STATE_BODY,
+ tone: 'success',
+ };
+}