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.

Make Patrol recommendation actions operational

rcourtman91a2904ed20d
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 859f8bc65b..4b34b8aca0 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -572,7 +572,10 @@ the canonical monitored-system blocked payload.
step without adding another API field: the frontend summary contract derives
the recommendation from existing overall-health, run-history, active
finding, runtime, and pending-approval state, so the API remains the source
- of facts while Patrol presentation owns the operator decision wording.
+ of facts while Patrol presentation owns the operator decision wording and
+ bounded action kind. Those action kinds map back to existing API-backed
+ Patrol controls and approval/finding filters; recommendation transport
+ must not become a new execution or approval API.
17. Keep Pulse Mobile relay credential minting and permission ownership on backend ownership: `internal/api/router_routes_auth_security.go`, `internal/api/security_tokens.go`, `internal/api/auth.go`, `internal/api/relay_mobile_capability.go`, `internal/api/router_routes_ai_relay.go`, and `frontend-modern/src/api/security.ts` may expose the canonical mobile runtime token creator and governed route gates, but browser callers must only consume that route and must not define the mobile runtime scope, compatibility gate list, route inventory, or token-purpose metadata locally.
18. Keep hosted tenant browser-session precedence on the shared auth boundary: `internal/api/auth.go`, `internal/api/contract_test.go`, and hosted tenant callers must treat a valid `pulse_session` as authoritative before any API-only token fallback or no-local-auth anonymous fallback, so cloud handoff can continue into protected hosted routes without flattening the operator back to `anonymous` or forcing a browser session through bearer-token-only mode after the tenant has minted API tokens.
That same shared auth boundary also owns hosted handoff authorization. `internal/api/cloud_handoff.go`,
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index c7ba77e731..da41b36f5b 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -228,7 +228,10 @@ their governed presentation helpers and render them inside the shared neutral
Pulse surface language rather than introducing page-local verdict bands or
nested cards. Patrol's primary recommended next step follows this boundary:
the Patrol helper owns the decision text, while the section component only
-renders a compact inline accent inside the existing assessment shell.
+renders a compact inline accent and one bounded action inside the existing
+assessment shell. Feature-owned recommendation actions may use the shared
+button/link shape, but they must not create a second full-width action band or
+nest another card inside the primary Pulse surface.
1. Add shared primitives in `frontend-modern/src/components/shared/`
Framed product table surfaces must consume the shared `TableCard` frame and
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index d67d47a024..6af25e31ad 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -495,6 +495,13 @@ ask for full verification before any all-clear claim, runtime impairment must
point the operator back to restoring Patrol visibility, and verified healthy
states should fall back to continued scheduled monitoring rather than
inviting generic Assistant chat.
+When that recommendation has an immediate governed operator path, the same
+helper must also declare the bounded action kind. The summary card may map
+those action kinds only to existing Patrol controls: run a full Patrol,
+review approval-scoped findings, review active findings, open Patrol provider
+settings, or open the Patrol-owned Assistant assessment handoff. It must not
+invent page-local remediation, approval, or execution authority from
+recommendation text.
That same runtime-owned assessment must expose the fix path directly. When the
primary Patrol issue is a Patrol runtime/provider problem rather than an
infrastructure finding, the summary card should offer a direct `Open Patrol
diff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx
index 616aa459bb..1bef979302 100644
--- a/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx
+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx
@@ -5,8 +5,9 @@ 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 MessageSquareIcon from 'lucide-solid/icons/message-square';
+import PlayIcon from 'lucide-solid/icons/play';
+import SettingsIcon from 'lucide-solid/icons/settings';
import {
- getPatrolAssessmentAction,
getPatrolAssessmentShellPresentation,
getPatrolAssessmentPresentation,
getPatrolRecommendedNextStepPresentation,
@@ -15,6 +16,7 @@ import {
getPatrolVerificationPresentation,
getPatrolSummaryPresentation,
getPatrolSummaryMetricState,
+ type PatrolRecommendedNextStepAction,
} from '@/utils/patrolSummaryPresentation';
import {
getPatrolLatestRunPresentation,
@@ -165,11 +167,6 @@ export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceStat
activeFindings: state.activePatrolFindings(),
}),
);
- const assessmentAction = createMemo(() =>
- getPatrolAssessmentAction({
- activeFindings: state.activePatrolFindings(),
- }),
- );
const recommendedNextStep = createMemo(() =>
getPatrolRecommendedNextStepPresentation({
assessment: assessment(),
@@ -178,6 +175,36 @@ export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceStat
pendingApprovalCount: aiIntelligenceStore.patrolPendingApprovals.length,
}),
);
+ const recommendedNextStepAction = createMemo(() => recommendedNextStep().action);
+ const recommendedNextStepActionDisabled = createMemo(() => {
+ const action = recommendedNextStepAction();
+ return (
+ action?.kind === 'run_patrol' &&
+ (state.isTriggeringPatrol() ||
+ !state.canTriggerPatrol() ||
+ state.manualRunRequested() ||
+ state.patrolStream.isStreaming())
+ );
+ });
+ const recommendedNextStepActionLabel = createMemo(() => {
+ const action = recommendedNextStepAction();
+ if (action?.kind !== 'run_patrol') {
+ return action?.label;
+ }
+
+ if (state.isTriggeringPatrol()) {
+ return 'Starting...';
+ }
+
+ if (state.manualRunRequested() || state.patrolStream.isStreaming()) {
+ return 'Running...';
+ }
+
+ return action.label;
+ });
+ const showAssessmentAssistantButton = createMemo(
+ () => recommendedNextStepAction()?.kind !== 'discuss_assessment',
+ );
const hasAttentionMetrics = createMemo(
() => metricState().primaryValue > 0 || metricState().secondaryValue > 0,
);
@@ -282,6 +309,29 @@ export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceStat
aiChatStore.openWithPrompt(handoff.prompt, handoff.context);
};
+ const handleRecommendedNextStepAction = (action: PatrolRecommendedNextStepAction) => {
+ switch (action.kind) {
+ case 'discuss_assessment':
+ void handleDiscussAssessment();
+ return;
+ case 'review_approvals':
+ state.setSelectedRun(null);
+ state.setActiveTab('findings');
+ state.setFindingsFilterOverride('approvals');
+ return;
+ case 'review_findings':
+ state.setSelectedRun(null);
+ state.setActiveTab('findings');
+ state.setFindingsFilterOverride('active');
+ return;
+ case 'run_patrol':
+ void state.handleRunPatrol();
+ return;
+ case 'open_provider_settings':
+ return;
+ }
+ };
+
const renderAssessmentIcon = () => {
const iconClass = `w-5 h-5 ${assessmentShellPresentation().iconClass}`;
switch (assessment().tone) {
@@ -389,28 +439,62 @@ export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceStat
<p class="mt-1 max-w-3xl text-sm leading-6 text-muted">
{recommendedNextStep().description}
</p>
- </div>
- <div class="mt-4 flex flex-wrap items-center gap-2">
- <Show when={assessmentAction()}>
+ <Show when={recommendedNextStepAction()}>
{(action) => (
- <a
- href={action().href}
- class="inline-flex items-center rounded-md border border-border bg-surface px-3 py-1.5 text-xs font-semibold text-base-content shadow-sm transition-colors hover:bg-surface-hover"
- >
- {action().label}
- </a>
+ <div class="mt-3">
+ <Show
+ when={action().href}
+ fallback={
+ <button
+ type="button"
+ data-testid="patrol-recommended-next-step-action"
+ disabled={recommendedNextStepActionDisabled()}
+ title={
+ action().kind === 'run_patrol'
+ ? state.triggerPatrolDisabledReason()
+ : undefined
+ }
+ class="inline-flex items-center gap-1.5 rounded-md border border-blue-600 bg-blue-600 px-3 py-1.5 text-xs font-semibold text-white shadow-sm transition-colors hover:bg-blue-700 disabled:border-border disabled:bg-surface-alt disabled:text-muted"
+ onClick={() => handleRecommendedNextStepAction(action())}
+ >
+ {renderRecommendedNextStepActionIcon(
+ action(),
+ state.isTriggeringPatrol() ||
+ state.manualRunRequested() ||
+ state.patrolStream.isStreaming(),
+ )}
+ <span>{recommendedNextStepActionLabel()}</span>
+ </button>
+ }
+ >
+ {(href) => (
+ <a
+ href={href()}
+ data-testid="patrol-recommended-next-step-action"
+ class="inline-flex items-center gap-1.5 rounded-md border border-blue-600 bg-blue-600 px-3 py-1.5 text-xs font-semibold text-white shadow-sm transition-colors hover:bg-blue-700"
+ >
+ {renderRecommendedNextStepActionIcon(action(), false)}
+ <span>{action().label}</span>
+ </a>
+ )}
+ </Show>
+ </div>
)}
</Show>
- <button
- type="button"
- data-testid="patrol-assessment-assistant-button"
- class="inline-flex items-center gap-1.5 rounded-md border border-border bg-surface px-3 py-1.5 text-xs font-semibold text-base-content shadow-sm transition-colors hover:bg-surface-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/40"
- title="Discuss current Patrol assessment"
- onClick={handleDiscussAssessment}
- >
- <MessageSquareIcon class="h-4 w-4" aria-hidden="true" />
- <span>Discuss with Assistant</span>
- </button>
+ </div>
+ <div class="mt-4 flex flex-wrap items-center gap-2">
+ <Show when={showAssessmentAssistantButton()}>
+ <button
+ type="button"
+ data-testid="patrol-assessment-assistant-button"
+ class="inline-flex items-center gap-1.5 rounded-md border border-border bg-surface px-3 py-1.5 text-xs font-semibold text-base-content shadow-sm transition-colors hover:bg-surface-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/40"
+ title="Discuss current Patrol assessment"
+ onClick={handleDiscussAssessment}
+ >
+ <MessageSquareIcon class="h-4 w-4" aria-hidden="true" />
+ <span>Discuss with Assistant</span>
+ </button>
+ </Show>
</div>
</div>
</div>
@@ -568,3 +652,23 @@ function getPatrolRecommendedNextStepAccentClass(
return 'border-blue-400 dark:border-blue-500';
}
}
+
+function renderRecommendedNextStepActionIcon(
+ action: PatrolRecommendedNextStepAction,
+ running: boolean,
+) {
+ const iconClass = `h-4 w-4 ${running && action.kind === 'run_patrol' ? 'animate-pulse' : ''}`;
+
+ switch (action.kind) {
+ case 'open_provider_settings':
+ return <SettingsIcon class={iconClass} aria-hidden="true" />;
+ case 'run_patrol':
+ return <PlayIcon class={iconClass} aria-hidden="true" />;
+ case 'discuss_assessment':
+ return <MessageSquareIcon class={iconClass} aria-hidden="true" />;
+ case 'review_approvals':
+ return <CheckCircleIcon class={iconClass} aria-hidden="true" />;
+ case 'review_findings':
+ return <ActivityIcon class={iconClass} aria-hidden="true" />;
+ }
+}
diff --git a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx
index 72b1fbac74..c98be4d3ae 100644
--- a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx
+++ b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx
@@ -45,7 +45,8 @@ describe('PatrolIntelligenceSummary', () => {
},
]);
- render(() => <PatrolIntelligenceSummary state={createPatrolState()} />);
+ const patrolState = createPatrolState();
+ render(() => <PatrolIntelligenceSummary state={patrolState} />);
expect(screen.getByTestId('patrol-recommended-next-step').textContent).toContain(
'Review the pending Patrol approval',
@@ -54,6 +55,12 @@ describe('PatrolIntelligenceSummary', () => {
'risk, dry-run posture, and expiry',
);
+ fireEvent.click(screen.getByTestId('patrol-recommended-next-step-action'));
+
+ expect(patrolState.setSelectedRun).toHaveBeenCalledWith(null);
+ expect(patrolState.setActiveTab).toHaveBeenCalledWith('findings');
+ expect(patrolState.setFindingsFilterOverride).toHaveBeenCalledWith('approvals');
+
fireEvent.click(screen.getByTestId('patrol-assessment-assistant-button'));
await waitFor(() => expect(openWithPrompt).toHaveBeenCalledTimes(1));
@@ -162,6 +169,7 @@ function createPatrolState(): PatrolIntelligenceState {
},
],
blockedReason: () => undefined,
+ canTriggerPatrol: () => true,
circuitBreakerStatus: () => undefined,
correlationTotal: () => 2,
correlations: () => [
@@ -182,6 +190,7 @@ function createPatrolState(): PatrolIntelligenceState {
],
hasInvestigationContext: () => true,
initialSurfaceReady: () => true,
+ isTriggeringPatrol: () => false,
intelligenceSummary: () => ({
overall_health: {
grade: 'B',
@@ -224,6 +233,8 @@ function createPatrolState(): PatrolIntelligenceState {
}),
investigationContextSummary: () =>
'2 recent changes · 2 correlations · 4 policy-covered resources',
+ handleRunPatrol: vi.fn(),
+ manualRunRequested: () => false,
patrolRunHistory: {
value: () => [
{
@@ -250,6 +261,12 @@ function createPatrolState(): PatrolIntelligenceState {
}),
recentChangeCount: () => 2,
runtimeState: () => 'active',
+ patrolStream: {
+ isStreaming: () => false,
+ },
+ setActiveTab: vi.fn(),
+ setFindingsFilterOverride: vi.fn(),
+ setSelectedRun: vi.fn(),
summaryStats: () => ({
criticalFindings: 1,
warningFindings: 0,
@@ -257,5 +274,6 @@ function createPatrolState(): PatrolIntelligenceState {
fixedCount: 0,
hasAnyPatrolFindings: true,
}),
+ triggerPatrolDisabledReason: () => '',
} as unknown as PatrolIntelligenceState;
}
diff --git a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
index 1e7a42c360..c3a5ff5b8a 100644
--- a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
+++ b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
@@ -1104,6 +1104,9 @@ describe('AIIntelligence entitlement gating', () => {
expect(screen.getAllByText('Coverage incomplete').length).toBeGreaterThan(0);
expect(screen.getByText('Recommended next step')).toBeInTheDocument();
expect(screen.getByText('Verify full coverage')).toBeInTheDocument();
+ expect(screen.getByTestId('patrol-recommended-next-step-action')).toHaveTextContent(
+ 'Run Patrol',
+ );
expect(screen.getByText('No recent full patrol')).toBeInTheDocument();
expect(screen.getAllByText(/Last activity/i)).toHaveLength(1);
expect(findingsPanelState.latestProps).not.toBeNull();
diff --git a/frontend-modern/src/utils/__tests__/patrolSummaryPresentation.test.ts b/frontend-modern/src/utils/__tests__/patrolSummaryPresentation.test.ts
index f8246b4be1..ca3a0ccb5d 100644
--- a/frontend-modern/src/utils/__tests__/patrolSummaryPresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/patrolSummaryPresentation.test.ts
@@ -267,6 +267,10 @@ describe('getPatrolSummaryPresentation', () => {
title: 'Review the pending Patrol approval',
description:
'Patrol is waiting on 1 governed Patrol approval. Review risk, dry-run posture, and expiry before approving or starting another remediation.',
+ action: {
+ kind: 'review_approvals',
+ label: 'Review approvals',
+ },
tone: 'warning',
});
});
@@ -293,6 +297,49 @@ describe('getPatrolSummaryPresentation', () => {
title: 'Verify full coverage',
description:
'Run a full Patrol sweep before treating this assessment as an all-clear; recent evidence is incomplete or limited to targeted activity.',
+ action: {
+ kind: 'run_patrol',
+ label: 'Run Patrol',
+ },
+ tone: 'warning',
+ });
+ });
+
+ it('routes Patrol runtime recommendations to provider settings', () => {
+ expect(
+ getPatrolRecommendedNextStepPresentation({
+ assessment: {
+ title: 'Patrol runtime issue',
+ description: 'Patrol has an active runtime issue: Provider billing or quota issue.',
+ eyebrow: 'Patrol assessment',
+ compactLabel: 'Patrol runtime issue',
+ tone: 'warning',
+ },
+ verification: {
+ title: 'No recent full patrol',
+ description: 'Patrol has not completed a recent full verification run yet.',
+ compactLabel: 'Verification pending',
+ tone: 'info',
+ },
+ activeFindings: [
+ {
+ status: 'active',
+ severity: 'warning',
+ resourceId: 'ai-service',
+ resourceName: 'Pulse Patrol Service',
+ title: 'Pulse Patrol: Provider billing or quota issue',
+ },
+ ] as never,
+ }),
+ ).toEqual({
+ title: 'Restore Patrol visibility',
+ description:
+ 'Fix the Patrol runtime issue and rerun Patrol before treating the infrastructure assessment as current.',
+ action: {
+ kind: 'open_provider_settings',
+ label: 'Open Patrol provider settings',
+ href: '/settings/system-ai',
+ },
tone: 'warning',
});
});
diff --git a/frontend-modern/src/utils/patrolSummaryPresentation.ts b/frontend-modern/src/utils/patrolSummaryPresentation.ts
index afec53b3a6..95012a7611 100644
--- a/frontend-modern/src/utils/patrolSummaryPresentation.ts
+++ b/frontend-modern/src/utils/patrolSummaryPresentation.ts
@@ -46,9 +46,23 @@ export interface PatrolAssessmentAction {
href: string;
}
+export type PatrolRecommendedNextStepActionKind =
+ | 'discuss_assessment'
+ | 'open_provider_settings'
+ | 'review_approvals'
+ | 'review_findings'
+ | 'run_patrol';
+
+export interface PatrolRecommendedNextStepAction {
+ kind: PatrolRecommendedNextStepActionKind;
+ label: string;
+ href?: string;
+}
+
export interface PatrolRecommendedNextStepPresentation {
title: string;
description: string;
+ action?: PatrolRecommendedNextStepAction;
tone: SemanticTone;
}
@@ -301,15 +315,25 @@ export function getPatrolRecommendedNextStepPresentation(args: {
? 'Review the pending Patrol approval'
: 'Review pending Patrol approvals',
description: `Patrol is waiting on ${formatPendingApprovalCount(pendingApprovalCount)}. Review risk, dry-run posture, and expiry before approving or starting another remediation.`,
+ action: {
+ kind: 'review_approvals',
+ label: 'Review approvals',
+ },
tone: 'warning',
};
}
if (classified.infrastructureTotal === 0 && classified.runtimeTotal > 0) {
+ const action = getPatrolProviderSettingsAction();
return {
title: 'Restore Patrol visibility',
description:
'Fix the Patrol runtime issue and rerun Patrol before treating the infrastructure assessment as current.',
+ action: {
+ kind: 'open_provider_settings',
+ label: action.label,
+ href: action.href,
+ },
tone: args.assessment.tone,
};
}
@@ -319,6 +343,10 @@ export function getPatrolRecommendedNextStepPresentation(args: {
title: 'Triage the critical finding',
description:
'Start with the highest-risk active finding, review the attached evidence and approval posture, then choose the safest governed action.',
+ action: {
+ kind: 'review_findings',
+ label: 'Review findings',
+ },
tone: 'error',
};
}
@@ -328,6 +356,10 @@ export function getPatrolRecommendedNextStepPresentation(args: {
title: 'Review active findings',
description:
'Use the findings workspace to prioritize current risk, recent changes, and any governed remediation before waiting for the next scheduled Patrol run.',
+ action: {
+ kind: 'review_findings',
+ label: 'Review findings',
+ },
tone: 'warning',
};
}
@@ -336,6 +368,10 @@ export function getPatrolRecommendedNextStepPresentation(args: {
return {
title: 'Verify full coverage',
description: VERIFY_FULL_COVERAGE_DESCRIPTION,
+ action: {
+ kind: 'run_patrol',
+ label: 'Run Patrol',
+ },
tone: args.assessment.tone,
};
}
@@ -344,6 +380,10 @@ export function getPatrolRecommendedNextStepPresentation(args: {
return {
title: 'Verify full coverage',
description: VERIFY_FULL_COVERAGE_DESCRIPTION,
+ action: {
+ kind: 'run_patrol',
+ label: 'Run Patrol',
+ },
tone: args.verification.tone,
};
}
@@ -353,6 +393,10 @@ export function getPatrolRecommendedNextStepPresentation(args: {
title: 'Review assessment evidence',
description:
'Review the supporting context or discuss the assessment with Assistant to understand why Patrol still marks it as needing attention.',
+ action: {
+ kind: 'discuss_assessment',
+ label: 'Discuss with Assistant',
+ },
tone: args.assessment.tone,
};
}