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 Patrol handoff suggested prompts
rcourtman1f5098f89e34
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex babfce16e1..87abaeb958 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -76,7 +76,10 @@ runtime cost control, and shared AI transport surfaces.and meaningful badge text rather than icon title duplication. Scopedapproval handoffs sourced from Patrol, active alerts, or alert incidenttimelines must render as source-named investigation handoffs in the drawer- instead of generic dashboard briefs.+ instead of generic dashboard briefs. Source-owned handoff helpers may attach+ bounded suggested prompts to that briefing, but those prompts are only input+ starters; they must not auto-submit, bypass approval mode, or carry raw+ command payloads.9. Add or change public AI overview wording through `docs/AI.md`; it maydescribe Assistant and Patrol capabilities, but it must not revive legacycommercial shorthand such as `incident memory` as a current product promise.diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex ea31d8db8f..ccb6ca131a 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -434,8 +434,8 @@ the canonical monitored-system blocked payload.and that same Patrol investigation-context owner, so the current Patrolassessment summary may open Assistant with bounded model-only assessment,verification, latest-run, supporting-context evidence, active-finding, and- resource reference context instead of pasting page-local UI text or raw- command payloads into chat+ resource reference context plus safe source-owned suggested prompts instead+ of pasting page-local UI text or raw command payloads into chatand that same Patrol investigation-context owner, so visible Assistantdrawer handoffs may include live pending-approval metadata only as safeoperator context: approval ID, status, risk, requested/expiry timestamps,diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex b5e6321a42..d41862357c 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -817,7 +817,10 @@ frontend primitive boundary.summary prompt builder. The drawer may render a genericcontext-briefing band from `frontend-modern/src/stores/aiChat.ts`, butfeature-owned helpers must provide the source labels, attention reason,- evidence summaries, operator-decision copy, action copy, and safety note.+ evidence summaries, operator-decision copy, action copy, safety note, and+ any bounded suggested prompts. Suggested prompts may fill the drawer input+ for the operator, but they must not submit automatically or change the+ request-local approval-required mode.When those feature-owned helpers attach backend model-only context, thedrawer store may carry only bounded handoff text and structured resourcereferences for the shared chat transport; approval, lifecycle, and commanddiff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.mdindex 10a4ab3581..6b005ac36b 100644--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md@@ -194,11 +194,11 @@ Patrol-specific presentation helpers.The summary action may pass the current assessment title, health score,verification recency, latest run, secondary investigation context, boundedrecent-change and learned-correlation evidence, active-finding summaries,- and structured resource references as model-only context. It must force- request-local approval-required mode, keep raw command and approval payloads- out of prompt and drawer copy, and frame Assistant as explanation,- prioritization, and safe next-step review rather than a generic reactive chat- box.+ structured resource references, and safe source-owned suggested prompts as+ model-only context. It must force request-local approval-required mode, keep+ raw command and approval payloads out of prompt and drawer copy, and frame+ Assistant as explanation, prioritization, and safe next-step review rather+ than a generic reactive chat box.## Current State@@ -252,10 +252,10 @@ opens Assistant through`frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts`, whichpackages the current Patrol assessment, verification posture, latest run,secondary investigation context, bounded recent-change and learned-correlation-evidence, bounded active-finding summaries, and deduped resource references as-model-only context while forcing `autonomousMode:false` and summarizing-proposed-fix command-bearing records and command-bearing change events without-raw command text.+evidence, bounded active-finding summaries, source-owned suggested prompts, and+deduped resource references as model-only context while forcing+`autonomousMode:false` and summarizing proposed-fix command-bearing records and+command-bearing change events without raw command text.That active-runtime label must stay operational rather than verdict-like: theheader chip should communicate that Patrol is enabled or available, not implythat infrastructure health is currently good merely because the runtime is on.diff --git a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsxindex e5ec4a2310..50c9c51974 100644--- a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx+++ b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx@@ -104,6 +104,7 @@ const {actionLabel?: string;commandSummary?: string;safetyNote?: string;+ suggestedPrompts?: string[];};},clearInitialPrompt: vi.fn(),@@ -323,6 +324,7 @@ describe('AIChat', () => {actionLabel: 'Restart the workload service',commandSummary: '1 command recorded for approval context',safetyNote: 'Command details stay in approval context.',+ suggestedPrompts: ['Explain recent changes and correlations'],},};@@ -333,6 +335,12 @@ describe('AIChat', () => {expect(screen.getByText('High CPU usage on web-server')).toBeInTheDocument();expect(screen.getByText('Backup job saturated CPU.')).toBeInTheDocument();expect(screen.getByText('1 command recorded for approval context')).toBeInTheDocument();+ fireEvent.click(+ screen.getByRole('button', { name: 'Explain recent changes and correlations' }),+ );+ expect(screen.getByPlaceholderText('Ask about your infrastructure...')).toHaveValue(+ 'Explain recent changes and correlations',+ );expect(screen.queryByText('systemctl restart workload.service')).not.toBeInTheDocument();});diff --git a/frontend-modern/src/components/AI/Chat/index.tsx b/frontend-modern/src/components/AI/Chat/index.tsxindex 40820b95fb..a2b399b694 100644--- a/frontend-modern/src/components/AI/Chat/index.tsx+++ b/frontend-modern/src/components/AI/Chat/index.tsx@@ -314,6 +314,9 @@ export const AIChat: Component<AIChatProps> = (props) => {const contextBriefing = createMemo(() => aiChatStore.context.briefing);const contextBriefingEvidence = createMemo(() => contextBriefing()?.evidence ?? []);const contextBriefingDetails = createMemo(() => contextBriefing()?.detailLines ?? []);+ const contextBriefingSuggestedPrompts = createMemo(+ () => contextBriefing()?.suggestedPrompts ?? [],+ );const scopedApprovalHandoffLabel = createMemo(() => {const source = contextBriefing()?.sourceLabel?.toLowerCase() || '';if (source.includes('patrol')) return 'this Patrol handoff';@@ -348,6 +351,13 @@ export const AIChat: Component<AIChatProps> = (props) => {return { type: 'thinking', text: 'Thinking...' };});+ const handleContextBriefingPrompt = (prompt: string) => {+ setInput(prompt);+ setMentionActive(false);+ setMentionQuery('');+ queueMicrotask(() => textareaRef?.focus());+ };+createEffect(() => {if (!isOpen()) {return;@@ -1239,6 +1249,21 @@ export const AIChat: Component<AIChatProps> = (props) => {</For></div></Show>+ <Show when={contextBriefingSuggestedPrompts().length > 0}>+ <div class="mt-2 flex flex-wrap gap-1.5">+ <For each={contextBriefingSuggestedPrompts()}>+ {(prompt) => (+ <button+ type="button"+ onClick={() => handleContextBriefingPrompt(prompt)}+ class="max-w-full rounded border border-border bg-surface px-2 py-1 text-left text-[11px] font-medium text-base-content transition-colors hover:bg-surface-alt focus:outline-none focus:ring-2 focus:ring-blue-500"+ >+ {prompt}+ </button>+ )}+ </For>+ </div>+ </Show><Show when={contextBriefing()!.actionLabel || contextBriefing()!.commandSummary}><div class="mt-2 rounded border border-border bg-surface-alt px-2.5 py-2 text-[11px] text-muted"><Show when={contextBriefing()!.actionLabel}>diff --git a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsxindex ba8f02427e..3742bd131b 100644--- a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx+++ b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx@@ -32,6 +32,13 @@ describe('PatrolIntelligenceSummary', () => {{ id: 'vm-100', name: 'web-server', type: 'vm', node: 'pve-1' },{ id: 'backup-job', name: 'Nightly backup job', type: 'job', node: undefined },]);+ expect(context.briefing).toMatchObject({+ suggestedPrompts: [+ 'Prioritize findings and safest next step',+ 'Explain recent changes and correlations',+ 'Summarize governed remediation risks',+ ],+ });expect(JSON.stringify(context)).not.toContain('systemctl restart workload.service');});});diff --git a/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts b/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.tsindex 5c81750c0f..95b58d7848 100644--- a/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts+++ b/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts@@ -262,6 +262,11 @@ describe('patrolInvestigationContextModel', () => {title: 'Patrol assessment attached',subject: 'Issues detected',safetyNote: 'Diagnostics and remediation require governed approval.',+ suggestedPrompts: [+ 'Prioritize findings and safest next step',+ 'Explain recent changes and correlations',+ 'Summarize governed remediation risks',+ ],});expect(JSON.stringify(handoff)).not.toContain('systemctl restart workload.service');});diff --git a/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts b/frontend-modern/src/features/patrol/patrolInvestigationContextModel.tsindex 0afedc84b9..c8b87014a4 100644--- a/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts+++ b/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts@@ -170,6 +170,7 @@ const MAX_ASSESSMENT_FINDINGS = 5;const MAX_ASSESSMENT_RECENT_CHANGES = 3;const MAX_ASSESSMENT_CORRELATIONS = 3;const MAX_ASSESSMENT_RESOURCES = 8;+const MAX_ASSESSMENT_SUGGESTED_PROMPTS = 3;export function buildPatrolInvestigationContextSummary(input: PatrolInvestigationContextSummaryInput,@@ -341,9 +342,68 @@ function buildPatrolAssessmentAssistantBriefing(evidence: [...findingEvidence.slice(0, 3), ...supportingEvidence].slice(0, 5),actionLabel: 'Discuss Patrol assessment',safetyNote: 'Diagnostics and remediation require governed approval.',+ suggestedPrompts: buildPatrolAssessmentSuggestedPrompts(input, {+ findings,+ recentChanges,+ correlations,+ }),};}+function buildPatrolAssessmentSuggestedPrompts(+ input: PatrolAssessmentAssistantHandoffInput,+ normalized: {+ findings: PatrolAssessmentAssistantFindingInput[];+ recentChanges: ResourceChange[];+ correlations: ResourceCorrelation[];+ },+): string[] {+ const prompts: string[] = [];+ const activeFindingCount = normalizeNonNegativeCount(input.activeFindings?.length);+ const hasSupportingEvidence =+ normalized.recentChanges.length > 0 || normalized.correlations.length > 0;+ const hasGovernedAction = normalized.findings.some(assessmentFindingHasGovernedAction);++ if (activeFindingCount > 0) {+ prompts.push('Prioritize findings and safest next step');+ } else {+ prompts.push('Explain current health and what to watch');+ }++ if (hasSupportingEvidence) {+ prompts.push('Explain recent changes and correlations');+ }++ if (hasGovernedAction) {+ prompts.push('Summarize governed remediation risks');+ } else if (activeFindingCount > 0) {+ prompts.push('List evidence to verify before action');+ } else if (hasSupportingEvidence) {+ prompts.push('Identify early warning signals');+ }++ return Array.from(new Set(prompts.map(normalizeText).filter(isNonEmptyString))).slice(+ 0,+ MAX_ASSESSMENT_SUGGESTED_PROMPTS,+ );+}++function assessmentFindingHasGovernedAction(+ finding: PatrolAssessmentAssistantFindingInput,+): boolean {+ if (+ patrolAssistantFindingHandoffRequiresApprovalMode({+ investigationOutcome: finding.investigationOutcome,+ investigationRecord: finding.investigationRecord,+ })+ ) {+ return true;+ }++ const loopState = normalizeText(finding.loopState).toLowerCase();+ return loopState.includes('approval') || loopState.includes('remediation');+}+function buildPatrolAssessmentAssistantModelContext(input: PatrolAssessmentAssistantHandoffInput,): string {diff --git a/frontend-modern/src/stores/__tests__/aiChat.test.ts b/frontend-modern/src/stores/__tests__/aiChat.test.tsindex 51aa39019a..7759ab0cb1 100644--- a/frontend-modern/src/stores/__tests__/aiChat.test.ts+++ b/frontend-modern/src/stores/__tests__/aiChat.test.ts@@ -4,7 +4,10 @@ import { describe, expect, it, beforeEach } from 'vitest';import { aiChatStore } from '@/stores/aiChat';import { eventBus } from '@/stores/events';-const aiChatSource = readFileSync(resolve(process.cwd(), 'src/components/AI/Chat/index.tsx'), 'utf8');+const aiChatSource = readFileSync(+ resolve(process.cwd(), 'src/components/AI/Chat/index.tsx'),+ 'utf8',+);describe('aiChatStore', () => {beforeEach(() => {@@ -84,7 +87,10 @@ describe('aiChatStore', () => {});it('prefers guestName, then name, then target id for target context labels', () => {- aiChatStore.setTargetContext('vm', 'vm-101', { guestName: 'guest-first', name: 'ignored-name' });+ aiChatStore.setTargetContext('vm', 'vm-101', {+ guestName: 'guest-first',+ name: 'ignored-name',+ });expect(aiChatStore.contextItems[0].name).toBe('guest-first');aiChatStore.openForTarget('agent', 'agent-1', { name: 'node-name' });@@ -101,12 +107,16 @@ describe('aiChatStore', () => {briefing: {sourceLabel: 'Pulse Patrol',title: 'Investigation record attached',+ suggestedPrompts: ['Explain recent changes and correlations'],},});expect(aiChatStore.isOpen).toBe(true);expect(aiChatStore.context.initialPrompt).toBe('hello');expect(aiChatStore.context.targetId).toBe('vm-101');expect(aiChatStore.context.briefing?.title).toBe('Investigation record attached');+ expect(aiChatStore.context.briefing?.suggestedPrompts).toEqual([+ 'Explain recent changes and correlations',+ ]);});it('preserves scoped autonomous-mode overrides for pre-filled prompts', () => {diff --git a/frontend-modern/src/stores/aiChat.ts b/frontend-modern/src/stores/aiChat.tsindex f6d3cbe0ac..7e0ee3aed7 100644--- a/frontend-modern/src/stores/aiChat.ts+++ b/frontend-modern/src/stores/aiChat.ts@@ -14,6 +14,7 @@ export interface AIChatContextBriefing {actionLabel?: string;commandSummary?: string;safetyNote?: string;+ suggestedPrompts?: string[];}export interface AIChatHandoffResource {