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
Render briefing timestamps as relative time and drop noise
rcourtman7d4d270b44b7
diff --git a/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts b/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.tsindex d39b62c515..0291478f6d 100644--- a/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts+++ b/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts@@ -1,6 +1,6 @@import { readFileSync } from 'node:fs';import { resolve } from 'node:path';-import { describe, expect, it } from 'vitest';+import { describe, expect, it, vi } from 'vitest';import type { RemediationPlan } from '@/api/ai';import type { PatrolRunRecord } from '@/api/patrol';@@ -1250,6 +1250,13 @@ describe('patrolInvestigationContextModel', () => {});it('builds a drawer briefing for Assistant handoff without exposing raw commands', () => {+ // Pin "now" so the relative-time formatting in the briefing+ // (`last regression {relative}`) is deterministic against the+ // fixed fixture timestamp two hours earlier. Restored after.+ const pinnedNow = new Date('2026-05-06T14:06:00Z');+ vi.useFakeTimers();+ vi.setSystemTime(pinnedNow);+const approvalRequestedAt = new Date(Date.now() - 60_000).toISOString();const approvalExpiresAt = new Date(Date.now() + 10 * 60_000).toISOString();@@ -1303,7 +1310,7 @@ describe('patrolInvestigationContextModel', () => {subject: 'High CPU usage on web-server',statusLabel: 'Completed · Fix Queued · High confidence',detailLines: [- 'Attention: active critical finding; regressed 2 times; last regression 2026-05-06T12:06:00Z; loop awaiting approval; approval approval-1; live approval pending; destructive proposed fix; fix queued for governed review',+ 'Attention: active critical finding; regressed 2 times; last regression 2 hours ago; loop awaiting approval; approval approval-1; live approval pending; destructive proposed fix; fix queued for governed review','Backup job saturated CPU.','Approve a controlled restart after the backup completes.',`Decision: review live governed approval approval-1 before execution; approval pending; target web-server; expires ${approvalExpiresAt}; requested ${approvalRequestedAt}; proposed fix fix-1; risk high; destructive true`,@@ -1320,6 +1327,7 @@ describe('patrolInvestigationContextModel', () => {],});expect(JSON.stringify(briefing)).not.toContain('systemctl restart workload.service');+ vi.useRealTimers();});it('builds remediation plan Assistant handoff context without exposing raw commands', () => {diff --git a/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts b/frontend-modern/src/features/patrol/patrolInvestigationContextModel.tsindex 5c8ce22655..39accd933b 100644--- a/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts+++ b/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts@@ -35,6 +35,19 @@ import {getPatrolRunKindLabel,getPatrolRunStatusPresentation,} from '@/utils/patrolRunPresentation';+import { formatRelativeTime } from '@/utils/format';++// formatBriefingTimestamp renders a timestamp in a way that's readable for+// both the operator (who sees the briefing copy in the Assistant drawer)+// and the LLM (which receives the same string as part of the handoff+// context). Relative time satisfies both: humans read it naturally, and+// LLMs interpret "22 mins ago" just as well as a raw ISO timestamp. The+// precise timestamp is still available in the structured handoff fields+// that flow alongside the briefing copy for any caller that needs it.+function formatBriefingTimestamp(value: string | undefined): string {+ if (!value) return '';+ return formatRelativeTime(value, { compact: false, emptyText: '' });+}export interface PatrolInvestigationContextSummaryInput {recentChangesCount?: number | null;@@ -2119,8 +2132,8 @@ function formatAssessmentFindingContextLine(normalizeNonNegativeCount(finding.regressionCount) === 1 ? '' : 's'}`: undefined,- normalizeText(finding.lastRegressionAt)- ? `last regression ${normalizeText(finding.lastRegressionAt)}`+ formatBriefingTimestamp(normalizeText(finding.lastRegressionAt))+ ? `last regression ${formatBriefingTimestamp(normalizeText(finding.lastRegressionAt))}`: undefined,];const recordParts = [@@ -2187,8 +2200,8 @@ function buildPatrolAssistantFindingModelContext(normalizeNonNegativeCount(input.regressionCount) === 1 ? '' : 's'}`: undefined,- normalizeText(input.lastRegressionAt)- ? `last regression ${normalizeText(input.lastRegressionAt)}`+ formatBriefingTimestamp(normalizeText(input.lastRegressionAt))+ ? `last regression ${formatBriefingTimestamp(normalizeText(input.lastRegressionAt))}`: undefined,].filter(isNonEmptyString);const nextStepAction = normalizePatrolAssistantNextStepAction(input.nextStepAction);@@ -2624,14 +2637,23 @@ function buildPatrolAssistantAttentionReason(parts.push(`raised ${timesRaised} times`);}- const lastRegressionAt = normalizeText(input.lastRegressionAt);+ const lastRegressionAt = formatBriefingTimestamp(normalizeText(input.lastRegressionAt));if (lastRegressionAt) {parts.push(`last regression ${lastRegressionAt}`);}- const loopState = formatIdentifierLabel(input.loopState)?.toLowerCase();- if (loopState) {- parts.push(`loop ${loopState}`);+ // Only surface loop state when it differs from the default "detected".+ // Loop=detected means "Patrol detected it, no investigation in flight"+ // which is the trivial state for any active finding; rendering "loop+ // detected" in the Attention line adds noise without information. Keep+ // the loop signal only when it indicates a non-default investigation+ // posture ("awaiting approval", "remediation failed", etc.).+ const rawLoopState = normalizeText(input.loopState).toLowerCase();+ if (rawLoopState && rawLoopState !== 'detected') {+ const loopLabel = formatIdentifierLabel(input.loopState)?.toLowerCase();+ if (loopLabel) {+ parts.push(`loop ${loopLabel}`);+ }}const rawRecord = input.investigationRecord;