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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Add status filters and copyable diagnostic reports to Agent Doctor
rcourtmanc87ad1cf26d4
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex d71c476d9a..9276fd0776 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -1991,11 +1991,18 @@ appended as diagnostics-only targets, honoring the scoped-agent filter, so acritical workload-only agent can no longer vanish from the fleet view.Diagnostics-only rows render the diagnostic's status, reasons, and evidencebut offer no host-local command (there is no ledger connection to derive one-from). Dialog presentation follows the same honesty rule: the-"Supported target" cell renders only when a target version is actually-published, the host-local command explainer renders only when at least one-row offers a command, and the summary strip lists only non-zero status-counts.+from). Page presentation follows the same honesty rule: the+"Target" column renders a version only when one is actually published, the+host-local command explainer renders only when at least one row offers a+command, and the summary chips list only non-zero status counts. The summary+chips double as status filters over the fleet table, and a filter whose+status empties out clears itself rather than dead-ending the table. The page+also offers plain-text diagnostic reports (fleet-level over the currently+visible rows and per-agent from a row expansion) via+`formatInfrastructureAgentDoctorReport`; reports carry status, versions,+last-seen, reasons, identity evidence, and non-command repair actions, and+must never embed host-local update commands because those can carry install+tokens.### Governed action readiness remains outside agent lifecycle authoritydiff --git a/frontend-modern/src/components/Settings/InfrastructureAgentDoctorPage.tsx b/frontend-modern/src/components/Settings/InfrastructureAgentDoctorPage.tsxindex f500041fca..03c302b76b 100644--- a/frontend-modern/src/components/Settings/InfrastructureAgentDoctorPage.tsx+++ b/frontend-modern/src/components/Settings/InfrastructureAgentDoctorPage.tsx@@ -1,4 +1,4 @@-import { For, Show, createMemo, createSignal, type Component } from 'solid-js';+import { For, Show, createEffect, createMemo, createSignal, type Component } from 'solid-js';import { ChevronDown, ChevronLeft, ChevronRight, RefreshCw } from 'lucide-solid';import { Button, CommandCopyButton } from '@/components/shared/Button';import {@@ -17,6 +17,7 @@ import {getUnifiedAgentClipboardCopySuccessMessage,} from '@/utils/unifiedAgentInventoryPresentation';import {+ formatInfrastructureAgentDoctorReport,summarizeInfrastructureAgentDoctorTargets,type InfrastructureAgentDoctorStatus,type InfrastructureAgentDoctorTarget,@@ -123,6 +124,33 @@ export const InfrastructureAgentDoctorPage: Component<InfrastructureAgentDoctorPnotificationStore.error(getUnifiedAgentClipboardCopyErrorMessage());};+ const copyReport = async (reportTargets: readonly InfrastructureAgentDoctorTarget[]) => {+ const success = await copyToClipboard(formatInfrastructureAgentDoctorReport(reportTargets));+ if (success) {+ notificationStore.success('Diagnostic report copied');+ return;+ }+ notificationStore.error(getUnifiedAgentClipboardCopyErrorMessage());+ };++ const [statusFilter, setStatusFilter] = createSignal<InfrastructureAgentDoctorStatus | null>(+ null,+ );+ // A filtered status can empty out as agents recover, taking its chip with+ // it; clear the filter then so the table never dead-ends under a filter the+ // user can no longer see or unset.+ createEffect(() => {+ const filter = statusFilter();+ if (filter && !props.targets.some((target) => target.status === filter)) {+ setStatusFilter(null);+ }+ });+ const visibleTargets = createMemo(() => {+ const filter = statusFilter();+ if (!filter) return props.targets;+ return props.targets.filter((target) => target.status === filter);+ });+// A lone target (the common case when a platform page deep-links one stale// agent) starts expanded so its diagnosis and update command are immediately// visible; larger fleets start collapsed and expand per row.@@ -195,17 +223,39 @@ export const InfrastructureAgentDoctorPage: Component<InfrastructureAgentDoctorP</Show>}>- <section aria-label="Agent Doctor summary" class="flex flex-wrap items-center gap-2">- <For each={summaryChips()}>- {(chip) => (- <span- class={`inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-xs font-medium ${STATUS_PRESENTATION[chip.status].badgeClass}`}- >- <span class="font-semibold">{chip.count}</span>- {STATUS_PRESENTATION[chip.status].label}- </span>- )}- </For>+ <section+ aria-label="Agent Doctor summary"+ class="flex flex-wrap items-center justify-between gap-2"+ >+ <div class="flex flex-wrap items-center gap-2">+ <For each={summaryChips()}>+ {(chip) => (+ <button+ type="button"+ aria-pressed={statusFilter() === chip.status}+ onClick={() =>+ setStatusFilter((current) => (current === chip.status ? null : chip.status))+ }+ class={`inline-flex cursor-pointer items-center gap-1 rounded-full px-2.5 py-1 text-xs font-medium transition-shadow ${STATUS_PRESENTATION[chip.status].badgeClass} ${+ statusFilter() === chip.status+ ? 'ring-2 ring-blue-500 ring-offset-1 ring-offset-surface'+ : ''+ }`}+ >+ <span class="font-semibold">{chip.count}</span>+ {STATUS_PRESENTATION[chip.status].label}+ </button>+ )}+ </For>+ </div>+ <Button+ type="button"+ variant="outline"+ size="sm"+ onClick={() => void copyReport(visibleTargets())}+ >+ Copy diagnostic report+ </Button></section><Show when={anyTargetNeedsUpdate()}>@@ -307,7 +357,7 @@ export const InfrastructureAgentDoctorPage: Component<InfrastructureAgentDoctorP</TableRow></TableHeader><TableBody>- <For each={props.targets}>+ <For each={visibleTargets()}>{(target) => {const status = () => STATUS_PRESENTATION[target.status];const lastSeen = () => formatLastSeen(target.lastSeen);@@ -475,6 +525,15 @@ export const InfrastructureAgentDoctorPage: Component<InfrastructureAgentDoctorP</Show></Show></Show>++ <Button+ type="button"+ variant="outline"+ size="sm"+ onClick={() => void copyReport([target])}+ >+ Copy diagnostic report for {target.displayName}+ </Button></div></InlineDetailTableRow></Show>diff --git a/frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx b/frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsxindex 650960624b..af59d510c7 100644--- a/frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx+++ b/frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx@@ -454,6 +454,78 @@ describe('InfrastructureWorkspace', () => {);});+ it('filters the Agent Doctor table by clicking a status chip', async () => {+ routeState.pathname = '/settings/infrastructure/agent-doctor';+ routeState.search = '';+ const staleAgent = connectionFixture({+ id: 'agent:agent-zeus',+ type: 'agent',+ name: 'zeus-agent',+ address: 'zeus.lab',+ surfaces: ['host'],+ scope: { host: true },+ source: 'agent',+ agentVersion: '5.1.34',+ expectedAgentVersion: '6.0.0-rc.6',+ agentUpdateAvailable: true,+ agentIdentity: { hostname: 'zeus', platform: 'linux' },+ capabilities: { supportsPause: false, supportsScope: false, supportsTest: false },+ });+ const unreachableAgent = connectionFixture({+ id: 'agent:agent-apollo',+ type: 'agent',+ name: 'apollo-agent',+ address: 'apollo.lab',+ state: 'unreachable',+ surfaces: ['host'],+ scope: { host: true },+ source: 'agent',+ agentVersion: '6.0.0-rc.6',+ agentIdentity: { hostname: 'apollo', platform: 'linux' },+ capabilities: { supportsPause: false, supportsScope: false, supportsTest: false },+ });+ connectionState.connections = [staleAgent, unreachableAgent];+ connectionState.rows = [staleAgent, unreachableAgent].map((connection) => ({+ id: connection.id,+ ownerType: 'agent' as const,+ name: connection.name,+ subtitle: 'via Pulse Agent',+ source: 'agent' as const,+ host: connection.address,+ coverageLabels: ['Host telemetry'],+ statusLabel: 'Active',+ statusClassName: 'bg-green-100 text-green-800',+ agentUpdateCount: 0,+ lastActivityText: '1m ago',+ ...emptyFleetRow,+ enabled: true,+ canEdit: true,+ canPause: false,+ canRemove: true,+ isAgent: true,+ isCluster: false,+ attachedConnections: [],+ members: [],+ connection,+ }));++ renderWorkspace();++ await waitFor(() => expect(screen.getByText('zeus')).toBeInTheDocument());+ expect(screen.getByText('apollo')).toBeInTheDocument();+ expect(screen.getByRole('button', { name: 'Copy diagnostic report' })).toBeInTheDocument();++ const attentionChip = screen.getByRole('button', { name: '1 Needs attention' });+ fireEvent.click(attentionChip);+ expect(attentionChip).toHaveAttribute('aria-pressed', 'true');+ expect(screen.getByText('zeus')).toBeInTheDocument();+ expect(screen.queryByText('apollo')).not.toBeInTheDocument();++ fireEvent.click(attentionChip);+ expect(attentionChip).toHaveAttribute('aria-pressed', 'false');+ expect(screen.getByText('apollo')).toBeInTheDocument();+ });+it('does not invent scoped update commands when the backend publishes no agent target', async () => {routeState.search = '?agentUpdates=1&agents=agent%3Aagent-zeus';const primaryConnection = connectionFixture();diff --git a/frontend-modern/src/components/Settings/__tests__/infrastructureAgentDoctorModel.test.ts b/frontend-modern/src/components/Settings/__tests__/infrastructureAgentDoctorModel.test.tsindex 29cafd40c3..8d50e64c49 100644--- a/frontend-modern/src/components/Settings/__tests__/infrastructureAgentDoctorModel.test.ts+++ b/frontend-modern/src/components/Settings/__tests__/infrastructureAgentDoctorModel.test.ts@@ -5,7 +5,9 @@ import type { InfrastructureSystemRow } from '../connectionsTableModel';import {collectInfrastructureAgentDoctorTargets,diagnosticConnectionID,+ formatInfrastructureAgentDoctorReport,resolveKnownAgentCommandPlatform,+ type InfrastructureAgentDoctorTarget,} from '../infrastructureAgentUpdateCommandsModel';const connectionFixture = (overrides: Partial<Connection> = {}): Connection => ({@@ -370,4 +372,105 @@ describe('Agent Doctor model', () => {expect(resolveKnownAgentCommandPlatform('')).toBeNull();expect(resolveKnownAgentCommandPlatform('Haiku')).toBeNull();});++ describe('formatInfrastructureAgentDoctorReport', () => {+ const doctorTargetFixture = (+ overrides: Partial<InfrastructureAgentDoctorTarget> = {},+ ): InfrastructureAgentDoctorTarget => ({+ key: 'agent:host-1',+ connectionId: 'agent:host-1',+ displayName: 'host-1',+ contextLabel: 'Machine',+ installFlags: [],+ status: 'critical',+ reasons: [],+ evidence: [],+ needsUpdate: false,+ commandPlatform: null,+ source: 'diagnostics',+ ...overrides,+ });++ it('reports fleet counts, per-agent state, and diagnosis detail', () => {+ const report = formatInfrastructureAgentDoctorReport([+ doctorTargetFixture({+ currentVersion: '5.1.34',+ expectedVersion: '6.1.0',+ lastSeen: '2026-07-22T09:00:00Z',+ updaterLabel: 'systemd unit',+ profileLabel: 'default',+ profileVersionLabel: 'v3',+ reasons: [+ {+ code: 'agent_stale',+ severity: 'critical',+ message: 'No report has arrived for 10m.',+ evidence: ['Expected report interval: 30s'],+ },+ ],+ evidence: ['hostname host-1'],+ }),+ doctorTargetFixture({+ key: 'agent:host-2',+ connectionId: 'agent:host-2',+ displayName: 'host-2',+ status: 'healthy',+ }),+ ]);++ expect(report).toContain('Pulse Agent Doctor report (2 agents; 1 critical, 1 healthy)');+ expect(report).toContain('host-1 (Machine)');+ expect(report).toContain(' Connection agent:host-1');+ expect(report).toContain(' Status Critical');+ expect(report).toContain(' Reported agent 5.1.34');+ expect(report).toContain(' Supported target 6.1.0');+ expect(report).toContain(' Last seen 2026-07-22T09:00:00.000Z');+ expect(report).toContain(' Updater systemd unit');+ expect(report).toContain(' Profile default (v3)');+ expect(report).toContain(' - No report has arrived for 10m.');+ expect(report).toContain(' Expected report interval: 30s');+ expect(report).toContain(' Identity evidence');+ expect(report).toContain(' - hostname host-1');+ expect(report).toContain('host-2 (Machine)');+ expect(report).toContain(' Status Healthy');+ });++ it('omits absent fields and never embeds update commands', () => {+ const report = formatInfrastructureAgentDoctorReport([+ doctorTargetFixture({+ needsUpdate: true,+ commandBlockedReason: 'The reported platform is unsupported.',+ diagnostic: {+ connectionId: 'agent:host-1',+ repairActions: [+ {+ code: 'copy_upgrade_command',+ label: 'Copy update command',+ description: 'Copy the host-local update command.',+ supported: true,+ },+ {+ code: 'reissue_token',+ label: 'Reissue token',+ description: 'Generate a fresh install token.',+ supported: true,+ },+ ],+ } as unknown as InfrastructureAgentDoctorTarget['diagnostic'],+ }),+ ]);++ expect(report).toContain('Pulse Agent Doctor report (1 agent; 1 critical)');+ expect(report).not.toContain('Reported agent');+ expect(report).not.toContain('Supported target');+ expect(report).not.toContain('Last seen');+ expect(report).not.toContain('Updater');+ expect(report).not.toContain('Profile');+ // The update-command handoff stays on the page; reports carry the+ // blocked reason and non-command repairs only.+ expect(report).not.toContain('Copy update command');+ expect(report).toContain(' - Reissue token. Generate a fresh install token.');+ expect(report).toContain(' Update command blocked. The reported platform is unsupported.');+ });+ });});diff --git a/frontend-modern/src/components/Settings/infrastructureAgentUpdateCommandsModel.ts b/frontend-modern/src/components/Settings/infrastructureAgentUpdateCommandsModel.tsindex e4531e6ceb..15438c3ed2 100644--- a/frontend-modern/src/components/Settings/infrastructureAgentUpdateCommandsModel.ts+++ b/frontend-modern/src/components/Settings/infrastructureAgentUpdateCommandsModel.ts@@ -683,3 +683,81 @@ export const summarizeInfrastructureAgentDoctorTargets = (unknown: targets.filter((target) => target.status === 'unknown').length,removed: targets.filter((target) => target.status === 'removed').length,});++const DOCTOR_REPORT_STATUS_LABEL: Record<InfrastructureAgentDoctorStatus, string> = {+ healthy: 'Healthy',+ waiting: 'Waiting for updater',+ warning: 'Needs attention',+ critical: 'Critical',+ removed: 'Removed',+ unknown: 'Unknown',+};++const doctorReportLastSeen = (value?: number | string | null): string | undefined => {+ if (value === null || value === undefined || value === '') return undefined;+ const timestamp = typeof value === 'number' ? value : Date.parse(value);+ if (!Number.isFinite(timestamp)) return typeof value === 'string' ? value : undefined;+ return new Date(timestamp).toISOString();+};++// Plain-text diagnosis for pasting into a support thread or GitHub issue.+// Deliberately excludes update commands: they can embed install tokens.+export const formatInfrastructureAgentDoctorReport = (+ targets: readonly InfrastructureAgentDoctorTarget[],+): string => {+ const counts = summarizeInfrastructureAgentDoctorTargets(targets);+ const countParts = (['critical', 'warning', 'waiting', 'unknown', 'removed', 'healthy'] as const)+ .filter((status) => counts[status] > 0)+ .map((status) => `${counts[status]} ${DOCTOR_REPORT_STATUS_LABEL[status].toLowerCase()}`);+ const lines: string[] = [+ `Pulse Agent Doctor report (${counts.total} agent${counts.total === 1 ? '' : 's'}${+ countParts.length > 0 ? `; ${countParts.join(', ')}` : ''+ })`,+ ];+ for (const target of targets) {+ lines.push('');+ lines.push(`${target.displayName} (${target.contextLabel})`);+ lines.push(` Connection ${target.connectionId}`);+ lines.push(` Status ${DOCTOR_REPORT_STATUS_LABEL[target.status]}`);+ if (target.currentVersion) lines.push(` Reported agent ${target.currentVersion}`);+ if (target.expectedVersion) lines.push(` Supported target ${target.expectedVersion}`);+ const lastSeen = doctorReportLastSeen(target.lastSeen);+ if (lastSeen) lines.push(` Last seen ${lastSeen}`);+ if (target.updaterLabel) lines.push(` Updater ${target.updaterLabel}`);+ if (target.profileLabel) {+ lines.push(+ ` Profile ${target.profileLabel}${+ target.profileVersionLabel ? ` (${target.profileVersionLabel})` : ''+ }`,+ );+ }+ if (target.reasons.length > 0) {+ lines.push(' Issues');+ for (const reason of target.reasons) {+ lines.push(` - ${reason.message}`);+ for (const item of reason.evidence ?? []) {+ lines.push(` ${item}`);+ }+ }+ }+ if (target.evidence.length > 0) {+ lines.push(' Identity evidence');+ for (const item of target.evidence) {+ lines.push(` - ${item}`);+ }+ }+ const repairs = (target.diagnostic?.repairActions ?? []).filter(+ (action) => action.code !== 'copy_upgrade_command',+ );+ if (repairs.length > 0) {+ lines.push(' Repair actions');+ for (const repair of repairs) {+ lines.push(` - ${repair.label}. ${repair.description}`);+ }+ }+ if (target.commandBlockedReason) {+ lines.push(` Update command blocked. ${target.commandBlockedReason}`);+ }+ }+ return lines.join('\n');+};