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.

Expose manual Mark resolved on findings, wired to existing patrol/resolve

rcourtmanc3e74668fc15
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 57788c313d..3e76760128 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -1554,3 +1554,10 @@ already cleared the dismissal in the canonical store), and the TS API
clients in `frontend-modern/src/api/patrol.ts` and
`frontend-modern/src/api/ai.ts` must round-trip the `remind_at` field
verbatim so the operator surface can preview and badge the deadline.
+The same Patrol API client also exposes the operator-driven manual
+resolve path. `resolveFinding(findingId)` in
+`frontend-modern/src/api/patrol.ts` must POST `{finding_id}` to the
+canonical `/api/ai/patrol/resolve` endpoint owned by
+`HandleResolveFinding` in `internal/api/ai_handlers.go`, mirroring the
+acknowledge / snooze / dismiss client surface so the same Patrol service
+contract drives every operator-feedback action.
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index ab130d891f..d7c2417026 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -1028,7 +1028,16 @@ the canonical monitored-system blocked payload.
Findings panel must visibly preview the deadline at dismiss-confirm
time and badge dismissed-as-will_fix_later rows with the pending
remind-at, otherwise the new behavior is invisible until the
- reminder fires
+ reminder fires.
+ The Patrol operator-feedback endpoint surface also includes
+ `POST /api/ai/patrol/resolve` (handled by `HandleResolveFinding` in
+ `internal/api/ai_handlers.go`) for operator-driven manual resolution
+ when the operator has fixed an issue out-of-band. The TS client
+ `resolveFinding(findingId)` in `frontend-modern/src/api/patrol.ts`
+ must post `{finding_id}` to that endpoint and surface the boolean
+ result through `aiIntelligenceStore.resolveFinding` so the operator
+ surface gets uniform refresh and error UX with acknowledge / snooze
+ / dismiss
and the Assistant finding-context request contract, so `/api/ai/chat`
payloads carrying `finding_id` may hydrate a structured investigation
summary from the unified finding, but raw proposed-fix commands must stay
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index fd6318983f..3ef623c7cc 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -1115,3 +1115,12 @@ pill next to the investigation-confidence badge whenever
absent on fresh detections (count == 0) so the row stays clean for
ordinary findings, and the styling (amber tone) reads as a recurrence
signal rather than a generic muted note.
+The Patrol surface must also expose a manual "Mark resolved" action on
+active findings, calling the canonical `/api/ai/patrol/resolve` endpoint
+through `aiIntelligenceStore.resolveFinding`. This closes the loop when
+the operator has fixed the underlying issue out-of-band and shouldn't
+have to wait for Pulse's auto-detection to clear it. The action is gated
+to `status === 'active'` (the server rejects double-resolves) and is
+visually distinct (emerald accent) from the destructive dismiss
+controls; it must route through the shared store action so the refresh
+and error UX stays uniform with acknowledge, snooze, and dismiss.
diff --git a/frontend-modern/src/api/__tests__/patrol.test.ts b/frontend-modern/src/api/__tests__/patrol.test.ts
index 4120e2ff35..9f17d790ba 100644
--- a/frontend-modern/src/api/__tests__/patrol.test.ts
+++ b/frontend-modern/src/api/__tests__/patrol.test.ts
@@ -11,6 +11,7 @@ import {
getPatrolRunHistory,
getPatrolRunHistoryWithToolCalls,
getPatrolRunWithToolCalls,
+ resolveFinding,
type Finding as PatrolFinding,
} from '@/api/patrol';
import { apiFetchJSON } from '@/utils/apiClient';
@@ -312,6 +313,21 @@ describe('patrol api', () => {
});
});
+ it('posts the canonical manual-resolve payload for /api/ai/patrol/resolve', async () => {
+ // /api/ai/patrol/resolve was already wired server-side but had no TS
+ // client. Pin the canonical request shape so future refactors can't
+ // silently drift the body or method — the server returns 405 for GET
+ // and 400 for missing finding_id, so the contract is strict.
+ apiFetchJSONMock.mockResolvedValueOnce({ success: true, message: 'ok' } as any);
+
+ await resolveFinding('finding-resolve-123');
+
+ expect(apiFetchJSONMock).toHaveBeenCalledWith('/api/ai/patrol/resolve', {
+ method: 'POST',
+ body: JSON.stringify({ finding_id: 'finding-resolve-123' }),
+ });
+ });
+
it('round-trips remind_at on dismissed-as-will_fix_later patrol findings', async () => {
// The backend treats will_fix_later as an operator commitment with a
// wake-up deadline (Finding.RemindAt, default 7 days). The TS API client
diff --git a/frontend-modern/src/api/patrol.ts b/frontend-modern/src/api/patrol.ts
index e06e8dfae5..d4d23457d8 100644
--- a/frontend-modern/src/api/patrol.ts
+++ b/frontend-modern/src/api/patrol.ts
@@ -256,6 +256,25 @@ export async function acknowledgeFinding(
});
}
+/**
+ * Manually mark a finding as resolved.
+ *
+ * Use this when the operator has fixed the issue out-of-band and wants Pulse
+ * to close the loop without waiting for auto-resolution. The server records
+ * `auto=false` so analytics can distinguish operator-driven resolution from
+ * Pulse's own auto-resolution; subsequent re-detection of the same finding
+ * still flows through the regression path and captures
+ * `previous_resolved_fix_summary` in operational memory.
+ */
+export async function resolveFinding(
+ findingId: string,
+): Promise<{ success: boolean; message: string }> {
+ return apiFetchJSON('/api/ai/patrol/resolve', {
+ method: 'POST',
+ body: JSON.stringify({ finding_id: findingId }),
+ });
+}
+
/**
* Snooze a finding for a specified duration
* @param findingId The ID of the finding to snooze
diff --git a/frontend-modern/src/components/AI/FindingsPanel.tsx b/frontend-modern/src/components/AI/FindingsPanel.tsx
index b3d12d46ea..6503cdd2e2 100644
--- a/frontend-modern/src/components/AI/FindingsPanel.tsx
+++ b/frontend-modern/src/components/AI/FindingsPanel.tsx
@@ -384,6 +384,23 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
}
};
+ // Operator-driven manual resolve. Use case: the operator fixed the
+ // underlying issue out-of-band and wants to close the loop without
+ // waiting for Pulse's auto-detection to clear it. The server records
+ // auto=false so analytics can distinguish operator vs Pulse resolution;
+ // re-detection still flows through the regression path.
+ const handleResolve = async (finding: UnifiedFinding, e: Event) => {
+ e.stopPropagation();
+ setActionLoading(finding.id);
+ const ok = await aiIntelligenceStore.resolveFinding(finding.id);
+ setActionLoading(null);
+ if (ok) {
+ notificationStore.success('Finding marked resolved');
+ } else {
+ notificationStore.error('Failed to mark finding resolved');
+ }
+ };
+
const handleStartDismiss = (
finding: UnifiedFinding,
reason: 'not_an_issue' | 'expected_behavior' | 'will_fix_later',
@@ -1120,6 +1137,17 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
Acknowledge
</button>
</Show>
+ <Show when={manualControls.acknowledge && finding.status === 'active'}>
+ <button
+ type="button"
+ onClick={(e) => handleResolve(finding, e)}
+ class="px-2 py-1 rounded border border-emerald-200 text-emerald-700 hover:bg-emerald-50 dark:border-emerald-800 dark:text-emerald-300 dark:hover:bg-emerald-900"
+ title="Mark this finding as resolved. Use when you have fixed the issue out-of-band."
+ disabled={actionLoading() === finding.id}
+ >
+ Mark resolved
+ </button>
+ </Show>
<Show when={manualControls.snooze}>
<>
<button
diff --git a/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts b/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
index a4d6ea4e17..ec16ebebed 100644
--- a/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
+++ b/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
@@ -124,6 +124,21 @@ describe('FindingsPanel assistant handoff', () => {
expect(findingsPanelSource).toContain('Pulse will permanently suppress');
});
+ it('exposes a manual Mark resolved action that goes through the patrol resolve store action', () => {
+ // The /api/ai/patrol/resolve endpoint exists server-side but had no
+ // operator path on the canonical Patrol surface. An operator fixing
+ // an issue out-of-band must be able to close the loop without waiting
+ // for auto-resolution. The button is gated to active findings (the
+ // server rejects double-resolves with 404) and routes through
+ // aiIntelligenceStore.resolveFinding so refresh/error UX stays
+ // uniform with the existing acknowledge/snooze/dismiss patterns.
+ expect(findingsPanelSource).toContain('handleResolve');
+ expect(findingsPanelSource).toContain('aiIntelligenceStore.resolveFinding(finding.id)');
+ expect(findingsPanelSource).toContain('Mark resolved');
+ expect(findingsPanelSource).toContain("manualControls.acknowledge && finding.status === 'active'");
+ expect(findingsPanelSource).toContain('Finding marked resolved');
+ });
+
it('surfaces regressionCount as a pill on the collapsed finding row', () => {
// regressionCount is the strongest "this is not a one-off" signal Pulse
// can give an operator scanning a list. The pill must appear in the
diff --git a/frontend-modern/src/stores/__tests__/aiIntelligence.test.ts b/frontend-modern/src/stores/__tests__/aiIntelligence.test.ts
index 841959d7a7..88585e89d4 100644
--- a/frontend-modern/src/stores/__tests__/aiIntelligence.test.ts
+++ b/frontend-modern/src/stores/__tests__/aiIntelligence.test.ts
@@ -15,6 +15,7 @@ vi.mock('@/api/patrol', () => ({
acknowledgeFinding: vi.fn(),
snoozeFinding: vi.fn(),
dismissFinding: vi.fn(),
+ resolveFinding: vi.fn(),
setFindingNote: vi.fn(),
}));
@@ -32,7 +33,7 @@ vi.mock('@/stores/sessionPresentationPolicy', () => ({
}));
import { AIAPI } from '@/api/ai';
-import { getPatrolFindings } from '@/api/patrol';
+import { getPatrolFindings, resolveFinding } from '@/api/patrol';
import { aiIntelligenceStore } from '@/stores/aiIntelligence';
import { presentationPolicyIsDemoMode } from '@/stores/sessionPresentationPolicy';
@@ -142,6 +143,26 @@ describe('aiIntelligenceStore', () => {
});
});
+ it('routes Mark resolved through the canonical patrol resolve client and refreshes both finding sources', async () => {
+ // The Patrol surface's manual Mark resolved button must go through
+ // aiIntelligenceStore.resolveFinding so the refresh and error UX stays
+ // uniform with the existing acknowledge/snooze/dismiss store actions.
+ // After a successful resolve the store must reload BOTH the unified
+ // findings (for the unified workspace) and the patrol-direct findings
+ // (for the Patrol page) — otherwise the operator sees a stale row on
+ // whichever surface it didn't refresh.
+ vi.mocked(resolveFinding).mockResolvedValueOnce({ success: true, message: 'ok' } as never);
+ vi.mocked(AIAPI.getUnifiedFindings).mockResolvedValueOnce({ findings: [] } as never);
+ vi.mocked(getPatrolFindings).mockResolvedValueOnce([]);
+
+ const ok = await aiIntelligenceStore.resolveFinding('finding-resolve');
+
+ expect(ok).toBe(true);
+ expect(resolveFinding).toHaveBeenCalledWith('finding-resolve');
+ expect(AIAPI.getUnifiedFindings).toHaveBeenCalledTimes(1);
+ expect(getPatrolFindings).toHaveBeenCalledTimes(1);
+ });
+
it('promotes remind_at on dismissed-as-will_fix_later patrol findings to camelCase remindAt', async () => {
// The store-level UnifiedFinding is what render code consumes; if the
// normalizer drops remind_at, the dismiss confirmation panel and the
diff --git a/frontend-modern/src/stores/aiIntelligence.ts b/frontend-modern/src/stores/aiIntelligence.ts
index 21dc08a7ae..6742ca516a 100644
--- a/frontend-modern/src/stores/aiIntelligence.ts
+++ b/frontend-modern/src/stores/aiIntelligence.ts
@@ -12,6 +12,7 @@ import { createSignal } from 'solid-js';
import { AIAPI } from '@/api/ai';
import {
acknowledgeFinding,
+ resolveFinding,
snoozeFinding,
dismissFinding,
setFindingNote,
@@ -525,6 +526,21 @@ export const aiIntelligenceStore = {
}
},
+ // Manually mark a finding as resolved when the operator has fixed it
+ // out-of-band. Mirrors the existing acknowledge/snooze/dismiss store
+ // pattern: call the server, refresh both finding sources, swallow errors
+ // into a boolean for the caller's UX feedback.
+ async resolveFinding(findingId: string) {
+ try {
+ await resolveFinding(findingId);
+ await Promise.all([this.loadFindings(), this.loadPatrolFindings()]);
+ return true;
+ } catch (e) {
+ logger.error('Failed to resolve finding:', e);
+ return false;
+ }
+ },
+
async snoozeFinding(findingId: string, durationHours: number) {
try {
await snoozeFinding(findingId, durationHours);