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.

Add Copy summary action to share findings as paste-ready Markdown

rcourtman06ebe55e1321
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index 205b3ce0e7..6816592818 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -1163,3 +1163,15 @@ temporal recency and coverage in one line. The field stays optional
(omitted when zero) so a degenerate run that completed without
checking any resources does not render a misleading "verified 0
resources" line.
+The expanded finding card must also expose a "Copy summary" action
+that produces a paste-ready Markdown summary of the finding (severity,
+title, resource header, description, impact, recommendation,
+confidence, regression count). The formatter is the canonical
+`formatFindingForClipboard` helper in
+`frontend-modern/src/utils/aiFindingPresentation.ts`; the render must
+route through `copyToClipboard` from `@/utils/clipboard` so the
+delegate-to-teammate workflow is uniform with the existing Discuss
+and Explain entry points. Investigation evidence and rollback plans
+are intentionally omitted from the clipboard shape — those are
+conversation context for the Assistant flow, not "share this
+finding" context for chat or tickets.
diff --git a/frontend-modern/src/components/AI/FindingsPanel.tsx b/frontend-modern/src/components/AI/FindingsPanel.tsx
index 6503cdd2e2..e5904c0c4d 100644
--- a/frontend-modern/src/components/AI/FindingsPanel.tsx
+++ b/frontend-modern/src/components/AI/FindingsPanel.tsx
@@ -45,6 +45,7 @@ import AlertCircleIcon from 'lucide-solid/icons/alert-circle';
import AlertTriangleIcon from 'lucide-solid/icons/alert-triangle';
import {
buildFindingFilterOptions,
+ formatFindingForClipboard,
formatFindingLifecycleType,
formatFindingLoopState,
getFindingActiveRuntimeSortOrder,
@@ -70,6 +71,7 @@ import {
getInvestigationOutcomeSortOrder,
getInvestigationStatusBadgeClasses,
} from '@/utils/aiFindingPresentation';
+import { copyToClipboard } from '@/utils/clipboard';
interface FindingsPanelProps {
resourceId?: string;
@@ -568,6 +570,24 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
await openFindingInAssistant(finding, 'explain');
};
+ // Copy a Markdown summary of the finding to the clipboard so the operator
+ // can paste it into a chat, ticket, or incident channel. The shape mirrors
+ // the seven-question schema (title + impact + recommendation + trust
+ // signals) so a teammate seeing the finding cold has the operator-facing
+ // context they need without opening Pulse. Investigation evidence and
+ // rollback plans are deferred to Discuss with Assistant — they're
+ // conversation context, not "share this finding" context.
+ const handleCopyFindingSummary = async (finding: UnifiedFinding, e: Event) => {
+ e.stopPropagation();
+ const text = formatFindingForClipboard(finding);
+ const ok = await copyToClipboard(text);
+ if (ok) {
+ notificationStore.success('Finding summary copied');
+ } else {
+ notificationStore.error('Could not copy finding summary');
+ }
+ };
+
const handleOpenPlanInAssistant = (finding: UnifiedFinding, plan: RemediationPlan, e: Event) => {
e.stopPropagation();
const subject = getFindingSubjectPresentation(finding).label;
@@ -1108,6 +1128,22 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
</svg>
Explain
</button>
+ <button
+ type="button"
+ onClick={(e) => handleCopyFindingSummary(finding, e)}
+ class="px-2 py-1 rounded border border-border hover:bg-surface-hover flex items-center gap-1"
+ title="Copy a Markdown summary of this finding for sharing with a teammate"
+ >
+ <svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
+ <path
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"
+ />
+ </svg>
+ Copy summary
+ </button>
<button
type="button"
onClick={(e) => handleDiscussWithAssistant(finding, e)}
diff --git a/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts b/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
index 0fdaf628a7..551ebb008c 100644
--- a/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
+++ b/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
@@ -3,6 +3,7 @@ import { resolve } from 'node:path';
import { describe, expect, it } from 'vitest';
import {
buildFindingFilterOptions,
+ formatFindingForClipboard,
formatFindingLifecycleType,
formatFindingLoopState,
getFindingActiveRuntimeSortOrder,
@@ -124,6 +125,20 @@ describe('FindingsPanel assistant handoff', () => {
expect(findingsPanelSource).toContain('Pulse will permanently suppress');
});
+ it('exposes a Copy summary action wired to formatFindingForClipboard and the shared clipboard helper', () => {
+ // Operators frequently need to delegate a finding by pasting a summary
+ // into Slack, email, or a ticket. Pin the wiring so the Copy summary
+ // button routes through the canonical formatter (same shape as the
+ // helper test below) and the shared copyToClipboard helper, with
+ // success/error notifications routed through notificationStore.
+ expect(findingsPanelSource).toContain('handleCopyFindingSummary');
+ expect(findingsPanelSource).toContain('formatFindingForClipboard(finding)');
+ expect(findingsPanelSource).toContain('copyToClipboard(text)');
+ expect(findingsPanelSource).toContain('Finding summary copied');
+ expect(findingsPanelSource).toContain('Could not copy finding summary');
+ expect(findingsPanelSource).toMatch(/>\s*Copy summary\s*</);
+ });
+
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
@@ -976,6 +991,55 @@ describe('aiFindingPresentation', () => {
).toBe('CPU returned to normal 2m ago');
});
+ it('formats findings as a Markdown summary mirroring the seven-question schema for paste-into-chat sharing', () => {
+ // The Copy summary action must produce paste-ready Markdown that
+ // mirrors render order: severity + title + resource header, then
+ // description, impact, recommendation, plus trust signals
+ // (confidence, regression count). Anything beyond that — evidence,
+ // rollback plans, internal IDs — is deferred to the Discuss flow
+ // because that's conversation context, not "share this finding"
+ // context. Pin the exact shape so the operator-facing output
+ // doesn't drift between releases.
+ const formatted = formatFindingForClipboard({
+ severity: 'warning',
+ title: 'Disk pressure',
+ resourceName: 'db-01',
+ resourceType: 'vm',
+ description: 'Datastore is at 92% capacity.',
+ impact: 'Backups will be skipped if free space drops below 5%.',
+ recommendation: 'Free 200GB before the next backup window.',
+ investigationRecord: { confidence: 'medium' } as never,
+ regressionCount: 2,
+ } as never);
+ expect(formatted).toContain('**[WARNING] Disk pressure**');
+ expect(formatted).toContain('Resource: db-01 (vm)');
+ expect(formatted).toContain('Description: Datastore is at 92% capacity.');
+ expect(formatted).toContain('Impact: Backups will be skipped if free space drops below 5%.');
+ expect(formatted).toContain('Recommendation: Free 200GB before the next backup window.');
+ expect(formatted).toContain('Confidence: medium');
+ expect(formatted).toContain('Regressed: 2×');
+ });
+
+ it('omits empty fields cleanly when the finding has not been investigated yet', () => {
+ // A threshold-only finding (no InvestigationRecord, no Impact) must
+ // still produce useful Markdown — the formatter must not include
+ // empty "Impact:" or "Confidence:" lines that read as alarm signals.
+ const formatted = formatFindingForClipboard({
+ severity: 'critical',
+ title: 'Host offline',
+ resourceName: 'pve-01',
+ resourceType: 'node',
+ description: 'Host is not responding.',
+ } as never);
+ expect(formatted).toContain('**[CRITICAL] Host offline**');
+ expect(formatted).toContain('Resource: pve-01 (node)');
+ expect(formatted).toContain('Description: Host is not responding.');
+ expect(formatted).not.toContain('Impact:');
+ expect(formatted).not.toContain('Recommendation:');
+ expect(formatted).not.toContain('Confidence:');
+ expect(formatted).not.toContain('Regressed:');
+ });
+
it('returns canonical patrol resolution reasons', () => {
expect(
getFindingResolutionReason(
diff --git a/frontend-modern/src/utils/aiFindingPresentation.ts b/frontend-modern/src/utils/aiFindingPresentation.ts
index c1ba774d8c..e3d58252d0 100644
--- a/frontend-modern/src/utils/aiFindingPresentation.ts
+++ b/frontend-modern/src/utils/aiFindingPresentation.ts
@@ -748,3 +748,66 @@ export const getFindingEmptyStateCopy = (filter: FindingsFilter): FindingEmptySt
};
}
};
+
+/**
+ * Format a finding as a Markdown summary the operator can paste into a chat
+ * message, ticket, or incident channel. The output mirrors the seven-question
+ * schema in render order — title + resource header, then description, impact,
+ * recommendation, plus the trust signals (confidence, regression count) that
+ * matter most to a teammate seeing the finding cold.
+ *
+ * Intentionally lean: only fields the operator can paste verbatim, no internal
+ * IDs or timestamps in epoch form. Investigation evidence and rollback plans
+ * are deferred to the Discuss with Assistant flow because those are
+ * conversation context, not "share this finding" context.
+ */
+export const formatFindingForClipboard = (
+ finding: Pick<
+ UnifiedFinding,
+ | 'severity'
+ | 'title'
+ | 'resourceName'
+ | 'resourceType'
+ | 'description'
+ | 'impact'
+ | 'recommendation'
+ | 'investigationRecord'
+ | 'regressionCount'
+ >,
+): string => {
+ const lines: string[] = [];
+ const severity = finding.severity ? finding.severity.toUpperCase() : 'FINDING';
+ const resource = [finding.resourceName, finding.resourceType ? `(${finding.resourceType})` : '']
+ .filter(Boolean)
+ .join(' ')
+ .trim();
+ lines.push(`**[${severity}] ${finding.title || 'Untitled finding'}**`);
+ if (resource) {
+ lines.push(`Resource: ${resource}`);
+ }
+ if (finding.description) {
+ lines.push('');
+ lines.push(`Description: ${finding.description}`);
+ }
+ if (finding.impact) {
+ lines.push('');
+ lines.push(`Impact: ${finding.impact}`);
+ }
+ if (finding.recommendation) {
+ lines.push('');
+ lines.push(`Recommendation: ${finding.recommendation}`);
+ }
+ const trustParts: string[] = [];
+ const confidence = finding.investigationRecord?.confidence;
+ if (confidence) {
+ trustParts.push(`Confidence: ${confidence}`);
+ }
+ if ((finding.regressionCount || 0) > 0) {
+ trustParts.push(`Regressed: ${finding.regressionCount}×`);
+ }
+ if (trustParts.length > 0) {
+ lines.push('');
+ lines.push(trustParts.join(' · '));
+ }
+ return lines.join('\n');
+};