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.

Remove Assistant prompt routing heuristics

rcourtman14d328423328
diff --git a/docs/release-control/v6/internal/status.json b/docs/release-control/v6/internal/status.json
index 896ff7266c..6f5db86479 100644
--- a/docs/release-control/v6/internal/status.json
+++ b/docs/release-control/v6/internal/status.json
@@ -2956,7 +2956,7 @@
},
{
"id": "RA29",
- "summary": "Interactive Pulse Assistant chat behaves like a governed LLM tool surface, not a Pulse-authored intent router: the operator's selected model receives the user turn and governed tools, decides whether tools are needed, and Pulse must not use prompt heuristics to force tool_choice, force a named tool, retry because an expected tool was not used, hide tools from the model by keyword detection, or rewrite recent-context turns into Pulse-targeted instructions. Pulse only provides context and enforces approvals, resource resolution, FSM gates, and tool policy after that model choice. The chat surface must echo user messages before network/session creation finishes and must not render Pulse-owned explore or internal workflow status cards as assistant output.",
+ "summary": "Interactive Pulse Assistant chat behaves like a governed LLM tool surface, not a Pulse-authored intent router: the operator's selected model receives the user turn and governed tools, decides whether tools are needed, and Pulse must not use prompt heuristics to force tool_choice, force a named tool, retry because an expected tool was not used, hide tools from the model by keyword detection, rewrite recent-context turns into Pulse-targeted instructions, or synthesize/prefill/auto-submit product-authored Assistant prompts from handoffs. Pulse only provides context and enforces approvals, resource resolution, FSM gates, and tool policy after that model choice. The chat surface must echo user messages before network/session creation finishes and must not render Pulse-owned explore or internal workflow status cards as assistant output.",
"kind": "invariant",
"blocking_level": "repo-ready",
"proof_type": "automated",
@@ -3069,6 +3069,16 @@
"path": "frontend-modern/src/api/generated/aiChatEvents.ts",
"kind": "file"
},
+ {
+ "repo": "pulse",
+ "path": "frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts",
+ "kind": "file"
+ },
+ {
+ "repo": "pulse",
+ "path": "frontend-modern/src/components/AI/Chat/__tests__/ChatMessages.test.tsx",
+ "kind": "file"
+ },
{
"repo": "pulse",
"path": "frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx",
@@ -3079,11 +3089,21 @@
"path": "frontend-modern/src/components/AI/Chat/__tests__/useChat.test.ts",
"kind": "file"
},
+ {
+ "repo": "pulse",
+ "path": "frontend-modern/src/components/AI/Chat/ChatMessages.tsx",
+ "kind": "file"
+ },
{
"repo": "pulse",
"path": "frontend-modern/src/components/AI/Chat/hooks/useChat.ts",
"kind": "file"
},
+ {
+ "repo": "pulse",
+ "path": "frontend-modern/src/components/AI/Chat/index.tsx",
+ "kind": "file"
+ },
{
"repo": "pulse",
"path": "frontend-modern/src/components/AI/Chat/MessageItem.tsx",
@@ -3094,11 +3114,56 @@
"path": "frontend-modern/src/components/AI/Chat/types.ts",
"kind": "file"
},
+ {
+ "repo": "pulse",
+ "path": "frontend-modern/src/components/AI/FindingsPanel.tsx",
+ "kind": "file"
+ },
+ {
+ "repo": "pulse",
+ "path": "frontend-modern/src/components/Alerts/alertAssistantHandoffModel.ts",
+ "kind": "file"
+ },
+ {
+ "repo": "pulse",
+ "path": "frontend-modern/src/components/Alerts/incidentAssistantHandoffModel.ts",
+ "kind": "file"
+ },
+ {
+ "repo": "pulse",
+ "path": "frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts",
+ "kind": "file"
+ },
+ {
+ "repo": "pulse",
+ "path": "frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts",
+ "kind": "file"
+ },
+ {
+ "repo": "pulse",
+ "path": "frontend-modern/src/stores/__tests__/aiChat.test.ts",
+ "kind": "file"
+ },
+ {
+ "repo": "pulse",
+ "path": "frontend-modern/src/stores/aiChat.ts",
+ "kind": "file"
+ },
+ {
+ "repo": "pulse",
+ "path": "frontend-modern/src/utils/__tests__/aiChatPresentation.test.ts",
+ "kind": "file"
+ },
{
"repo": "pulse",
"path": "frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts",
"kind": "file"
},
+ {
+ "repo": "pulse",
+ "path": "frontend-modern/src/utils/aiChatPresentation.ts",
+ "kind": "file"
+ },
{
"repo": "pulse",
"path": "internal/ai/chat/agentic.go",
@@ -3164,6 +3229,21 @@
"path": "internal/ai/tools/tools_read_test.go",
"kind": "file"
},
+ {
+ "repo": "pulse",
+ "path": "internal/ai/unified/alerts.go",
+ "kind": "file"
+ },
+ {
+ "repo": "pulse",
+ "path": "internal/api/ai_handler.go",
+ "kind": "file"
+ },
+ {
+ "repo": "pulse",
+ "path": "internal/api/ai_handler_test.go",
+ "kind": "file"
+ },
{
"repo": "pulse",
"path": "internal/api/contract_test.go",
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index cb388dcd89..7e7e02c47f 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -1420,6 +1420,10 @@ lifecycle-adjacent surfaces may treat those references as AI/runtime
explanation context only, and must not reinterpret them as agent readiness,
install status, command reachability, enrollment health, fleet execution
authority, or agent command grants.
+Those handoffs must remain context-only for the configured model. Lifecycle
+code must not convert alert, incident, or Patrol Assistant handoffs into
+pre-filled prompts, suggested prompt chips, required tool routes, or agent
+lifecycle next-step instructions.
That same shared `internal/api/` dependency also now assumes SSO test and
metadata-preview routes fail closed on validated outbound URL handling.
Lifecycle-adjacent setup and hosted bootstrap surfaces may depend on those
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index ce8bf4afe3..dff8b0e9dc 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -91,12 +91,13 @@ runtime cost control, and shared AI transport surfaces.
and meaningful badge text rather than icon title duplication. Scoped
approval handoffs sourced from Patrol, active alerts, or alert incident
timelines must render as source-named investigation handoffs in the drawer
- instead of generic dashboard briefs. Source-owned handoff helpers may retain
- bounded prompt and action metadata for model/request context, but the drawer
+ instead of generic dashboard briefs. Source-owned handoff helpers may attach
+ bounded model-only context, resources, action references, and metadata, but
+ they must not synthesize, prefill, or auto-submit a user prompt. The drawer
presentation must stay compact: source, status, one primary subject, and an
optional safe route link. It must not render Patrol-authored remediation
- steps, evidence chips, command summaries, or suggested-prompt chips as the
- answer. Patrol assessment handoffs must use the same
+ steps, evidence chips, command summaries, recommendations, or suggested-prompt
+ chips as the answer. Patrol assessment handoffs must use the same
`patrol-assessment` target identity for live opens and restored sessions
rather than inheriting retired dashboard context. While such a handoff is
attached, the Assistant empty
@@ -277,10 +278,11 @@ runtime cost control, and shared AI transport surfaces.
AI investigation. The unified-store update paths
(`UnifiedStore.AddFromAlert` and `UnifiedStore.AddFromAI`) must
propagate Impact on re-detected findings the same way they propagate
- Description and Recommendation: AddFromAlert backfills empty Impact
- on existing findings; AddFromAI overwrites existing Impact when the
- incoming finding carries one. Unknown alert types must return an
- empty impact rather than synthesizing generic copy.
+ Description: AddFromAlert backfills empty Impact on existing findings;
+ AddFromAI overwrites existing Impact when the incoming finding carries
+ one. Threshold-alert conversion must not synthesize remediation
+ recommendations; unknown alert types must return an empty impact rather
+ than synthesizing generic copy.
Investigation-record `Rollback` is sourced from the canonical
`RemediationPlan` when one exists for the finding:
`AggregatePlanRollbackSteps` in
diff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.md
index 1be49b7c5e..b8b49974f8 100644
--- a/docs/release-control/v6/internal/subsystems/alerts.md
+++ b/docs/release-control/v6/internal/subsystems/alerts.md
@@ -111,9 +111,10 @@ operator-facing alert routing behavior for live runtime alerts.
`frontend-modern/src/components/Alerts/alertAssistantHandoffModel.ts`;
these handoffs must preserve alert context, force request-scoped approval
mode, send bounded model-only handoff context plus structured resource
- references through the shared Assistant chat transport, and render a visible
+ references through the shared Assistant chat transport, and render a compact
Alerts-owned briefing in the Assistant drawer without transferring raw
- command payloads.
+ command payloads or synthesizing, pre-filling, or auto-submitting a chat
+ prompt.
8. Add or change Pulse Assistant incident timeline handoffs through
`frontend-modern/src/components/Alerts/IncidentAssistantHandoffButton.tsx`
and `frontend-modern/src/components/Alerts/incidentAssistantHandoffModel.ts`;
@@ -121,7 +122,10 @@ operator-facing alert routing behavior for live runtime alerts.
summaries, force request-scoped approval mode, send the same sanitized facts
as model-only handoff context plus structured resource references through
the shared Assistant chat transport, and keep raw command/output details in
- the incident or approval surface rather than the chat handoff.
+ the incident or approval surface rather than the chat handoff. Incident
+ handoffs must not add suggested prompt chips or route-owned remediation
+ instructions; the configured model owns investigation and next-step
+ reasoning after it receives the context.
## Forbidden Paths
@@ -375,9 +379,9 @@ show Pro-required tooltip copy, track upgrade clicks, or open the commercial
handoff route.
Unlocked alert-investigation Assistant handoffs are contextual explanation and
triage entries, not autonomous execution grants. `InvestigateAlertButton.tsx`
-must pass `autonomousMode: false` when it opens Pulse Assistant, and the seeded
-prompt may ask for root-cause analysis, metrics checks, and remediation advice
-only if command or change execution remains explicitly approval-bound. The
+must pass `autonomousMode: false` when it opens Pulse Assistant, and it must
+open the drawer with context only rather than seeding a product-authored prompt
+or choosing a diagnostic/remediation route. The
visible drawer briefing for that same handoff is Alerts-owned presentation
context: alert identifier, severity, metric, resource, threshold, duration,
node label, and message may be shown, while raw diagnostic or remediation
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index d08649f475..ecd2d3f424 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -396,8 +396,8 @@ the canonical monitored-system blocked payload.
request/expiry timestamps, action plan identity and expiry, safe generated
approval summaries, command counts, and fix/action references, never the
approval command payload. Patrol
- remediation-plan handoffs must use the same boundary for frontend-authored
- prompts: plan status, risk, step labels, and command counts are allowed,
+ remediation-plan handoffs must use the same boundary for model-only
+ context: plan status, risk, step labels, and command counts are allowed,
while raw command and rollback command payloads remain in governed action
surfaces. Frontend Patrol finding-discussion handoffs must force a
request-local approval-required Assistant mode instead of inheriting the
@@ -581,12 +581,12 @@ the canonical monitored-system blocked payload.
and that same Patrol investigation-context owner, so coverage signals from
the canonical AI summary remain secondary caveats when the same assessment
carries active findings, pending approvals, or governed action references;
- Assistant prompt emphasis, briefing action labels, and safety notes must
+ Assistant context, briefing action labels, and safety notes must
carry finding priority, affected resources, evidence, and governed approval
posture as context instead of recasting the whole handoff as a coverage gap
and that same Patrol investigation-context owner, so coverage-incomplete
assessments with no active infrastructure findings are serialized as a
- verification-gap handoff: prompt and visible briefing copy must explain what
+ verification-gap handoff: model-only context and visible briefing copy must explain what
scoped activity did and did not prove, keep latest-run and supporting-context
facts model-only, and leave next-step selection to the configured LLM
handoff-only metadata, and avoid introducing backend fields beyond the
@@ -596,10 +596,10 @@ the canonical monitored-system blocked payload.
operator context: approval ID, status, risk, requested/expiry timestamps,
target label, generated approval summary, and command count are allowed, while
approval command payloads stay inside governed approval/remediation surfaces,
- and finding-level first-turn prompt emphasis may be derived from the same
- bounded metadata only so Assistant starts by reviewing approval status, risk,
- dry-run posture, proposed-fix posture, and safest next step without receiving
- raw command or execution payloads; finding-level handoffs may also send one
+ and finding-level handoff context may be derived from the same
+ bounded metadata only so Assistant receives approval status, risk,
+ dry-run posture, and proposed-fix posture without Pulse choosing the next
+ step or receiving raw command/execution payloads; finding-level handoffs may also send one
bounded model-only `handoff_context`, one `handoff_resources` target
reference, and one `handoff_actions` entry for that governed approval or
proposed fix so the Assistant runtime can refresh finding and action posture
@@ -2616,9 +2616,10 @@ reason, route-action facts, or prompt chips; the configured model owns those
decisions from the structured handoff metadata and bounded chat context.
Frontend handoff builders may send these fields for owned alert, incident,
Patrol assessment, Patrol finding, or Patrol run-history context, but the
-backend must not
-persist them as user-authored message text and must treat them as
-explanation/review context only. When a Patrol `finding_id` resolves,
+backend must not persist them as user-authored message text, and the frontend
+must not prefill or auto-submit a product-authored user prompt from them. They
+are context only and must be treated as explanation/review context only. When a
+Patrol `finding_id` resolves,
backend-refreshed durable finding context remains canonical; the handler may
merge only recognized same-finding Patrol product handoff text and same-finding
resource/action references as secondary model-only review context, while
@@ -3806,9 +3807,11 @@ The `/api/ai/chat` finding handoff contract must also include a model-only
investigation record before detailed `[Finding Context]`. The briefing is the
canonical operator-facing frame for Assistant: it carries the finding summary,
resource, priority, current attention reason, current recency facts, bounded
-evidence and verification summaries, investigation confidence, recommended next
-step, and operator-decision framing plus approval/proposed-fix posture without
-raw command text. That approval/proposed-fix posture must come from the same
+evidence and verification summaries, investigation confidence, and
+operator-decision framing plus approval/proposed-fix posture without raw command
+text. It must not include a Pulse-authored recommended next step. Any recorded
+action note from a durable investigation record is context, not remediation
+guidance. That approval/proposed-fix posture must come from the same
structured action reference sent to chat execution, including any recovered live
Patrol approval, so visible and model-only handoffs stay consistent. Patrol's
frontend Assistant drawer briefing must use that same operator frame for
@@ -3822,14 +3825,13 @@ approval list payloads only as safe metadata for that visible briefing and any
structured `handoff_actions`: approval ID, status, risk, request/expiry
timestamps, target label, requester identity, action ID, approval policy,
plan expiry, and dry-run summary are allowed. Assessment-level visible
- briefings may reuse that same
- safe metadata for action labels, safety notes, and approval-aware suggested
- prompts, while approval command text remains inside the governed
- approval/remediation surface.
-Patrol approval-row Assistant prompts must use the same safe metadata boundary
+ briefings may reuse that same safe metadata for action labels and safety notes,
+ while approval command text remains inside the governed approval/remediation
+ surface.
+Patrol approval-row Assistant handoffs must use the same safe metadata boundary
and set `autonomousMode:false` for the request-local chat handoff; they must not
-paste raw approval or proposed-fix command text into the authored chat prompt.
-Patrol remediation-plan or action-artifact Assistant prompts must pass only safe
+paste raw approval or proposed-fix command text into a chat prompt.
+Patrol remediation-plan or action-artifact Assistant handoffs must pass only safe
status, risk, description, and command-count posture as non-authoritative context
for the configured LLM to critique; raw plan command and rollback command
payloads remain owned by the governed remediation/action APIs and panels. The
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index e88f709b2f..753b10a868 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -195,7 +195,7 @@ work extends shared components instead of creating new local variants.
must remain visibly sourced to Pulse Patrol, restore a `patrol-run` target
plus run ID/type/status/runtime-failure presentation only, and must not
rehydrate model-only runtime failure detail into browser context. New Patrol
- run requests follow the same drawer boundary: source-owned prompt text and
+ run requests follow the same drawer boundary: source-owned context and
briefing copy may show classified, redacted failure summaries for operator
review, but `handoffContext`, `handoffResources`, and `handoffActions` for
run-history context must stay absent from the browser request so the backend
@@ -242,13 +242,12 @@ Patrol's primary assessment strip is descriptive only; it must not render a
Patrol-authored recommended next step, suggested prompt chips, or a secondary
action band inside the assessment shell. If the same assessment opens
Assistant, the Patrol-to-Assistant handoff must carry only bounded evidence,
-resource references, and governed approval/action posture as model-only context.
-recommendation as safe bounded metadata so the drawer briefing and first-turn
-prompt explain the same operator-facing priority. Feature-owned Assistant
-handoff prompts may provide source context and safe metadata, but the shared
-drawer boundary must not turn those prompts into frontend-authored tool routes
-or remediation plans; the configured model owns tool choice and diagnostic
-reasoning after the request reaches the AI runtime.
+resource references, and governed approval/action posture as model-only
+context. Feature-owned Assistant handoffs may provide source context and safe
+metadata, but the shared drawer boundary must not turn those handoffs into
+frontend-authored prompts, tool routes, or remediation plans; the configured
+model owns tool choice and diagnostic reasoning after the request reaches the
+AI runtime.
1. Add shared primitives in `frontend-modern/src/components/shared/`
Framed product table surfaces must consume the shared `TableCard` frame and
@@ -1003,18 +1002,15 @@ reasoning after the request reaches the AI runtime.
than guessing a model in the modal.
Scoped Assistant handoffs must keep request-local execution overrides in
drawer context. Dashboard and other route-owned entry points may open the
- Assistant drawer with a pre-filled prompt, context, and
- `autonomousMode:false`, but they must not mutate persistent AI control-level
+ Assistant drawer with source context and `autonomousMode:false`, but they
+ must not pre-fill or auto-submit a prompt, mutate persistent AI control-level
settings or trigger background Assistant settings/model bootstrap before
the drawer is open. Patrol finding handoffs that add structured
- investigation-record framing must derive that prompt copy through
+ investigation-record framing must derive that context through
`frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts`
so shared drawer primitives stay shell-owned rather than becoming a
- Patrol-specific prompt formatter. The Patrol-owned helper exposes a
- `PatrolAssistantFindingIntent` parameter ('discuss' | 'explain') so
- contextual entry points can vary the seeded leading sentence without
- duplicating the structured-context attachment; shared drawer
- primitives must not branch on intent themselves. Patrol-page
+ Patrol-specific diagnosis formatter; shared drawer primitives must not
+ branch on intent themselves. Patrol-page
surfaces must not add standalone trust strips to shared header or
workspace chrome; high-signal trust facts may feed the Patrol-owned
assessment readout, but shared drawer/chrome primitives stay free of
@@ -3169,8 +3165,9 @@ that plain settings routes render without assistant bootstrap traffic or
console noise.
When an owned Patrol or alert surface attaches a source-named Assistant
handoff, that same drawer shell must keep the empty conversation state aligned
-with the attached briefing instead of rendering generic cluster/system starter
-prompts below the source-owned context.
+with the attached briefing as neutral `Context attached` copy instead of
+rendering generic cluster/system starter prompts or feature-authored suggested
+prompt chips below the source-owned context.
Shared table, disclosure, and form primitives must also stay explicitly typed
at the browser edge. Summary rows may memoize repeated pending-update reads,
shared buttons must preserve discriminated disclosure props, toggle and a11y
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index 5b79e7e6cd..b7a90a7458 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -135,7 +135,7 @@ Patrol-specific presentation helpers.
8. Keep the Patrol store aligned with the shared structured investigation
record when transport carries one. `frontend-modern/src/stores/aiIntelligence.ts`
may retain `investigationRecord` as data for Assistant handoff and Patrol
- presentation, but visible Patrol copy and Assistant handoff prompt framing
+ presentation, but visible Patrol copy and Assistant handoff context
must flow through the governed Patrol investigation-context helpers. Those
helpers also own the Assistant drawer briefing content for Patrol records,
including the rule that proposed-fix commands are summarized by count only
@@ -181,10 +181,11 @@ Patrol-specific presentation helpers.
governed approval/action posture instead of behaving like a generic chat over
a pasted incident dump. Patrol is the scheduled
probe, context assembler, and execution-governance owner; the configured LLM
- is the diagnostic and remediation-reasoning owner. Patrol handoff prompts may
+ is the diagnostic and remediation-reasoning owner. Patrol handoffs may
provide system context, resource posture, action posture, and governed tools,
- but must not force active tool use, name a required tool path, or present a
- Patrol-authored remediation answer for the LLM to execute. Patrol
+ but must not synthesize, pre-fill, or auto-submit chat prompts, force active
+ tool use, name a required tool path, show suggested prompt chips, or present
+ a Patrol-authored remediation answer for the LLM to execute. Patrol
runs must still call the configured model when deterministic triage is quiet,
and unmatched deterministic signals may be returned as context for another
model pass but must not be converted into Pulse-authored findings after the
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 5cacbd2e4e..f6858c9857 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -1339,7 +1339,9 @@ including safe approval status, request/expiry timestamps, action plan identity,
approval policy, plan expiry, and dry-run posture, but they must not reinterpret
a recovered approval or clearer proposed-fix posture as backup freshness,
restore authority, recovery proof, or storage-local remediation execution
-state.
+state. Those handoffs must remain context-only for the configured model and
+must not be converted by storage/recovery code into pre-filled prompts,
+suggested prompt chips, or recovery-owned next-step instructions.
Patrol run `handoff_metadata` retained for saved Assistant sessions is also
AI/runtime review identity only. Storage and recovery may display or link from
the safe run ID, run type/status, runtime-failure flag, or scoped resource label
@@ -1350,7 +1352,8 @@ non-empty `finding_id` follow the same adjacent API boundary: storage and
recovery may treat the resulting Assistant session as incident context, but
must not reinterpret the finding ID or approval-required chat mode as backup
freshness, restore authorization, storage remediation permission, or recovery
-transport state.
+transport state, and must not treat the context-only handoff as a
+storage/recovery-authored diagnostic prompt.
Patrol queued-fix approvals that seed shared action-audit records follow the
same rule: storage and recovery may display the resulting action history as
incident-adjacent context, including the requester identity that distinguishes
diff --git a/frontend-modern/src/components/AI/Chat/ChatMessages.tsx b/frontend-modern/src/components/AI/Chat/ChatMessages.tsx
index 0614c4a70e..7e17a335ad 100644
--- a/frontend-modern/src/components/AI/Chat/ChatMessages.tsx
+++ b/frontend-modern/src/components/AI/Chat/ChatMessages.tsx
@@ -2,7 +2,6 @@ import { Component, Show, For, createEffect, createMemo } from 'solid-js';
import { MessageItem } from './MessageItem';
import type { ChatSession } from '@/api/aiChat';
import type { ChatMessage, PendingApproval, PendingQuestion } from './types';
-import { AI_CHAT_SUGGESTIONS_LABEL } from '@/utils/aiChatPresentation';
interface ChatMessagesProps {
messages: ChatMessage[];
@@ -20,8 +19,6 @@ interface ChatMessagesProps {
emptyState?: {
title: string;
subtitle?: string;
- suggestions?: string[];
- onSuggestionClick?: (suggestion: string) => void;
};
}
@@ -30,7 +27,7 @@ interface ChatMessagesProps {
*
* Features:
* - Auto-scroll to bottom on new messages
- * - Empty state with suggestions
+ * - Empty state
* - Smooth scrolling behavior
*/
export const ChatMessages: Component<ChatMessagesProps> = (props) => {
@@ -78,31 +75,8 @@ export const ChatMessages: Component<ChatMessagesProps> = (props) => {
<div class="flex flex-col items-center justify-center min-h-full text-center py-8">
<h3 class="text-base font-semibold text-base-content mb-3">{props.emptyState!.title}</h3>
<Show when={props.emptyState!.subtitle}>
- <p class="text-sm text-muted max-w-xs mb-6">{props.emptyState!.subtitle}</p>
+ <p class="text-sm text-muted max-w-xs">{props.emptyState!.subtitle}</p>
</Show>
-
- <div class="w-full max-w-xs space-y-6">
- {/* Suggestions */}
- <Show when={props.emptyState!.suggestions && props.emptyState!.suggestions!.length > 0}>
- <div class="space-y-2">
- <div class="text-xs font-medium text-muted text-left uppercase tracking-wider pl-1">
- {AI_CHAT_SUGGESTIONS_LABEL}
- </div>
- <For each={props.emptyState!.suggestions}>
- {(suggestion) => (
- <button
- type="button"
- onClick={() => props.emptyState!.onSuggestionClick?.(suggestion)}
- class="w-full text-left px-4 py-2.5 rounded-md bg-surface-alt text-base-content text-sm hover:bg-surface-hover transition-colors border border-transparent hover:border-border"
- >
- <span class="text-blue-500 dark:text-blue-400 mr-2">→</span>
- {suggestion}
- </button>
- )}
- </For>
- </div>
- </Show>
- </div>
</div>
</Show>
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
index 2e61823d45..fa73d17ded 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
@@ -73,7 +73,6 @@ const {
};
const emptyChatContext = () => ({
- initialPrompt: undefined,
findingId: undefined,
autonomousMode: undefined,
context: undefined,
@@ -86,7 +85,6 @@ const {
const mockAiChatStore = {
isOpenSignal: vi.fn(() => true),
context: emptyChatContext() as {
- initialPrompt?: string;
findingId?: string;
autonomousMode?: boolean;
context?: Record<string, unknown>;
@@ -112,7 +110,6 @@ const {
actionLabel?: string;
commandSummary?: string;
safetyNote?: string;
- suggestedPrompts?: string[];
actionHref?: string;
};
},
@@ -122,7 +119,6 @@ const {
clearContext: vi.fn(() => {
mockAiChatStore.context = emptyChatContext();
}),
- clearInitialPrompt: vi.fn(),
clearFindingId: vi.fn(() => {
const { findingId: _findingId, ...rest } = mockAiChatStore.context;
mockAiChatStore.context = rest;
@@ -163,11 +159,17 @@ vi.mock('../hooks/useChat', () => ({
}));
vi.mock('../ChatMessages', () => ({
- ChatMessages: (props: { messages: ChatMessage[]; emptyState?: { title: string } }) => (
+ ChatMessages: (props: {
+ messages: ChatMessage[];
+ emptyState?: { title: string; subtitle?: string };
+ }) => (
<div data-testid="chat-messages" data-msg-count={props.messages.length}>
{props.emptyState?.title && (
<span data-testid="empty-state-title">{props.emptyState.title}</span>
)}
+ {props.emptyState?.subtitle && (
+ <span data-testid="empty-state-subtitle">{props.emptyState.subtitle}</span>
+ )}
</div>
),
}));
@@ -275,7 +277,6 @@ beforeEach(() => {
resetAIRuntimeState();
mockAiChatStore.isOpenSignal.mockReturnValue(true);
mockAiChatStore.context = {
- initialPrompt: undefined,
findingId: undefined,
autonomousMode: undefined,
briefing: undefined,
@@ -338,7 +339,6 @@ describe('AIChat', () => {
it('renders attached context briefing without raw command text', () => {
mockAiChatStore.context = {
- initialPrompt: undefined,
findingId: 'finding-1',
autonomousMode: undefined,
briefing: {
@@ -351,7 +351,6 @@ 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'],
},
};
@@ -370,7 +369,6 @@ describe('AIChat', () => {
it('renders safe briefing actions as links when a route is attached', () => {
mockAiChatStore.context = {
- initialPrompt: undefined,
autonomousMode: false,
briefing: {
sourceLabel: 'Pulse Patrol',
@@ -391,7 +389,6 @@ describe('AIChat', () => {
it('keeps Patrol action-artifact briefings compact in the sidebar', () => {
mockAiChatStore.context = {
- initialPrompt: undefined,
autonomousMode: false,
briefing: {
sourceLabel: 'Pulse Patrol',
@@ -430,7 +427,6 @@ describe('AIChat', () => {
it('does not expose legacy Patrol remediation-plan briefing internals', () => {
mockAiChatStore.context = {
- initialPrompt: undefined,
autonomousMode: false,
briefing: {
sourceLabel: 'Pulse Patrol',
@@ -442,10 +438,6 @@ describe('AIChat', () => {
actionLabel: 'Fix: Backup failed',
commandSummary: '4 commands recorded for approval context',
safetyNote: 'Command details stay in governed remediation context.',
- suggestedPrompts: [
- 'Review plan risk and prerequisites',
- 'Check rollback and verification steps',
- ],
},
};
@@ -468,24 +460,22 @@ describe('AIChat', () => {
).not.toBeInTheDocument();
});
- it('uses Patrol briefing context instead of generic empty-state suggestions', () => {
+ it('uses attached briefing context instead of product-authored empty-state prompts', () => {
mockAiChatStore.context = {
- initialPrompt: undefined,
autonomousMode: false,
briefing: {
sourceLabel: 'Pulse Patrol',
title: 'Patrol assessment attached',
subject: 'Coverage incomplete',
- suggestedPrompts: [
- 'Explain why coverage is incomplete',
- 'Explain scoped activity and full-run gap',
- ],
},
};
renderChat();
- expect(screen.getByText('Review Pulse Patrol context')).toBeInTheDocument();
+ expect(screen.getByText('Context attached')).toBeInTheDocument();
+ expect(
+ screen.getByText('Pulse Patrol · Patrol assessment attached · Coverage incomplete'),
+ ).toBeInTheDocument();
expect(
screen.queryByRole('button', { name: 'Explain why coverage is incomplete' }),
).not.toBeInTheDocument();
@@ -1703,7 +1693,6 @@ describe('AIChat', () => {
discovery_enabled: true,
});
mockAiChatStore.context = {
- initialPrompt: undefined,
findingId: undefined,
autonomousMode: false,
briefing: undefined,
@@ -1740,7 +1729,6 @@ describe('AIChat', () => {
discovery_enabled: true,
});
mockAiChatStore.context = {
- initialPrompt: undefined,
findingId: 'finding-1',
autonomousMode: false,
briefing: {
@@ -1772,7 +1760,6 @@ describe('AIChat', () => {
discovery_enabled: true,
});
mockAiChatStore.context = {
- initialPrompt: undefined,
autonomousMode: false,
briefing: {
sourceLabel: 'Pulse Alerts',
@@ -1806,7 +1793,6 @@ describe('AIChat', () => {
discovery_enabled: true,
});
mockAiChatStore.context = {
- initialPrompt: undefined,
autonomousMode: false,
handoffContext:
'[Alert Incident Context]\nIncident ID: incident-1\nTimeline Event 1: Command event recorded',
@@ -1873,7 +1859,6 @@ describe('AIChat', () => {
discovery_enabled: true,
});
mockAiChatStore.context = {
- initialPrompt: undefined,
findingId: 'finding-1',
autonomousMode: false,
handoffContext: '[Patrol Finding Context]\nFinding ID: finding-1',
@@ -2014,7 +1999,6 @@ describe('AIChat', () => {
describe('finding ID context', () => {
it('passes findingId from store context on first message', () => {
mockAiChatStore.context = {
- initialPrompt: undefined,
findingId: 'finding-123',
autonomousMode: undefined,
briefing: undefined,
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/ChatMessages.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/ChatMessages.test.tsx
index d38d636784..c033012462 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/ChatMessages.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/ChatMessages.test.tsx
@@ -1,5 +1,5 @@
import { describe, expect, it, vi, afterEach, beforeEach } from 'vitest';
-import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
+import { cleanup, render, screen } from '@solidjs/testing-library';
import { ChatMessages } from '../ChatMessages';
import type { ChatMessage, PendingApproval, PendingQuestion } from '../types';
@@ -100,89 +100,6 @@ describe('ChatMessages', () => {
expect(screen.queryByText('Ask me anything')).not.toBeInTheDocument();
});
- it('renders suggestion buttons when suggestions provided', () => {
- render(() => (
- <ChatMessages
- messages={[]}
- {...makeHandlers()}
- emptyState={{
- title: 'Welcome',
- suggestions: ['Show disk usage', 'Check CPU load'],
- }}
- />
- ));
-
- expect(screen.getByText('Show disk usage')).toBeInTheDocument();
- expect(screen.getByText('Check CPU load')).toBeInTheDocument();
- });
-
- it('calls onSuggestionClick when a suggestion is clicked', () => {
- const onSuggestionClick = vi.fn();
- render(() => (
- <ChatMessages
- messages={[]}
- {...makeHandlers()}
- emptyState={{
- title: 'Welcome',
- suggestions: ['Show disk usage', 'Check CPU load'],
- onSuggestionClick,
- }}
- />
- ));
-
- fireEvent.click(screen.getByText('Show disk usage'));
- expect(onSuggestionClick).toHaveBeenCalledWith('Show disk usage');
- expect(onSuggestionClick).toHaveBeenCalledTimes(1);
- });
-
- it('calls onSuggestionClick with the correct suggestion text', () => {
- const onSuggestionClick = vi.fn();
- render(() => (
- <ChatMessages
- messages={[]}
- {...makeHandlers()}
- emptyState={{
- title: 'Welcome',
- suggestions: ['Show disk usage', 'Check CPU load'],
- onSuggestionClick,
- }}
- />
- ));
-
- fireEvent.click(screen.getByText('Check CPU load'));
- expect(onSuggestionClick).toHaveBeenCalledWith('Check CPU load');
- });
-
- it('does not render suggestions section when suggestions array is empty', () => {
- render(() => (
- <ChatMessages
- messages={[]}
- {...makeHandlers()}
- emptyState={{
- title: 'Welcome',
- suggestions: [],
- }}
- />
- ));
-
- expect(screen.queryByText('Try asking')).not.toBeInTheDocument();
- });
-
- it('renders "Try asking" label when suggestions exist', () => {
- render(() => (
- <ChatMessages
- messages={[]}
- {...makeHandlers()}
- emptyState={{
- title: 'Welcome',
- suggestions: ['Check nodes'],
- }}
- />
- ));
-
- expect(screen.getByText('Try asking')).toBeInTheDocument();
- });
-
it('does not show empty state when there are messages', () => {
render(() => (
<ChatMessages
@@ -201,30 +118,6 @@ describe('ChatMessages', () => {
expect(screen.queryByText('Welcome')).not.toBeInTheDocument();
expect(screen.queryByText('Try asking')).not.toBeInTheDocument();
});
-
- it('each suggestion button is individually clickable', () => {
- const onSuggestionClick = vi.fn();
- render(() => (
- <ChatMessages
- messages={[]}
- {...makeHandlers()}
- emptyState={{
- title: 'Welcome',
- suggestions: ['A', 'B', 'C'],
- onSuggestionClick,
- }}
- />
- ));
-
- fireEvent.click(screen.getByText('A'));
- fireEvent.click(screen.getByText('B'));
- fireEvent.click(screen.getByText('C'));
-
- expect(onSuggestionClick).toHaveBeenCalledTimes(3);
- expect(onSuggestionClick).toHaveBeenNthCalledWith(1, 'A');
- expect(onSuggestionClick).toHaveBeenNthCalledWith(2, 'B');
- expect(onSuggestionClick).toHaveBeenNthCalledWith(3, 'C');
- });
});
describe('message rendering', () => {
diff --git a/frontend-modern/src/components/AI/Chat/index.tsx b/frontend-modern/src/components/AI/Chat/index.tsx
index 1121a3a390..b4ee124eee 100644
--- a/frontend-modern/src/components/AI/Chat/index.tsx
+++ b/frontend-modern/src/components/AI/Chat/index.tsx
@@ -266,9 +266,6 @@ const buildSessionHandoffContext = (session?: ChatSession): AIChatContext | unde
: actionCount > 0
? 'Detailed command payloads stay in governed approval context.'
: undefined,
- suggestedPrompts: isPatrolSessionHandoff(summary)
- ? []
- : ['Summarize this handoff', 'What needs attention?', 'What should I verify next?'],
},
};
};
@@ -500,34 +497,6 @@ export const AIChat: Component<AIChatProps> = (props) => {
}
};
- // Pre-fill input when opened with an initialPrompt (e.g., "Discuss with
- // Assistant" from findings). When autoSendInitialPrompt is true,
- // immediately submit instead of waiting for the operator to press Enter
- // — used by action-style entry points like "Explain" where clicking the
- // button is itself the operator's decision to invoke the action.
- createEffect(() => {
- const ctx = aiChatStore.context;
- if (ctx.initialPrompt && isOpen()) {
- const promptToSend = ctx.initialPrompt;
- const shouldAutoSend = Boolean(ctx.autoSendInitialPrompt);
- setInput(promptToSend);
- // Clear flags so they don't re-fire on subsequent opens
- aiChatStore.clearInitialPrompt?.();
- aiChatStore.clearAutoSendFlag?.();
- if (shouldAutoSend) {
- // Defer to the next tick so the input signal has propagated to
- // handleSubmit's `input()` read, and so the drawer mount /
- // session-load effects can settle. handleSubmit itself guards
- // against empty prompts and against double-firing while a chat
- // is in flight, so this is safe.
- queueMicrotask(() => {
- if (!isOpen()) return;
- handleSubmit();
- });
- }
- }
- });
-
const contextBriefing = createMemo(() => aiChatStore.context.briefing);
const hasScopedApprovalHandoff = createMemo(() => aiChatStore.context.autonomousMode === false);
const controlPresentation = createMemo(() =>
@@ -1538,8 +1507,6 @@ export const AIChat: Component<AIChatProps> = (props) => {
emptyState={{
title: emptyStatePresentation().title,
subtitle: emptyStatePresentation().subtitle,
- suggestions: emptyStatePresentation().suggestions,
- onSuggestionClick: (s) => setInput(s),
}}
/>
diff --git a/frontend-modern/src/components/AI/FindingsPanel.tsx b/frontend-modern/src/components/AI/FindingsPanel.tsx
index e13b093c0a..158bf37954 100644
--- a/frontend-modern/src/components/AI/FindingsPanel.tsx
+++ b/frontend-modern/src/components/AI/FindingsPanel.tsx
@@ -23,7 +23,6 @@ import {
buildPatrolAssistantProposedFixBriefingInput,
buildPatrolRemediationPlanAssistantBriefing,
buildPatrolRemediationPlanAssistantModelContext,
- buildPatrolRemediationPlanAssistantPrompt,
patrolAssistantFindingHandoffRequiresApprovalMode,
type PatrolAssistantApprovalBriefingInput,
type PatrolAssistantProposedFixBriefingInput,
@@ -65,7 +64,6 @@ import {
getFindingSubjectPresentation,
getFindingTitlePresentation,
getFindingRecencyPresentation,
- findingHasAppliedFix,
hasFindingInvestigationDetails,
hasFindingInvestigationHandoffPointer,
getInvestigationConfidenceBadgeClasses,
@@ -103,31 +101,13 @@ interface FindingsPanelProps {
>;
}
-type FindingAssistantIntent = 'discuss' | 'explain' | 'investigate' | 'why' | 'verify_fix';
-
-function getPrimaryAssistantFindingAction(finding: UnifiedFinding): {
- intent: FindingAssistantIntent;
+function getPrimaryAssistantFindingAction(_finding: UnifiedFinding): {
label: string;
title: string;
} {
- if (findingHasAppliedFix(finding) && finding.status === 'active') {
- return {
- intent: 'verify_fix',
- label: 'Verify fix',
- title: 'Ask Pulse Assistant to verify whether the applied fix cleared the condition',
- };
- }
- if (finding.status === 'active') {
- return {
- intent: 'investigate',
- label: 'Investigate',
- title: 'Ask Pulse Assistant to investigate this finding with the attached evidence',
- };
- }
return {
- intent: 'explain',
- label: 'Explain',
- title: 'Ask Pulse Assistant to explain what happened and why it matters',
+ label: 'Open in Assistant',
+ title: 'Open Pulse Assistant with this finding attached',
};
}
@@ -623,10 +603,7 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
}
};
- const openFindingInAssistant = async (
- finding: UnifiedFinding,
- intent: FindingAssistantIntent,
- ) => {
+ const openFindingInAssistant = async (finding: UnifiedFinding) => {
await aiIntelligenceStore.loadPendingApprovals();
const subject = getFindingSubjectPresentation(finding).label;
const title = getFindingTitlePresentation(finding).label;
@@ -662,70 +639,10 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
pendingApproval: pendingApprovalBriefing,
proposedFix,
investigationRecord: finding.investigationRecord,
- intent,
- });
- // Explain, Investigate, and Why-did-this-happen are action-style
- // entry points — clicking the button is the operator asking "do this
- // for me," not "open chat so I can type a question." Auto-submit the
- // handoff prompt so the work is already in flight when the drawer is
- // on screen. Discuss with Assistant keeps the previous behaviour
- // (pre-fill, operator drives) because that entry is open-ended by
- // intent.
- aiChatStore.openWithPrompt(handoff.prompt, {
- ...handoff.context,
- autoSendInitialPrompt:
- intent === 'explain' ||
- intent === 'investigate' ||
- intent === 'why' ||
- intent === 'verify_fix',
});
+ aiChatStore.open(handoff.context);
};
- const handleDiscussWithAssistant = async (finding: UnifiedFinding, e: Event) => {
- e.stopPropagation();
- await openFindingInAssistant(finding, 'discuss');
- };
-
- const handleExplainFinding = async (finding: UnifiedFinding, e: Event) => {
- e.stopPropagation();
- await openFindingInAssistant(finding, 'explain');
- };
-
- // Investigate is the active counterpart to Explain. Explain says "tell me
- // what we already know"; Investigate says "go find out what's true right
- // now." The prompt instructs the LLM to use its Pulse tools (metrics,
- // alerts, state, recent changes, correlations) rather than just narrate
- // the attached context, and the surface auto-sends so the work is in
- // flight when the operator lands.
- const handleInvestigateFinding = async (finding: UnifiedFinding, e: Event) => {
- e.stopPropagation();
- await openFindingInAssistant(finding, 'investigate');
- };
-
- // Why is the diagnostic counterpart. Where Explain says "what we know"
- // and Investigate says "what's true now," Why says "what caused this":
- // the prompt focuses the LLM on recent changes around detection time,
- // learned correlations, prior incidents, and regression history rather
- // than current state.
- const handleWhyFinding = async (finding: UnifiedFinding, e: Event) => {
- e.stopPropagation();
- await openFindingInAssistant(finding, 'why');
- };
-
- // Verify fix is the post-remediation check. After a fix has been
- // executed against this finding, the operator asks the Assistant
- // whether it actually worked — confirming the underlying condition
- // cleared rather than trusting the fix command's exit code. Only
- // meaningful when a fix has been applied (see hasAppliedFix).
- const handleVerifyFixFinding = async (finding: UnifiedFinding, e: Event) => {
- e.stopPropagation();
- await openFindingInAssistant(finding, 'verify_fix');
- };
-
- // hasAppliedFix logic lives in @/utils/aiFindingPresentation as
- // findingHasAppliedFix so the investigation-outcome switch stays in a
- // shared adapter (per the resource-type-boundaries test).
-
// Create rule from this is the promotion path: take the operator's
// implicit pattern (silencing the same {resource, category} pair
// repeatedly) and turn it into a durable suppression rule the backend
@@ -815,7 +732,6 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
e.stopPropagation();
const subject = getFindingSubjectPresentation(finding).label;
const title = getFindingTitlePresentation(finding).label;
- const prompt = buildPatrolRemediationPlanAssistantPrompt({ title, subject, plan });
const briefing = buildPatrolRemediationPlanAssistantBriefing({ title, subject, plan });
const handoffContext = buildPatrolRemediationPlanAssistantModelContext({
title,
@@ -823,7 +739,7 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
plan,
});
- aiChatStore.openWithPrompt(prompt, {
+ aiChatStore.open({
targetType: finding.resourceType,
targetId: finding.resourceId,
findingId: finding.id,
@@ -1234,11 +1150,6 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
<span class="font-medium">Impact:</span> {finding.impact}
</p>
</Show>
- <Show when={finding.recommendation}>
- <p class="text-sm text-base-content mt-2">
- <span class="font-medium">Recommendation:</span> {finding.recommendation}
- </p>
- </Show>
<Show when={finding.previousResolvedFixSummary}>
<p class="text-sm text-base-content mt-2 px-2 py-1 rounded border border-emerald-200 bg-emerald-50/40 dark:border-emerald-800 dark:bg-emerald-950/30">
<span class="font-medium text-emerald-800 dark:text-emerald-300">
@@ -1374,9 +1285,8 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
<button
type="button"
onClick={(e) => {
- const action = getPrimaryAssistantFindingAction(finding);
e.stopPropagation();
- void openFindingInAssistant(finding, action.intent);
+ void openFindingInAssistant(finding);
}}
class="inline-flex items-center gap-1 rounded bg-blue-600 px-3 py-1.5 font-semibold text-white transition-colors hover:bg-blue-700"
title={getPrimaryAssistantFindingAction(finding).title}
@@ -1392,53 +1302,6 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
{getPrimaryAssistantFindingAction(finding).label}
</button>
- <details onClick={(e) => e.stopPropagation()}>
- <summary class="list-none cursor-pointer rounded border border-border bg-surface px-3 py-1.5 font-medium text-base-content hover:bg-surface-hover">
- Assistant
- </summary>
- <div class="mt-1 flex min-w-40 flex-col gap-1 rounded border border-border bg-surface p-1 shadow-sm">
- <button
- type="button"
- onClick={(e) => handleExplainFinding(finding, e)}
- class="rounded px-2 py-1 text-left hover:bg-surface-hover"
- >
- Explain
- </button>
- <Show when={finding.status === 'active'}>
- <button
- type="button"
- onClick={(e) => handleInvestigateFinding(finding, e)}
- class="rounded px-2 py-1 text-left hover:bg-surface-hover"
- >
- Investigate
- </button>
- </Show>
- <button
- type="button"
- onClick={(e) => handleWhyFinding(finding, e)}
- class="rounded px-2 py-1 text-left hover:bg-surface-hover"
- >
- Why
- </button>
- <Show when={findingHasAppliedFix(finding) && finding.status === 'active'}>
- <button
- type="button"
- onClick={(e) => handleVerifyFixFinding(finding, e)}
- class="rounded px-2 py-1 text-left hover:bg-surface-hover"
- >
- Verify fix
- </button>
- </Show>
- <button
- type="button"
- onClick={(e) => handleDiscussWithAssistant(finding, e)}
- class="rounded px-2 py-1 text-left hover:bg-surface-hover"
- >
- Discuss
- </button>
- </div>
- </details>
-
<details onClick={(e) => e.stopPropagation()}>
<summary class="list-none cursor-pointer rounded border border-border bg-surface px-3 py-1.5 font-medium text-base-content hover:bg-surface-hover">
Manage
diff --git a/frontend-modern/src/components/AI/__tests__/FindingsPanel.links.test.tsx b/frontend-modern/src/components/AI/__tests__/FindingsPanel.links.test.tsx
index 69918f0c29..f5e7801f47 100644
--- a/frontend-modern/src/components/AI/__tests__/FindingsPanel.links.test.tsx
+++ b/frontend-modern/src/components/AI/__tests__/FindingsPanel.links.test.tsx
@@ -105,7 +105,7 @@ vi.mock('@/stores/notifications', () => ({
vi.mock('@/stores/aiChat', () => ({
aiChatStore: {
- openWithPrompt: vi.fn(),
+ open: vi.fn(),
},
}));
diff --git a/frontend-modern/src/components/AI/__tests__/FindingsPanel.overdue.test.tsx b/frontend-modern/src/components/AI/__tests__/FindingsPanel.overdue.test.tsx
index b649cf3e92..a70084d363 100644
--- a/frontend-modern/src/components/AI/__tests__/FindingsPanel.overdue.test.tsx
+++ b/frontend-modern/src/components/AI/__tests__/FindingsPanel.overdue.test.tsx
@@ -62,7 +62,7 @@ vi.mock('@/stores/notifications', () => ({
vi.mock('@/stores/aiChat', () => ({
aiChatStore: {
- openWithPrompt: vi.fn(),
+ open: vi.fn(),
},
}));
diff --git a/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts b/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
index b0c8966c03..336e3b417e 100644
--- a/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
+++ b/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
@@ -51,12 +51,9 @@ describe('FindingsPanel assistant handoff', () => {
expect(findingsPanelSource).toContain('buildPatrolAssistantFindingHandoff');
expect(findingsPanelSource).toContain('buildPatrolAssistantApprovalBriefingInput');
expect(findingsPanelSource).toContain('buildPatrolAssistantProposedFixBriefingInput');
- // openWithPrompt receives the handoff context spread inline (so the call
- // site can layer autoSendInitialPrompt for verb-style entrypoints like
- // Investigate / Why / Verify fix). The base handoff.context must still
- // flow through.
- expect(findingsPanelSource).toContain('aiChatStore.openWithPrompt(handoff.prompt, {');
- expect(findingsPanelSource).toContain('...handoff.context');
+ expect(findingsPanelSource).toContain('aiChatStore.open(handoff.context)');
+ expect(findingsPanelSource).not.toContain('autoSendInitialPrompt');
+ expect(findingsPanelSource).not.toContain('openWithPrompt');
expect(findingsPanelSource).toContain('investigationOutcome: finding.investigationOutcome');
expect(findingsPanelSource).toContain('investigationStatus: finding.investigationStatus');
expect(findingsPanelSource).toContain('remediationId: finding.remediationPlanId');
@@ -72,7 +69,7 @@ describe('FindingsPanel assistant handoff', () => {
});
it('routes remediation plan handoffs through the command-free Patrol handoff model', () => {
- expect(findingsPanelSource).toContain('buildPatrolRemediationPlanAssistantPrompt');
+ expect(findingsPanelSource).not.toContain('buildPatrolRemediationPlanAssistantPrompt');
expect(findingsPanelSource).toContain('buildPatrolRemediationPlanAssistantModelContext');
expect(findingsPanelSource).toContain('buildPatrolRemediationPlanAssistantBriefing');
expect(findingsPanelSource).toContain('handoffContext,');
@@ -91,15 +88,13 @@ describe('FindingsPanel assistant handoff', () => {
expect(findingsPanelSource).toContain('Last time this resolved');
});
- it('exposes an Explain entry point that seeds Assistant with an explanation prompt', () => {
- // The Explain button is a contextual entry point parallel to "Discuss with
- // Assistant" but with an intent that produces explanation framing rather
- // than open-ended discussion. Both flow through the same handoff builder
- // so context attachment stays uniform.
- expect(findingsPanelSource).toContain('handleExplainFinding');
- expect(findingsPanelSource).toContain("openFindingInAssistant(finding, 'explain')");
- expect(findingsPanelSource).toMatch(/>\s*Explain\s*</);
- expect(findingsPanelSource).toContain("openFindingInAssistant(finding, 'discuss')");
+ it('does not expose intent-specific Assistant routing from finding actions', () => {
+ expect(findingsPanelSource).toContain('Open in Assistant');
+ expect(findingsPanelSource).not.toContain('handleExplainFinding');
+ expect(findingsPanelSource).not.toContain('handleInvestigateFinding');
+ expect(findingsPanelSource).not.toContain('handleWhyFinding');
+ expect(findingsPanelSource).not.toContain('handleVerifyFixFinding');
+ expect(findingsPanelSource).not.toContain("openFindingInAssistant(finding, '");
});
it('surfaces investigation_record.confidence as a badge in the collapsed row', () => {
@@ -153,12 +148,11 @@ describe('FindingsPanel assistant handoff', () => {
expect(findingsPanelSource).toMatch(/>\s*Copy summary\s*</);
});
- it('keeps expanded finding actions behind a primary action and compact menus', () => {
+ it('keeps expanded finding actions behind a primary Assistant action and compact Manage menu', () => {
expect(findingsPanelSource).toContain('getPrimaryAssistantFindingAction');
- expect(findingsPanelSource).toContain('Assistant');
expect(findingsPanelSource).toContain('Manage');
- expect(findingsPanelSource).toContain('min-w-40');
expect(findingsPanelSource).toContain('min-w-48');
+ expect(findingsPanelSource).not.toContain('min-w-40');
});
it('exposes a manual Mark resolved action that goes through the patrol resolve store action', () => {
@@ -252,19 +246,13 @@ describe('FindingsPanel assistant handoff', () => {
expect(findingsPanelSource).not.toContain('<For each={plan().steps}>');
});
- it('renders the operator-facing Impact line between Description and Recommendation', () => {
+ it('renders the operator-facing Impact line without a Pulse-authored recommendation line', () => {
// The expanded finding card must surface Finding.Impact directly so
// detection-time consequence-if-ignored copy reaches the operator on the
// findings list, not just inside the durable investigation record.
expect(findingsPanelSource).toContain('Show when={finding.impact}');
expect(findingsPanelSource).toContain('>Impact:</span> {finding.impact}');
- // Impact must precede Recommendation in the rendered card, mirroring the
- // narrative order: what we found, why it matters, what to do about it.
- const impactIndex = findingsPanelSource.indexOf('>Impact:</span>');
- const recommendationIndex = findingsPanelSource.indexOf('>Recommendation:</span>');
- expect(impactIndex).toBeGreaterThan(0);
- expect(recommendationIndex).toBeGreaterThan(0);
- expect(impactIndex).toBeLessThan(recommendationIndex);
+ expect(findingsPanelSource).not.toContain('>Recommendation:</span>');
});
});
@@ -1072,7 +1060,7 @@ describe('aiFindingPresentation', () => {
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).not.toContain('Recommendation: Free 200GB before the next backup window.');
expect(formatted).toContain('Confidence: medium');
expect(formatted).toContain('Regressed: 2×');
});
diff --git a/frontend-modern/src/components/Alerts/IncidentAssistantHandoffButton.tsx b/frontend-modern/src/components/Alerts/IncidentAssistantHandoffButton.tsx
index 9e3cc9d296..fc5f7e6ad5 100644
--- a/frontend-modern/src/components/Alerts/IncidentAssistantHandoffButton.tsx
+++ b/frontend-modern/src/components/Alerts/IncidentAssistantHandoffButton.tsx
@@ -19,7 +19,7 @@ export function IncidentAssistantHandoffButton(props: IncidentAssistantHandoffBu
event.stopPropagation();
const handoff = buildAlertIncidentAssistantHandoff({ incident: props.incident });
- aiChatStore.openWithPrompt(handoff.prompt, handoff.context);
+ aiChatStore.open(handoff.context);
};
return (
diff --git a/frontend-modern/src/components/Alerts/InvestigateAlertButton.tsx b/frontend-modern/src/components/Alerts/InvestigateAlertButton.tsx
index bf3798cdb4..a2807e350a 100644
--- a/frontend-modern/src/components/Alerts/InvestigateAlertButton.tsx
+++ b/frontend-modern/src/components/Alerts/InvestigateAlertButton.tsx
@@ -54,8 +54,7 @@ export function InvestigateAlertButton(props: InvestigateAlertButtonProps) {
vmid: props.vmid,
});
- // Open AI chat with this context and prompt
- aiChatStore.openWithPrompt(handoff.prompt, handoff.context);
+ aiChatStore.open(handoff.context);
};
const sizeClasses = {
diff --git a/frontend-modern/src/components/Alerts/__tests__/IncidentTimelinePanel.test.tsx b/frontend-modern/src/components/Alerts/__tests__/IncidentTimelinePanel.test.tsx
index adde563b66..5689b79abe 100644
--- a/frontend-modern/src/components/Alerts/__tests__/IncidentTimelinePanel.test.tsx
+++ b/frontend-modern/src/components/Alerts/__tests__/IncidentTimelinePanel.test.tsx
@@ -122,7 +122,7 @@ describe('IncidentTimelinePanel', () => {
it('opens Assistant with a sanitized incident briefing from the loaded timeline', () => {
const [filters, setFilters] = createSignal(new Set(['command']));
- const openWithPromptSpy = vi.spyOn(aiChatStore, 'openWithPrompt');
+ const openSpy = vi.spyOn(aiChatStore, 'open');
aiChatStore.setEnabled(true);
render(() => (
@@ -148,9 +148,8 @@ describe('IncidentTimelinePanel', () => {
}),
);
- expect(openWithPromptSpy).toHaveBeenCalledTimes(1);
- const [prompt, context] = openWithPromptSpy.mock.calls[0] as [string, Record<string, unknown>];
- expect(prompt).toContain('Discuss this Warning alert incident from Pulse Alerts.');
+ expect(openSpy).toHaveBeenCalledTimes(1);
+ const [context] = openSpy.mock.calls[0] as [Record<string, unknown>];
expect(context).toMatchObject({
autonomousMode: false,
briefing: {
diff --git a/frontend-modern/src/components/Alerts/__tests__/InvestigateAlertButton.test.tsx b/frontend-modern/src/components/Alerts/__tests__/InvestigateAlertButton.test.tsx
index e8c6e5959b..92e150ef56 100644
--- a/frontend-modern/src/components/Alerts/__tests__/InvestigateAlertButton.test.tsx
+++ b/frontend-modern/src/components/Alerts/__tests__/InvestigateAlertButton.test.tsx
@@ -8,7 +8,7 @@ import { getPublicPricingUrl } from '@/utils/pricingHandoff';
// ---------------------------------------------------------------------------
const {
- openWithPromptMock,
+ openMock,
openUpgradeDestinationMock,
formatAlertValueMock,
mockAiChatStore,
@@ -16,7 +16,7 @@ const {
getUpgradeActionUrlOrFallbackMock,
presentationPolicyHidesUpgradePromptsMock,
} = vi.hoisted(() => {
- const openWithPromptMock = vi.fn();
+ const openMock = vi.fn();
const openUpgradeDestinationMock = vi.fn();
const formatAlertValueMock = vi.fn((value?: number, _type?: string) =>
value !== undefined ? `${value.toFixed(1)}%` : 'N/A',
@@ -26,10 +26,10 @@ const {
const presentationPolicyHidesUpgradePromptsMock = vi.fn();
const mockAiChatStore = {
enabled: true as boolean | null,
- openWithPrompt: (...args: unknown[]) => openWithPromptMock(...args),
+ open: (...args: unknown[]) => openMock(...args),
};
return {
- openWithPromptMock,
+ openMock,
openUpgradeDestinationMock,
formatAlertValueMock,
mockAiChatStore,
@@ -86,6 +86,18 @@ function makeAlert(overrides: Partial<Alert> = {}): Alert {
};
}
+function openedContext(): Record<string, unknown> {
+ return openMock.mock.calls[0]?.[0] as Record<string, unknown>;
+}
+
+function openedBriefing(): { statusLabel?: string; detailLines?: string[]; subject?: string } {
+ return openedContext().briefing as {
+ statusLabel?: string;
+ detailLines?: string[];
+ subject?: string;
+ };
+}
+
// ---------------------------------------------------------------------------
// Tests
// ---------------------------------------------------------------------------
@@ -96,7 +108,7 @@ afterEach(() => {
});
beforeEach(() => {
- openWithPromptMock.mockReset();
+ openMock.mockReset();
formatAlertValueMock.mockClear();
openUpgradeDestinationMock.mockReset();
getUpgradeActionDestinationMock.mockReset();
@@ -231,7 +243,7 @@ describe('InvestigateAlertButton', () => {
href: getPublicPricingUrl('ai_alerts'),
external: true,
});
- expect(openWithPromptMock).not.toHaveBeenCalled();
+ expect(openMock).not.toHaveBeenCalled();
});
it('keeps the locked state non-promotional when upgrade prompts are hidden', async () => {
@@ -248,7 +260,7 @@ describe('InvestigateAlertButton', () => {
await fireEvent.click(button);
expect(openUpgradeDestinationMock).not.toHaveBeenCalled();
- expect(openWithPromptMock).not.toHaveBeenCalled();
+ expect(openMock).not.toHaveBeenCalled();
});
it('still stops propagation when locked and clicked', () => {
@@ -270,23 +282,14 @@ describe('InvestigateAlertButton', () => {
// Click behavior (unlocked)
// ---------------------------------------------------------------------------
describe('click behavior (unlocked)', () => {
- it('calls openWithPrompt with alert context on click', async () => {
+ it('calls open with alert context on click', async () => {
const alert = makeAlert();
render(() => <InvestigateAlertButton alert={alert} />);
const button = screen.getByRole('button');
await fireEvent.click(button);
- expect(openWithPromptMock).toHaveBeenCalledTimes(1);
- const [prompt, context] = openWithPromptMock.mock.calls[0] as [
- string,
- Record<string, unknown>,
- ];
-
- // Verify prompt contains key alert details
- expect(prompt).toContain('WARNING');
- expect(prompt).toContain('test-vm');
- expect(prompt).toContain('cpu');
- expect(prompt).toContain('PVE Node 1');
+ expect(openMock).toHaveBeenCalledTimes(1);
+ const context = openedContext();
// Verify context
expect(context).toMatchObject({
@@ -322,18 +325,14 @@ describe('InvestigateAlertButton', () => {
render(() => <InvestigateAlertButton alert={alert} />);
await fireEvent.click(screen.getByRole('button'));
- const [prompt, context] = openWithPromptMock.mock.calls[0] as [
- string,
- Record<string, unknown>,
- ];
+ const context = openedContext();
expect(context.autonomousMode).toBe(false);
expect(context.briefing).toMatchObject({
sourceLabel: 'Pulse Alerts',
title: 'Alert investigation attached',
});
- expect(prompt).toContain('Ask for operator approval before running any diagnostic command');
- expect(prompt).not.toContain('Execute diagnostic commands if safe');
+ expect(JSON.stringify(context)).not.toContain('Execute diagnostic commands if safe');
expect(JSON.stringify(context.briefing)).not.toContain('systemctl');
});
@@ -362,7 +361,7 @@ describe('InvestigateAlertButton', () => {
render(() => <InvestigateAlertButton alert={alert} />);
await fireEvent.click(screen.getByRole('button'));
- const [, context] = openWithPromptMock.mock.calls[0] as [string, Record<string, unknown>];
+ const context = openedContext();
expect(context.targetType).toBe('agent');
});
@@ -371,7 +370,7 @@ describe('InvestigateAlertButton', () => {
render(() => <InvestigateAlertButton alert={alert} />);
await fireEvent.click(screen.getByRole('button'));
- const [, context] = openWithPromptMock.mock.calls[0] as [string, Record<string, unknown>];
+ const context = openedContext();
expect(context.targetType).toBe('app-container');
});
@@ -380,7 +379,7 @@ describe('InvestigateAlertButton', () => {
render(() => <InvestigateAlertButton alert={alert} />);
await fireEvent.click(screen.getByRole('button'));
- const [, context] = openWithPromptMock.mock.calls[0] as [string, Record<string, unknown>];
+ const context = openedContext();
expect(context.targetType).toBe('storage');
});
@@ -389,7 +388,7 @@ describe('InvestigateAlertButton', () => {
render(() => <InvestigateAlertButton alert={alert} resourceType="lxc" />);
await fireEvent.click(screen.getByRole('button'));
- const [, context] = openWithPromptMock.mock.calls[0] as [string, Record<string, unknown>];
+ const context = openedContext();
expect(context.targetType).toBe('vm');
});
@@ -398,7 +397,7 @@ describe('InvestigateAlertButton', () => {
render(() => <InvestigateAlertButton alert={alert} />);
await fireEvent.click(screen.getByRole('button'));
- const [, context] = openWithPromptMock.mock.calls[0] as [string, Record<string, unknown>];
+ const context = openedContext();
expect(context.targetType).toBe('vm');
});
@@ -407,7 +406,7 @@ describe('InvestigateAlertButton', () => {
render(() => <InvestigateAlertButton alert={alert} />);
await fireEvent.click(screen.getByRole('button'));
- const [, context] = openWithPromptMock.mock.calls[0] as [string, Record<string, unknown>];
+ const context = openedContext();
expect(context.targetType).toBe('agent');
});
@@ -416,7 +415,7 @@ describe('InvestigateAlertButton', () => {
render(() => <InvestigateAlertButton alert={alert} />);
await fireEvent.click(screen.getByRole('button'));
- const [, context] = openWithPromptMock.mock.calls[0] as [string, Record<string, unknown>];
+ const context = openedContext();
expect(context.targetType).toBe('pod');
});
@@ -425,7 +424,7 @@ describe('InvestigateAlertButton', () => {
render(() => <InvestigateAlertButton alert={alert} />);
await fireEvent.click(screen.getByRole('button'));
- const [, context] = openWithPromptMock.mock.calls[0] as [string, Record<string, unknown>];
+ const context = openedContext();
expect(context.targetType).toBe('pod');
});
@@ -437,7 +436,7 @@ describe('InvestigateAlertButton', () => {
render(() => <InvestigateAlertButton alert={alert} />);
await fireEvent.click(screen.getByRole('button'));
- const [, context] = openWithPromptMock.mock.calls[0] as [string, Record<string, unknown>];
+ const context = openedContext();
expect(context.targetType).toBe('agent');
});
@@ -449,7 +448,7 @@ describe('InvestigateAlertButton', () => {
render(() => <InvestigateAlertButton alert={alert} />);
await fireEvent.click(screen.getByRole('button'));
- const [, context] = openWithPromptMock.mock.calls[0] as [string, Record<string, unknown>];
+ const context = openedContext();
expect(context.targetType).toBe('agent');
});
@@ -458,13 +457,13 @@ describe('InvestigateAlertButton', () => {
render(() => <InvestigateAlertButton alert={alert} resourceType="lxc" />);
await fireEvent.click(screen.getByRole('button'));
- const [, context] = openWithPromptMock.mock.calls[0] as [string, Record<string, unknown>];
+ const context = openedContext();
expect(context.targetType).toBe('agent');
});
});
// ---------------------------------------------------------------------------
- // Duration formatting in prompt
+ // Duration formatting in attached context
// ---------------------------------------------------------------------------
describe('duration formatting', () => {
const FIXED_NOW = new Date('2026-03-02T12:00:00Z').getTime();
@@ -485,8 +484,7 @@ describe('InvestigateAlertButton', () => {
render(() => <InvestigateAlertButton alert={alert} />);
await fireEvent.click(screen.getByRole('button'));
- const [prompt] = openWithPromptMock.mock.calls[0] as [string];
- expect(prompt).toContain('15 mins');
+ expect(openedBriefing().statusLabel).toContain('15 mins');
});
it('formats 1 minute as singular "1 min"', async () => {
@@ -496,9 +494,8 @@ describe('InvestigateAlertButton', () => {
render(() => <InvestigateAlertButton alert={alert} />);
await fireEvent.click(screen.getByRole('button'));
- const [prompt] = openWithPromptMock.mock.calls[0] as [string];
- expect(prompt).toContain('1 min');
- expect(prompt).not.toContain('1 mins');
+ expect(openedBriefing().statusLabel).toContain('1 min');
+ expect(openedBriefing().statusLabel).not.toContain('1 mins');
});
it('formats duration in hours and minutes for long-lived alerts', async () => {
@@ -508,8 +505,7 @@ describe('InvestigateAlertButton', () => {
render(() => <InvestigateAlertButton alert={alert} />);
await fireEvent.click(screen.getByRole('button'));
- const [prompt] = openWithPromptMock.mock.calls[0] as [string];
- expect(prompt).toContain('1h 30m');
+ expect(openedBriefing().statusLabel).toContain('1h 30m');
});
it('formats 0 minutes for alerts that just started', async () => {
@@ -519,22 +515,20 @@ describe('InvestigateAlertButton', () => {
render(() => <InvestigateAlertButton alert={alert} />);
await fireEvent.click(screen.getByRole('button'));
- const [prompt] = openWithPromptMock.mock.calls[0] as [string];
- expect(prompt).toContain('0 mins');
+ expect(openedBriefing().statusLabel).toContain('0 mins');
});
});
// ---------------------------------------------------------------------------
- // Prompt content — node display name
+ // Attached-context content — node display name
// ---------------------------------------------------------------------------
- describe('prompt content', () => {
+ describe('attached context content', () => {
it('uses nodeDisplayName when available', async () => {
const alert = makeAlert({ node: 'pve1', nodeDisplayName: 'My Node' });
render(() => <InvestigateAlertButton alert={alert} />);
await fireEvent.click(screen.getByRole('button'));
- const [prompt] = openWithPromptMock.mock.calls[0] as [string];
- expect(prompt).toContain('**Node:** My Node');
+ expect(openedBriefing().detailLines).toContain('Node: My Node');
});
it('falls back to node ID when nodeDisplayName is absent', async () => {
@@ -542,8 +536,7 @@ describe('InvestigateAlertButton', () => {
render(() => <InvestigateAlertButton alert={alert} />);
await fireEvent.click(screen.getByRole('button'));
- const [prompt] = openWithPromptMock.mock.calls[0] as [string];
- expect(prompt).toContain('**Node:** pve2');
+ expect(openedBriefing().detailLines).toContain('Node: pve2');
});
it('omits node line when node is empty', async () => {
@@ -551,17 +544,15 @@ describe('InvestigateAlertButton', () => {
render(() => <InvestigateAlertButton alert={alert} />);
await fireEvent.click(screen.getByRole('button'));
- const [prompt] = openWithPromptMock.mock.calls[0] as [string];
- expect(prompt).not.toContain('**Node:**');
+ expect(openedBriefing().detailLines?.some((line) => line.startsWith('Node:'))).toBe(false);
});
- it('includes CRITICAL in prompt for critical alerts', async () => {
+ it('includes Critical in context for critical alerts', async () => {
const alert = makeAlert({ level: 'critical' });
render(() => <InvestigateAlertButton alert={alert} />);
await fireEvent.click(screen.getByRole('button'));
- const [prompt] = openWithPromptMock.mock.calls[0] as [string];
- expect(prompt).toContain('CRITICAL');
+ expect(openedBriefing().subject).toContain('Critical');
});
it('passes vmid in context when provided', async () => {
@@ -569,7 +560,7 @@ describe('InvestigateAlertButton', () => {
render(() => <InvestigateAlertButton alert={alert} vmid={101} />);
await fireEvent.click(screen.getByRole('button'));
- const [, context] = openWithPromptMock.mock.calls[0] as [string, Record<string, unknown>];
+ const context = openedContext();
expect((context.context as Record<string, unknown>).vmid).toBe(101);
});
});
diff --git a/frontend-modern/src/components/Alerts/__tests__/alertAssistantHandoffModel.test.ts b/frontend-modern/src/components/Alerts/__tests__/alertAssistantHandoffModel.test.ts
index a4ab6e3d0c..c808446c4b 100644
--- a/frontend-modern/src/components/Alerts/__tests__/alertAssistantHandoffModel.test.ts
+++ b/frontend-modern/src/components/Alerts/__tests__/alertAssistantHandoffModel.test.ts
@@ -29,10 +29,7 @@ describe('alertAssistantHandoffModel', () => {
vmid: 101,
});
- expect(handoff.prompt).toContain('Investigate this WARNING alert');
- expect(handoff.prompt).toContain(
- 'Ask for operator approval before running any diagnostic command',
- );
+ expect(handoff).not.toHaveProperty('prompt');
expect(handoff.context).toMatchObject({
targetType: 'vm',
targetId: 'vm-101',
@@ -91,8 +88,8 @@ describe('alertAssistantHandoffModel', () => {
it('suppresses current-value and threshold for state alerts (powered-off, etc.)', () => {
// State alerts are binary/enumerated conditions. The backend sends
// value=0 and threshold=0 for those; rendering "current 0.0% / threshold
- // 0.0%" is meaningless. The briefing and prompt must omit those lines
- // and use the alert message instead to convey what's wrong.
+ // 0.0%" is meaningless. The briefing must omit those lines and use the
+ // alert message instead to convey what's wrong.
const handoff = buildAlertAssistantHandoff({
alert: makeAlert({
type: 'powered-off',
@@ -103,12 +100,6 @@ describe('alertAssistantHandoffModel', () => {
now: new Date('2026-05-07T10:05:00.000Z'),
});
- expect(handoff.prompt).not.toContain('**Current Value:**');
- expect(handoff.prompt).not.toContain('**Threshold:**');
- expect(handoff.prompt).not.toContain('0.0%');
- expect(handoff.prompt).toContain('**Alert Type:** powered-off');
- expect(handoff.prompt).toContain("**Message:** VM 'docker' is powered off");
-
const briefing = handoff.context.briefing as { detailLines: string[] };
for (const line of briefing.detailLines) {
expect(line).not.toContain('Current value');
@@ -129,8 +120,6 @@ describe('alertAssistantHandoffModel', () => {
now: new Date('2026-05-07T10:05:00.000Z'),
});
- expect(handoff.prompt).toContain('**Current Value:** 92.5%');
- expect(handoff.prompt).toContain('**Threshold:** 80.0%');
const briefing = handoff.context.briefing as { detailLines: string[] };
expect(briefing.detailLines).toContain('Current value 92.5%; threshold 80.0%');
});
diff --git a/frontend-modern/src/components/Alerts/__tests__/incidentAssistantHandoffModel.test.ts b/frontend-modern/src/components/Alerts/__tests__/incidentAssistantHandoffModel.test.ts
index a850461354..ada64019d4 100644
--- a/frontend-modern/src/components/Alerts/__tests__/incidentAssistantHandoffModel.test.ts
+++ b/frontend-modern/src/components/Alerts/__tests__/incidentAssistantHandoffModel.test.ts
@@ -47,8 +47,7 @@ describe('incidentAssistantHandoffModel', () => {
now: new Date('2026-03-20T10:05:00Z'),
});
- expect(handoff.prompt).toContain('Discuss this Critical alert incident from Pulse Alerts.');
- expect(handoff.prompt).toContain('Command details and output stay in the incident');
+ expect(handoff).not.toHaveProperty('prompt');
expect(handoff.context).toMatchObject({
targetType: 'app-container',
targetId: 'docker:app-1',
diff --git a/frontend-modern/src/components/Alerts/alertAssistantHandoffModel.ts b/frontend-modern/src/components/Alerts/alertAssistantHandoffModel.ts
index 5a4bf65d0a..78ecae7a8b 100644
--- a/frontend-modern/src/components/Alerts/alertAssistantHandoffModel.ts
+++ b/frontend-modern/src/components/Alerts/alertAssistantHandoffModel.ts
@@ -13,8 +13,7 @@ interface BuildAlertAssistantHandoffInput {
}
interface AlertAssistantHandoff {
- prompt: string;
- context: Omit<AIChatContext, 'initialPrompt'>;
+ context: AIChatContext;
}
export function buildAlertAssistantHandoff({
@@ -55,35 +54,7 @@ export function buildAlertAssistantHandoff({
levelLabel,
});
- const promptLines = [
- `Investigate this ${alert.level.toUpperCase()} alert:`,
- ``,
- `**Resource:** ${alert.resourceName}`,
- `**Alert Type:** ${alert.type}`,
- ];
- if (hasMetricValues) {
- promptLines.push(`**Current Value:** ${currentValue}`);
- promptLines.push(`**Threshold:** ${thresholdValue}`);
- }
- promptLines.push(`**Duration:** ${durationText}`);
- if (nodeLabel) promptLines.push(`**Node:** ${nodeLabel}`);
- if (alert.message) promptLines.push(`**Message:** ${alert.message}`);
- promptLines.push(``);
- promptLines.push(`Please:`);
- promptLines.push(`1. Identify the root cause`);
- if (hasMetricValues) {
- promptLines.push(`2. Check related metrics`);
- promptLines.push(`3. Suggest specific remediation steps`);
- promptLines.push(`4. Ask for operator approval before running any diagnostic command or change`);
- } else {
- promptLines.push(`2. Check what changed recently for this resource (state events, recent commands, related alerts)`);
- promptLines.push(`3. Suggest specific remediation steps`);
- promptLines.push(`4. Ask for operator approval before running any diagnostic command or change`);
- }
- const prompt = promptLines.join('\n');
-
return {
- prompt,
context: {
targetType,
targetId: alert.resourceId,
diff --git a/frontend-modern/src/components/Alerts/incidentAssistantHandoffModel.ts b/frontend-modern/src/components/Alerts/incidentAssistantHandoffModel.ts
index 401740e1ec..0dc9768508 100644
--- a/frontend-modern/src/components/Alerts/incidentAssistantHandoffModel.ts
+++ b/frontend-modern/src/components/Alerts/incidentAssistantHandoffModel.ts
@@ -8,8 +8,7 @@ interface BuildAlertIncidentAssistantHandoffInput {
}
interface AlertIncidentAssistantHandoff {
- prompt: string;
- context: Omit<AIChatContext, 'initialPrompt'>;
+ context: AIChatContext;
}
interface SanitizedIncidentEvent {
@@ -55,29 +54,7 @@ export function buildAlertIncidentAssistantHandoff({
eventCountLabel,
});
- const prompt = [
- `Discuss this ${levelLabel} alert incident from Pulse Alerts.`,
- '',
- `**Resource:** ${resourceLabel}`,
- `**Alert Type:** ${incident.alertType}`,
- `**Status:** ${statusLabel}`,
- `**Duration:** ${durationText}`,
- incident.node ? `**Node:** ${incident.node}` : undefined,
- incident.message ? `**Message:** ${incident.message}` : undefined,
- '',
- 'Use the attached sanitized incident timeline context. Command details and output stay in the incident or approval surface; do not infer, repeat, or execute raw command text from this chat handoff.',
- '',
- 'Please:',
- '1. Explain what the incident record says happened',
- '2. Identify the likely cause and any uncertainty',
- '3. Call out related checks the operator should review',
- '4. Ask for approval before running diagnostics or remediation',
- ]
- .filter((line): line is string => line !== undefined)
- .join('\n');
-
return {
- prompt,
context: {
targetType,
targetId: incident.resourceId,
diff --git a/frontend-modern/src/components/patrol/ApprovalSection.tsx b/frontend-modern/src/components/patrol/ApprovalSection.tsx
index 0f9d1f8021..3cc3410e0b 100644
--- a/frontend-modern/src/components/patrol/ApprovalSection.tsx
+++ b/frontend-modern/src/components/patrol/ApprovalSection.tsx
@@ -91,13 +91,13 @@ export const ApprovalSection: Component<ApprovalSectionProps> = (props) => {
) => {
e.stopPropagation();
const handoff = assistantHandoff(approval, fix);
- aiChatStore.openWithPrompt(handoff.prompt, handoff.context);
+ aiChatStore.open(handoff.context);
};
const handleDiscussQueuedFix = (e: Event) => {
e.stopPropagation();
const handoff = assistantHandoff(null);
- aiChatStore.openWithPrompt(handoff.prompt, handoff.context);
+ aiChatStore.open(handoff.context);
};
// Load investigation details when outcome indicates a fix was proposed/executed
diff --git a/frontend-modern/src/components/patrol/RunHistoryEntry.tsx b/frontend-modern/src/components/patrol/RunHistoryEntry.tsx
index 0fd46cfd29..2abc2788a2 100644
--- a/frontend-modern/src/components/patrol/RunHistoryEntry.tsx
+++ b/frontend-modern/src/components/patrol/RunHistoryEntry.tsx
@@ -170,7 +170,7 @@ export function RunHistoryEntry(props: RunHistoryEntryProps) {
const handleDiscussRun = (event: Event) => {
event.stopPropagation();
const handoff = buildPatrolRunAssistantHandoff(run);
- aiChatStore.openWithPrompt(handoff.prompt, handoff.context);
+ aiChatStore.open(handoff.context);
};
return (
diff --git a/frontend-modern/src/components/patrol/__tests__/ApprovalSection.test.tsx b/frontend-modern/src/components/patrol/__tests__/ApprovalSection.test.tsx
index c7e851acee..5fe24a20a8 100644
--- a/frontend-modern/src/components/patrol/__tests__/ApprovalSection.test.tsx
+++ b/frontend-modern/src/components/patrol/__tests__/ApprovalSection.test.tsx
@@ -21,7 +21,7 @@ const approveInvestigationFixMock = vi.hoisted(() => vi.fn());
const denyInvestigationFixMock = vi.hoisted(() => vi.fn());
const notificationSuccessMock = vi.hoisted(() => vi.fn());
const notificationErrorMock = vi.hoisted(() => vi.fn());
-const openWithPromptMock = vi.hoisted(() => vi.fn());
+const openMock = vi.hoisted(() => vi.fn());
vi.mock('@/api/ai', () => ({
AIAPI: {
@@ -52,7 +52,7 @@ vi.mock('@/stores/notifications', () => ({
vi.mock('@/stores/aiChat', () => ({
aiChatStore: {
- openWithPrompt: (...args: unknown[]) => openWithPromptMock(...args),
+ open: (...args: unknown[]) => openMock(...args),
},
}));
@@ -85,7 +85,7 @@ describe('ApprovalSection', () => {
denyInvestigationFixMock.mockReset();
notificationSuccessMock.mockReset();
notificationErrorMock.mockReset();
- openWithPromptMock.mockReset();
+ openMock.mockReset();
});
afterEach(() => {
@@ -122,13 +122,8 @@ describe('ApprovalSection', () => {
fireEvent.click(screen.getByRole('button', { name: /discuss with assistant/i }));
- expect(openWithPromptMock).toHaveBeenCalledTimes(1);
- const [prompt, context] = openWithPromptMock.mock.calls[0];
- expect(prompt).toContain(
- 'I\'d like to discuss this Patrol finding: "CPU saturation" on node-1',
- );
- expect(prompt).toContain('Governed action posture is attached');
- expect(prompt).toContain('Recover or regenerate the governed approval before execution');
+ expect(openMock).toHaveBeenCalledTimes(1);
+ const [context] = openMock.mock.calls[0];
expect(context).toEqual(
expect.objectContaining({
targetType: 'host',
@@ -195,13 +190,10 @@ describe('ApprovalSection', () => {
fireEvent.click(await screen.findByRole('button', { name: /fix with assistant/i }));
- expect(openWithPromptMock).toHaveBeenCalledTimes(1);
- const [prompt, context] = openWithPromptMock.mock.calls[0];
- expect(prompt).toContain('Governed approval approval-1 is attached');
- expect(prompt).toContain('approval status pending');
- expect(prompt).toContain('high risk');
- expect(prompt).not.toContain('systemctl restart nginx');
- expect(prompt).not.toContain('Please execute this fix');
+ expect(openMock).toHaveBeenCalledTimes(1);
+ const [context] = openMock.mock.calls[0];
+ expect(JSON.stringify(context)).not.toContain('systemctl restart nginx');
+ expect(JSON.stringify(context)).not.toContain('Please execute this fix');
expect(context).toEqual(
expect.objectContaining({
targetType: 'agent',
@@ -293,13 +285,9 @@ describe('ApprovalSection', () => {
expect(await screen.findByText('approval expired')).toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: /fix with assistant/i }));
- expect(openWithPromptMock).toHaveBeenCalledTimes(1);
- const [prompt, context] = openWithPromptMock.mock.calls[0];
- expect(prompt).toContain('Governed action posture is attached');
- expect(prompt).toContain('recorded action artifact Restart the workload service');
- expect(prompt).toContain('target node-1');
- expect(prompt).toContain('high risk');
- expect(prompt).not.toContain('systemctl restart nginx');
+ expect(openMock).toHaveBeenCalledTimes(1);
+ const [context] = openMock.mock.calls[0];
+ expect(JSON.stringify(context)).not.toContain('systemctl restart nginx');
expect(context).toEqual(
expect.objectContaining({
targetType: 'agent',
diff --git a/frontend-modern/src/components/patrol/__tests__/RunHistoryEntry.test.tsx b/frontend-modern/src/components/patrol/__tests__/RunHistoryEntry.test.tsx
index c281992cf5..02c988b002 100644
--- a/frontend-modern/src/components/patrol/__tests__/RunHistoryEntry.test.tsx
+++ b/frontend-modern/src/components/patrol/__tests__/RunHistoryEntry.test.tsx
@@ -3,11 +3,11 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import type { PatrolRunRecord } from '@/api/patrol';
import { RunHistoryEntry } from '../RunHistoryEntry';
-const { findingsPanelState, openWithPromptMock } = vi.hoisted(() => ({
+const { findingsPanelState, openMock } = vi.hoisted(() => ({
findingsPanelState: {
latestProps: null as Record<string, unknown> | null,
},
- openWithPromptMock: vi.fn(),
+ openMock: vi.fn(),
}));
vi.mock('@/components/AI/FindingsPanel', () => ({
@@ -42,7 +42,7 @@ vi.mock('@/components/AI/aiChatUtils', () => ({
vi.mock('@/stores/aiChat', () => ({
aiChatStore: {
- openWithPrompt: openWithPromptMock,
+ open: openMock,
},
}));
@@ -96,7 +96,7 @@ describe('RunHistoryEntry', () => {
beforeEach(() => {
findingsPanelState.latestProps = null;
- openWithPromptMock.mockReset();
+ openMock.mockReset();
});
afterEach(() => {
@@ -281,13 +281,10 @@ describe('RunHistoryEntry', () => {
fireEvent.click(screen.getByRole('button', { name: /discuss/i }));
- expect(openWithPromptMock).toHaveBeenCalledTimes(1);
- const [prompt, context] = openWithPromptMock.mock.calls[0];
- expect(prompt).toContain('Discuss this Pulse Patrol run');
- expect(prompt).toContain('Start by explaining the Patrol runtime failure');
- expect(prompt).toContain('Provider rejected Patrol tool calls');
- expect(prompt).not.toContain('tool_choice');
- expect(prompt).not.toContain('No endpoints found');
+ expect(openMock).toHaveBeenCalledTimes(1);
+ const [context] = openMock.mock.calls[0];
+ expect(JSON.stringify(context)).not.toContain('tool_choice');
+ expect(JSON.stringify(context)).not.toContain('No endpoints found');
expect(context).toMatchObject({
targetType: 'patrol-run',
targetId: 'run-runtime-error',
diff --git a/frontend-modern/src/features/alerts/__tests__/AlertResourceIncidentsPanel.test.tsx b/frontend-modern/src/features/alerts/__tests__/AlertResourceIncidentsPanel.test.tsx
index af1dfcaf93..1789b04fb2 100644
--- a/frontend-modern/src/features/alerts/__tests__/AlertResourceIncidentsPanel.test.tsx
+++ b/frontend-modern/src/features/alerts/__tests__/AlertResourceIncidentsPanel.test.tsx
@@ -88,7 +88,7 @@ describe('AlertResourceIncidentsPanel', () => {
});
it('opens Assistant from a resource incident without carrying raw command details', () => {
- const openWithPromptSpy = vi.spyOn(aiChatStore, 'openWithPrompt');
+ const openSpy = vi.spyOn(aiChatStore, 'open');
aiChatStore.setEnabled(true);
render(() => (
@@ -147,8 +147,8 @@ describe('AlertResourceIncidentsPanel', () => {
}),
);
- expect(openWithPromptSpy).toHaveBeenCalledTimes(1);
- const [, context] = openWithPromptSpy.mock.calls[0] as [string, Record<string, unknown>];
+ expect(openSpy).toHaveBeenCalledTimes(1);
+ const [context] = openSpy.mock.calls[0] as [Record<string, unknown>];
expect(context).toMatchObject({
targetType: 'storage',
targetId: 'storage:tank',
diff --git a/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts b/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts
index ff4addc08c..9bd4c306e0 100644
--- a/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts
+++ b/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts
@@ -10,7 +10,6 @@ import {
buildPatrolAssistantFindingBriefing,
buildPatrolAssistantFindingHandoff,
buildPatrolAssistantFindingHandoffActions,
- buildPatrolAssistantFindingPrompt,
buildPatrolAssistantProposedFixBriefingInput,
buildPatrolConfigurationFailureHandoff,
buildPatrolInvestigationContextSummary,
@@ -18,7 +17,6 @@ import {
buildPatrolInvestigationRecordPresentation,
buildPatrolRemediationPlanAssistantBriefing,
buildPatrolRemediationPlanAssistantModelContext,
- buildPatrolRemediationPlanAssistantPrompt,
patrolAssistantFindingHandoffRequiresApprovalMode,
selectPatrolSupportingRecentChanges,
} from '../patrolInvestigationContextModel';
@@ -359,9 +357,7 @@ describe('patrolInvestigationContextModel', () => {
],
});
- expect(handoff.prompt).toContain('Discuss the current Pulse Patrol assessment');
- expect(handoff.prompt).toContain('1 governed action reference');
- expect(handoff.prompt).toContain('Do not infer, repeat, or execute raw command text');
+ expect(handoff).not.toHaveProperty('prompt');
expect(handoff.context.autonomousMode).toBe(false);
expect(handoff.context.handoffContext).toContain('[Patrol Assessment Context]');
expect(handoff.context.handoffContext).toContain('Source: Pulse Patrol current assessment');
@@ -397,7 +393,6 @@ describe('patrolInvestigationContextModel', () => {
safetyNote:
'Review action posture in the governed flow; raw command payloads stay out of Assistant.',
});
- expect(handoff.context.briefing?.suggestedPrompts).toBeUndefined();
expect(JSON.stringify(handoff)).not.toContain('systemctl restart workload.service');
});
@@ -447,15 +442,12 @@ describe('patrolInvestigationContextModel', () => {
activeFindings: [],
});
- expect(handoff.prompt).toContain('incomplete Patrol coverage signals');
- expect(handoff.prompt).toContain('Decide from the evidence whether more verification is needed');
- expect(handoff.prompt).not.toContain('next-step metadata');
+ expect(handoff).not.toHaveProperty('prompt');
expect(handoff.context.briefing).toMatchObject({
actionLabel: 'Discuss Patrol coverage',
safetyNote:
'Assistant can review the coverage evidence; Patrol runs, diagnostics, and remediation remain governed controls.',
});
- expect(handoff.context.briefing?.suggestedPrompts).toBeUndefined();
expect(handoff.context.briefing?.actionHref).toBeUndefined();
expect(handoff.context.handoffContext).toContain('Assessment: Coverage incomplete');
expect(handoff.context.handoffContext).not.toContain('Recommended Next Step');
@@ -521,13 +513,11 @@ describe('patrolInvestigationContextModel', () => {
],
});
- expect(handoff.prompt).toContain('1 active finding');
- expect(handoff.prompt).not.toContain('next-step metadata');
+ expect(handoff).not.toHaveProperty('prompt');
expect(handoff.context.briefing).toMatchObject({
actionLabel: 'Discuss Patrol assessment',
safetyNote: 'Diagnostics and remediation require governed approval.',
});
- expect(handoff.context.briefing?.suggestedPrompts).toBeUndefined();
expect(handoff.context.handoffContext).not.toContain('Recommended Next Step');
});
@@ -572,8 +562,7 @@ describe('patrolInvestigationContextModel', () => {
});
expect(handoff.context.autonomousMode).toBe(false);
- expect(handoff.prompt).toContain('The attached context includes 1 pending governed approval');
- expect(handoff.prompt).toContain('approval policy, dry-run posture');
+ expect(handoff).not.toHaveProperty('prompt');
expect(handoff.context.handoffContext).toContain('Finding 1: High CPU usage');
expect(handoff.context.handoffContext).toContain('approval approval-1');
expect(handoff.context.handoffContext).toContain('live approval pending');
@@ -614,7 +603,6 @@ describe('patrolInvestigationContextModel', () => {
safetyNote:
'Review approvals in the governed flow; approval policy is attached; dry-run posture is attached; destructive actions remain approval-bound; raw command payloads stay out of Assistant.',
});
- expect(handoff.context.briefing?.suggestedPrompts).toBeUndefined();
expect(JSON.stringify(handoff)).not.toContain('systemctl restart workload.service');
});
@@ -659,11 +647,9 @@ describe('patrolInvestigationContextModel', () => {
const handoff = buildPatrolRunAssistantHandoff(run);
- expect(handoff.prompt).toContain('Discuss this Pulse Patrol run');
- expect(handoff.prompt).toContain('The attached context includes a Patrol runtime failure');
- expect(handoff.prompt).toContain('Provider rejected Patrol tool calls');
- expect(handoff.prompt).not.toContain('tool_choice');
- expect(handoff.prompt).not.toContain('No endpoints found');
+ expect(handoff).not.toHaveProperty('prompt');
+ expect(JSON.stringify(handoff.context)).not.toContain('tool_choice');
+ expect(JSON.stringify(handoff.context)).not.toContain('No endpoints found');
expect(handoff.context.autonomousMode).toBe(false);
expect(handoff.context).toMatchObject({
targetType: 'patrol-run',
@@ -692,7 +678,6 @@ describe('patrolInvestigationContextModel', () => {
title: 'Patrol run attached',
actionLabel: 'Review Patrol runtime failure',
});
- expect(handoff.context.briefing?.suggestedPrompts).toBeUndefined();
expect(JSON.stringify(handoff)).not.toContain('provider trace');
expect(JSON.stringify(handoff)).not.toContain('tool_choice');
expect(JSON.stringify(handoff)).not.toContain('No endpoints found');
@@ -722,8 +707,7 @@ describe('patrolInvestigationContextModel', () => {
runtimeState: 'active',
});
- expect(handoff.prompt).toContain('Discuss this Pulse Patrol configuration failure');
- expect(handoff.prompt).toContain('Do not infer, repeat, or execute raw command text');
+ expect(handoff).not.toHaveProperty('prompt');
expect(handoff.context.autonomousMode).toBe(false);
expect(handoff.context.handoffMetadata).toMatchObject({
kind: 'patrol_configuration_failure',
@@ -741,7 +725,6 @@ describe('patrolInvestigationContextModel', () => {
title: 'Patrol configuration failure attached',
actionLabel: 'Review Patrol configuration failure',
});
- expect(handoff.context.briefing?.suggestedPrompts).toBeUndefined();
expect(JSON.stringify(handoff)).not.toContain('systemctl restart pulse.service');
});
@@ -759,7 +742,7 @@ describe('patrolInvestigationContextModel', () => {
},
});
- expect(handoff.prompt).toContain('Discuss this Pulse Patrol configuration issue');
+ expect(handoff).not.toHaveProperty('prompt');
expect(handoff.context.briefing).toMatchObject({
title: 'Patrol configuration issue attached',
actionLabel: 'Review Patrol configuration issue',
@@ -872,116 +855,6 @@ describe('patrolInvestigationContextModel', () => {
expect(presentation.rollbackSummaries).toEqual([]);
});
- it('seeds an explain-intent prompt with explanation framing rather than discussion framing', () => {
- const discussPrompt = buildPatrolAssistantFindingPrompt({
- title: 'Backup job failing',
- subject: 'vm-101',
- description: 'Datastore quota exhausted',
- });
- const explainPrompt = buildPatrolAssistantFindingPrompt({
- title: 'Backup job failing',
- subject: 'vm-101',
- description: 'Datastore quota exhausted',
- intent: 'explain',
- });
-
- expect(discussPrompt).toContain("I'd like to discuss");
- expect(explainPrompt).toContain('Explain this Patrol finding');
- expect(explainPrompt.toLowerCase()).toContain('walk me through what we know');
- // Both prompts include the title and subject so the seed reads naturally.
- expect(explainPrompt).toContain('Backup job failing');
- expect(explainPrompt).toContain('vm-101');
- });
-
- it('seeds a verify_fix-intent prompt that asks the LLM to confirm the fix actually worked', () => {
- // Verify fix is the post-remediation check. After a fix has run,
- // the operator asks "did that actually clear the underlying
- // condition" — and the LLM should check via Pulse tools rather
- // than trust the fix command's exit code. Verification is
- // read-only; no state-changing tool calls.
- const prompt = buildPatrolAssistantFindingPrompt({
- title: 'Backup job failing',
- subject: 'vm-101',
- description: 'Datastore quota exhausted',
- intent: 'verify_fix',
- });
-
- expect(prompt).toContain('Verify the fix applied to this Patrol finding');
- expect(prompt).toContain('Backup job failing');
- expect(prompt).toContain('vm-101');
- // The verification dimensions: condition cleared, evidence,
- // confidence, residual risk.
- expect(prompt.toLowerCase()).toContain('condition');
- expect(prompt.toLowerCase()).toContain('cleared');
- expect(prompt.toLowerCase()).toContain('evidence');
- expect(prompt.toLowerCase()).toContain('confident');
- expect(prompt.toLowerCase()).toMatch(/residual|monitor/);
- // Read-only safety: no state-changing commands during verification.
- expect(prompt.toLowerCase()).toContain('read-only');
- expect(prompt).not.toContain("I'd like to discuss");
- expect(prompt).not.toContain('Investigate this Patrol finding now');
- });
-
- it('seeds a why-intent prompt that focuses on cause, not current state', () => {
- // Why-did-this-happen is the diagnostic counterpart to Explain. Where
- // Explain says "tell me what we know" and Investigate says "go find
- // out what's true now," Why focuses the LLM on cause — recent
- // changes, correlations, prior incidents, regression patterns. Not
- // "is it bad right now" but "what made it become bad."
- const prompt = buildPatrolAssistantFindingPrompt({
- title: 'Backup job failing',
- subject: 'vm-101',
- description: 'Datastore quota exhausted',
- intent: 'why',
- });
-
- expect(prompt).toContain('Why did this Patrol finding happen');
- expect(prompt).toContain('Backup job failing');
- expect(prompt).toContain('vm-101');
- expect(prompt.toLowerCase()).toContain('cause, not on current state');
- // The diagnostic signals the prompt directs the LLM toward.
- expect(prompt.toLowerCase()).toMatch(/recent changes|correlations|prior incidents|regression/);
- // Synthesis: what caused it, what evidence supports the cause, what
- // would have to be true for it to recur.
- expect(prompt.toLowerCase()).toContain('most likely caused');
- expect(prompt.toLowerCase()).toContain('evidence');
- expect(prompt.toLowerCase()).toContain('recur');
- // Safety: cause investigation may need tools but must not run
- // anything that changes state without operator approval.
- expect(prompt.toLowerCase()).toContain('operator approval');
- expect(prompt).not.toContain("I'd like to discuss");
- expect(prompt).not.toContain('Investigate this Patrol finding now');
- });
-
- it('seeds an investigate-intent prompt that lets the model decide whether tools are needed', () => {
- // Investigate is the action counterpart to Explain. Where Explain says
- // "tell me what we know," Investigate says "go find out what's true
- // right now" — the prompt should provide the available context without
- // forcing a specific tool path before the model has reasoned about it.
- const prompt = buildPatrolAssistantFindingPrompt({
- title: 'Backup job failing',
- subject: 'vm-101',
- description: 'Datastore quota exhausted',
- intent: 'investigate',
- });
-
- expect(prompt).toContain('Investigate this Patrol finding now');
- expect(prompt).toContain('Backup job failing');
- expect(prompt).toContain('vm-101');
- // Model-owned tool choice — the differentiator vs Explain.
- expect(prompt.toLowerCase()).toContain('decide whether the available pulse tools are needed');
- expect(prompt.toLowerCase()).toContain('fresh evidence');
- // Synthesis instruction — root cause + confidence + model-owned next step.
- expect(prompt.toLowerCase()).toContain('root cause');
- expect(prompt.toLowerCase()).toContain('confidence');
- expect(prompt.toLowerCase()).toContain('what should happen next');
- // Safety: any command-running must route through governed approval,
- // not the LLM's own judgment.
- expect(prompt.toLowerCase()).toContain('governed approval');
- // Must not be the open-ended Discuss prompt.
- expect(prompt).not.toContain("I'd like to discuss");
- });
-
it('surfaces investigation impact and rollback when the backend record carries them', () => {
const presentation = buildPatrolInvestigationRecordPresentation({
id: 'record-2',
@@ -1060,83 +933,6 @@ describe('patrolInvestigationContextModel', () => {
expect(JSON.stringify(briefing)).not.toContain('systemctl restart nginx');
});
- it('frames Assistant handoff around the structured Patrol record when one exists', () => {
- expect(
- buildPatrolAssistantFindingPrompt({
- title: 'High CPU usage',
- subject: 'web-server',
- description: 'CPU stayed above 95%.',
- investigationRecord: {
- id: 'record-1',
- finding_id: 'finding-1',
- subject: { resource_id: 'vm-100' },
- trigger: { detected_at: '2026-05-06T12:00:00Z' },
- status: 'completed',
- evidence: [],
- verification: [],
- rollback: [],
- tools_used: [],
- started_at: '2026-05-06T12:00:00Z',
- },
- }),
- ).toContain('Use that record as context, then decide next steps from current evidence.');
- });
-
- it('leads finding prompts with live governed approval context without command text', () => {
- const prompt = buildPatrolAssistantFindingPrompt({
- title: 'High CPU usage',
- subject: 'web-server',
- description: 'CPU stayed above 95%.',
- pendingApproval: {
- id: 'approval-1',
- status: 'pending',
- riskLevel: 'high',
- targetName: 'web-server',
- actionApprovalPolicy: 'operator',
- actionPreflight: 'Service restart would be attempted after health checks.',
- actionDryRunSummary: 'Dry run completed with one restart action.',
- },
- proposedFix: buildPatrolAssistantProposedFixBriefingInput({
- description: 'Restart the workload service',
- commands: ['systemctl restart workload.service'],
- riskLevel: 'high',
- targetHost: 'web-server',
- }),
- });
-
- expect(prompt).toContain('Governed approval approval-1 is attached');
- expect(prompt).toContain('approval status pending');
- expect(prompt).toContain('high risk');
- expect(prompt).toContain('approval policy attached');
- expect(prompt).toContain('dry-run posture attached');
- expect(prompt).toContain('next steps');
- expect(prompt).not.toContain('systemctl restart workload.service');
- });
-
- it('leads finding prompts with proposed-fix posture without command text', () => {
- const prompt = buildPatrolAssistantFindingPrompt({
- title: 'Nginx down',
- subject: 'node-1',
- description: 'The service stopped responding.',
- investigationOutcome: 'fix_queued',
- remediationId: 'remediation-1',
- proposedFix: buildPatrolAssistantProposedFixBriefingInput({
- description: 'Restart nginx',
- commands: ['systemctl restart nginx'],
- riskLevel: 'medium',
- targetHost: 'node-1',
- destructive: true,
- }),
- });
-
- expect(prompt).toContain('Governed action posture is attached');
- expect(prompt).toContain('medium risk');
- expect(prompt).toContain('1 command recorded for approval context');
- expect(prompt).toContain('destructive action');
- expect(prompt).toContain('next steps');
- expect(prompt).not.toContain('systemctl restart nginx');
- });
-
it('builds finding-level Assistant handoff actions without raw command text', () => {
const actions = buildPatrolAssistantFindingHandoffActions({
id: 'finding-1',
@@ -1250,7 +1046,7 @@ describe('patrolInvestigationContextModel', () => {
}),
});
- expect(handoff.prompt).toContain('Governed approval approval-1 is attached');
+ expect(handoff).not.toHaveProperty('prompt');
expect(handoff.context).toMatchObject({
targetType: 'agent',
targetId: 'agent-1',
@@ -1343,7 +1139,6 @@ describe('patrolInvestigationContextModel', () => {
detailLines: [
'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}; action artifact fix-1; risk high; destructive true`,
],
evidence: ['CPU stayed above 95% for 10 minutes', 'Verified: CPU returned below 50%'],
@@ -1383,11 +1178,6 @@ describe('patrolInvestigationContextModel', () => {
],
};
- const prompt = buildPatrolRemediationPlanAssistantPrompt({
- title: 'Nginx down',
- subject: 'node-1',
- plan,
- });
const modelContext = buildPatrolRemediationPlanAssistantModelContext({
title: 'Nginx down',
subject: 'node-1',
@@ -1399,9 +1189,6 @@ describe('patrolInvestigationContextModel', () => {
plan,
});
- expect(prompt).toBe(
- 'Review this Patrol finding with the attached evidence: "Nginx down" on node-1. Decide what, if anything, should happen next.',
- );
expect(modelContext).toContain('[Patrol Finding Action Context]');
expect(modelContext).toContain(
'Pulse is attaching observed finding context and any existing governed action artifact',
@@ -1434,7 +1221,6 @@ describe('patrolInvestigationContextModel', () => {
expect(briefing.safetyNote).toBe(
'Assistant should decide remediation from evidence; command execution requires governed approval.',
);
- expect(briefing.suggestedPrompts).toBeUndefined();
expect(JSON.stringify(briefing)).not.toContain('systemctl');
});
@@ -1511,14 +1297,13 @@ describe('patrolInvestigationContextModel', () => {
actionReferenceCount: 0,
},
});
- expect(handoff.prompt).not.toContain('visible Patrol navigation');
+ expect(handoff).not.toHaveProperty('prompt');
expect(handoff.context.briefing).toMatchObject({
title: 'Operator briefing attached',
subject: 'Provider connection issue on Patrol runtime',
});
expect(handoff.context.briefing?.actionLabel).toBeUndefined();
expect(handoff.context.briefing?.actionHref).toBeUndefined();
- expect(handoff.context.briefing?.suggestedPrompts).toBeUndefined();
expect(handoff.context.handoffMetadata).toEqual({
kind: 'patrol_finding',
});
diff --git a/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts b/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts
index 9c7eda1b93..d25a51ba46 100644
--- a/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts
+++ b/frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts
@@ -86,39 +86,6 @@ export interface PatrolInvestigationRecordPresentation {
error?: string;
}
-// 'discuss' = open-ended chat entry, operator drives.
-// 'explain' = action-style "do the explaining," auto-sent.
-// 'investigate' = action-style "work out what's true now" — the prompt
-// gives the LLM context and lets it decide whether fresh tool evidence is
-// needed before synthesis. The surface auto-sends the prompt so the work is
-// already in flight on the screen the operator lands on.
-// 'why' = diagnostic "why did this happen" — focuses the LLM on cause
-// rather than current state: recent changes around detection time,
-// learned correlations, prior incident memory, regression history.
-// Action-style and auto-sent like Explain and Investigate.
-// 'verify_fix' = post-remediation verification — ask the LLM to confirm
-// whether the recently-applied fix actually resolved the underlying
-// condition. Only meaningful when a fix has been applied to the
-// finding (investigation outcome is one of the fix-* states).
-export type PatrolAssistantFindingIntent =
- | 'discuss'
- | 'explain'
- | 'investigate'
- | 'why'
- | 'verify_fix';
-
-export interface PatrolAssistantFindingPromptInput {
- title: string;
- subject: string;
- description: string;
- investigationOutcome?: string | null;
- remediationId?: string | null;
- pendingApproval?: PatrolAssistantApprovalBriefingInput | null;
- proposedFix?: PatrolAssistantProposedFixBriefingInput | null;
- investigationRecord?: InvestigationRecord | null;
- intent?: PatrolAssistantFindingIntent;
-}
-
export interface PatrolAssistantApprovalBriefingInput {
id?: string | null;
status?: string | null;
@@ -194,7 +161,6 @@ export interface PatrolAssistantFindingHandoffInput {
pendingApproval?: PatrolAssistantApprovalBriefingInput | null;
proposedFix?: PatrolAssistantProposedFixBriefingInput | null;
investigationRecord?: InvestigationRecord | null;
- intent?: PatrolAssistantFindingIntent;
}
export interface PatrolAssistantFindingModeInput {
@@ -281,18 +247,15 @@ export interface PatrolAssessmentAssistantHandoffInput {
}
export interface PatrolAssessmentAssistantHandoff {
- prompt: string;
- context: Omit<AIChatContext, 'initialPrompt'>;
+ context: AIChatContext;
}
export interface PatrolAssistantFindingHandoff {
- prompt: string;
- context: Omit<AIChatContext, 'initialPrompt'>;
+ context: AIChatContext;
}
export interface PatrolRunAssistantHandoff {
- prompt: string;
- context: Omit<AIChatContext, 'initialPrompt'>;
+ context: AIChatContext;
}
export interface PatrolConfigurationFailureInput {
@@ -318,8 +281,7 @@ export interface PatrolConfigurationFailureInput {
}
export interface PatrolConfigurationFailureHandoff {
- prompt: string;
- context: Omit<AIChatContext, 'initialPrompt'>;
+ context: AIChatContext;
}
const MAX_ASSESSMENT_FINDINGS = 5;
@@ -481,140 +443,15 @@ export function buildPatrolAssistantApprovalBriefingInput(
};
}
-export function buildPatrolAssistantFindingPrompt(
- input: PatrolAssistantFindingPromptInput,
-): string {
- const title = normalizeText(input.title) || 'Patrol finding';
- const subject = normalizeText(input.subject) || 'the affected resource';
- const description = normalizeText(input.description);
- const hasRecord = Boolean(input.investigationRecord?.id);
- const actionInstruction = buildPatrolAssistantFindingActionPromptInstruction(input);
-
- let prompt: string;
- if (input.intent === 'explain') {
- prompt =
- `Explain this Patrol finding: "${title}" on ${subject}. ` +
- 'Walk me through what we know, why it matters for the affected workloads, ' +
- 'how confident the analysis is, what remains uncertain, and what you would do next. ' +
- 'Use the structured investigation record and operational memory in the attached context as the primary source.';
- } else if (input.intent === 'investigate') {
- prompt =
- `Investigate this Patrol finding now: "${title}" on ${subject}. ` +
- 'Use the attached context and decide whether the available Pulse tools are needed to gather fresh evidence ' +
- 'about the current state of the affected resource and related resources. ' +
- 'Then synthesize: what is the root cause given the current evidence, ' +
- 'what is your confidence, and what should happen next? ' +
- 'If any command-running step is involved, surface it for governed approval rather than executing on your own judgment.';
- } else if (input.intent === 'why') {
- prompt =
- `Why did this Patrol finding happen: "${title}" on ${subject}? ` +
- 'Focus on cause, not on current state. Look at recent changes around the detection time, ' +
- 'learned correlations with other resources, prior incidents for this resource, and any ' +
- 'regression history that suggests a recurring trigger. ' +
- 'Then answer: what most likely caused this to fire now, ' +
- 'what evidence in the attached context supports that cause, ' +
- 'and what would have to be true for the cause to recur. ' +
- 'If the cause requires verification, decide whether the available Pulse tools are needed; do not run anything that changes state without operator approval.';
- } else if (input.intent === 'verify_fix') {
- prompt =
- `Verify the fix applied to this Patrol finding: "${title}" on ${subject}. ` +
- 'A remediation step has been executed against this finding — confirm whether the underlying ' +
- 'condition has actually cleared. Decide whether the available Pulse tools are needed to check current evidence against the original signal that fired this ' +
- 'finding, not against an unrelated state. ' +
- 'Then answer: is the condition cleared, what evidence supports that judgment, ' +
- 'how confident are you, and is there any residual risk the operator should monitor for. ' +
- 'Do not execute any new state-changing commands; verification is read-only.';
- } else {
- prompt = `I'd like to discuss this Patrol finding: "${title}" on ${subject}.`;
- }
- if (
- hasRecord &&
- input.intent !== 'explain' &&
- input.intent !== 'investigate' &&
- input.intent !== 'why' &&
- input.intent !== 'verify_fix'
- ) {
- prompt +=
- '\n\nPulse Patrol has a structured investigation record for this finding. Use that record as context, then decide next steps from current evidence.';
- }
- if (actionInstruction) {
- prompt += `\n\n${actionInstruction}`;
- }
- if (description) {
- prompt += `\n\n${description}`;
- }
- return prompt;
-}
-
-function buildPatrolAssistantFindingActionPromptInstruction(
- input: PatrolAssistantFindingPromptInput,
-): string | undefined {
- const pendingApproval = normalizeApprovalBriefing(input.pendingApproval);
- const record = buildPatrolInvestigationRecordPresentation(input.investigationRecord);
- const proposedFix = record.proposedFix || normalizeProposedFixBriefing(input.proposedFix);
- const remediationId = normalizeText(input.remediationId);
- const outcome = normalizeText(input.investigationOutcome || input.investigationRecord?.outcome);
- const normalizedOutcome = outcome.toLowerCase();
-
- if (pendingApproval.id) {
- const contextParts = [
- pendingApproval.status ? `approval status ${pendingApproval.status}` : undefined,
- pendingApproval.riskLevel ? `${pendingApproval.riskLevel} risk` : undefined,
- pendingApproval.targetName
- ? `target ${truncateContextText(pendingApproval.targetName, 120)}`
- : undefined,
- pendingApproval.actionApprovalPolicy ? 'approval policy attached' : undefined,
- pendingApproval.actionPreflight || pendingApproval.actionDryRunSummary
- ? 'dry-run posture attached'
- : undefined,
- ].filter(isNonEmptyString);
-
- return `Governed approval ${pendingApproval.id} is attached${
- contextParts.length > 0 ? ` (${contextParts.join('; ')})` : ''
- }. Treat it as approval context. Use the attached Patrol evidence to decide prerequisites, risk, and next steps before any execution.`;
- }
-
- const hasGovernedActionPosture = Boolean(
- proposedFix ||
- remediationId ||
- normalizeText(input.investigationRecord?.approval_id) ||
- GOVERNED_ACTION_OUTCOMES.has(normalizedOutcome),
- );
- if (!hasGovernedActionPosture) {
- return undefined;
- }
-
- const contextParts = [
- proposedFix?.description
- ? `recorded action artifact ${truncateContextText(proposedFix.description, 120)}`
- : undefined,
- proposedFix?.riskLabel ? `${proposedFix.riskLabel.toLowerCase()} risk` : undefined,
- proposedFix?.targetHost
- ? `target ${truncateContextText(proposedFix.targetHost, 120)}`
- : undefined,
- proposedFix?.commandSummary,
- proposedFix?.destructive ? 'destructive action' : undefined,
- remediationId ? `remediation ${truncateContextText(remediationId, 120)}` : undefined,
- outcome ? `outcome ${formatIdentifierLabel(outcome)?.toLowerCase() || outcome}` : undefined,
- ].filter(isNonEmptyString);
-
- return `Governed action posture is attached${
- contextParts.length > 0 ? ` (${contextParts.join('; ')})` : ''
- }. Treat it as approval context, not a remediation decision. Use the attached Patrol evidence to decide risk, prerequisites, and next steps without repeating command text.`;
-}
-
export function buildPatrolAssessmentAssistantHandoff(
input: PatrolAssessmentAssistantHandoffInput,
): PatrolAssessmentAssistantHandoff {
- const title = normalizeText(input.assessment?.title) || 'Pulse Patrol assessment';
- const description = normalizeText(input.assessment?.description);
const handoffContext = buildPatrolAssessmentAssistantModelContext(input);
const recentChanges = normalizeAssessmentRecentChanges(input.supportingEvidence?.recentChanges);
const correlations = normalizeAssessmentCorrelations(input.supportingEvidence?.correlations);
const handoffActions = buildPatrolAssessmentHandoffActions(input);
return {
- prompt: buildPatrolAssessmentAssistantPrompt(input, title, description, handoffActions),
context: {
targetType: 'patrol-assessment',
targetId: 'pulse-patrol-assessment',
@@ -649,17 +486,6 @@ export function buildPatrolAssistantFindingHandoff(
const handoffActions = buildPatrolAssistantFindingHandoffActions(input);
return {
- prompt: buildPatrolAssistantFindingPrompt({
- title: input.title,
- subject: input.subject,
- description: normalizeText(input.description),
- investigationOutcome: input.investigationOutcome,
- remediationId: input.remediationId,
- pendingApproval: input.pendingApproval,
- proposedFix: input.proposedFix,
- investigationRecord: input.investigationRecord,
- intent: input.intent,
- }),
context: {
targetType: resource?.type,
targetId: resource?.id,
@@ -713,7 +539,6 @@ export function buildPatrolRunAssistantHandoff(run: PatrolRunRecord): PatrolRunA
const handoffResources = buildPatrolRunHandoffResources(run);
return {
- prompt: buildPatrolRunAssistantPrompt(run, kindLabel, statusLabel, runtimeFailure),
context: {
targetType: 'patrol-run',
targetId: runId || undefined,
@@ -761,7 +586,6 @@ export function buildPatrolConfigurationFailureHandoff(
].filter(isNonEmptyString);
return {
- prompt: buildPatrolConfigurationFailurePrompt(input, message, detailLines),
context: {
targetType: 'patrol-configuration',
targetId: 'pulse-patrol-configuration',
@@ -806,62 +630,6 @@ export function buildPatrolAssistantFindingHandoffActions(
return action ? [action] : [];
}
-function buildPatrolAssessmentAssistantPrompt(
- input: PatrolAssessmentAssistantHandoffInput,
- title: string,
- description: string,
- handoffActions: AIChatHandoffAction[],
-): string {
- const reviewInstruction = buildPatrolAssessmentReviewPromptInstruction(input, handoffActions);
-
- return [
- `Discuss the current Pulse Patrol assessment: ${title}.`,
- description,
- reviewInstruction,
- 'Use the attached model-only assessment context and decide what, if anything, needs fresh evidence, operator action, or governed tool use.',
- 'Do not infer, repeat, or execute raw command text from this handoff.',
- ]
- .filter(isNonEmptyString)
- .join('\n\n');
-}
-
-function buildPatrolAssessmentReviewPromptInstruction(
- input: PatrolAssessmentAssistantHandoffInput,
- handoffActions: AIChatHandoffAction[],
-): string {
- const pendingApprovalCount = normalizeAssessmentPendingApprovalCount(input.activeFindings);
- const actionCount = handoffActions.length;
- const activeFindingCount = normalizeNonNegativeCount(input.activeFindings?.length);
- const hasCoverageOnlyGap = assessmentHasCoverageGap(input) && activeFindingCount === 0;
-
- if (pendingApprovalCount > 0) {
- return `The attached context includes ${formatAssessmentMetricCount(
- 'pending governed approvals',
- pendingApprovalCount,
- )}, approval policy, dry-run posture, and current evidence.`;
- }
-
- if (actionCount > 0) {
- return `The attached context includes ${formatAssessmentMetricCount(
- 'governed action references',
- actionCount,
- )}, risk, and current evidence.`;
- }
-
- if (activeFindingCount > 0) {
- return `The attached context includes ${formatAssessmentMetricCount(
- 'active findings',
- activeFindingCount,
- )}, affected resources, evidence, and verification caveats.`;
- }
-
- if (hasCoverageOnlyGap) {
- return 'The attached context includes incomplete Patrol coverage signals. Decide from the evidence whether more verification is needed before action.';
- }
-
- return 'Review the attached model-only Patrol assessment context.';
-}
-
function buildPatrolAssessmentAssistantBriefing(
input: PatrolAssessmentAssistantHandoffInput,
): AIChatContextBriefing {
@@ -1061,31 +829,6 @@ function buildPatrolAssessmentAssistantModelContext(
.join('\n');
}
-function buildPatrolRunAssistantPrompt(
- run: PatrolRunRecord,
- kindLabel: string,
- statusLabel: string,
- runtimeFailure: string | undefined,
-): string {
- const runId = normalizeText(run.id);
- const trigger = formatTriggerReason(run.trigger_reason);
- const runLabel = [kindLabel, runId].filter(isNonEmptyString).join(' ') || 'Patrol run';
- const focus = runtimeFailure
- ? `The attached context includes a Patrol runtime failure: ${truncateContextText(runtimeFailure, 180)}.`
- : `The attached context includes a Patrol run outcome: ${statusLabel}${
- trigger ? `, ${trigger.toLowerCase()}` : ''
- }.`;
-
- return [
- `Discuss this Pulse Patrol run: ${runLabel}.`,
- focus,
- 'Use the attached model-only run history context and decide what, if anything, needs fresh evidence, operator action, or governed tool use.',
- 'Do not infer, repeat, or execute raw command text from this handoff.',
- ]
- .filter(isNonEmptyString)
- .join('\n\n');
-}
-
function buildPatrolRunAssistantBriefing(
run: PatrolRunRecord,
kindLabel: string,
@@ -1120,25 +863,6 @@ function buildPatrolRunAssistantBriefing(
};
}
-function buildPatrolConfigurationFailurePrompt(
- input: PatrolConfigurationFailureInput,
- message: string,
- detailLines: string[],
-): string {
- const code = normalizeText(input.code);
- const issueLabel = input.saved ? 'configuration issue' : 'configuration failure';
- return [
- `Discuss this Pulse Patrol ${issueLabel}.`,
- code ? `Server code: ${code}.` : undefined,
- `The attached context includes this failure: ${truncateContextText(message, 220)}.`,
- detailLines.length > 0 ? `Attached details: ${detailLines.join('; ')}.` : undefined,
- 'Use the attached model-only configuration context and decide what, if anything, needs fresh evidence, operator action, or governed tool use.',
- 'Do not infer, repeat, or execute raw command text from this handoff.',
- ]
- .filter(isNonEmptyString)
- .join('\n\n');
-}
-
function buildPatrolConfigurationFailureModelContext(
input: PatrolConfigurationFailureInput,
message: string,
@@ -1943,7 +1667,7 @@ function formatAssessmentFindingContextLine(
record.confidenceLabel,
record.conclusion ? `conclusion ${truncateContextText(record.conclusion, 180)}` : undefined,
record.recommendedAction
- ? `recommended ${truncateContextText(record.recommendedAction, 180)}`
+ ? `recorded action note ${truncateContextText(record.recommendedAction, 180)}`
: undefined,
recordApprovalId && recordApprovalId !== pendingApproval.id
? `approval ${recordApprovalId}`
@@ -2044,7 +1768,7 @@ function buildPatrolAssistantFindingModelContext(
'Impact',
record.hasRecord ? record.impact || 'Impact not assessed' : record.impact,
),
- formatContextLine('Recommended Action', record.recommendedAction),
+ formatContextLine('Recorded Action Note', record.recommendedAction),
...record.evidenceSummaries.map((summary, index) =>
formatContextLine(`Evidence ${index + 1}`, summary),
),
@@ -2160,15 +1884,6 @@ export function patrolAssistantFindingHandoffRequiresApprovalMode(
return GOVERNED_ACTION_OUTCOMES.has(outcome);
}
-export function buildPatrolRemediationPlanAssistantPrompt(
- input: PatrolRemediationPlanAssistantInput,
-): string {
- const title = normalizeText(input.title) || 'Patrol finding';
- const subject = normalizeText(input.subject) || 'the affected resource';
-
- return `Review this Patrol finding with the attached evidence: "${title}" on ${subject}. Decide what, if anything, should happen next.`;
-}
-
export function buildPatrolRemediationPlanAssistantModelContext(
input: PatrolRemediationPlanAssistantInput,
): string {
@@ -2264,7 +1979,6 @@ export function buildPatrolAssistantFindingBriefing(
attentionReason ? `Attention: ${attentionReason}` : undefined,
record.conclusion,
record.impact ? `Impact: ${record.impact}` : undefined,
- record.recommendedAction,
proposedFixDetail,
operatorDecision ? `Decision: ${operatorDecision}` : undefined,
]
diff --git a/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts b/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts
index 9d9e7b1c8c..da95d6e8d6 100644
--- a/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts
+++ b/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts
@@ -782,7 +782,7 @@ export function usePatrolIntelligenceState() {
const failure = advancedSettingsError();
if (!failure) return;
const handoff = buildPatrolConfigurationFailureHandoff(failure);
- aiChatStore.openWithPrompt(handoff.prompt, handoff.context);
+ aiChatStore.open(handoff.context);
setShowAdvancedSettings(false);
}
diff --git a/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts b/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts
index bf70358579..a179cd2c01 100644
--- a/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts
+++ b/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts
@@ -478,7 +478,7 @@ describe('tab path helpers', () => {
expect(alertResourceIncidentsPanelSource).toContain('IncidentAssistantHandoffButton');
expect(incidentTimelinePanelSource).toContain('IncidentAssistantHandoffButton');
expect(incidentAssistantHandoffButtonSource).toContain('buildAlertIncidentAssistantHandoff');
- expect(incidentAssistantHandoffButtonSource).toContain('aiChatStore.openWithPrompt');
+ expect(incidentAssistantHandoffButtonSource).toContain('aiChatStore.open');
expect(alertAssistantHandoffModelSource).toContain('handoffContext');
expect(alertAssistantHandoffModelSource).toContain('handoffResources');
expect(alertAssistantHandoffModelSource).toContain('[Alert Investigation Context]');
diff --git a/frontend-modern/src/stores/__tests__/aiChat.test.ts b/frontend-modern/src/stores/__tests__/aiChat.test.ts
index 0c468e99bf..58282f63dd 100644
--- a/frontend-modern/src/stores/__tests__/aiChat.test.ts
+++ b/frontend-modern/src/stores/__tests__/aiChat.test.ts
@@ -100,8 +100,8 @@ describe('aiChatStore', () => {
expect(aiChatStore.contextItems[0].name).toBe('storage-1');
});
- it('opens with a pre-filled prompt', () => {
- aiChatStore.openWithPrompt('hello', {
+ it('opens with attached context only', () => {
+ aiChatStore.open({
targetType: 'vm',
targetId: 'vm-101',
briefing: {
@@ -109,76 +109,34 @@ describe('aiChatStore', () => {
title: 'Investigation record attached',
actionLabel: 'Open Patrol provider settings',
actionHref: '/settings/system-ai',
- suggestedPrompts: ['Explain recent changes and correlations'],
},
handoffMetadata: {
kind: 'patrol_finding',
},
});
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?.actionLabel).toBe('Open Patrol provider settings');
expect(aiChatStore.context.briefing?.actionHref).toBe('/settings/system-ai');
- expect(aiChatStore.context.briefing?.suggestedPrompts).toEqual([
- 'Explain recent changes and correlations',
- ]);
expect(aiChatStore.context.handoffMetadata).toMatchObject({
kind: 'patrol_finding',
});
});
- it('threads autoSendInitialPrompt through openWithPrompt and clears it on clearAutoSendFlag', () => {
- // Action-style entry points (Explain, Investigate, eventually Verify
- // fix) set autoSendInitialPrompt: true so the chat surface submits
- // immediately on open instead of pre-filling the input and waiting
- // for Enter. Discuss-style entries leave it falsy.
- aiChatStore.openWithPrompt('Explain this Patrol finding', {
- targetType: 'vm',
- targetId: 'vm-100',
- autoSendInitialPrompt: true,
- });
-
- expect(aiChatStore.context.initialPrompt).toBe('Explain this Patrol finding');
- expect(aiChatStore.context.autoSendInitialPrompt).toBe(true);
-
- aiChatStore.clearAutoSendFlag();
-
- expect(aiChatStore.context.autoSendInitialPrompt).toBeUndefined();
- // The initialPrompt is independent — clearAutoSendFlag must not also
- // clear the prompt itself (the chat effect still needs to read and
- // submit it before its own clearInitialPrompt runs).
- expect(aiChatStore.context.initialPrompt).toBe('Explain this Patrol finding');
- });
-
- it('defaults autoSendInitialPrompt to undefined when not provided', () => {
- aiChatStore.openWithPrompt('discuss this', {
- targetType: 'vm',
- targetId: 'vm-200',
- });
- expect(aiChatStore.context.autoSendInitialPrompt).toBeUndefined();
- });
-
- it('preserves scoped autonomous-mode overrides for pre-filled prompts', () => {
- aiChatStore.openWithPrompt('brief me', {
+ it('preserves scoped autonomous-mode overrides for context-only opens', () => {
+ aiChatStore.open({
targetType: 'dashboard',
targetId: 'pulse-brief',
autonomousMode: false,
});
expect(aiChatStore.isOpen).toBe(true);
- expect(aiChatStore.context.initialPrompt).toBe('brief me');
- expect(aiChatStore.context.autonomousMode).toBe(false);
-
- aiChatStore.clearInitialPrompt();
-
- expect(aiChatStore.context.initialPrompt).toBeUndefined();
expect(aiChatStore.context.autonomousMode).toBe(false);
});
- it('preserves model-only handoff context and resources for pre-filled prompts', () => {
- aiChatStore.openWithPrompt('discuss this incident', {
+ it('preserves model-only handoff context and resources for context-only opens', () => {
+ aiChatStore.open({
targetType: 'storage',
targetId: 'storage-1',
autonomousMode: false,
@@ -188,7 +146,6 @@ describe('aiChatStore', () => {
handoffActions: [{ findingId: 'finding-1', approvalId: 'approval-1' }],
});
- expect(aiChatStore.context.initialPrompt).toBe('discuss this incident');
expect(aiChatStore.context.handoffContext).toContain('[Alert Incident Context]');
expect(aiChatStore.context.handoffResources).toEqual([
{ id: 'storage-1', name: 'tank', type: 'storage', node: 'nas-1' },
@@ -196,21 +153,10 @@ describe('aiChatStore', () => {
expect(aiChatStore.context.handoffActions).toEqual([
{ findingId: 'finding-1', approvalId: 'approval-1' },
]);
-
- aiChatStore.clearInitialPrompt();
-
- expect(aiChatStore.context.initialPrompt).toBeUndefined();
- expect(aiChatStore.context.handoffContext).toContain('Command event recorded');
- expect(aiChatStore.context.handoffResources).toEqual([
- { id: 'storage-1', name: 'tank', type: 'storage', node: 'nas-1' },
- ]);
- expect(aiChatStore.context.handoffActions).toEqual([
- { findingId: 'finding-1', approvalId: 'approval-1' },
- ]);
});
it('clears request handoff payloads while preserving safe visible context', () => {
- aiChatStore.openWithPrompt('discuss this incident', {
+ aiChatStore.open({
targetType: 'storage',
targetId: 'storage-1',
autonomousMode: false,
diff --git a/frontend-modern/src/stores/aiChat.ts b/frontend-modern/src/stores/aiChat.ts
index 2e37fce30b..769a6bb9a7 100644
--- a/frontend-modern/src/stores/aiChat.ts
+++ b/frontend-modern/src/stores/aiChat.ts
@@ -15,7 +15,6 @@ export interface AIChatContextBriefing {
actionHref?: string;
commandSummary?: string;
safetyNote?: string;
- suggestedPrompts?: string[];
}
export interface AIChatHandoffResource {
@@ -69,7 +68,6 @@ export interface AIChatContext {
targetType?: string;
targetId?: string;
context?: Record<string, unknown>;
- initialPrompt?: string;
findingId?: string; // If opened from AI Insights "Get Help", the finding ID to resolve on success
briefing?: AIChatContextBriefing;
handoffContext?: string;
@@ -78,15 +76,6 @@ export interface AIChatContext {
handoffMetadata?: AIChatHandoffMetadata;
// Per-request execution mode override; false keeps scoped handoffs approval-required.
autonomousMode?: boolean;
- // When true, the chat surface should auto-submit the initialPrompt as
- // soon as the drawer opens, rather than just pre-filling the input and
- // waiting for the operator to press Enter. Used by action-style entry
- // points like "Explain" / "Investigate" where the operator has already
- // decided to invoke the action by clicking the button — leaving them
- // to also press Enter is friction. Discuss-style entry points where
- // the operator is opening chat to drive the conversation themselves
- // should leave this false (the default).
- autoSendInitialPrompt?: boolean;
}
// A single context item that can be accumulated
@@ -470,34 +459,6 @@ export const aiChatStore = {
setIsAIChatOpen(true);
},
- // Open with a pre-filled prompt
- openWithPrompt(prompt: string, context?: Omit<AIChatContext, 'initialPrompt'>) {
- setAIChatContext({
- ...context,
- initialPrompt: prompt,
- });
- setIsAIChatOpen(true);
- },
-
- // Clear the initialPrompt so it doesn't re-fire on subsequent opens
- clearInitialPrompt() {
- setAIChatContext((prev) => {
- if (!prev.initialPrompt) return prev;
- const { initialPrompt: _, ...rest } = prev;
- return rest;
- });
- },
-
- // Clear the auto-send flag after firing, so a subsequent open of the
- // drawer without an explicit autoSend doesn't accidentally re-fire.
- clearAutoSendFlag() {
- setAIChatContext((prev) => {
- if (!prev.autoSendInitialPrompt) return prev;
- const { autoSendInitialPrompt: _, ...rest } = prev;
- return rest;
- });
- },
-
// Clear the findingId after first message is sent
clearFindingId() {
setAIChatContext((prev) => {
diff --git a/frontend-modern/src/utils/__tests__/aiChatPresentation.test.ts b/frontend-modern/src/utils/__tests__/aiChatPresentation.test.ts
index f66e3adad0..d03e3d2320 100644
--- a/frontend-modern/src/utils/__tests__/aiChatPresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/aiChatPresentation.test.ts
@@ -15,9 +15,7 @@ import {
AI_CHAT_QUESTION_CARD_TITLE,
AI_CHAT_SESSION_EMPTY_STATE,
AI_CHAT_SESSION_MENU_TITLE,
- AI_CHAT_SUGGESTIONS_LABEL,
getAIChatLauncherTitle,
- getAIChatEmptyStateSuggestions,
getAIChatEmptyStatePresentation,
} from '@/utils/aiChatPresentation';
@@ -41,7 +39,6 @@ describe('aiChatPresentation', () => {
expect(AI_CHAT_SESSION_MENU_TITLE).toBe('Pulse Assistant sessions');
expect(AI_CHAT_SESSION_EMPTY_STATE).toBe('No previous assistant sessions');
expect(AI_CHAT_MODEL_SELECTOR_EMPTY_STATE).toBe('No matching models.');
- expect(AI_CHAT_SUGGESTIONS_LABEL).toBe('Try asking');
expect(AI_CHAT_QUESTION_CARD_TITLE).toBe('Pulse Assistant needs your input');
expect(AI_CHAT_ASSISTANT_MESSAGE_LABEL).toBe('Pulse Assistant');
expect(AI_CHAT_CONTEXT_USED_LABEL).toBe('Context used');
@@ -53,11 +50,6 @@ describe('aiChatPresentation', () => {
expect(getAIChatLauncherTitle()).not.toContain('⌘K');
});
- it('keeps the default empty state as plain chat without prompt chips', () => {
- expect(getAIChatEmptyStateSuggestions(true)).toEqual([]);
- expect(getAIChatEmptyStateSuggestions(false)).toEqual([]);
- });
-
it('uses attached briefing context for scoped assistant handoff empty states', () => {
expect(
getAIChatEmptyStatePresentation({
@@ -66,16 +58,11 @@ describe('aiChatPresentation', () => {
sourceLabel: 'Pulse Patrol',
title: 'Patrol assessment attached',
subject: 'Coverage incomplete',
- suggestedPrompts: [
- 'Explain why coverage is incomplete',
- 'Explain scoped activity and full-run gap',
- ],
},
}),
).toEqual({
- title: 'Review Pulse Patrol context',
- subtitle: 'Patrol assessment attached · Coverage incomplete',
- suggestions: [],
+ title: 'Context attached',
+ subtitle: 'Pulse Patrol · Patrol assessment attached · Coverage incomplete',
});
});
});
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index 7e27d1160a..62992bef37 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -4348,7 +4348,7 @@ describe('frontend resource type boundaries', () => {
expect(patrolInvestigationContextModelSource).toContain(
'export function buildPatrolInvestigationRecordPresentation',
);
- expect(patrolInvestigationContextModelSource).toContain(
+ expect(patrolInvestigationContextModelSource).not.toContain(
'export function buildPatrolAssistantFindingPrompt',
);
expect(patrolInvestigationContextModelSource).toContain(
@@ -4367,7 +4367,6 @@ describe('frontend resource type boundaries', () => {
expect(patrolIntelligenceHeaderSource).not.toContain('getAIQuickstartCreditsPresentation');
expect(patrolIntelligenceHeaderSource).not.toContain('quickstart_credits');
expect(patrolIntelligenceHeaderSource).not.toContain('using_quickstart');
- expect(patrolIntelligenceSummarySource).toContain('getPatrolSummaryPresentation');
expect(patrolIntelligenceSummarySource).toContain('getPatrolAssessmentPresentation');
expect(patrolIntelligenceWorkspaceSource).toContain('ApprovalBanner');
expect(patrolIntelligenceWorkspaceSource).toContain('FindingsPanel');
@@ -4496,7 +4495,8 @@ describe('frontend resource type boundaries', () => {
expect(aiChatPresentationSource).toContain('export const AI_CHAT_DISCOVERY_HINT_TITLE');
expect(aiChatPresentationSource).toContain('export const AI_CHAT_QUESTION_CARD_TITLE');
expect(aiChatPresentationSource).toContain('export function getAIChatLauncherTitle');
- expect(aiChatPresentationSource).toContain('export function getAIChatEmptyStateSuggestions');
+ expect(aiChatPresentationSource).not.toContain('AI_CHAT_SUGGESTIONS_LABEL');
+ expect(aiChatPresentationSource).not.toContain('getAIChatEmptyStateSuggestions');
expect(remediationStatusSource).toContain('getRemediationPresentation');
expect(remediationStatusSource).not.toContain(
"'bg-green-50 dark:bg-green-900 border border-green-200 dark:border-green-800'",
diff --git a/frontend-modern/src/utils/aiChatPresentation.ts b/frontend-modern/src/utils/aiChatPresentation.ts
index 331ab8f542..9a91bae69d 100644
--- a/frontend-modern/src/utils/aiChatPresentation.ts
+++ b/frontend-modern/src/utils/aiChatPresentation.ts
@@ -16,7 +16,6 @@ export const AI_CHAT_EMPTY_STATE_TITLE = 'Ask about your infrastructure';
export const AI_CHAT_EMPTY_STATE_SUBTITLE =
'Chat with your configured model using Pulse context and governed tools.';
export const AI_CHAT_INPUT_PLACEHOLDER = 'Ask about your infrastructure...';
-export const AI_CHAT_SUGGESTIONS_LABEL = 'Try asking';
export const AI_CHAT_QUESTION_CARD_TITLE = 'Pulse Assistant needs your input';
export const AI_CHAT_QUESTION_CARD_PLACEHOLDER = 'Type your answer...';
export const AI_CHAT_ASSISTANT_MESSAGE_LABEL = 'Pulse Assistant';
@@ -25,12 +24,10 @@ export const AI_CHAT_CONTEXT_USED_LABEL = 'Context used';
export interface AIChatEmptyStateBriefingInput {
sourceLabel?: string;
subject?: string;
- suggestedPrompts?: string[];
title?: string;
}
export interface AIChatEmptyStatePresentation {
- suggestions: string[];
subtitle?: string;
title: string;
}
@@ -43,11 +40,6 @@ export function getAIChatLauncherTitle(contextName?: unknown) {
return 'Open Pulse Assistant';
}
-export function getAIChatEmptyStateSuggestions(isCluster: boolean) {
- void isCluster;
- return [];
-}
-
export function getAIChatEmptyStatePresentation(args: {
briefing?: AIChatEmptyStateBriefingInput;
isCluster: boolean;
@@ -55,21 +47,17 @@ export function getAIChatEmptyStatePresentation(args: {
const sourceLabel = args.briefing?.sourceLabel?.trim();
const title = args.briefing?.title?.trim();
const subject = args.briefing?.subject?.trim();
- const hasSuggestedPrompts = (args.briefing?.suggestedPrompts ?? []).some(
- (prompt) => prompt.trim().length > 0,
- );
+ void args.isCluster;
- if (args.briefing && (sourceLabel || title || subject || hasSuggestedPrompts)) {
+ if (args.briefing && (sourceLabel || title || subject)) {
return {
- title: sourceLabel ? `Review ${sourceLabel} context` : 'Review attached context',
- subtitle: [title, subject].filter(Boolean).join(' · ') || undefined,
- suggestions: [],
+ title: 'Context attached',
+ subtitle: [sourceLabel, title, subject].filter(Boolean).join(' · ') || undefined,
};
}
return {
title: AI_CHAT_EMPTY_STATE_TITLE,
subtitle: AI_CHAT_EMPTY_STATE_SUBTITLE,
- suggestions: getAIChatEmptyStateSuggestions(args.isCluster),
};
}
diff --git a/frontend-modern/src/utils/aiFindingPresentation.ts b/frontend-modern/src/utils/aiFindingPresentation.ts
index 401ec5169f..5de3b56b1d 100644
--- a/frontend-modern/src/utils/aiFindingPresentation.ts
+++ b/frontend-modern/src/utils/aiFindingPresentation.ts
@@ -812,10 +812,6 @@ export const formatFindingForClipboard = (
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) {
diff --git a/internal/ai/unified/alerts.go b/internal/ai/unified/alerts.go
index d796d81b3a..c7c5eb75b8 100644
--- a/internal/ai/unified/alerts.go
+++ b/internal/ai/unified/alerts.go
@@ -313,8 +313,6 @@ type AlertToFindingConfig struct {
DefaultCategory UnifiedCategory
// TypeCategoryMap maps alert types to categories
TypeCategoryMap map[string]UnifiedCategory
- // GenerateRecommendation enables AI-style recommendations for threshold alerts
- GenerateRecommendation bool
}
// DefaultAlertToFindingConfig returns sensible defaults
@@ -346,7 +344,6 @@ func DefaultAlertToFindingConfig() AlertToFindingConfig {
"oom": CategoryReliability,
"imageUpdateAvail": CategoryConfiguration,
},
- GenerateRecommendation: true,
}
}
@@ -514,11 +511,6 @@ func (s *UnifiedStore) ConvertAlert(alert AlertAdapter) *UnifiedFinding {
finding.Evidence = fmt.Sprintf("Threshold alert triggered: %s = %.1f (threshold: %.1f)",
alertType, alert.GetValue(), alert.GetThreshold())
- // Generate recommendation if enabled
- if s.config.GenerateRecommendation {
- finding.Recommendation = generateRecommendation(alertType, alert.GetValue(), alert.GetThreshold())
- }
-
// Author detection-time impact text per alert type. The text describes the
// operational consequence of operator inaction; it does not vary with
// severity or threshold value because the consequence shape is intrinsic
@@ -1284,30 +1276,6 @@ func generateImpact(alertType string) string {
}
}
-func generateRecommendation(alertType string, value, threshold float64) string {
- switch alertType {
- case "cpu":
- return "Consider investigating high CPU processes or allocating more CPU resources."
- case "memory":
- return "Consider investigating memory-intensive processes or increasing RAM allocation."
- case "disk":
- if value > 95 {
- return "URGENT: Disk is nearly full. Free up space immediately or expand storage."
- }
- return "Consider cleaning up unused files or expanding disk capacity."
- case "usage", "storage":
- return "Consider removing unused data or expanding storage capacity."
- case "temperature":
- return "Check cooling systems and airflow. Consider reducing workload."
- case "offline", "nodeOffline":
- return "Investigate connectivity and check if the resource is accessible."
- case "poweredOff":
- return "Start the resource if it should be running, or acknowledge if maintenance is planned."
- default:
- return "Investigate the alert and take appropriate action."
- }
-}
-
func formatSourceName(source FindingSource) string {
switch source {
case SourceThreshold:
diff --git a/internal/ai/unified/store_additional_test.go b/internal/ai/unified/store_additional_test.go
index 6860ddc761..37efb23e14 100644
--- a/internal/ai/unified/store_additional_test.go
+++ b/internal/ai/unified/store_additional_test.go
@@ -94,8 +94,8 @@ func TestUnifiedStore_ConvertAlert_MetadataAndRecommendation(t *testing.T) {
if finding.ResourceType != "node" {
t.Fatalf("expected resource type from metadata")
}
- if !strings.Contains(finding.Recommendation, "URGENT") {
- t.Fatalf("expected urgent recommendation, got %q", finding.Recommendation)
+ if finding.Recommendation != "" {
+ t.Fatalf("expected no product-authored recommendation, got %q", finding.Recommendation)
}
}
@@ -394,12 +394,6 @@ func TestUnifiedHelpers(t *testing.T) {
if !strings.Contains(title, "offline") {
t.Fatalf("expected offline title")
}
- if !strings.Contains(generateRecommendation("temperature", 0, 0), "cooling") {
- t.Fatalf("expected temperature recommendation")
- }
- if !strings.Contains(generateRecommendation("unknown", 0, 0), "Investigate") {
- t.Fatalf("expected default recommendation")
- }
if formatSourceName("custom") != "custom" {
t.Fatalf("expected fallback source name")
}
diff --git a/internal/api/ai_handler.go b/internal/api/ai_handler.go
index 4c166baec1..eadcc4be85 100644
--- a/internal/api/ai_handler.go
+++ b/internal/api/ai_handler.go
@@ -1062,7 +1062,6 @@ func buildUnifiedFindingChatContext(f *unified.UnifiedFinding, lookup unifiedFin
appendChatContextLine(&b, "Finding Times Raised", strconv.Itoa(f.TimesRaised))
}
appendChatContextLine(&b, "Description", f.Description)
- appendChatContextLine(&b, "Recommendation", f.Recommendation)
appendChatContextLine(&b, "Evidence", f.Evidence)
appendChatContextLine(&b, "AI Context", f.AIContext)
if f.AIConfidence > 0 {
@@ -1218,7 +1217,7 @@ func isSafePatrolFindingRequestHandoffLine(line string) bool {
"Investigation Outcome",
"Investigation Confidence",
"Conclusion",
- "Recommended Action",
+ "Recorded Action Note",
"Tools Used",
"Approval",
"Approval Status",
@@ -1485,7 +1484,6 @@ func appendUnifiedFindingOperatorBriefingContext(b *strings.Builder, f *unified.
appendChatContextLine(b, "Latest Lifecycle Event", latestLifecycle)
}
appendChatContextLine(b, "Current Conclusion", unifiedFindingBriefingConclusion(f))
- appendChatContextLine(b, "Recommended Next Step", unifiedFindingBriefingNextStep(f))
if decision := unifiedFindingBriefingOperatorDecision(f, handoffActions); decision != "" {
appendChatContextLine(b, "Operator Decision", decision)
}
@@ -1750,29 +1748,6 @@ func unifiedFindingBriefingVerification(f *unified.UnifiedFinding) string {
return formatBriefingStringList(f.InvestigationRecord.Verification, 2, "verification")
}
-func unifiedFindingBriefingNextStep(f *unified.UnifiedFinding) string {
- if f == nil {
- return ""
- }
- if unifiedFindingChatStatus(f, time.Now()) == "resolved" {
- return "Explain the resolution and any monitoring follow-up; do not propose execution unless a new active finding is raised."
- }
- if f.InvestigationRecord != nil {
- if next := strings.TrimSpace(f.InvestigationRecord.RecommendedAction); next != "" {
- return next
- }
- if f.InvestigationRecord.ProposedFix != nil {
- if description := strings.TrimSpace(f.InvestigationRecord.ProposedFix.Description); description != "" {
- return "Review proposed fix: " + description
- }
- }
- }
- if recommendation := strings.TrimSpace(f.Recommendation); recommendation != "" {
- return recommendation
- }
- return "Explain what Patrol knows and identify the next evidence to verify before remediation."
-}
-
func unifiedFindingBriefingOperatorDecision(f *unified.UnifiedFinding, handoffActions []chat.HandoffAction) string {
if f == nil {
return ""
@@ -2192,7 +2167,7 @@ func appendInvestigationRecordChatContext(b *strings.Builder, rec *aicontracts.I
appendChatContextLine(b, "Subject Resource ID", rec.Subject.ResourceID)
appendChatContextLine(b, "Subject Node", rec.Subject.Node)
appendChatContextLine(b, "Conclusion", rec.Conclusion)
- appendChatContextLine(b, "Recommended Action", rec.RecommendedAction)
+ appendChatContextLine(b, "Recorded Action Note", rec.RecommendedAction)
appendChatContextLine(b, "Trigger", rec.Trigger.Title)
appendChatContextLine(b, "Trigger Description", rec.Trigger.Description)
if !rec.Trigger.DetectedAt.IsZero() {
diff --git a/internal/api/ai_handler_test.go b/internal/api/ai_handler_test.go
index 386b726437..a40a6729f2 100644
--- a/internal/api/ai_handler_test.go
+++ b/internal/api/ai_handler_test.go
@@ -1082,7 +1082,7 @@ func TestHandleChat_IncludesInvestigationRecordContext(t *testing.T) {
assert.Contains(t, reqArg.HandoffContext, "Verification: CPU returned below 50%")
assert.Contains(t, reqArg.HandoffContext, "Latest Lifecycle Event: 2026-05-06T12:03:00Z | investigation_completed | Fix queued for approval | investigating -> fix_queued")
assert.Contains(t, reqArg.HandoffContext, "Current Conclusion: Backup job saturated CPU.")
- assert.Contains(t, reqArg.HandoffContext, "Recommended Next Step: Approve a controlled service restart after backup completion.")
+ assert.NotContains(t, reqArg.HandoffContext, "Recommended Next Step:")
assert.Contains(t, reqArg.HandoffContext, "Operator Decision: review governed approval approval-123 before execution; proposed fix fix-123; risk medium; destructive true")
assert.Contains(t, reqArg.HandoffContext, "Action Posture: approval approval-123; proposed fix fix-123; risk medium; destructive true; remediation remediation-123")
assert.Contains(t, reqArg.HandoffContext, "Operator Boundary: Treat Patrol data as product context for explanation and review")
@@ -1113,7 +1113,7 @@ func TestHandleChat_IncludesInvestigationRecordContext(t *testing.T) {
assert.Contains(t, reqArg.HandoffContext, "Resource ID: vm-100")
assert.Contains(t, reqArg.HandoffContext, "Subject Resource ID: vm-100")
assert.Contains(t, reqArg.HandoffContext, "Conclusion: Backup job saturated CPU.")
- assert.Contains(t, reqArg.HandoffContext, "Recommended Action: Approve a controlled service restart after backup completion.")
+ assert.Contains(t, reqArg.HandoffContext, "Recorded Action Note: Approve a controlled service restart after backup completion.")
assert.Contains(t, reqArg.HandoffContext, "Evidence 1: metrics: CPU stayed above 95% for 10 minutes")
assert.Contains(t, reqArg.HandoffContext, "Proposed Fix: Restart the workload service")
assert.Contains(t, reqArg.HandoffContext, "Proposed Fix Commands: 1 command recorded for approval context")
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index 359db0fd9f..19b2dfeaf0 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -277,6 +277,14 @@ func TestContract_AssistantFindingContextUsesModelOnlyHandoff(t *testing.T) {
if strings.Contains(handlerText, "prompt = findingCtx +") {
t.Fatal("ai_handler.go must not prepend finding context into the persisted prompt")
}
+ for _, forbidden := range []string{
+ "Recommended Next Step",
+ "unifiedFindingBriefingNextStep",
+ } {
+ if strings.Contains(handlerText, forbidden) {
+ t.Fatalf("ai_handler.go must not synthesize product-authored handoff recommendations: found %q", forbidden)
+ }
+ }
settingsHandlerText := string(settingsHandlerSource)
for _, required := range []string{