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.

Split patrol intelligence render owners

rcourtmana64b252f2d5a
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index f6ae4d0b7e..5cceae4954 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -106,7 +106,7 @@ Own canonical runtime payload shapes between backend and frontend.
4. Route unified resource sensitivity, routing, and `aiSafeSummary` payload changes through `internal/api/resources.go`, `internal/api/contract_test.go`, and the canonical frontend resource consumer proofs together; resource governance metadata must not ship as an API-only or frontend-only heuristic
5. Route unified-resource action, lifecycle, and export audit reads through `internal/api/activity_audit_handlers.go`, `internal/api/router_routes_licensing.go`, and `internal/api/contract_test.go` together so the control-plane execution trail stays on a governed API contract instead of a store-only shape
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/features/patrol/usePatrolIntelligenceState.ts`, `frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx`, `frontend-modern/src/pages/AIIntelligence.tsx`, `internal/api/ai_handlers.go`, and `internal/api/contract_test.go` together so the summary card, runtime hook, store state, route shell, and backend payload stay aligned on one governed surface, including the canonical recent-changes slice
+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/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, 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 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
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 0c0febc20c..5d38ff21a6 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -365,10 +365,11 @@ Feature-owned route surfaces under `frontend-modern/src/features/` must also
keep their shell/runtime split explicit once a subsystem grows real transport
or polling lifecycle. The Patrol feature is the current reference shape:
`frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx` stays the
-render shell while `frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts`
-owns the runtime state machine. Shared shell governance should reinforce that
-pattern instead of letting feature render surfaces re-accumulate API and timer
-orchestration inline.
+feature shell, `frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts`
+owns the runtime state machine, and the Patrol-owned header/banner/summary/workspace
+section files under `frontend-modern/src/features/patrol/` own the heavy render
+surfaces. Shared shell governance should reinforce that pattern instead of
+letting feature render surfaces re-accumulate API and timer orchestration inline.
Shared primitive consumers that split status-dot tone and status-text tone
must now keep both values routed through the same exported presentation helper.
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index 6e25b459f9..37c9e7ad20 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -23,20 +23,24 @@ Patrol-specific presentation helpers.
1. `frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx`
2. `frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts`
-3. `frontend-modern/src/pages/AIIntelligence.tsx`
-4. `frontend-modern/src/stores/aiIntelligence.ts`
-5. `frontend-modern/src/types/aiIntelligence.ts`
-6. `frontend-modern/src/components/AI/FindingsPanel.tsx`
-7. `frontend-modern/src/components/Brand/PulsePatrolLogo.tsx`
-8. `frontend-modern/src/components/patrol/`
-9. `frontend-modern/src/utils/aiFindingPresentation.ts`
-10. `frontend-modern/src/utils/approvalRiskPresentation.ts`
-11. `frontend-modern/src/utils/findingAlertIdentity.ts`
-12. `frontend-modern/src/utils/patrolEmptyStatePresentation.ts`
-13. `frontend-modern/src/utils/patrolFormat.ts`
-14. `frontend-modern/src/utils/patrolRunPresentation.ts`
-15. `frontend-modern/src/utils/patrolSummaryPresentation.ts`
-16. `frontend-modern/src/utils/textPresentation.ts`
+3. `frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx`
+4. `frontend-modern/src/features/patrol/PatrolIntelligenceBanners.tsx`
+5. `frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx`
+6. `frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx`
+7. `frontend-modern/src/pages/AIIntelligence.tsx`
+8. `frontend-modern/src/stores/aiIntelligence.ts`
+9. `frontend-modern/src/types/aiIntelligence.ts`
+10. `frontend-modern/src/components/AI/FindingsPanel.tsx`
+11. `frontend-modern/src/components/Brand/PulsePatrolLogo.tsx`
+12. `frontend-modern/src/components/patrol/`
+13. `frontend-modern/src/utils/aiFindingPresentation.ts`
+14. `frontend-modern/src/utils/approvalRiskPresentation.ts`
+15. `frontend-modern/src/utils/findingAlertIdentity.ts`
+16. `frontend-modern/src/utils/patrolEmptyStatePresentation.ts`
+17. `frontend-modern/src/utils/patrolFormat.ts`
+18. `frontend-modern/src/utils/patrolRunPresentation.ts`
+19. `frontend-modern/src/utils/patrolSummaryPresentation.ts`
+20. `frontend-modern/src/utils/textPresentation.ts`
## Shared Boundaries
@@ -44,7 +48,7 @@ Patrol-specific presentation helpers.
## Extension Points
-1. Add or change Patrol page orchestration through `frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts`, keep `frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx` as the feature render shell, keep `frontend-modern/src/pages/AIIntelligence.tsx` as the route shell, and update `frontend-modern/src/stores/aiIntelligence.ts` together
+1. Add or change Patrol page orchestration through `frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts`, keep `frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx` as the feature shell, keep the Patrol-owned section files under `frontend-modern/src/features/patrol/` as the heavy render owners, keep `frontend-modern/src/pages/AIIntelligence.tsx` as the route shell, and update `frontend-modern/src/stores/aiIntelligence.ts` together
2. Add or change Patrol findings, approvals, investigation, or run-history presentation through `frontend-modern/src/components/AI/FindingsPanel.tsx` and `frontend-modern/src/components/patrol/`
3. Keep Patrol and chat identifier-label presentation aligned through the shared `frontend-modern/src/utils/textPresentation.ts`
4. Keep Patrol and chat stream-matching / mention dedupe aligned through the shared `frontend-modern/src/utils/chatIdentifiers.ts`
@@ -76,12 +80,14 @@ thin shell that delegates to the feature-owned
runtime state and presentation no longer accumulate directly in the route
component itself.
The feature surface now also keeps the same shell/runtime split internally:
-`frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx` owns render
-composition and Patrol page presentation, while
+`frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx` owns feature
+composition, the Patrol-owned section files under
+`frontend-modern/src/features/patrol/` own the header, banner, summary, and
+workspace render surfaces, and
`frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts` owns Patrol
-state, transport, polling, and effect lifecycle. The render shell must not
-re-accumulate Patrol API calls, timer orchestration, or store refresh flow
-inline.
+state, transport, polling, and effect lifecycle. The shell and section surfaces
+must not re-accumulate Patrol API calls, timer orchestration, or store refresh
+flow inline.
Patrol finding state must now also consume the canonical camelCase
`alertIdentifier` field and pending-approval expiry metadata end to end.
diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.json
index d2e8b399df..6ccb7b8c4c 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -2442,7 +2442,11 @@
"frontend-modern/src/components/patrol/RunHistoryEntry.tsx",
"frontend-modern/src/components/patrol/RunHistoryPanel.tsx",
"frontend-modern/src/components/patrol/RunToolCallTrace.tsx",
+ "frontend-modern/src/features/patrol/PatrolIntelligenceBanners.tsx",
+ "frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx",
+ "frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx",
"frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx",
+ "frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx",
"frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts",
"frontend-modern/src/pages/AIIntelligence.tsx",
"frontend-modern/src/stores/aiIntelligence.ts",
@@ -2472,7 +2476,11 @@
"match_files": [
"frontend-modern/src/components/Brand/PulsePatrolLogo.tsx",
"frontend-modern/src/components/patrol/index.ts",
+ "frontend-modern/src/features/patrol/PatrolIntelligenceBanners.tsx",
+ "frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx",
+ "frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx",
"frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx",
+ "frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx",
"frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts",
"frontend-modern/src/pages/AIIntelligence.tsx",
"frontend-modern/src/stores/aiIntelligence.ts",
diff --git a/frontend-modern/src/components/Settings/__tests__/monitoredSystemModelGuardrails.test.ts b/frontend-modern/src/components/Settings/__tests__/monitoredSystemModelGuardrails.test.ts
index 56d88d39cb..39fcb9124a 100644
--- a/frontend-modern/src/components/Settings/__tests__/monitoredSystemModelGuardrails.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/monitoredSystemModelGuardrails.test.ts
@@ -35,8 +35,12 @@ import infrastructureSelectorComponentSource from '@/components/shared/Infrastru
import workloadsLinkSource from '@/components/Infrastructure/workloadsLink.ts?raw';
import unifiedResourceTableSource from '@/components/Infrastructure/UnifiedResourceTable.tsx?raw';
import thresholdsTableSource from '@/components/Alerts/ThresholdsTable.tsx?raw';
+import thresholdsTableAgentDisksSectionSource from '@/components/Alerts/ThresholdsTableAgentDisksSection.tsx?raw';
+import thresholdsTableAgentsResourcesSectionSource from '@/components/Alerts/ThresholdsTableAgentsResourcesSection.tsx?raw';
import alertsConfigurationSurfaceSource from '@/features/alerts/AlertsConfigurationSurface.tsx?raw';
import thresholdsDataHookSource from '@/features/alerts/thresholds/hooks/useThresholdsData.ts?raw';
+import thresholdsHostDataHookSource from '@/features/alerts/thresholds/hooks/useThresholdsHostData.ts?raw';
+import thresholdsTableStateSource from '@/features/alerts/thresholds/hooks/useThresholdsTableState.ts?raw';
import collapsibleSectionSource from '@/components/Alerts/Thresholds/sections/CollapsibleSection.tsx?raw';
import alertThresholdsPresentationSource from '@/utils/alertThresholdsPresentation.ts?raw';
import alertThresholdsSectionPresentationSource from '@/utils/alertThresholdsSectionPresentation.ts?raw';
@@ -56,8 +60,12 @@ import reportingPanelModelSource from '../reportingPanelModel.ts?raw';
import updatesSettingsPanelSource from '../UpdatesSettingsPanel.tsx?raw';
import suggestProfileModalSource from '../SuggestProfileModal.tsx?raw';
import aiIntelligenceSource from '@/pages/AIIntelligence.tsx?raw';
+import patrolIntelligenceBannersSource from '@/features/patrol/PatrolIntelligenceBanners.tsx?raw';
+import patrolIntelligenceHeaderSource from '@/features/patrol/PatrolIntelligenceHeader.tsx?raw';
+import patrolIntelligenceSummarySource from '@/features/patrol/PatrolIntelligenceSummary.tsx?raw';
import patrolIntelligenceSurfaceSource from '@/features/patrol/PatrolIntelligenceSurface.tsx?raw';
import patrolIntelligenceStateSource from '@/features/patrol/usePatrolIntelligenceState.ts?raw';
+import patrolIntelligenceWorkspaceSource from '@/features/patrol/PatrolIntelligenceWorkspace.tsx?raw';
import aiPatrolSchedulePresentationSource from '@/utils/aiPatrolSchedulePresentation.ts?raw';
import patrolSummaryPresentationSource from '@/utils/patrolSummaryPresentation.ts?raw';
import aiCostDashboardSource from '@/components/AI/AICostDashboard.tsx?raw';
@@ -587,12 +595,24 @@ describe('monitored-system model guardrails', () => {
expect(aiIntelligenceSource).not.toContain('buildPatrolScheduleOptions');
expect(aiIntelligenceSource).not.toContain('PATROL_NO_ISSUES_LABEL');
expect(patrolIntelligenceSurfaceSource).toContain("./usePatrolIntelligenceState");
- expect(patrolIntelligenceSurfaceSource).toContain('buildPatrolScheduleOptions');
- expect(patrolIntelligenceSurfaceSource).toContain('PATROL_NO_ISSUES_LABEL');
+ expect(patrolIntelligenceSurfaceSource).toContain('./PatrolIntelligenceHeader');
+ expect(patrolIntelligenceSurfaceSource).toContain('./PatrolIntelligenceBanners');
+ expect(patrolIntelligenceSurfaceSource).toContain('./PatrolIntelligenceSummary');
+ expect(patrolIntelligenceSurfaceSource).toContain('./PatrolIntelligenceWorkspace');
+ expect(patrolIntelligenceSurfaceSource).not.toContain('buildPatrolScheduleOptions');
+ expect(patrolIntelligenceSurfaceSource).not.toContain('PATROL_NO_ISSUES_LABEL');
expect(patrolIntelligenceStateSource).toContain('export function usePatrolIntelligenceState');
+ expect(patrolIntelligenceStateSource).toContain('export type PatrolIntelligenceState =');
expect(patrolIntelligenceStateSource).toContain('getPatrolStatus');
expect(patrolIntelligenceStateSource).toContain('usePatrolStream');
expect(patrolIntelligenceStateSource).toContain('updatePatrolAutonomySettings');
+ expect(patrolIntelligenceHeaderSource).toContain('buildPatrolScheduleOptions');
+ expect(patrolIntelligenceHeaderSource).toContain('getAIQuickstartCreditsPresentation');
+ expect(patrolIntelligenceSummarySource).toContain('PATROL_NO_ISSUES_LABEL');
+ expect(patrolIntelligenceSummarySource).toContain('getPatrolSummaryPresentation');
+ expect(patrolIntelligenceWorkspaceSource).toContain('ApprovalBanner');
+ expect(patrolIntelligenceWorkspaceSource).toContain('FindingsPanel');
+ expect(patrolIntelligenceBannersSource).toContain('trackUpgradeClicked');
expect(aiIntelligenceSource).not.toContain('No issues found');
expect(patrolIntelligenceSurfaceSource).not.toContain('No issues found');
expect(aiIntelligenceSource).not.toContain('const SCHEDULE_PRESETS =');
@@ -828,13 +848,12 @@ describe('monitored-system model guardrails', () => {
expect(alertsPageSource).not.toContain('const agentResources = createMemo(');
expect(alertsPageSource).not.toContain("resourceType: 'Agent Disk'");
expect(alertsConfigurationSurfaceSource).toContain('<ThresholdsTab');
- expect(thresholdsTableSource).toContain(
- "import { useThresholdsData } from '@/features/alerts/thresholds/hooks/useThresholdsData';",
- );
- expect(thresholdsDataHookSource).toContain("resourceType: 'Agent Disk'");
- expect(thresholdsDataHookSource).not.toContain("resourceType: 'Host Disk'");
- expect(thresholdsTableSource).toContain('props.agentDefaults');
- expect(thresholdsTableSource).toContain('disableAllAgents');
+ expect(thresholdsTableStateSource).toContain("import { useThresholdsData } from './useThresholdsData';");
+ expect(thresholdsDataHookSource).toContain('useThresholdsHostData');
+ expect(thresholdsHostDataHookSource).toContain("resourceType: 'Agent Disk'");
+ expect(thresholdsHostDataHookSource).not.toContain("resourceType: 'Host Disk'");
+ expect(thresholdsHostDataHookSource).toContain('props.agentDefaults');
+ expect(thresholdsTableAgentsResourcesSectionSource).toContain('disableAllAgents');
expect(thresholdsTableSource).not.toContain('hostDefaults');
expect(thresholdsTableSource).not.toContain('disableAllHosts');
});
@@ -1194,38 +1213,40 @@ describe('monitored-system model guardrails', () => {
});
it('keeps alert thresholds routes on v6 container path only', () => {
- expect(thresholdsTableSource).toContain(
+ expect(thresholdsTableStateSource).toContain(
"if (path.includes('/thresholds/containers')) return 'docker';",
);
- expect(thresholdsTableSource).toContain('/thresholds/agents');
- expect(thresholdsDataHookSource).toContain("resourceType: 'Agent Disk'");
- expect(thresholdsTableSource).toContain('getAlertThresholdsSectionTitles');
- expect(thresholdsTableSource).toContain('title={sectionTitles.agentDisks}');
- expect(thresholdsDataHookSource).not.toContain("resourceType: 'Host Disk'");
- expect(thresholdsTableSource).toContain('props.agentDefaults');
- expect(thresholdsTableSource).not.toContain('props.hostDefaults');
- expect(thresholdsTableSource).not.toContain('timeThresholds().host');
- expect(thresholdsTableSource).not.toContain('/thresholds/docker');
- expect(thresholdsTableSource).toContain('PBS_THRESHOLDS_EMPTY_STATE');
- expect(thresholdsTableSource).toContain('GUEST_THRESHOLDS_EMPTY_STATE');
- expect(thresholdsTableSource).toContain('NODE_THRESHOLDS_FILTER_EMPTY_STATE');
- expect(thresholdsTableSource).toContain('PBS_THRESHOLDS_FILTER_EMPTY_STATE');
- expect(thresholdsTableSource).toContain('GUEST_THRESHOLDS_FILTER_EMPTY_STATE');
- expect(thresholdsTableSource).toContain('GUEST_FILTERING_EMPTY_STATE');
- expect(thresholdsTableSource).toContain('BACKUP_THRESHOLDS_EMPTY_STATE');
- expect(thresholdsTableSource).toContain('SNAPSHOT_THRESHOLDS_EMPTY_STATE');
- expect(thresholdsTableSource).toContain('STORAGE_THRESHOLDS_EMPTY_STATE');
- expect(thresholdsTableSource).toContain('STORAGE_THRESHOLDS_FILTER_EMPTY_STATE');
- expect(thresholdsTableSource).toContain('PMG_THRESHOLDS_EMPTY_STATE');
- expect(thresholdsTableSource).toContain('PMG_THRESHOLDS_FILTER_EMPTY_STATE');
- expect(thresholdsTableSource).toContain('AGENT_THRESHOLDS_FILTER_EMPTY_STATE');
- expect(thresholdsTableSource).toContain('AGENT_DISKS_EMPTY_STATE');
- expect(thresholdsTableSource).toContain('AGENT_DISKS_FILTER_EMPTY_STATE');
- expect(thresholdsTableSource).toContain('CONTAINER_RUNTIMES_FILTER_EMPTY_STATE');
- expect(thresholdsTableSource).toContain('CONTAINERS_FILTER_EMPTY_STATE');
- expect(thresholdsTableSource).toContain('getAlertThresholdsGuestFilterPresentation');
- expect(thresholdsTableSource).toContain('getAlertThresholdsBackupOrphanedPresentation');
- expect(thresholdsTableSource).toContain('getAlertThresholdsDockerIgnoredPrefixesPresentation');
+ expect(thresholdsTableStateSource).toContain('/thresholds/agents');
+ expect(thresholdsHostDataHookSource).toContain("resourceType: 'Agent Disk'");
+ expect(thresholdsTableStateSource).toContain('getAlertThresholdsSectionTitles');
+ expect(thresholdsTableAgentDisksSectionSource).toContain('title={state.sectionTitles.agentDisks}');
+ expect(thresholdsHostDataHookSource).not.toContain("resourceType: 'Host Disk'");
+ expect(thresholdsHostDataHookSource).toContain('props.agentDefaults');
+ expect(thresholdsTableStateSource).not.toContain('props.hostDefaults');
+ expect(thresholdsTableStateSource).not.toContain('timeThresholds().host');
+ expect(thresholdsTableStateSource).not.toContain('/thresholds/docker');
+ expect(thresholdsTableStateSource).toContain('PBS_THRESHOLDS_EMPTY_STATE');
+ expect(thresholdsTableStateSource).toContain('GUEST_THRESHOLDS_EMPTY_STATE');
+ expect(thresholdsTableStateSource).toContain('NODE_THRESHOLDS_FILTER_EMPTY_STATE');
+ expect(thresholdsTableStateSource).toContain('PBS_THRESHOLDS_FILTER_EMPTY_STATE');
+ expect(thresholdsTableStateSource).toContain('GUEST_THRESHOLDS_FILTER_EMPTY_STATE');
+ expect(thresholdsTableStateSource).toContain('GUEST_FILTERING_EMPTY_STATE');
+ expect(thresholdsTableStateSource).toContain('BACKUP_THRESHOLDS_EMPTY_STATE');
+ expect(thresholdsTableStateSource).toContain('SNAPSHOT_THRESHOLDS_EMPTY_STATE');
+ expect(thresholdsTableStateSource).toContain('STORAGE_THRESHOLDS_EMPTY_STATE');
+ expect(thresholdsTableStateSource).toContain('STORAGE_THRESHOLDS_FILTER_EMPTY_STATE');
+ expect(thresholdsTableStateSource).toContain('PMG_THRESHOLDS_EMPTY_STATE');
+ expect(thresholdsTableStateSource).toContain('PMG_THRESHOLDS_FILTER_EMPTY_STATE');
+ expect(thresholdsTableStateSource).toContain('AGENT_THRESHOLDS_FILTER_EMPTY_STATE');
+ expect(thresholdsTableStateSource).toContain('AGENT_DISKS_EMPTY_STATE');
+ expect(thresholdsTableStateSource).toContain('AGENT_DISKS_FILTER_EMPTY_STATE');
+ expect(thresholdsTableStateSource).toContain('CONTAINER_RUNTIMES_FILTER_EMPTY_STATE');
+ expect(thresholdsTableStateSource).toContain('CONTAINERS_FILTER_EMPTY_STATE');
+ expect(thresholdsTableStateSource).toContain('getAlertThresholdsGuestFilterPresentation');
+ expect(thresholdsTableStateSource).toContain('getAlertThresholdsBackupOrphanedPresentation');
+ expect(thresholdsTableStateSource).toContain(
+ 'getAlertThresholdsDockerIgnoredPrefixesPresentation',
+ );
expect(thresholdsTableSource).not.toContain('No PBS servers configured.');
expect(thresholdsTableSource).not.toContain('No VMs or containers found.');
expect(thresholdsTableSource).not.toContain('No nodes match the current filters.');
diff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceBanners.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceBanners.tsx
new file mode 100644
index 0000000000..8269b567f6
--- /dev/null
+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceBanners.tsx
@@ -0,0 +1,103 @@
+import { Show } from 'solid-js';
+import ShieldAlertIcon from 'lucide-solid/icons/shield-alert';
+import SettingsIcon from 'lucide-solid/icons/settings';
+import SparklesIcon from 'lucide-solid/icons/sparkles';
+import { formatRelativeTime } from '@/utils/format';
+import { trackUpgradeClicked } from '@/utils/upgradeMetrics';
+import type { PatrolIntelligenceState } from './usePatrolIntelligenceState';
+
+export function PatrolIntelligenceBanners(props: { state: PatrolIntelligenceState }) {
+ const state = props.state;
+
+ return (
+ <>
+ <Show when={state.patrolStream.isStreaming()}>
+ <div class="flex-shrink-0 bg-blue-50 dark:bg-blue-900 border-b border-blue-200 dark:border-blue-800 px-4 py-2">
+ <div class="flex items-center gap-3 text-sm">
+ <div class="flex items-center gap-2">
+ <div class="w-2 h-2 rounded-full bg-blue-500 animate-pulse" />
+ <span class="font-medium text-blue-800 dark:text-blue-200">Patrol running</span>
+ </div>
+ <Show when={state.patrolStream.phase()}>
+ <span class="text-blue-700 dark:text-blue-300">{state.patrolStream.phase()}</span>
+ </Show>
+ <Show when={state.patrolStream.currentTool()}>
+ <span class="text-blue-600 dark:text-blue-400 font-mono text-xs bg-blue-100 dark:bg-blue-900 px-1.5 py-0.5 rounded">
+ {state.patrolStream.currentTool()}
+ </span>
+ </Show>
+ <Show when={state.patrolStream.tokens() > 0}>
+ <span class="text-blue-500 dark:text-blue-400 text-xs ml-auto">
+ {state.patrolStream.tokens().toLocaleString()} tokens
+ </span>
+ </Show>
+ </div>
+ </div>
+ </Show>
+
+ <Show when={state.licenseRequired() && !state.showBlockedBanner()}>
+ <div class="flex-shrink-0 bg-blue-50 dark:bg-blue-900 border-b border-blue-200 dark:border-blue-800 px-3 py-2">
+ <div class="flex flex-wrap items-center justify-between gap-2">
+ <p class="text-xs text-blue-700 dark:text-blue-300">
+ <a
+ class="text-indigo-600 dark:text-indigo-400 font-semibold hover:underline"
+ href={state.upgradeUrl()}
+ target="_blank"
+ rel="noopener noreferrer"
+ onClick={() => trackUpgradeClicked('ai_intelligence_banner', 'ai_autofix')}
+ >
+ Upgrade to Pro
+ </a>{' '}
+ to unlock automatic fixes and alert-triggered analysis.
+ </p>
+ </div>
+ </div>
+ </Show>
+
+ <Show when={state.showBlockedBanner()}>
+ <div class="flex-shrink-0 bg-amber-50 dark:bg-amber-900 border-b border-amber-200 dark:border-amber-800 px-4 py-3">
+ <div class="flex flex-wrap items-center justify-between gap-3">
+ <div class="flex items-start gap-3">
+ <div class="flex-shrink-0 p-1.5 bg-amber-100 dark:bg-amber-900 rounded-md">
+ <ShieldAlertIcon class="w-4 h-4 text-amber-600 dark:text-amber-400" />
+ </div>
+ <div>
+ <p class="text-sm font-semibold text-amber-900 dark:text-amber-100">
+ Patrol paused
+ </p>
+ <p class="text-xs text-amber-700 dark:text-amber-300">
+ {state.blockedReason()}
+ </p>
+ <Show when={state.blockedAt()}>
+ <p class="text-[10px] text-amber-700 dark:text-amber-300">
+ Blocked {formatRelativeTime(state.blockedAt(), { compact: true })}
+ </p>
+ </Show>
+ </div>
+ </div>
+ <div class="flex items-center gap-2">
+ <a
+ href="/settings/system-ai"
+ class="inline-flex items-center justify-center gap-2 px-3 py-1.5 text-xs font-semibold text-amber-900 dark:text-amber-100 bg-amber-100 dark:bg-amber-900 border border-amber-200 dark:border-amber-700 rounded-md hover:bg-amber-200 dark:hover:bg-amber-900 transition-colors"
+ >
+ <SettingsIcon class="w-3.5 h-3.5" />
+ Open AI Settings
+ </a>
+ <Show when={state.licenseRequired()}>
+ <a
+ href={state.upgradeUrl()}
+ target="_blank"
+ rel="noopener noreferrer"
+ class="inline-flex items-center justify-center gap-2 px-3 py-1.5 text-xs font-semibold text-white bg-amber-600 hover:bg-amber-700 rounded-md transition-colors"
+ >
+ <SparklesIcon class="w-3.5 h-3.5" />
+ Upgrade
+ </a>
+ </Show>
+ </div>
+ </div>
+ </div>
+ </Show>
+ </>
+ );
+}
diff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx
new file mode 100644
index 0000000000..7019e8f969
--- /dev/null
+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx
@@ -0,0 +1,398 @@
+import { createMemo, For, Show } from 'solid-js';
+import RefreshCwIcon from 'lucide-solid/icons/refresh-cw';
+import PlayIcon from 'lucide-solid/icons/play';
+import CircleHelpIcon from 'lucide-solid/icons/circle-help';
+import XIcon from 'lucide-solid/icons/x';
+import SettingsIcon from 'lucide-solid/icons/settings';
+import { PulsePatrolLogo } from '@/components/Brand/PulsePatrolLogo';
+import { PageHeader } from '@/components/shared/PageHeader';
+import { Toggle, TogglePrimitive } from '@/components/shared/Toggle';
+import { CountdownTimer } from '@/components/patrol';
+import { formatRelativeTime } from '@/utils/format';
+import { groupModelsByProvider } from '@/utils/patrolFormat';
+import { getAIQuickstartCreditsPresentation } from '@/utils/aiQuickstartPresentation';
+import { buildPatrolScheduleOptions } from '@/utils/aiPatrolSchedulePresentation';
+import type { PatrolIntelligenceState } from './usePatrolIntelligenceState';
+
+export function PatrolIntelligenceHeader(props: { state: PatrolIntelligenceState }) {
+ const state = props.state;
+ const quickstartPresentation = createMemo(() =>
+ getAIQuickstartCreditsPresentation(
+ state.patrolStatus()?.quickstart_credits_remaining ?? 0,
+ state.patrolStatus()?.quickstart_credits_total ?? 0,
+ ),
+ );
+ const scheduleOptions = createMemo(() =>
+ buildPatrolScheduleOptions(state.patrolInterval()),
+ );
+ const patrolModelStale = createMemo(() => {
+ const model = state.patrolModel();
+ const models = state.availableModels();
+ if (!model || models.length === 0) return false;
+ return !models.some((candidate) => candidate.id === model);
+ });
+
+ return (
+ <div class="flex-shrink-0 bg-surface border-b border-border px-4 py-3">
+ <PageHeader
+ id="patrol-title"
+ title={
+ <span
+ class="inline-flex items-center gap-3"
+ title="Pulse Patrol constantly monitors your infrastructure, investigates alerts, and can automatically fix issues based on your autonomy settings."
+ >
+ <PulsePatrolLogo class="w-6 h-6 text-base-content" />
+ <span>Patrol</span>
+ </span>
+ }
+ description="Pulse Patrol monitoring and analysis"
+ class="mb-3"
+ actions={
+ <div class="flex flex-wrap items-center justify-end gap-3">
+ <Show when={state.patrolStatus()?.last_patrol_at}>
+ <div class="hidden sm:flex items-center gap-3 text-xs text-muted">
+ <span>
+ Last:{' '}
+ {formatRelativeTime(state.patrolStatus()?.last_patrol_at, {
+ compact: true,
+ emptyText: 'Never',
+ })}
+ </span>
+ <Show when={state.patrolStatus()?.next_patrol_at}>
+ <span class="text-muted">|</span>
+ <CountdownTimer
+ targetDate={state.patrolStatus()!.next_patrol_at!}
+ prefix="Next run: "
+ class="font-variant-numeric tabular-nums font-medium text-blue-600 dark:text-blue-400"
+ />
+ </Show>
+ </div>
+ </Show>
+
+ <button
+ onClick={() => state.handleRunPatrol()}
+ disabled={
+ state.isTriggeringPatrol() ||
+ !state.canTriggerPatrol() ||
+ state.manualRunRequested() ||
+ state.patrolStream.isStreaming()
+ }
+ title={state.triggerPatrolDisabledReason()}
+ class="flex items-center gap-2 px-3 py-1.5 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 disabled:bg-surface-alt disabled:text-muted rounded-md transition-colors"
+ >
+ <PlayIcon
+ class={`w-4 h-4 ${state.isTriggeringPatrol() || state.manualRunRequested() || state.patrolStream.isStreaming() ? 'animate-pulse' : ''}`}
+ />
+ {state.isTriggeringPatrol()
+ ? 'Starting…'
+ : state.manualRunRequested() || state.patrolStream.isStreaming()
+ ? 'Running…'
+ : 'Run Patrol'}
+ </button>
+
+ <button
+ onClick={() => state.loadAllData()}
+ disabled={state.isRefreshing()}
+ class="flex items-center gap-2 px-3 py-1.5 text-sm font-medium text-base-content bg-surface border border-border rounded-md hover:bg-surface-hover disabled:opacity-50 transition-colors"
+ >
+ <RefreshCwIcon class={`w-4 h-4 ${state.isRefreshing() ? 'animate-spin' : ''}`} />
+ Refresh
+ </button>
+ </div>
+ }
+ />
+
+ <div class="flex items-center gap-4 mt-2 mb-1">
+ <div class="flex items-center gap-2 bg-surface-hover px-3 py-1.5 rounded-md border border-border">
+ <TogglePrimitive
+ checked={state.patrolEnabledLocal()}
+ disabled={state.isTogglingPatrol()}
+ onToggle={state.handleTogglePatrol}
+ size="sm"
+ ariaLabel="Toggle Patrol"
+ />
+ <span class="text-sm font-medium text-base-content">
+ {state.patrolEnabledLocal() ? 'Patrol Active' : 'Patrol Disabled'}
+ </span>
+ </div>
+
+ <Show
+ when={
+ state.patrolStatus()?.using_quickstart ||
+ (state.patrolStatus()?.quickstart_credits_total &&
+ state.patrolStatus()!.quickstart_credits_total! > 0 &&
+ state.patrolStatus()!.quickstart_credits_remaining !== undefined)
+ }
+ >
+ <div
+ class={`flex items-center gap-1.5 px-3 py-1.5 rounded-md border text-xs font-medium ${quickstartPresentation().className}`}
+ title={quickstartPresentation().title}
+ >
+ <Show
+ when={(state.patrolStatus()?.quickstart_credits_remaining ?? 0) > 0}
+ fallback={<span>{quickstartPresentation().summary}</span>}
+ >
+ <span>{quickstartPresentation().summary}</span>
+ </Show>
+ </div>
+ </Show>
+
+ <div class="flex-1"></div>
+
+ <div class="relative" ref={state.setAdvancedSettingsRef}>
+ <button
+ onClick={() => state.setShowAdvancedSettings(!state.showAdvancedSettings())}
+ disabled={!state.patrolEnabledLocal()}
+ class={`flex items-center gap-2 px-3 py-1.5 text-sm font-medium rounded-md transition-all shadow-sm ${state.showAdvancedSettings() ? 'bg-blue-50 text-blue-700 border border-blue-200 dark:bg-blue-900 dark:text-blue-300 dark:border-blue-800' : ' text-base-content border border-border hover:bg-surface-alt'} ${!state.patrolEnabledLocal() ? 'opacity-50 cursor-not-allowed hidden' : ''}`}
+ >
+ <SettingsIcon class="w-4 h-4" />
+ Configure Patrol
+ </button>
+
+ <Show when={state.showAdvancedSettings()}>
+ <div class="absolute right-0 top-10 z-50 w-[340px] p-5 bg-surface rounded-md shadow-sm border border-border animate-slide-up transform origin-top-right">
+ <div class="flex items-center justify-between mb-5 pb-3 border-b border-border-subtle">
+ <h4 class="text-base font-semibold tracking-tight text-base-content">
+ Patrol Configuration
+ </h4>
+ <button
+ onClick={() => state.setShowAdvancedSettings(false)}
+ class="p-1 rounded-md hover:text-base-content hover:bg-surface-hover transition-colors"
+ >
+ <XIcon class="w-4 h-4" />
+ </button>
+ </div>
+
+ <div class="space-y-6">
+ <div class="grid grid-cols-2 gap-4">
+ <div class="space-y-1.5">
+ <label class="text-xs font-semibold uppercase tracking-wider text-muted">
+ AI Model
+ </label>
+ <select
+ ref={state.setPatrolModelSelectRef}
+ value={state.patrolModel()}
+ onChange={(e) => state.handleModelChange(e.currentTarget.value)}
+ disabled={state.isUpdatingSettings() || !state.patrolEnabledLocal()}
+ class="w-full text-sm bg-base border border-border rounded-md py-2 pl-3 pr-8 text-base-content focus:ring-2 focus:ring-blue-500 focus:border-blue-500 disabled:opacity-50"
+ >
+ <option value="">
+ Default ({state.defaultModel().split(':').pop() || 'not set'})
+ </option>
+ <Show when={patrolModelStale()}>
+ <option value={state.patrolModel()} disabled>
+ {state.patrolModel().split(':').pop()} (unavailable)
+ </option>
+ </Show>
+ {Array.from(groupModelsByProvider(state.availableModels()).entries()).map(
+ ([provider, models]) => (
+ <optgroup label={provider.charAt(0).toUpperCase() + provider.slice(1)}>
+ {models.map((model) => (
+ <option value={model.id}>
+ {model.name || model.id.split(':').pop()}
+ </option>
+ ))}
+ </optgroup>
+ ),
+ )}
+ </select>
+ </div>
+
+ <div class="space-y-1.5">
+ <label class="text-xs font-semibold uppercase tracking-wider text-muted">
+ Run Every
+ </label>
+ <select
+ value={state.patrolInterval()}
+ onChange={(e) =>
+ state.handleIntervalChange(parseInt(e.currentTarget.value, 10))
+ }
+ disabled={state.isUpdatingSettings() || !state.patrolEnabledLocal()}
+ class="w-full text-sm bg-base border border-border rounded-md py-2 pl-3 pr-8 text-base-content focus:ring-2 focus:ring-blue-500 focus:border-blue-500 disabled:opacity-50"
+ >
+ <For each={scheduleOptions()}>
+ {(preset) => <option value={preset.value}>{preset.label}</option>}
+ </For>
+ </select>
+ </div>
+ </div>
+
+ <div class="space-y-2">
+ <div class="flex items-center justify-between">
+ <label class="text-xs font-semibold uppercase tracking-wider text-muted flex items-center gap-1.5">
+ Operational Mode
+ <div class="relative group">
+ <CircleHelpIcon class="w-3.5 h-3.5 cursor-help" />
+ <div class="absolute left-1/2 -translate-x-1/2 bottom-full mb-2 hidden group-hover:block w-64 p-3 bg-surface text-white rounded-md shadow-md text-xs z-50 pointer-events-none before:absolute before:top-full before:left-1/2 before:-translate-x-1/2 before:border-4 before:border-transparent before:border-t-slate-800">
+ <strong>Monitor:</strong> Detect only.
+ <br />
+ <strong>Investigate:</strong> Detect & propose fixes.
+ <br />
+ <strong>Auto-fix:</strong> Execute safe fixes automatically.
+ </div>
+ </div>
+ </label>
+ </div>
+
+ <div class="flex items-center bg-base rounded-md p-1 border shadow-inner">
+ <For each={['monitor', 'approval', 'assisted'] as const}>
+ {(level) => {
+ const isProLocked = () =>
+ state.autoFixLocked() &&
+ (level === 'approval' || level === 'assisted');
+ const isDisabled = () => !state.patrolEnabledLocal() || isProLocked();
+ const isActive = () =>
+ level === 'assisted'
+ ? state.autonomyLevel() === 'assisted' ||
+ state.autonomyLevel() === 'full'
+ : state.autonomyLevel() === level;
+
+ return (
+ <button
+ onClick={() => state.handleAutonomyChange(level)}
+ disabled={isDisabled()}
+ title={
+ isProLocked()
+ ? level === 'approval'
+ ? 'Upgrade to Pro to investigate findings'
+ : 'Upgrade to Pro for automatic fixes'
+ : undefined
+ }
+ class={`flex-1 py-1.5 px-2 text-xs font-semibold rounded-md transition-all duration-200 ${isActive() ? ' text-blue-600 dark:text-blue-400 shadow-[0_1px_3px_rgba(0,0,0,0.1)]' : isDisabled() ? ' ' : 'text-muted hover:text-base-content hover:bg-surface-hover'} ${isDisabled() ? 'opacity-50 cursor-not-allowed' : ''}`}
+ >
+ {level === 'monitor'
+ ? 'Monitor'
+ : level === 'approval'
+ ? 'Investigate'
+ : 'Auto-fix'}
+ </button>
+ );
+ }}
+ </For>
+ </div>
+ <Show when={state.autoFixLocked()}>
+ <div class="pl-1 text-[11px] text-slate-500">
+ <a
+ href={state.upgradeUrl()}
+ target="_blank"
+ class="text-indigo-500 font-medium hover:underline"
+ >
+ Upgrade to Pro
+ </a>{' '}
+ to unlock investigation and auto-fix.
+ <Show when={state.canStartTrial()}>
+ {' '}
+ <button
+ type="button"
+ onClick={state.handleStartTrial}
+ disabled={state.startingTrial()}
+ class="text-indigo-500 hover:underline"
+ >
+ Start free trial
+ </button>
+ </Show>
+ </div>
+ </Show>
+ </div>
+
+ <div class="space-y-4 pt-4 border-t border-border-subtle">
+ <div class="flex items-start justify-between gap-3">
+ <div class="flex-1">
+ <label class="text-sm font-medium text-base-content">
+ Alert-Triggered Analysis
+ </label>
+ <p class="text-[11px] text-muted mt-0.5 leading-tight">
+ Analyze infrastructure automatically when critical alerts fire.
+ </p>
+ </div>
+ <Toggle
+ checked={state.alertTriggeredAnalysis()}
+ onChange={(e) =>
+ state.handleAlertTriggeredAnalysisChange(e.currentTarget.checked)
+ }
+ disabled={state.isUpdatingSettings() || state.alertAnalysisLocked()}
+ />
+ </div>
+
+ <Show when={state.alertAnalysisLocked()}>
+ <div class="-my-1 pl-1 text-[11px]">
+ <a
+ href={state.alertAnalysisUpgradeUrl()}
+ target="_blank"
+ class="text-indigo-500 font-medium hover:underline"
+ >
+ Upgrade
+ </a>{' '}
+ to enable.
+ <Show when={state.canStartTrial()}>
+ <button
+ type="button"
+ onClick={state.handleStartTrial}
+ disabled={state.startingTrial()}
+ class="ml-1 text-indigo-500 hover:underline"
+ >
+ Start free trial
+ </button>
+ </Show>
+ </div>
+ </Show>
+
+ <div class="flex items-start justify-between gap-3">
+ <div class="flex-1">
+ <label class="text-sm font-medium text-base-content">
+ Event-Triggered Patrols
+ </label>
+ <p class="text-[11px] text-muted mt-0.5 leading-tight">
+ Run extra patrols when alerts fire or anomalies are detected.
+ </p>
+ </div>
+ <Toggle
+ checked={state.patrolEventTriggers()}
+ onChange={(e) =>
+ state.handlePatrolEventTriggersChange(e.currentTarget.checked)
+ }
+ disabled={state.isUpdatingSettings() || !state.patrolEnabledLocal()}
+ />
+ </div>
+
+ <div class="flex items-start justify-between gap-3">
+ <div class="flex-1">
+ <label class="text-sm font-medium text-red-600 dark:text-red-400">
+ Auto-fix critical issues
+ </label>
+ <p class="text-[11px] text-muted mt-0.5 leading-tight">
+ Permit Patrol to execute critical remediations without approval.
+ </p>
+ </div>
+ <Toggle
+ checked={!state.autoFixLocked() && state.fullModeUnlocked()}
+ onChange={(e) => state.setFullModeUnlocked(e.currentTarget.checked)}
+ disabled={
+ state.autoFixLocked() ||
+ !(state.autonomyLevel() === 'assisted' ||
+ state.autonomyLevel() === 'full')
+ }
+ />
+ </div>
+ </div>
+
+ <div class="pt-4 border-t border-border-subtle">
+ <button
+ onClick={state.saveAdvancedSettings}
+ disabled={state.isSavingAdvanced()}
+ class="w-full py-2.5 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md shadow-sm transition-all focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-70 flex items-center justify-center gap-2"
+ >
+ <Show when={state.isSavingAdvanced()}>
+ <div class="animate-spin w-4 h-4 border-2 border-current border-t-transparent rounded-full"></div>
+ </Show>
+ <Show when={!state.isSavingAdvanced()}>Apply Configuration</Show>
+ </button>
+ </div>
+ </div>
+ </div>
+ </Show>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx
new file mode 100644
index 0000000000..83824b4ca7
--- /dev/null
+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx
@@ -0,0 +1,178 @@
+import { createMemo, Show } from 'solid-js';
+import ActivityIcon from 'lucide-solid/icons/activity';
+import ShieldAlertIcon from 'lucide-solid/icons/shield-alert';
+import CheckCircleIcon from 'lucide-solid/icons/check-circle';
+import { getPatrolSummaryPresentation, PATROL_NO_ISSUES_LABEL } from '@/utils/patrolSummaryPresentation';
+import { ResourcePolicySummary } from '@/components/Infrastructure/ResourcePolicySummary';
+import { ResourceCorrelationSummary } from '@/components/Infrastructure/ResourceCorrelationSummary';
+import { ResourceChangeSummary } from '@/components/Infrastructure/ResourceChangeSummary';
+import type { PatrolIntelligenceState } from './usePatrolIntelligenceState';
+
+export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceState }) {
+ const state = props.state;
+ const criticalSummaryPresentation = createMemo(() =>
+ getPatrolSummaryPresentation('critical', state.summaryStats().criticalFindings > 0),
+ );
+ const warningSummaryPresentation = createMemo(() =>
+ getPatrolSummaryPresentation('warning', state.summaryStats().warningFindings > 0),
+ );
+ const fixedSummaryPresentation = createMemo(() =>
+ getPatrolSummaryPresentation('success', state.summaryStats().fixedCount > 0),
+ );
+
+ return (
+ <>
+ <Show when={state.intelligenceSummary()}>
+ {(summary) => (
+ <section class="rounded-md border border-border bg-surface p-4">
+ <div class="flex flex-wrap items-start justify-between gap-4">
+ <div>
+ <p class="text-xs font-semibold uppercase tracking-[0.16em] text-muted">
+ Patrol summary
+ </p>
+ <h2 class="mt-1 text-lg font-semibold text-base-content">
+ Health {summary().overall_health.grade} ·{' '}
+ {Math.round(summary().overall_health.score)}/100
+ </h2>
+ <p class="mt-1 text-sm text-muted">{summary().overall_health.prediction}</p>
+ </div>
+
+ <div class="flex flex-wrap items-center gap-2">
+ <span class="rounded-full border border-border-subtle bg-base px-2.5 py-1 text-xs font-medium text-base-content">
+ Critical {summary().findings_count.critical}
+ </span>
+ <span class="rounded-full border border-border-subtle bg-base px-2.5 py-1 text-xs font-medium text-base-content">
+ Warning {summary().findings_count.warning}
+ </span>
+ </div>
+ </div>
+
+ <Show when={state.hasInvestigationContext()}>
+ <div class="mt-4 rounded-md border border-border-subtle bg-base p-3">
+ <div class="flex flex-wrap items-start justify-between gap-3">
+ <div>
+ <p class="text-xs font-semibold uppercase tracking-[0.16em] text-muted">
+ Investigation context
+ </p>
+ <p class="mt-1 text-sm text-muted">
+ Secondary change and policy signals for deeper investigation.
+ </p>
+ <Show when={state.investigationContextSummary()}>
+ <p class="mt-1 text-xs text-base-content">
+ {state.investigationContextSummary()}
+ </p>
+ </Show>
+ </div>
+
+ <button
+ type="button"
+ onClick={() => state.setShowInvestigationContext((value) => !value)}
+ class="inline-flex items-center rounded-md border border-border bg-surface px-3 py-1.5 text-xs font-medium text-base-content transition-colors hover:bg-surface-hover"
+ >
+ {state.showInvestigationContext() ? 'Hide context' : 'Show context'}
+ </button>
+ </div>
+
+ <Show when={state.showInvestigationContext()}>
+ <div class="mt-4 grid gap-4 lg:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]">
+ <Show when={state.recentChangeCount() > 0}>
+ <ResourceChangeSummary
+ class="space-y-0"
+ title="Recent changes"
+ subtitle="Last 24 hours"
+ changes={summary().recent_changes}
+ maxChanges={3}
+ compact
+ />
+ </Show>
+
+ <div class="space-y-4">
+ <Show when={state.correlations().length > 0}>
+ <ResourceCorrelationSummary
+ title="Correlations"
+ correlations={state.correlations()}
+ summaryText={`${state.correlationTotal()} total`}
+ />
+ </Show>
+
+ <ResourcePolicySummary
+ posture={state.policyPosture()}
+ title="Policy posture"
+ />
+ </div>
+ </div>
+ </Show>
+ </div>
+ </Show>
+ </section>
+ )}
+ </Show>
+
+ <Show
+ when={
+ state.summaryStats().criticalFindings > 0 ||
+ state.summaryStats().warningFindings > 0 ||
+ state.summaryStats().fixedCount > 0
+ }
+ fallback={
+ <Show when={state.patrolStatus()?.last_patrol_at}>
+ <div class="flex items-center gap-2 px-4 py-3 bg-surface rounded-md border border-border">
+ <CheckCircleIcon class="w-4 h-4 text-green-500 dark:text-green-400" />
+ <span class="text-sm text-muted">{PATROL_NO_ISSUES_LABEL}</span>
+ </div>
+ </Show>
+ }
+ >
+ <div class="grid grid-cols-1 sm:grid-cols-3 gap-3">
+ <div class="bg-surface rounded-md border border-border p-3">
+ <div class="flex items-center gap-2">
+ <div
+ class={`p-1.5 rounded-md border ${criticalSummaryPresentation().iconContainerClass}`}
+ >
+ <ShieldAlertIcon class={`w-4 h-4 ${criticalSummaryPresentation().iconClass}`} />
+ </div>
+ <div>
+ <p class="text-xs text-muted">Critical</p>
+ <p class={`text-lg font-bold ${criticalSummaryPresentation().valueClass}`}>
+ {state.summaryStats().criticalFindings}
+ </p>
+ </div>
+ </div>
+ </div>
+
+ <div class="bg-surface rounded-md border border-border p-3">
+ <div class="flex items-center gap-2">
+ <div
+ class={`p-1.5 rounded-md border ${warningSummaryPresentation().iconContainerClass}`}
+ >
+ <ActivityIcon class={`w-4 h-4 ${warningSummaryPresentation().iconClass}`} />
+ </div>
+ <div>
+ <p class="text-xs text-muted">Warnings</p>
+ <p class={`text-lg font-bold ${warningSummaryPresentation().valueClass}`}>
+ {state.summaryStats().warningFindings}
+ </p>
+ </div>
+ </div>
+ </div>
+
+ <div class="bg-surface rounded-md border border-border p-3">
+ <div class="flex items-center gap-2">
+ <div
+ class={`p-1.5 rounded-md border ${fixedSummaryPresentation().iconContainerClass}`}
+ >
+ <CheckCircleIcon class={`w-4 h-4 ${fixedSummaryPresentation().iconClass}`} />
+ </div>
+ <div>
+ <p class="text-xs text-muted">Fixed</p>
+ <p class={`text-lg font-bold ${fixedSummaryPresentation().valueClass}`}>
+ {state.summaryStats().fixedCount}
+ </p>
+ </div>
+ </div>
+ </div>
+ </div>
+ </Show>
+ </>
+ );
+}
diff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx
index 24a1820445..16a94cce4f 100644
--- a/frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx
+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx
@@ -1,860 +1,23 @@
-/**
- * Patrol Intelligence Surface
- *
- * Canonical Patrol runtime surface for findings, runs, and patrol controls.
- */
-
-import { createMemo, For, Show } from 'solid-js';
-import { FindingsPanel } from '@/components/AI/FindingsPanel';
-import { getFindingSeverityToneClasses } from '@/utils/aiFindingPresentation';
-import {
- getPatrolSummaryPresentation,
- PATROL_NO_ISSUES_LABEL,
-} from '@/utils/patrolSummaryPresentation';
-
-import ActivityIcon from 'lucide-solid/icons/activity';
-import ShieldAlertIcon from 'lucide-solid/icons/shield-alert';
-import RefreshCwIcon from 'lucide-solid/icons/refresh-cw';
-import PlayIcon from 'lucide-solid/icons/play';
-import CircleHelpIcon from 'lucide-solid/icons/circle-help';
-import XIcon from 'lucide-solid/icons/x';
-
-import SparklesIcon from 'lucide-solid/icons/sparkles';
-import CheckCircleIcon from 'lucide-solid/icons/check-circle';
-import SettingsIcon from 'lucide-solid/icons/settings';
-import { PulsePatrolLogo } from '@/components/Brand/PulsePatrolLogo';
-import { PageHeader } from '@/components/shared/PageHeader';
-import { TogglePrimitive, Toggle } from '@/components/shared/Toggle';
-import {
- ApprovalBanner,
- PatrolStatusBar,
- RunHistoryPanel,
- CountdownTimer,
-} from '@/components/patrol';
-import { formatRelativeTime } from '@/utils/format';
-import { trackUpgradeClicked } from '@/utils/upgradeMetrics';
-import { formatTriggerReason, groupModelsByProvider } from '@/utils/patrolFormat';
-import { getAIQuickstartCreditsPresentation } from '@/utils/aiQuickstartPresentation';
-import { buildPatrolScheduleOptions } from '@/utils/aiPatrolSchedulePresentation';
-import { ResourcePolicySummary } from '@/components/Infrastructure/ResourcePolicySummary';
-import { ResourceCorrelationSummary } from '@/components/Infrastructure/ResourceCorrelationSummary';
-import { ResourceChangeSummary } from '@/components/Infrastructure/ResourceChangeSummary';
import { usePatrolIntelligenceState } from './usePatrolIntelligenceState';
+import { PatrolIntelligenceHeader } from './PatrolIntelligenceHeader';
+import { PatrolIntelligenceBanners } from './PatrolIntelligenceBanners';
+import { PatrolIntelligenceSummary } from './PatrolIntelligenceSummary';
+import { PatrolIntelligenceWorkspace } from './PatrolIntelligenceWorkspace';
export function PatrolIntelligenceSurface() {
- const {
- activeTab,
- activityRefreshTrigger,
- alertAnalysisUpgradeUrl,
- alertAnalysisLocked,
- alertTriggeredAnalysis,
- autonomyLevel,
- autoFixLocked,
- availableModels,
- blockedAt,
- blockedReason,
- canStartTrial,
- canTriggerPatrol,
- correlationTotal,
- correlations,
- clearScrollToFindingTimer,
- defaultModel,
- displayRunHistory,
- findingsFilterOverride,
- fullModeUnlocked,
- handleAlertTriggeredAnalysisChange,
- handleAutonomyChange,
- handleIntervalChange,
- handleModelChange,
- handlePatrolEventTriggersChange,
- handleRunPatrol,
- handleStartTrial,
- handleTogglePatrol,
- hasInvestigationContext,
- intelligenceSummary,
- investigationContextSummary,
- isRefreshing,
- isSavingAdvanced,
- isTogglingPatrol,
- isTriggeringPatrol,
- isUpdatingSettings,
- licenseRequired,
- loadAllData,
- manualRunRequested,
- patrolEnabledLocal,
- patrolEventTriggers,
- patrolInterval,
- patrolModel,
- patrolRunHistory,
- patrolStatus,
- patrolStream,
- policyPosture,
- recentChangeCount,
- saveAdvancedSettings,
- selectedRun,
- selectedRunFindingIds,
- selectedRunScopeResourceIds,
- setActiveTab,
- setAdvancedSettingsRef,
- setFindingScrollTimer,
- setFindingsFilterOverride,
- setFullModeUnlocked,
- setPatrolModelSelectRef,
- setScrollToFindingTimer,
- setSelectedRun,
- setShowAdvancedSettings,
- setShowInvestigationContext,
- showAdvancedSettings,
- showBlockedBanner,
- showInvestigationContext,
- startingTrial,
- summaryStats,
- triggerPatrolDisabledReason,
- upgradeUrl,
- } = usePatrolIntelligenceState();
-
- const quickstartPresentation = createMemo(() =>
- getAIQuickstartCreditsPresentation(
- patrolStatus()?.quickstart_credits_remaining ?? 0,
- patrolStatus()?.quickstart_credits_total ?? 0,
- ),
- );
- const criticalSummaryPresentation = createMemo(() =>
- getPatrolSummaryPresentation('critical', summaryStats().criticalFindings > 0),
- );
- const warningSummaryPresentation = createMemo(() =>
- getPatrolSummaryPresentation('warning', summaryStats().warningFindings > 0),
- );
- const fixedSummaryPresentation = createMemo(() =>
- getPatrolSummaryPresentation('success', summaryStats().fixedCount > 0),
- );
- const scheduleOptions = createMemo(() => buildPatrolScheduleOptions(patrolInterval()));
- const patrolModelStale = createMemo(() => {
- const model = patrolModel();
- const models = availableModels();
- if (!model || models.length === 0) return false;
- return !models.some((candidate) => candidate.id === model);
- });
+ const state = usePatrolIntelligenceState();
return (
<div class="h-full flex flex-col bg-base">
- {/* Header */}
- <div class="flex-shrink-0 bg-surface border-b border-border px-4 py-3">
- <PageHeader
- id="patrol-title"
- title={
- <span
- class="inline-flex items-center gap-3"
- title="Pulse Patrol constantly monitors your infrastructure, investigates alerts, and can automatically fix issues based on your autonomy settings."
- >
- <PulsePatrolLogo class="w-6 h-6 text-base-content" />
- <span>Patrol</span>
- </span>
- }
- description="Pulse Patrol monitoring and analysis"
- class="mb-3"
- actions={
- <div class="flex flex-wrap items-center justify-end gap-3">
- <Show when={patrolStatus()?.last_patrol_at}>
- <div class="hidden sm:flex items-center gap-3 text-xs text-muted">
- <span>
- Last:{' '}
- {formatRelativeTime(patrolStatus()?.last_patrol_at, {
- compact: true,
- emptyText: 'Never',
- })}
- </span>
- <Show when={patrolStatus()?.next_patrol_at}>
- <span class="text-muted">|</span>
- <CountdownTimer
- targetDate={patrolStatus()!.next_patrol_at!}
- prefix="Next run: "
- class="font-variant-numeric tabular-nums font-medium text-blue-600 dark:text-blue-400"
- />
- </Show>
- </div>
- </Show>
-
- <button
- onClick={() => handleRunPatrol()}
- disabled={
- isTriggeringPatrol() ||
- !canTriggerPatrol() ||
- manualRunRequested() ||
- patrolStream.isStreaming()
- }
- title={triggerPatrolDisabledReason()}
- class="flex items-center gap-2 px-3 py-1.5 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 disabled:bg-surface-alt disabled:text-muted rounded-md transition-colors"
- >
- <PlayIcon
- class={`w-4 h-4 ${isTriggeringPatrol() || manualRunRequested() || patrolStream.isStreaming() ? 'animate-pulse' : ''}`}
- />
- {isTriggeringPatrol()
- ? 'Starting…'
- : manualRunRequested() || patrolStream.isStreaming()
- ? 'Running…'
- : 'Run Patrol'}
- </button>
-
- <button
- onClick={() => loadAllData()}
- disabled={isRefreshing()}
- class="flex items-center gap-2 px-3 py-1.5 text-sm font-medium text-base-content bg-surface border border-border rounded-md hover:bg-surface-hover disabled:opacity-50 transition-colors"
- >
- <RefreshCwIcon class={`w-4 h-4 ${isRefreshing() ? 'animate-spin' : ''}`} />
- Refresh
- </button>
- </div>
- }
- />
-
- {/* Settings row - Simplified for Enterprise Feel */}
- <div class="flex items-center gap-4 mt-2 mb-1">
- {/* Global Patrol Toggle */}
- <div class="flex items-center gap-2 bg-surface-hover px-3 py-1.5 rounded-md border border-border">
- <TogglePrimitive
- checked={patrolEnabledLocal()}
- disabled={isTogglingPatrol()}
- onToggle={handleTogglePatrol}
- size="sm"
- ariaLabel="Toggle Patrol"
- />
- <span class="text-sm font-medium text-base-content">
- {patrolEnabledLocal() ? 'Patrol Active' : 'Patrol Disabled'}
- </span>
- </div>
-
- {/* Quickstart Credits Badge */}
- <Show
- when={
- patrolStatus()?.using_quickstart ||
- (patrolStatus()?.quickstart_credits_total &&
- patrolStatus()!.quickstart_credits_total! > 0 &&
- patrolStatus()!.quickstart_credits_remaining !== undefined)
- }
- >
- <div
- class={`flex items-center gap-1.5 px-3 py-1.5 rounded-md border text-xs font-medium ${quickstartPresentation().className}`}
- title={quickstartPresentation().title}
- >
- <Show
- when={(patrolStatus()?.quickstart_credits_remaining ?? 0) > 0}
- fallback={<span>{quickstartPresentation().summary}</span>}
- >
- <span>{quickstartPresentation().summary}</span>
- </Show>
- </div>
- </Show>
-
- <div class="flex-1"></div>
-
- {/* Configuration Popover */}
- <div class="relative" ref={setAdvancedSettingsRef}>
- <button
- onClick={() => setShowAdvancedSettings(!showAdvancedSettings())}
- disabled={!patrolEnabledLocal()}
- class={`flex items-center gap-2 px-3 py-1.5 text-sm font-medium rounded-md transition-all shadow-sm ${showAdvancedSettings() ? 'bg-blue-50 text-blue-700 border border-blue-200 dark:bg-blue-900 dark:text-blue-300 dark:border-blue-800' : ' text-base-content border border-border hover:bg-surface-alt'} ${!patrolEnabledLocal() ? 'opacity-50 cursor-not-allowed hidden' : ''}`}
- >
- <SettingsIcon class="w-4 h-4" />
- Configure Patrol
- </button>
-
- <Show when={showAdvancedSettings()}>
- <div class="absolute right-0 top-10 z-50 w-[340px] p-5 bg-surface rounded-md shadow-sm border border-border animate-slide-up transform origin-top-right">
- <div class="flex items-center justify-between mb-5 pb-3 border-b border-border-subtle">
- <h4 class="text-base font-semibold tracking-tight text-base-content">
- Patrol Configuration
- </h4>
- <button
- onClick={() => setShowAdvancedSettings(false)}
- class="p-1 rounded-md hover:text-base-content hover:bg-surface-hover transition-colors"
- >
- <XIcon class="w-4 h-4" />
- </button>
- </div>
-
- <div class="space-y-6">
- {/* Model & Schedule grouped */}
- <div class="grid grid-cols-2 gap-4">
- <div class="space-y-1.5">
- <label class="text-xs font-semibold uppercase tracking-wider text-muted">
- AI Model
- </label>
- <select
- ref={setPatrolModelSelectRef}
- value={patrolModel()}
- onChange={(e) => handleModelChange(e.currentTarget.value)}
- disabled={isUpdatingSettings() || !patrolEnabledLocal()}
- class="w-full text-sm bg-base border border-border rounded-md py-2 pl-3 pr-8 text-base-content focus:ring-2 focus:ring-blue-500 focus:border-blue-500 disabled:opacity-50"
- >
- <option value="">
- Default ({defaultModel().split(':').pop() || 'not set'})
- </option>
- <Show when={patrolModelStale()}>
- <option value={patrolModel()} disabled>
- {patrolModel().split(':').pop()} (unavailable)
- </option>
- </Show>
- {Array.from(groupModelsByProvider(availableModels()).entries()).map(
- ([provider, models]) => (
- <optgroup label={provider.charAt(0).toUpperCase() + provider.slice(1)}>
- {models.map((model) => (
- <option value={model.id}>
- {model.name || model.id.split(':').pop()}
- </option>
- ))}
- </optgroup>
- ),
- )}
- </select>
- </div>
-
- <div class="space-y-1.5">
- <label class="text-xs font-semibold uppercase tracking-wider text-muted">
- Run Every
- </label>
- <select
- value={patrolInterval()}
- onChange={(e) => handleIntervalChange(parseInt(e.currentTarget.value))}
- disabled={isUpdatingSettings() || !patrolEnabledLocal()}
- class="w-full text-sm bg-base border border-border rounded-md py-2 pl-3 pr-8 text-base-content focus:ring-2 focus:ring-blue-500 focus:border-blue-500 disabled:opacity-50"
- >
- <For each={scheduleOptions()}>
- {(preset) => <option value={preset.value}>{preset.label}</option>}
- </For>
- </select>
- </div>
- </div>
-
- {/* Operational Mode */}
- <div class="space-y-2">
- <div class="flex items-center justify-between">
- <label class="text-xs font-semibold uppercase tracking-wider text-muted flex items-center gap-1.5">
- Operational Mode
- <div class="relative group">
- <CircleHelpIcon class="w-3.5 h-3.5 cursor-help" />
- <div class="absolute left-1/2 -translate-x-1/2 bottom-full mb-2 hidden group-hover:block w-64 p-3 bg-surface text-white rounded-md shadow-md text-xs z-50 pointer-events-none before:absolute before:top-full before:left-1/2 before:-translate-x-1/2 before:border-4 before:border-transparent before:border-t-slate-800">
- <strong>Monitor:</strong> Detect only.
- <br />
- <strong>Investigate:</strong> Detect & propose fixes.
- <br />
- <strong>Auto-fix:</strong> Execute safe fixes automatically.
- </div>
- </div>
- </label>
- </div>
-
- <div class="flex items-center bg-base rounded-md p-1 border shadow-inner">
- <For each={['monitor', 'approval', 'assisted'] as const}>
- {(level) => {
- const isProLocked = () =>
- autoFixLocked() && (level === 'approval' || level === 'assisted');
- const isDisabled = () => !patrolEnabledLocal() || isProLocked();
- const isActive = () =>
- level === 'assisted'
- ? autonomyLevel() === 'assisted' || autonomyLevel() === 'full'
- : autonomyLevel() === level;
-
- return (
- <button
- onClick={() => handleAutonomyChange(level)}
- disabled={isDisabled()}
- title={
- isProLocked()
- ? level === 'approval'
- ? 'Upgrade to Pro to investigate findings'
- : 'Upgrade to Pro for automatic fixes'
- : undefined
- }
- class={`flex-1 py-1.5 px-2 text-xs font-semibold rounded-md transition-all duration-200 ${isActive() ? ' text-blue-600 dark:text-blue-400 shadow-[0_1px_3px_rgba(0,0,0,0.1)]' : isDisabled() ? ' ' : 'text-muted hover:text-base-content hover:bg-surface-hover'} ${isDisabled() ? 'opacity-50 cursor-not-allowed' : ''}`}
- >
- {level === 'monitor'
- ? 'Monitor'
- : level === 'approval'
- ? 'Investigate'
- : 'Auto-fix'}
- </button>
- );
- }}
- </For>
- </div>
- <Show when={autoFixLocked()}>
- <div class="pl-1 text-[11px] text-slate-500">
- <a
- href={upgradeUrl()}
- target="_blank"
- class="text-indigo-500 font-medium hover:underline"
- >
- Upgrade to Pro
- </a>{' '}
- to unlock investigation and auto-fix.
- <Show when={canStartTrial()}>
- {' '}
- <button
- type="button"
- onClick={handleStartTrial}
- disabled={startingTrial()}
- class="text-indigo-500 hover:underline"
- >
- Start free trial
- </button>
- </Show>
- </div>
- </Show>
- </div>
-
- {/* Toggles */}
- <div class="space-y-4 pt-4 border-t border-border-subtle">
- <div class="flex items-start justify-between gap-3">
- <div class="flex-1">
- <label class="text-sm font-medium text-base-content">
- Alert-Triggered Analysis
- </label>
- <p class="text-[11px] text-muted mt-0.5 leading-tight">
- Analyze infrastructure automatically when critical alerts fire.
- </p>
- </div>
- <Toggle
- checked={alertTriggeredAnalysis()}
- onChange={(e) =>
- handleAlertTriggeredAnalysisChange(e.currentTarget.checked)
- }
- disabled={isUpdatingSettings() || alertAnalysisLocked()}
- />
- </div>
-
- <Show when={alertAnalysisLocked()}>
- <div class="-my-1 pl-1 text-[11px]">
- <a
- href={alertAnalysisUpgradeUrl()}
- target="_blank"
- class="text-indigo-500 font-medium hover:underline"
- >
- Upgrade
- </a>{' '}
- to enable.
- <Show when={canStartTrial()}>
- <button
- type="button"
- onClick={handleStartTrial}
- disabled={startingTrial()}
- class="ml-1 text-indigo-500 hover:underline"
- >
- Start free trial
- </button>
- </Show>
- </div>
- </Show>
-
- <div class="flex items-start justify-between gap-3">
- <div class="flex-1">
- <label class="text-sm font-medium text-base-content">
- Event-Triggered Patrols
- </label>
- <p class="text-[11px] text-muted mt-0.5 leading-tight">
- Run extra patrols when alerts fire or anomalies are detected.
- </p>
- </div>
- <Toggle
- checked={patrolEventTriggers()}
- onChange={(e) => handlePatrolEventTriggersChange(e.currentTarget.checked)}
- disabled={isUpdatingSettings() || !patrolEnabledLocal()}
- />
- </div>
-
- <div class="flex items-start justify-between gap-3">
- <div class="flex-1">
- <label class="text-sm font-medium text-red-600 dark:text-red-400">
- Auto-fix critical issues
- </label>
- <p class="text-[11px] text-muted mt-0.5 leading-tight">
- Permit Patrol to execute critical remediations without approval.
- </p>
- </div>
- <Toggle
- checked={!autoFixLocked() && fullModeUnlocked()}
- onChange={(e) => setFullModeUnlocked(e.currentTarget.checked)}
- disabled={
- autoFixLocked() ||
- !(autonomyLevel() === 'assisted' || autonomyLevel() === 'full')
- }
- />
- </div>
- </div>
+ <PatrolIntelligenceHeader state={state} />
+ <PatrolIntelligenceBanners state={state} />
- {/* Save Footer */}
- <div class="pt-4 border-t border-border-subtle">
- <button
- onClick={saveAdvancedSettings}
- disabled={isSavingAdvanced()}
- class="w-full py-2.5 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md shadow-sm transition-all focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-70 flex items-center justify-center gap-2"
- >
- <Show when={isSavingAdvanced()}>
- <div class="animate-spin w-4 h-4 border-2 border-current border-t-transparent rounded-full"></div>
- </Show>
- <Show when={!isSavingAdvanced()}>Apply Configuration</Show>
- </button>
- </div>
- </div>
- </div>
- </Show>
- </div>
- </div>
- </div>
-
- {/* Live patrol streaming status bar */}
- <Show when={patrolStream.isStreaming()}>
- <div class="flex-shrink-0 bg-blue-50 dark:bg-blue-900 border-b border-blue-200 dark:border-blue-800 px-4 py-2">
- <div class="flex items-center gap-3 text-sm">
- <div class="flex items-center gap-2">
- <div class="w-2 h-2 rounded-full bg-blue-500 animate-pulse" />
- <span class="font-medium text-blue-800 dark:text-blue-200">Patrol running</span>
- </div>
- <Show when={patrolStream.phase()}>
- <span class="text-blue-700 dark:text-blue-300">{patrolStream.phase()}</span>
- </Show>
- <Show when={patrolStream.currentTool()}>
- <span class="text-blue-600 dark:text-blue-400 font-mono text-xs bg-blue-100 dark:bg-blue-900 px-1.5 py-0.5 rounded">
- {patrolStream.currentTool()}
- </span>
- </Show>
- <Show when={patrolStream.tokens() > 0}>
- <span class="text-blue-500 dark:text-blue-400 text-xs ml-auto">
- {patrolStream.tokens().toLocaleString()} tokens
- </span>
- </Show>
- </div>
- </div>
- </Show>
-
- <Show when={licenseRequired() && !showBlockedBanner()}>
- <div class="flex-shrink-0 bg-blue-50 dark:bg-blue-900 border-b border-blue-200 dark:border-blue-800 px-3 py-2">
- <div class="flex flex-wrap items-center justify-between gap-2">
- <p class="text-xs text-blue-700 dark:text-blue-300">
- <a
- class="text-indigo-600 dark:text-indigo-400 font-semibold hover:underline"
- href={upgradeUrl()}
- target="_blank"
- rel="noopener noreferrer"
- onClick={() => trackUpgradeClicked('ai_intelligence_banner', 'ai_autofix')}
- >
- Upgrade to Pro
- </a>{' '}
- to unlock automatic fixes and alert-triggered analysis.
- </p>
- </div>
- </div>
- </Show>
-
- <Show when={showBlockedBanner()}>
- <div class="flex-shrink-0 bg-amber-50 dark:bg-amber-900 border-b border-amber-200 dark:border-amber-800 px-4 py-3">
- <div class="flex flex-wrap items-center justify-between gap-3">
- <div class="flex items-start gap-3">
- <div class="flex-shrink-0 p-1.5 bg-amber-100 dark:bg-amber-900 rounded-md">
- <ShieldAlertIcon class="w-4 h-4 text-amber-600 dark:text-amber-400" />
- </div>
- <div>
- <p class="text-sm font-semibold text-amber-900 dark:text-amber-100">
- Patrol paused
- </p>
- <p class="text-xs text-amber-700 dark:text-amber-300">{blockedReason()}</p>
- <Show when={blockedAt()}>
- <p class="text-[10px] text-amber-700 dark:text-amber-300">
- Blocked {formatRelativeTime(blockedAt(), { compact: true })}
- </p>
- </Show>
- </div>
- </div>
- <div class="flex items-center gap-2">
- <a
- href="/settings/system-ai"
- class="inline-flex items-center justify-center gap-2 px-3 py-1.5 text-xs font-semibold text-amber-900 dark:text-amber-100 bg-amber-100 dark:bg-amber-900 border border-amber-200 dark:border-amber-700 rounded-md hover:bg-amber-200 dark:hover:bg-amber-900 transition-colors"
- >
- <SettingsIcon class="w-3.5 h-3.5" />
- Open AI Settings
- </a>
- <Show when={licenseRequired()}>
- <a
- href={upgradeUrl()}
- target="_blank"
- rel="noopener noreferrer"
- class="inline-flex items-center justify-center gap-2 px-3 py-1.5 text-xs font-semibold text-white bg-amber-600 hover:bg-amber-700 rounded-md transition-colors"
- >
- <SparklesIcon class="w-3.5 h-3.5" />
- Upgrade
- </a>
- </Show>
- </div>
- </div>
- </div>
- </Show>
-
- {/* Content */}
<div
- class={`flex-1 overflow-auto p-4 transition-opacity ${!patrolEnabledLocal() ? 'opacity-50 pointer-events-none' : ''}`}
+ class={`flex-1 overflow-auto p-4 transition-opacity ${!state.patrolEnabledLocal() ? 'opacity-50 pointer-events-none' : ''}`}
>
<div class="space-y-4">
- {/* Approval Banner */}
- <ApprovalBanner
- onScrollToFinding={(findingId) => {
- setActiveTab('findings');
- setFindingsFilterOverride('approvals');
- clearScrollToFindingTimer();
- setScrollToFindingTimer(
- setTimeout(() => {
- setScrollToFindingTimer(undefined);
- const el = document.getElementById(`finding-${findingId}`);
- el?.scrollIntoView({ behavior: 'smooth', block: 'start' });
- setFindingScrollTimer(undefined);
- }, 100),
- );
- }}
- />
-
- {/* Status Bar (replaces Activity tab) */}
- <PatrolStatusBar
- enabled={patrolEnabledLocal()}
- refreshTrigger={activityRefreshTrigger()}
- />
-
- <Show when={intelligenceSummary()}>
- {(summary) => (
- <section class="rounded-md border border-border bg-surface p-4">
- <div class="flex flex-wrap items-start justify-between gap-4">
- <div>
- <p class="text-xs font-semibold uppercase tracking-[0.16em] text-muted">
- Patrol summary
- </p>
- <h2 class="mt-1 text-lg font-semibold text-base-content">
- Health {summary().overall_health.grade} ·{' '}
- {Math.round(summary().overall_health.score)}/100
- </h2>
- <p class="mt-1 text-sm text-muted">{summary().overall_health.prediction}</p>
- </div>
-
- <div class="flex flex-wrap items-center gap-2">
- <span class="rounded-full border border-border-subtle bg-base px-2.5 py-1 text-xs font-medium text-base-content">
- Critical {summary().findings_count.critical}
- </span>
- <span class="rounded-full border border-border-subtle bg-base px-2.5 py-1 text-xs font-medium text-base-content">
- Warning {summary().findings_count.warning}
- </span>
- </div>
- </div>
-
- <Show when={hasInvestigationContext()}>
- <div class="mt-4 rounded-md border border-border-subtle bg-base p-3">
- <div class="flex flex-wrap items-start justify-between gap-3">
- <div>
- <p class="text-xs font-semibold uppercase tracking-[0.16em] text-muted">
- Investigation context
- </p>
- <p class="mt-1 text-sm text-muted">
- Secondary change and policy signals for deeper investigation.
- </p>
- <Show when={investigationContextSummary()}>
- <p class="mt-1 text-xs text-base-content">
- {investigationContextSummary()}
- </p>
- </Show>
- </div>
-
- <button
- type="button"
- onClick={() => setShowInvestigationContext((value) => !value)}
- class="inline-flex items-center rounded-md border border-border bg-surface px-3 py-1.5 text-xs font-medium text-base-content transition-colors hover:bg-surface-hover"
- >
- {showInvestigationContext() ? 'Hide context' : 'Show context'}
- </button>
- </div>
-
- <Show when={showInvestigationContext()}>
- <div class="mt-4 grid gap-4 lg:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]">
- <Show when={recentChangeCount() > 0}>
- <ResourceChangeSummary
- class="space-y-0"
- title="Recent changes"
- subtitle="Last 24 hours"
- changes={summary().recent_changes}
- maxChanges={3}
- compact
- />
- </Show>
-
- <div class="space-y-4">
- <Show when={correlations().length > 0}>
- <ResourceCorrelationSummary
- title="Correlations"
- correlations={correlations()}
- summaryText={`${correlationTotal()} total`}
- />
- </Show>
-
- <ResourcePolicySummary
- posture={policyPosture()}
- title="Policy posture"
- />
- </div>
- </div>
- </Show>
- </div>
- </Show>
- </section>
- )}
- </Show>
-
- {/* Summary Cards */}
- <Show
- when={
- summaryStats().criticalFindings > 0 ||
- summaryStats().warningFindings > 0 ||
- summaryStats().fixedCount > 0
- }
- fallback={
- <Show when={patrolStatus()?.last_patrol_at}>
- <div class="flex items-center gap-2 px-4 py-3 bg-surface rounded-md border border-border">
- <CheckCircleIcon class="w-4 h-4 text-green-500 dark:text-green-400" />
- <span class="text-sm text-muted">{PATROL_NO_ISSUES_LABEL}</span>
- </div>
- </Show>
- }
- >
- <div class="grid grid-cols-1 sm:grid-cols-3 gap-3">
- {/* Critical */}
- <div class="bg-surface rounded-md border border-border p-3">
- <div class="flex items-center gap-2">
- <div
- class={`p-1.5 rounded-md border ${criticalSummaryPresentation().iconContainerClass}`}
- >
- <ShieldAlertIcon class={`w-4 h-4 ${criticalSummaryPresentation().iconClass}`} />
- </div>
- <div>
- <p class="text-xs text-muted">Critical</p>
- <p class={`text-lg font-bold ${criticalSummaryPresentation().valueClass}`}>
- {summaryStats().criticalFindings}
- </p>
- </div>
- </div>
- </div>
-
- {/* Warnings */}
- <div class="bg-surface rounded-md border border-border p-3">
- <div class="flex items-center gap-2">
- <div
- class={`p-1.5 rounded-md border ${warningSummaryPresentation().iconContainerClass}`}
- >
- <ActivityIcon class={`w-4 h-4 ${warningSummaryPresentation().iconClass}`} />
- </div>
- <div>
- <p class="text-xs text-muted">Warnings</p>
- <p class={`text-lg font-bold ${warningSummaryPresentation().valueClass}`}>
- {summaryStats().warningFindings}
- </p>
- </div>
- </div>
- </div>
-
- {/* Fixed (issues resolved by Patrol) */}
- <div class="bg-surface rounded-md border border-border p-3">
- <div class="flex items-center gap-2">
- <div
- class={`p-1.5 rounded-md border ${fixedSummaryPresentation().iconContainerClass}`}
- >
- <CheckCircleIcon class={`w-4 h-4 ${fixedSummaryPresentation().iconClass}`} />
- </div>
- <div>
- <p class="text-xs text-muted">Fixed</p>
- <p class={`text-lg font-bold ${fixedSummaryPresentation().valueClass}`}>
- {summaryStats().fixedCount}
- </p>
- </div>
- </div>
- </div>
- </div>
- </Show>
-
- {/* Tab Bar */}
- <div class="flex items-center gap-1 border-b border-border">
- <button
- type="button"
- onClick={() => setActiveTab('findings')}
- class={`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${
- activeTab() === 'findings'
- ? 'border-blue-500 text-base-content'
- : 'border-transparent text-muted hover:text-base-content hover:border-border'
- }`}
- >
- Findings
- <Show when={summaryStats().totalActive > 0}>
- <span
- class={`ml-1.5 px-1.5 py-0.5 text-xs rounded-full ${getFindingSeverityToneClasses(summaryStats().criticalFindings > 0 ? 'critical' : 'warning')}`}
- >
- {summaryStats().totalActive}
- </span>
- </Show>
- </button>
- <button
- type="button"
- onClick={() => {
- setActiveTab('history');
- setFindingsFilterOverride(undefined);
- }}
- class={`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${
- activeTab() === 'history'
- ? 'border-blue-500 text-base-content'
- : 'border-transparent text-muted hover:text-base-content hover:border-border'
- }`}
- >
- Runs
- <Show when={displayRunHistory().length > 0}>
- <span class="ml-1.5 px-1.5 py-0.5 text-xs rounded-full bg-surface-alt text-muted">
- {displayRunHistory().length}
- </span>
- </Show>
- </button>
- </div>
-
- {/* Tab Content */}
- <Show when={activeTab() === 'findings'}>
- <Show when={selectedRun()}>
- {(run) => (
- <div class="flex items-center justify-between px-3 py-2 rounded-md bg-blue-50 dark:bg-blue-900 border border-blue-200 dark:border-blue-800 text-xs text-blue-700 dark:text-blue-300">
- <span>
- Filtered to run {formatRelativeTime(run().started_at, { compact: true })} (
- {formatTriggerReason(run().trigger_reason)})
- </span>
- <button
- type="button"
- onClick={() => setSelectedRun(null)}
- class="font-medium hover:underline"
- >
- Clear filter
- </button>
- </div>
- )}
- </Show>
-
- <FindingsPanel
- nextPatrolAt={patrolStatus()?.next_patrol_at}
- lastPatrolAt={patrolStatus()?.last_patrol_at}
- patrolIntervalMs={patrolStatus()?.interval_ms}
- filterOverride={selectedRun() ? 'all' : findingsFilterOverride()}
- filterFindingIds={selectedRunFindingIds()}
- scopeResourceIds={selectedRunScopeResourceIds()}
- scopeResourceTypes={selectedRun()?.scope_resource_types}
- showScopeWarnings={Boolean(selectedRun())}
- />
- </Show>
-
- <Show when={activeTab() === 'history'}>
- <RunHistoryPanel
- runs={displayRunHistory()}
- loading={patrolRunHistory.loading}
- selectedRun={selectedRun()}
- onSelectRun={setSelectedRun}
- patrolStream={patrolStream}
- />
- </Show>
+ <PatrolIntelligenceSummary state={state} />
+ <PatrolIntelligenceWorkspace state={state} />
</div>
</div>
</div>
diff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx
new file mode 100644
index 0000000000..6a22f4e91a
--- /dev/null
+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx
@@ -0,0 +1,117 @@
+import { Show } from 'solid-js';
+import { FindingsPanel } from '@/components/AI/FindingsPanel';
+import { ApprovalBanner, PatrolStatusBar, RunHistoryPanel } from '@/components/patrol';
+import { getFindingSeverityToneClasses } from '@/utils/aiFindingPresentation';
+import { formatRelativeTime } from '@/utils/format';
+import { formatTriggerReason } from '@/utils/patrolFormat';
+import type { PatrolIntelligenceState } from './usePatrolIntelligenceState';
+
+export function PatrolIntelligenceWorkspace(props: { state: PatrolIntelligenceState }) {
+ const state = props.state;
+
+ return (
+ <>
+ <ApprovalBanner
+ onScrollToFinding={(findingId) => {
+ state.setActiveTab('findings');
+ state.setFindingsFilterOverride('approvals');
+ state.clearScrollToFindingTimer();
+ state.setScrollToFindingTimer(
+ setTimeout(() => {
+ state.setScrollToFindingTimer(undefined);
+ const el = document.getElementById(`finding-${findingId}`);
+ el?.scrollIntoView({ behavior: 'smooth', block: 'start' });
+ state.setFindingScrollTimer(undefined);
+ }, 100),
+ );
+ }}
+ />
+
+ <PatrolStatusBar
+ enabled={state.patrolEnabledLocal()}
+ refreshTrigger={state.activityRefreshTrigger()}
+ />
+
+ <div class="flex items-center gap-1 border-b border-border">
+ <button
+ type="button"
+ onClick={() => state.setActiveTab('findings')}
+ class={`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${
+ state.activeTab() === 'findings'
+ ? 'border-blue-500 text-base-content'
+ : 'border-transparent text-muted hover:text-base-content hover:border-border'
+ }`}
+ >
+ Findings
+ <Show when={state.summaryStats().totalActive > 0}>
+ <span
+ class={`ml-1.5 px-1.5 py-0.5 text-xs rounded-full ${getFindingSeverityToneClasses(state.summaryStats().criticalFindings > 0 ? 'critical' : 'warning')}`}
+ >
+ {state.summaryStats().totalActive}
+ </span>
+ </Show>
+ </button>
+ <button
+ type="button"
+ onClick={() => {
+ state.setActiveTab('history');
+ state.setFindingsFilterOverride(undefined);
+ }}
+ class={`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${
+ state.activeTab() === 'history'
+ ? 'border-blue-500 text-base-content'
+ : 'border-transparent text-muted hover:text-base-content hover:border-border'
+ }`}
+ >
+ Runs
+ <Show when={state.displayRunHistory().length > 0}>
+ <span class="ml-1.5 px-1.5 py-0.5 text-xs rounded-full bg-surface-alt text-muted">
+ {state.displayRunHistory().length}
+ </span>
+ </Show>
+ </button>
+ </div>
+
+ <Show when={state.activeTab() === 'findings'}>
+ <Show when={state.selectedRun()}>
+ {(run) => (
+ <div class="flex items-center justify-between px-3 py-2 rounded-md bg-blue-50 dark:bg-blue-900 border border-blue-200 dark:border-blue-800 text-xs text-blue-700 dark:text-blue-300">
+ <span>
+ Filtered to run {formatRelativeTime(run().started_at, { compact: true })} (
+ {formatTriggerReason(run().trigger_reason)})
+ </span>
+ <button
+ type="button"
+ onClick={() => state.setSelectedRun(null)}
+ class="font-medium hover:underline"
+ >
+ Clear filter
+ </button>
+ </div>
+ )}
+ </Show>
+
+ <FindingsPanel
+ nextPatrolAt={state.patrolStatus()?.next_patrol_at}
+ lastPatrolAt={state.patrolStatus()?.last_patrol_at}
+ patrolIntervalMs={state.patrolStatus()?.interval_ms}
+ filterOverride={state.selectedRun() ? 'all' : state.findingsFilterOverride()}
+ filterFindingIds={state.selectedRunFindingIds()}
+ scopeResourceIds={state.selectedRunScopeResourceIds()}
+ scopeResourceTypes={state.selectedRun()?.scope_resource_types}
+ showScopeWarnings={Boolean(state.selectedRun())}
+ />
+ </Show>
+
+ <Show when={state.activeTab() === 'history'}>
+ <RunHistoryPanel
+ runs={state.displayRunHistory()}
+ loading={state.patrolRunHistory.loading}
+ selectedRun={state.selectedRun()}
+ onSelectRun={state.setSelectedRun}
+ patrolStream={state.patrolStream}
+ />
+ </Show>
+ </>
+ );
+}
diff --git a/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts b/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts
index 1c583c5eec..6335eca215 100644
--- a/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts
+++ b/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts
@@ -745,3 +745,5 @@ export function usePatrolIntelligenceState() {
upgradeUrl,
};
}
+
+export type PatrolIntelligenceState = ReturnType<typeof usePatrolIntelligenceState>;
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index 8e4cb05df1..7793a1f160 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -478,8 +478,12 @@ import aiRuntimeControlsSectionSource from '@/components/Settings/AIRuntimeContr
import aiSettingsStatusAndActionsSource from '@/components/Settings/AISettingsStatusAndActions.tsx?raw';
import aiSettingsStateSource from '@/components/Settings/useAISettingsState.ts?raw';
import aiIntelligenceSource from '@/pages/AIIntelligence.tsx?raw';
+import patrolIntelligenceBannersSource from '@/features/patrol/PatrolIntelligenceBanners.tsx?raw';
+import patrolIntelligenceHeaderSource from '@/features/patrol/PatrolIntelligenceHeader.tsx?raw';
+import patrolIntelligenceSummarySource from '@/features/patrol/PatrolIntelligenceSummary.tsx?raw';
import patrolIntelligenceSurfaceSource from '@/features/patrol/PatrolIntelligenceSurface.tsx?raw';
import patrolIntelligenceStateSource from '@/features/patrol/usePatrolIntelligenceState.ts?raw';
+import patrolIntelligenceWorkspaceSource from '@/features/patrol/PatrolIntelligenceWorkspace.tsx?raw';
import aiQuickstartPresentationSource from '@/utils/aiQuickstartPresentation.ts?raw';
import aiCostPresentationSource from '@/utils/aiCostPresentation.ts?raw';
import thresholdSliderPresentationSource from '@/utils/thresholdSliderPresentation.ts?raw';
@@ -3645,6 +3649,10 @@ describe('frontend resource type boundaries', () => {
expect(aiIntelligenceSource).not.toContain('getPatrolSummaryPresentation');
expect(aiIntelligenceSource).not.toContain('getAIQuickstartCreditsPresentation');
expect(patrolIntelligenceSurfaceSource).toContain("./usePatrolIntelligenceState");
+ expect(patrolIntelligenceSurfaceSource).toContain('./PatrolIntelligenceHeader');
+ expect(patrolIntelligenceSurfaceSource).toContain('./PatrolIntelligenceBanners');
+ expect(patrolIntelligenceSurfaceSource).toContain('./PatrolIntelligenceSummary');
+ expect(patrolIntelligenceSurfaceSource).toContain('./PatrolIntelligenceWorkspace');
expect(operationsPageRouteSource).toContain(
"import { OperationsPageSurface } from '@/features/operations/OperationsPageSurface';",
);
@@ -3664,12 +3672,20 @@ describe('frontend resource type boundaries', () => {
expect(reportingPanelSource).toContain('OperationsPanel');
expect(systemLogsPanelSource).toContain('OperationsPanel');
expect(systemLogsPanelSource).toContain('./useSystemLogsPanelState');
- expect(patrolIntelligenceSurfaceSource).toContain('getPatrolSummaryPresentation');
- expect(patrolIntelligenceSurfaceSource).toContain('getAIQuickstartCreditsPresentation');
+ expect(patrolIntelligenceSurfaceSource).not.toContain('getPatrolSummaryPresentation');
+ expect(patrolIntelligenceSurfaceSource).not.toContain('getAIQuickstartCreditsPresentation');
expect(patrolIntelligenceStateSource).toContain('export function usePatrolIntelligenceState');
+ expect(patrolIntelligenceStateSource).toContain('export type PatrolIntelligenceState =');
expect(patrolIntelligenceStateSource).toContain('getPatrolStatus');
expect(patrolIntelligenceStateSource).toContain('usePatrolStream');
expect(patrolIntelligenceStateSource).toContain('trackPaywallViewed');
+ expect(patrolIntelligenceHeaderSource).toContain('buildPatrolScheduleOptions');
+ expect(patrolIntelligenceHeaderSource).toContain('getAIQuickstartCreditsPresentation');
+ expect(patrolIntelligenceSummarySource).toContain('getPatrolSummaryPresentation');
+ expect(patrolIntelligenceSummarySource).toContain('PATROL_NO_ISSUES_LABEL');
+ expect(patrolIntelligenceWorkspaceSource).toContain('ApprovalBanner');
+ expect(patrolIntelligenceWorkspaceSource).toContain('FindingsPanel');
+ expect(patrolIntelligenceBannersSource).toContain('trackUpgradeClicked');
expect(patrolIntelligenceSurfaceSource).not.toContain(
"summaryStats().criticalFindings > 0\n ? 'bg-red-50 dark:bg-red-900 border-red-200 dark:border-red-800'",
);