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.

findings: add mode-gated Investigate action to the Patrol finding row

rcourtmane4c79260944b
diff --git a/frontend-modern/src/components/AI/FindingsPanel.tsx b/frontend-modern/src/components/AI/FindingsPanel.tsx
index e7d176756b..badf0d683e 100644
--- a/frontend-modern/src/components/AI/FindingsPanel.tsx
+++ b/frontend-modern/src/components/AI/FindingsPanel.tsx
@@ -33,7 +33,7 @@ import {
} from '@/features/patrol/patrolInvestigationContextModel';
import { InvestigationSection, ApprovalSection } from '@/components/patrol';
import { AIAPI, type RemediationPlan } from '@/api/ai';
-import { createSuppressionRuleFromFinding } from '@/api/patrol';
+import { createSuppressionRuleFromFinding, reinvestigateFinding } from '@/api/patrol';
import type { PatrolRunRecord, PatrolRuntimeState } from '@/api/patrol';
import { formatRelativeTime } from '@/utils/format';
import { getFindingAlertIdentifier, hasTriggeringAlert } from '@/utils/findingAlertIdentity';
@@ -609,6 +609,34 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
}
};
+ // Start (or re-start) Patrol's investigation of a finding. This is the
+ // forward path for an un-investigated finding on the Patrol surface, where
+ // the Assistant primary action is intentionally suppressed: it moves the
+ // row from a triage dead-end into the detect → investigate → propose →
+ // approve → verify loop, reusing the existing reinvestigate endpoint.
+ const handleInvestigate = async (finding: UnifiedFinding, e: Event) => {
+ e.stopPropagation();
+ setActionLoading(finding.id);
+ try {
+ const result = await reinvestigateFinding(finding.id);
+ setActionLoading(null);
+ if (result.success) {
+ notificationStore.success('Patrol is investigating this finding');
+ void Promise.all([
+ aiIntelligenceStore.loadFindings(),
+ aiIntelligenceStore.loadPatrolFindings(),
+ ]);
+ } else {
+ notificationStore.warning(result.message || 'Failed to start investigation');
+ }
+ } catch (err) {
+ setActionLoading(null);
+ notificationStore.error(
+ err instanceof Error ? err.message : 'Failed to start investigation',
+ );
+ }
+ };
+
const handleStartEditNote = (finding: UnifiedFinding, e: Event) => {
e.stopPropagation();
setEditingNoteId(finding.id);
@@ -1425,6 +1453,28 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
{getPrimaryAssistantFindingAction(finding).label}
</button>
</Show>
+ <Show
+ when={
+ !primaryAction &&
+ !shouldShowAssistantPrimaryAction &&
+ finding.status === 'active' &&
+ !finding.investigationStatus &&
+ !finding.investigationOutcome &&
+ !finding.lastInvestigatedAt &&
+ !!props.runtimeState?.autonomy_level &&
+ props.runtimeState.autonomy_level !== 'monitor'
+ }
+ >
+ <button
+ type="button"
+ onClick={(e) => handleInvestigate(finding, e)}
+ disabled={actionLoading() === finding.id}
+ class="inline-flex items-center gap-1 rounded bg-blue-600 px-3 py-1.5 font-semibold text-white transition-colors hover:bg-blue-700 disabled:opacity-50"
+ title="Have Patrol investigate this finding"
+ >
+ {actionLoading() === finding.id ? 'Investigating…' : 'Investigate'}
+ </button>
+ </Show>
<Show when={proHandoff}>
<div class="flex flex-wrap items-center gap-2">
<span class="text-muted">{proHandoff!.detail}</span>
diff --git a/frontend-modern/src/components/AI/__tests__/FindingsPanel.links.test.tsx b/frontend-modern/src/components/AI/__tests__/FindingsPanel.links.test.tsx
index 3329ea44bf..f903f1ac43 100644
--- a/frontend-modern/src/components/AI/__tests__/FindingsPanel.links.test.tsx
+++ b/frontend-modern/src/components/AI/__tests__/FindingsPanel.links.test.tsx
@@ -596,3 +596,55 @@ describe('FindingsPanel resource links', () => {
).toBeInTheDocument();
});
});
+
+describe('FindingsPanel investigate action gating', () => {
+ beforeEach(() => {
+ mockState.patrolFindings = [
+ {
+ id: 'finding-provider-issue',
+ source: 'ai-patrol',
+ resourceId: 'instance:node:100',
+ resourceName: 'vm-100',
+ resourceType: 'vm',
+ alertIdentifier: 'instance:node:100::patrol/provider',
+ category: 'reliability',
+ severity: 'warning',
+ title: 'Provider connection issue',
+ description: 'Pulse Patrol could not complete provider analysis.',
+ impact: 'Patrol cannot analyze infrastructure until provider setup is fixed.',
+ detectedAt: '2026-03-30T11:00:00Z',
+ lastSeenAt: '2026-03-30T11:05:00Z',
+ status: 'active',
+ },
+ ];
+ });
+
+ const expandRow = () =>
+ fireEvent.click(
+ screen.getByRole('button', { name: 'View details for Provider connection issue' }),
+ );
+
+ it('shows an Investigate action above Watch-only mode on an un-investigated patrol finding', async () => {
+ render(() => (
+ <FindingsPanel
+ findingsSource="patrol"
+ runtimeState={{ autonomy_level: 'approval' } as any}
+ />
+ ));
+ await waitFor(() => expect(mockState.loadPatrolFindings).toHaveBeenCalled());
+ expandRow();
+ expect(screen.getByRole('button', { name: /Investigate/ })).toBeInTheDocument();
+ });
+
+ it('hides the Investigate action in Watch-only (monitor) mode', async () => {
+ render(() => (
+ <FindingsPanel
+ findingsSource="patrol"
+ runtimeState={{ autonomy_level: 'monitor' } as any}
+ />
+ ));
+ await waitFor(() => expect(mockState.loadPatrolFindings).toHaveBeenCalled());
+ expandRow();
+ expect(screen.queryByRole('button', { name: /^Investigate$/ })).toBeNull();
+ });
+});