Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Make Patrol activity strip factual

rcourtman173317230b14
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index 5068a230f7..584393b8e5 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -134,6 +134,17 @@ operator whether Patrol recently completed a successful full patrol, only ran
scoped alert-triggered checks, or ended its most recent full patrol with
errors, so the page does not leave trust and coverage as implicit background
knowledge.
+The Patrol status bar should stay factual and operational within that same
+hierarchy. `frontend-modern/src/components/patrol/PatrolStatusBar.tsx` is a
+recent-activity strip, not a second health verdict: when Patrol is active it
+should report recent run activity, run kind, latest run result, and run-count
+context instead of emitting another green/amber all-clear headline that can
+drift from the governed assessment summary above it.
+That latest run result must come from the effective run outcome, not the raw
+status field alone: shared Patrol run presentation helpers must treat any run
+with execution errors as an error result even when the stored status text is
+still `healthy`, so run history and header activity surfaces do not present a
+false green outcome for an incomplete Patrol execution.
hook-local fallback logic.
The Patrol header now also has explicit helper ownership for its quickstart and
schedule presentation. `frontend-modern/src/utils/aiQuickstartPresentation.ts`
diff --git a/frontend-modern/src/components/patrol/PatrolStatusBar.tsx b/frontend-modern/src/components/patrol/PatrolStatusBar.tsx
index 875fb105a3..f8e45ce61c 100644
--- a/frontend-modern/src/components/patrol/PatrolStatusBar.tsx
+++ b/frontend-modern/src/components/patrol/PatrolStatusBar.tsx
@@ -10,8 +10,12 @@ import { getPatrolRunHistory, type PatrolRunRecord, type PatrolRuntimeState } fr
import { aiIntelligenceStore } from '@/stores/aiIntelligence';
import { formatRelativeTime } from '@/utils/format';
import { formatTriggerReason } from '@/utils/patrolFormat';
-import { isPatrolRunHealthy } from '@/utils/patrolRunPresentation';
+import {
+ getPatrolRunKindLabel,
+ getPatrolRunStatusPresentation,
+} from '@/utils/patrolRunPresentation';
import { getPatrolRuntimePresentation } from '@/utils/patrolRuntimePresentation';
+import ActivityIcon from 'lucide-solid/icons/activity';
import CheckCircleIcon from 'lucide-solid/icons/check-circle';
import AlertCircleIcon from 'lucide-solid/icons/alert-circle';
import AlertTriangleIcon from 'lucide-solid/icons/alert-triangle';
@@ -45,12 +49,18 @@ export const PatrolStatusBar: Component<PatrolStatusBarProps> = (props) => {
const lastRun = allRuns[0];
const lastRunTime = lastRun ? new Date(lastRun.started_at) : null;
+ const lastRunStatus = getPatrolRunStatusPresentation(
+ lastRun?.status ?? 'unknown',
+ lastRun?.error_count ?? 0,
+ );
return {
+ lastRun,
runsToday: todayRuns.length,
newFindingsToday: todayRuns.reduce((sum, r) => sum + (r.new_findings || 0), 0),
lastRunTime: lastRunTime ? formatRelativeTime(lastRunTime, { compact: true }) : null,
lastRunTrigger: formatTriggerReason(lastRun?.trigger_reason),
- isHealthy: isPatrolRunHealthy(lastRun?.status, lastRun?.error_count ?? 0),
+ lastRunTypeLabel: getPatrolRunKindLabel(lastRun?.type),
+ lastRunStatus,
};
});
@@ -96,22 +106,12 @@ export const PatrolStatusBar: Component<PatrolStatusBarProps> = (props) => {
<Show
when={showRuntimeState()}
fallback={
- <Show
- when={s().isHealthy}
- fallback={
- <>
- <AlertCircleIcon class="w-3.5 h-3.5 text-amber-500" />
- <span class="text-amber-600 dark:text-amber-400 font-medium text-xs">
- Issues detected
- </span>
- </>
- }
- >
- <CheckCircleIcon class="w-3.5 h-3.5 text-green-500" />
- <span class="text-green-600 dark:text-green-400 font-medium text-xs">
- Running normally
+ <>
+ <ActivityIcon class="w-3.5 h-3.5 text-blue-500" />
+ <span class="text-blue-600 dark:text-blue-400 font-medium text-xs">
+ Recent activity
</span>
- </Show>
+ </>
}
>
<Show
@@ -155,6 +155,17 @@ export const PatrolStatusBar: Component<PatrolStatusBarProps> = (props) => {
<span class="hidden sm:inline text-slate-300 ">|</span>
+ <Show when={s().lastRun}>
+ <span class="text-xs text-muted">
+ Latest: {s().lastRunTypeLabel}
+ <span class={`ml-1.5 px-1.5 py-0.5 rounded ${s().lastRunStatus.badgeClass}`}>
+ {s().lastRunStatus.label}
+ </span>
+ </span>
+ </Show>
+
+ <span class="hidden sm:inline text-slate-300 ">|</span>
+
{/* Today */}
<span class="text-xs text-muted">
Today: {s().runsToday} run{s().runsToday === 1 ? '' : 's'}
diff --git a/frontend-modern/src/components/patrol/RunHistoryEntry.tsx b/frontend-modern/src/components/patrol/RunHistoryEntry.tsx
index 98a13356a8..c19dd1623a 100644
--- a/frontend-modern/src/components/patrol/RunHistoryEntry.tsx
+++ b/frontend-modern/src/components/patrol/RunHistoryEntry.tsx
@@ -143,7 +143,7 @@ export function RunHistoryEntry(props: RunHistoryEntryProps) {
const run = props.run;
const scopeSummary = formatScope(run);
const duration = formatDurationMs(run.duration_ms);
- const runStatus = getPatrolRunStatusPresentation(run.status);
+ const runStatus = getPatrolRunStatusPresentation(run.status, run.error_count);
const canonicalScopeResourceIds = getCanonicalScopeResourceIds(run);
const runIsHealthy = isPatrolRunHealthy(run.status, run.error_count);
diff --git a/frontend-modern/src/components/patrol/__tests__/PatrolStatusBar.test.tsx b/frontend-modern/src/components/patrol/__tests__/PatrolStatusBar.test.tsx
index 2d1c3d014a..bc33a83c1b 100644
--- a/frontend-modern/src/components/patrol/__tests__/PatrolStatusBar.test.tsx
+++ b/frontend-modern/src/components/patrol/__tests__/PatrolStatusBar.test.tsx
@@ -1,4 +1,4 @@
-import { cleanup, render, screen, waitFor } from '@solidjs/testing-library';
+import { cleanup, render, screen, waitFor, within } from '@solidjs/testing-library';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import type { PatrolRunRecord } from '@/api/patrol';
import { PatrolStatusBar } from '../PatrolStatusBar';
@@ -24,7 +24,7 @@ describe('PatrolStatusBar', () => {
cleanup();
});
- it('shows healthy status only for healthy patrol runs', async () => {
+ it('shows recent activity instead of a healthy verdict for healthy patrol runs', async () => {
getPatrolRunHistoryMock.mockResolvedValue([
{
id: 'run-healthy',
@@ -58,8 +58,11 @@ describe('PatrolStatusBar', () => {
render(() => <PatrolStatusBar refreshTrigger={1} />);
await waitFor(() => {
- expect(screen.getByText('Running normally')).toBeInTheDocument();
+ expect(screen.getByText('Recent activity')).toBeInTheDocument();
});
+
+ expect(screen.getByText('Latest: Full patrol')).toBeInTheDocument();
+ expect(screen.getByText('healthy')).toBeInTheDocument();
});
it('shows patrol paused when the runtime is blocked even if the last run was healthy', async () => {
@@ -105,10 +108,10 @@ describe('PatrolStatusBar', () => {
expect(screen.getByText('Patrol Paused')).toBeInTheDocument();
});
- expect(screen.queryByText('Running normally')).not.toBeInTheDocument();
+ expect(screen.queryByText('Recent activity')).not.toBeInTheDocument();
});
- it('shows issues detected when the last patrol run found issues without transport errors', async () => {
+ it('shows the latest full-patrol result when the last patrol run found issues', async () => {
getPatrolRunHistoryMock.mockResolvedValue([
{
id: 'run-critical',
@@ -142,20 +145,22 @@ describe('PatrolStatusBar', () => {
render(() => <PatrolStatusBar refreshTrigger={1} />);
await waitFor(() => {
- expect(screen.getByText('Issues detected')).toBeInTheDocument();
+ expect(screen.getByText('Recent activity')).toBeInTheDocument();
});
- expect(screen.queryByText('Running normally')).not.toBeInTheDocument();
+ expect(screen.getByText('Latest: Full patrol')).toBeInTheDocument();
+ expect(screen.getByText('critical')).toBeInTheDocument();
});
- it('does not show healthy status when the run finished with errors', async () => {
+ it('shows scoped/erroring activity factually instead of a healthy summary', async () => {
getPatrolRunHistoryMock.mockResolvedValue([
{
id: 'run-error-count',
started_at: '2026-03-12T10:00:00Z',
completed_at: '2026-03-12T10:01:00Z',
duration_ms: 60000,
- type: 'patrol',
+ type: 'scoped',
+ trigger_reason: 'alert_fired',
resources_checked: 1,
nodes_checked: 0,
guests_checked: 0,
@@ -182,9 +187,12 @@ describe('PatrolStatusBar', () => {
render(() => <PatrolStatusBar refreshTrigger={1} />);
await waitFor(() => {
- expect(screen.getByText('Issues detected')).toBeInTheDocument();
+ expect(screen.getByText('Recent activity')).toBeInTheDocument();
});
- expect(screen.queryByText('Running normally')).not.toBeInTheDocument();
+ const latestRunSection = screen.getByText('Latest: Scoped run').closest('span');
+ expect(latestRunSection).not.toBeNull();
+ expect(within(latestRunSection as HTMLElement).queryByText('healthy')).not.toBeInTheDocument();
+ expect(within(latestRunSection as HTMLElement).getByText('error')).toBeInTheDocument();
});
});
diff --git a/frontend-modern/src/utils/__tests__/patrolRunPresentation.test.ts b/frontend-modern/src/utils/__tests__/patrolRunPresentation.test.ts
index 256b0cb621..68910d54ce 100644
--- a/frontend-modern/src/utils/__tests__/patrolRunPresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/patrolRunPresentation.test.ts
@@ -1,5 +1,6 @@
import { describe, expect, it } from 'vitest';
import {
+ getPatrolRunKindLabel,
getPatrolRunStatusPresentation,
isPatrolRunHealthy,
getRunHistoryLoadingState,
@@ -25,6 +26,12 @@ describe('patrolRunPresentation', () => {
expect(getPatrolRunStatusPresentation('healthy').badgeClass).toContain('green-100');
});
+ it('treats erroring runs as error presentation even when the raw status says healthy', () => {
+ const presentation = getPatrolRunStatusPresentation('healthy', 2);
+ expect(presentation.label).toBe('error');
+ expect(presentation.badgeClass).toContain('red-100');
+ });
+
it('treats only healthy runs without errors as healthy', () => {
expect(isPatrolRunHealthy('healthy', 0)).toBe(true);
expect(isPatrolRunHealthy('critical', 0)).toBe(false);
@@ -45,6 +52,12 @@ describe('patrolRunPresentation', () => {
expect(getToolCallResultTextClass(false)).toContain('text-red-600');
});
+ it('returns canonical patrol run kind labels', () => {
+ expect(getPatrolRunKindLabel('scoped')).toBe('Scoped run');
+ expect(getPatrolRunKindLabel('patrol')).toBe('Full patrol');
+ expect(getPatrolRunKindLabel('')).toBe('Full patrol');
+ });
+
it('returns canonical patrol run loading and unavailable copy', () => {
expect(getRunHistoryLoadingState()).toBe('Loading run history…');
expect(getToolCallsLoadingState()).toBe('Loading tool calls...');
diff --git a/frontend-modern/src/utils/patrolRunPresentation.ts b/frontend-modern/src/utils/patrolRunPresentation.ts
index e764dd87e2..fffbf8482c 100644
--- a/frontend-modern/src/utils/patrolRunPresentation.ts
+++ b/frontend-modern/src/utils/patrolRunPresentation.ts
@@ -6,6 +6,13 @@ export interface PatrolRunStatusPresentation {
label: string;
}
+function normalizePatrolRunType(type: string | undefined): string {
+ return String(type || '')
+ .trim()
+ .toLowerCase()
+ .replace(/\s+/g, '_');
+}
+
function normalizePatrolRunStatus(status: PatrolRunStatus | string | undefined): string {
return String(status || '')
.trim()
@@ -13,17 +20,29 @@ function normalizePatrolRunStatus(status: PatrolRunStatus | string | undefined):
.replace(/\s+/g, '_');
}
+function getEffectivePatrolRunStatus(
+ status: PatrolRunStatus | string | undefined,
+ errorCount: number = 0,
+): string {
+ const normalized = normalizePatrolRunStatus(status);
+ if (errorCount > 0) {
+ return 'error';
+ }
+ return normalized;
+}
+
export function isPatrolRunHealthy(
status: PatrolRunStatus | string | undefined,
errorCount: number = 0,
): boolean {
- return errorCount === 0 && normalizePatrolRunStatus(status) === 'healthy';
+ return getEffectivePatrolRunStatus(status, errorCount) === 'healthy';
}
export function getPatrolRunStatusPresentation(
status: PatrolRunStatus | string,
+ errorCount: number = 0,
): PatrolRunStatusPresentation {
- const normalized = normalizePatrolRunStatus(status);
+ const normalized = getEffectivePatrolRunStatus(status, errorCount);
switch (normalized) {
case 'critical':
@@ -60,6 +79,10 @@ export function getToolCallResultTextClass(success: boolean): string {
return success ? 'text-emerald-600 dark:text-emerald-400' : 'text-red-600 dark:text-red-400';
}
+export function getPatrolRunKindLabel(type: string | undefined): string {
+ return normalizePatrolRunType(type) === 'scoped' ? 'Scoped run' : 'Full patrol';
+}
+
export function getRunHistoryLoadingState(): string {
return 'Loading run history…';
}