Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Simplify Patrol assessment hierarchy
rcourtman44d9f1d9d535
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 8b208371e4..c06d48499e 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -647,10 +647,11 @@ the canonical monitored-system blocked payload.must not become a new execution or approval API.The API contract should stay presentation-neutral here: it supplies thescore, current risk facts, verification facts, and action state needed for a- compact operator summary, but it must not imply a hero, card, or duplicate- verdict layout. Frontend consumers may keep explanatory assessment and- recommendation copy behind a details expansion while deriving the collapsed- readout from the same canonical payloads.+ compact operator summary, but it must not imply a hero, card, duplicate+ verdict layout, or expanded assessment panel. Normal Patrol page consumers+ should keep explanatory assessment, verification, activity, and supporting+ context in the owning Findings, Runs, and Supporting context surfaces rather+ than re-expanding the primary assessment strip.17. Keep Pulse Mobile relay credential minting and permission ownership on backend ownership: `internal/api/router_routes_auth_security.go`, `internal/api/security_tokens.go`, `internal/api/auth.go`, `internal/api/relay_mobile_capability.go`, `internal/api/router_routes_ai_relay.go`, and `frontend-modern/src/api/security.ts` may expose the canonical mobile runtime token creator and governed route gates, but browser callers must only consume that route and must not define the mobile runtime scope, compatibility gate list, route inventory, or token-purpose metadata locally.18. Keep hosted tenant browser-session precedence on the shared auth boundary: `internal/api/auth.go`, `internal/api/contract_test.go`, and hosted tenant callers must treat a valid `pulse_session` as authoritative before any API-only token fallback or no-local-auth anonymous fallback, so cloud handoff can continue into protected hosted routes without flattening the operator back to `anonymous` or forcing a browser session through bearer-token-only mode after the tenant has minted API tokens.That same shared auth boundary also owns hosted handoff authorization. `internal/api/cloud_handoff.go`,@@ -1145,13 +1146,13 @@ the canonical monitored-system blocked payload.operator-facing framing of what Patrol does (proactiveinvestigation, evidence capture, governed action) stays tied to thecontract instead of drifting between hover and inline.- The same Patrol page header also surfaces a compact trust summary- above the runtime status row, reading- `state.patrolStatus()?.trust` (the `FindingsTrustSummary` block- already plumbed through the patrol status payload). It must not- introduce a new fetch path or duplicate data plumbing — the strip is- a render-only consumer of the existing canonical signal so the- header line and the workspace's detailed Trust strip stay aligned.+ The Patrol page must not introduce header or workspace trust strips over+ this payload. High-signal trust facts from+ `state.patrolStatus()?.trust` (the `FindingsTrustSummary` block already+ plumbed through the patrol status payload) may feed the primary+ assessment readout, but they remain render-only consumers of the existing+ canonical signal and must not introduce a new fetch path or duplicate data+ plumbing.The same page-header recency line also reads`PatrolRecencyPresentation.resourcesCheckedLabel` — derived by`getPatrolRecencyPresentation` from@@ -1254,7 +1255,7 @@ the canonical monitored-system blocked payload.and must not expose raw command text or raw execution output. Frontendhandoff briefings must derive from the same shared investigation payloadrather than inventing a second finding-context transport shape.-7. Keep Patrol summary payload consumers aligned on one assessment hierarchy: transport-driven Patrol summary surfaces may show supporting counts and outcomes, but the canonical assessment and verification states must remain singular and not be repeated as a second compact verdict strip+7. Keep Patrol summary payload consumers aligned on one assessment hierarchy: transport-driven Patrol summary surfaces may show supporting counts and outcomes, but the canonical assessment and verification states must remain singular and not be repeated as a second compact verdict strip. The collapsed readout should describe current operator state and score directly rather than combining reassuring grade labels with active-issue copy.8. Keep Patrol verification and activity facts unified on one transport-backed secondary status area: when frontend consumers combine Patrol status payloads (`runtime_state`, `last_patrol_at`, `last_activity_at`, `trigger_status`) with run-history transport, the latest run result, activity mix, scoped-trigger state, and circuit-breaker context must read as one supporting explanation beneath the primary assessment instead of being re-expanded into a separate full-width status strip plus duplicate summary layersand the Patrol runtime-failure run-history contract, so backend payloads,persistence adapters, and `frontend-modern/src/api/patrol.ts` preservediff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex 75399ddfe7..066b2a1fa0 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -1016,11 +1016,11 @@ prompt explain the same operator-facing priority.contextual entry points can vary the seeded leading sentence withoutduplicating the structured-context attachment; shared drawerprimitives must not branch on intent themselves. Patrol-page- surfaces may also render a Trust strip from- `state.patrolStatus()?.trust`, but the strip must read field names- that exist on `FindingsTrustSummary`; shared drawer/chrome- primitives stay free of the trust shape so adding new trust signals- goes through the contract first rather than per-shell branching.+ 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+ the `FindingsTrustSummary` shape so adding new trust signals goes+ through the contract first rather than per-shell branching.Patrol header refresh controls stay on that same feature-owned shellboundary: `frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts`must make the refresh affordance generation-aware and timeout-bounded, so@@ -1680,7 +1680,11 @@ supporting metrics under that strip must stay metric-oriented and must notrepeat assessment or verification labels as a second compact verdict row.The collapsed Patrol assessment strip itself must remain a compact readoutrather than a headline-plus-paragraph block; explanatory assessment and-recommendation copy belongs behind the summary details expansion.+recommendation copy belongs in the owning Findings, Runs, Supporting context,+or recommended-action surfaces rather than a normal-path summary details+expansion.+That readout should lead with current operator state and score rather than+mixing a reassuring grade label with issue-state copy in the same line.That same summary shell should also keep the shared Pulse surface neutral:severity belongs in compact accents, inline readouts, and badges rather thanturning the whole assessment into a tinted warning banner, nested card, ordiff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.mdindex ac487dcc17..79cb92cac3 100644--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md@@ -297,15 +297,15 @@ Patrol-specific presentation helpers.presentation; the Patrol-owned investigation-context model must notabsorb it into impact, verification, or rollback (those representthe current investigation, not history).- The Patrol page renders a small Trust strip above the Findings/Runs- tab bar that surfaces `state.patrolStatus()?.trust` (the- FindingsTrustSummary block on the patrol-status response) as compact- signals: fixes verified, auto-resolved, dismissed-as-noise,- dismissed-as-expected, currently-active, and regressed-at-least-once.- The strip is hidden when every signal is zero so a fresh install- does not show an empty pill. The strip must read field names that- exist on `FindingsTrustSummary`; new strip categories must extend- that contract first rather than inventing per-page keys.+ The Patrol page must not render a standalone Trust strip above the+ Findings/Runs tab bar or a parallel header trust line. The primary+ Patrol assessment readout is the default owner for current operator+ state, and may include high-signal trust facts such as+ `state.patrolStatus()?.trust.regressed_at_least_once` (the+ FindingsTrustSummary block on the patrol-status response) only as+ compact status text. New trust categories must extend the+ `FindingsTrustSummary` contract first rather than inventing+ per-page keys.Findings carry contextual Assistant entry points keyed on intent: thedefault "Discuss with Assistant" button opens an open-ended chathandoff, and a parallel "Explain" button opens the same handoff with@@ -411,11 +411,15 @@ Patrol-specific presentation helpers.9. Keep the normal Patrol assessment summary plain and operator-first ratherthan a hero-style or decorative card surface. The default collapsed state isa compact readout, not a headline block: show the Patrol assessment label,- score, concise current-risk copy, one recommended next-step title, and one- route-owned action. Assessment explanation, recommendation detail,- verification detail, supporting metrics, and whole-assessment Assistant- discussion belong behind the details expansion unless Assistant itself is- the recommended action.+ current operator state, concise high-signal trust posture such as+ regressions when present, score, one recommended next-step title, and one+ route-owned action. Do not combine reassuring grade labels such as+ `Health A` with issue-state copy such as `Issues detected` in the collapsed+ line. Do not add a normal-path assessment details expansion: assessment+ explanation, recommendation detail, verification detail, activity mix,+ supporting metrics, and whole-assessment Assistant discussion belong in the+ owning Findings, Runs, Supporting context, or recommended-action surfaces+ instead of reopening the compact strip into a sparse status panel.## Current State@@ -1201,15 +1205,11 @@ explanation + governed action). The tooltip on the page-header titlemust read the same string from the canonical helper rather thanmaintaining a parallel copy, so hover and inline never tell differentstories about what Patrol does.-The same Patrol page header must also surface a compact trust summary-("N active · M regressed · K fixes verified") read from-`state.patrolStatus()?.trust` immediately under the page title, gated-on at least one non-zero signal so a fresh install doesn't render an-empty header strip. The detailed Trust strip in-`PatrolIntelligenceWorkspace.tsx` stays as the canonical breakdown for-operators reviewing findings; the header line is the-trust-at-a-glance entry point that names what Patrol's loop has-produced before the operator scrolls into the workspace tabs.+The Patrol page header must not add a second trust-at-a-glance line under+the page title. Current active/regressed/finding posture belongs to the+primary assessment readout and the finding rows, so the header remains+focused on product title, recency, and route controls instead of repeating+the same trust counters above the workspace tabs.The same page-header recency line must also surface the coveragesignal from the most recent completed run via`PatrolRecencyPresentation.resourcesChecked`, populated bydiff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsxindex 1191a9bc38..b6ae9b8874 100644--- a/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx@@ -137,55 +137,6 @@ export function PatrolIntelligenceHeader(props: { state: PatrolIntelligenceState}/>- {/* Page-header trust summary — a compact one-liner of FindingsTrustSummary- shown directly under the page title so the operator sees the trust- loop's own state ("3 active, 1 regressed, 5 fixes verified")- before they ever scroll into the workspace. The detailed Trust- strip in PatrolIntelligenceWorkspace stays as the canonical- breakdown for when the operator is reviewing findings. Visibility- is gated on at least one non-zero signal so a fresh install- doesn't render an empty header line. */}- <Show- when={(() => {- const trust = state.patrolStatus()?.trust;- if (!trust) return false;- return (- trust.currently_active > 0 ||- trust.fix_verified > 0 ||- trust.regressed_at_least_once > 0- );- })()}- >- {(() => {- const trust = state.patrolStatus()!.trust!;- return (- <div- class="flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted"- aria-label="Patrol trust summary header"- >- <Show when={trust.currently_active > 0}>- <span class="inline-flex items-center gap-1">- <span class="font-semibold text-base-content">{trust.currently_active}</span>- <span>active</span>- </span>- </Show>- <Show when={trust.regressed_at_least_once > 0}>- <span class="inline-flex items-center gap-1 text-amber-700 dark:text-amber-300">- <span class="font-semibold">{trust.regressed_at_least_once}</span>- <span>regressed</span>- </span>- </Show>- <Show when={trust.fix_verified > 0}>- <span class="inline-flex items-center gap-1 text-emerald-700 dark:text-emerald-300">- <span class="font-semibold">{trust.fix_verified}</span>- <span>fix{trust.fix_verified === 1 ? '' : 'es'} verified</span>- </span>- </Show>- </div>- );- })()}- </Show>-<div class="flex flex-wrap items-center gap-3"><div class="flex items-center gap-2"><TogglePrimitive@@ -199,350 +150,341 @@ export function PatrolIntelligenceHeader(props: { state: PatrolIntelligenceState</div><div class="flex flex-wrap items-center gap-2 sm:ml-auto">- <button- onClick={() => state.handleRunPatrol()}- disabled={- state.isTriggeringPatrol() ||- !state.canTriggerPatrol() ||- state.manualRunRequested() ||- state.patrolStream.isStreaming()- }- title={state.triggerPatrolDisabledReason()}- class="sm:hidden flex items-center gap-2 px-3 py-1.5 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 disabled:bg-surface-alt disabled:text-muted rounded-md transition-colors"- >- <PlayIcon- class={`w-4 h-4 ${state.isTriggeringPatrol() || state.manualRunRequested() || state.patrolStream.isStreaming() ? 'animate-pulse' : ''}`}- />- {state.isTriggeringPatrol()- ? 'Starting…'- : state.manualRunRequested() || state.patrolStream.isStreaming()- ? 'Running…'- : 'Run Patrol'}- </button>+ <button+ onClick={() => state.handleRunPatrol()}+ disabled={+ state.isTriggeringPatrol() ||+ !state.canTriggerPatrol() ||+ state.manualRunRequested() ||+ state.patrolStream.isStreaming()+ }+ title={state.triggerPatrolDisabledReason()}+ class="sm:hidden flex items-center gap-2 px-3 py-1.5 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 disabled:bg-surface-alt disabled:text-muted rounded-md transition-colors"+ >+ <PlayIcon+ class={`w-4 h-4 ${state.isTriggeringPatrol() || state.manualRunRequested() || state.patrolStream.isStreaming() ? 'animate-pulse' : ''}`}+ />+ {state.isTriggeringPatrol()+ ? 'Starting…'+ : state.manualRunRequested() || state.patrolStream.isStreaming()+ ? 'Running…'+ : 'Run Patrol'}+ </button>++ <button+ onClick={() => state.loadAllData()}+ disabled={state.isRefreshing()}+ aria-label="Refresh"+ class="sm:hidden flex items-center gap-2 px-3 py-1.5 text-sm font-medium text-base-content bg-surface border border-border rounded-md hover:bg-surface-hover disabled:opacity-50 transition-colors"+ >+ <RefreshCwIcon class={`w-4 h-4 ${state.isRefreshing() ? 'animate-spin' : ''}`} />+ <span class="sr-only sm:not-sr-only">Refresh</span>+ </button>+ <div class="relative z-[120]" ref={state.setAdvancedSettingsRef}><button- onClick={() => state.loadAllData()}- disabled={state.isRefreshing()}- aria-label="Refresh"- class="sm:hidden flex items-center gap-2 px-3 py-1.5 text-sm font-medium text-base-content bg-surface border border-border rounded-md hover:bg-surface-hover disabled:opacity-50 transition-colors"+ onClick={() => state.setShowAdvancedSettings(!state.showAdvancedSettings())}+ disabled={!state.patrolEnabledLocal()}+ aria-label="Configure Patrol"+ title="Configure Patrol"+ class={`flex items-center gap-2 px-3 py-1.5 text-sm font-medium rounded-md transition-all shadow-sm ${state.showAdvancedSettings() ? 'bg-blue-50 text-blue-700 border border-blue-200 dark:bg-blue-900 dark:text-blue-300 dark:border-blue-800' : ' text-base-content border border-border hover:bg-surface-alt'} ${!state.patrolEnabledLocal() ? 'opacity-50 cursor-not-allowed hidden' : ''}`}>- <RefreshCwIcon class={`w-4 h-4 ${state.isRefreshing() ? 'animate-spin' : ''}`} />- <span class="sr-only sm:not-sr-only">Refresh</span>+ <SettingsIcon class="w-4 h-4" />+ <span class="sr-only sm:not-sr-only">Configure Patrol</span></button>- <div class="relative z-[120]" ref={state.setAdvancedSettingsRef}>- <button- onClick={() => state.setShowAdvancedSettings(!state.showAdvancedSettings())}- disabled={!state.patrolEnabledLocal()}- aria-label="Configure Patrol"- title="Configure Patrol"- class={`flex items-center gap-2 px-3 py-1.5 text-sm font-medium rounded-md transition-all shadow-sm ${state.showAdvancedSettings() ? 'bg-blue-50 text-blue-700 border border-blue-200 dark:bg-blue-900 dark:text-blue-300 dark:border-blue-800' : ' text-base-content border border-border hover:bg-surface-alt'} ${!state.patrolEnabledLocal() ? 'opacity-50 cursor-not-allowed hidden' : ''}`}+ <Show when={state.showAdvancedSettings()}>+ <div+ role="dialog"+ aria-label="Patrol Configuration"+ class="fixed right-4 top-32 z-[9999] isolate max-h-[calc(100vh-10rem)] w-[calc(100vw-2rem)] overflow-y-auto rounded-md border border-border bg-surface p-5 shadow-sm animate-slide-up transform origin-top-right sm:right-8 sm:top-[13rem] sm:max-h-[calc(100vh-14rem)] sm:w-[340px]">- <SettingsIcon class="w-4 h-4" />- <span class="sr-only sm:not-sr-only">Configure Patrol</span>- </button>+ <div class="flex items-center justify-between mb-5 pb-3 border-b border-border-subtle">+ <h4 class="text-base font-semibold tracking-tight text-base-content">+ Patrol Configuration+ </h4>+ <button+ onClick={() => state.setShowAdvancedSettings(false)}+ aria-label="Close patrol configuration"+ title="Close"+ class="p-1 rounded-md hover:text-base-content hover:bg-surface-hover transition-colors"+ >+ <XIcon class="w-4 h-4" />+ </button>+ </div>- <Show when={state.showAdvancedSettings()}>- <div- role="dialog"- aria-label="Patrol Configuration"- class="fixed right-4 top-32 z-[9999] isolate max-h-[calc(100vh-10rem)] w-[calc(100vw-2rem)] overflow-y-auto rounded-md border border-border bg-surface p-5 shadow-sm animate-slide-up transform origin-top-right sm:right-8 sm:top-[13rem] sm:max-h-[calc(100vh-14rem)] sm:w-[340px]"- >- <div class="flex items-center justify-between mb-5 pb-3 border-b border-border-subtle">- <h4 class="text-base font-semibold tracking-tight text-base-content">- Patrol Configuration- </h4>- <button- onClick={() => state.setShowAdvancedSettings(false)}- aria-label="Close patrol configuration"- title="Close"- class="p-1 rounded-md hover:text-base-content hover:bg-surface-hover transition-colors"+ <div class="space-y-6">+ <div class="grid grid-cols-2 gap-4">+ <FormSelect+ label="Provider model"+ labelClass="text-xs font-semibold uppercase tracking-wider text-muted"+ fieldClass="space-y-1.5"+ ref={state.setPatrolModelSelectRef}+ value={state.patrolModel()}+ onChange={(e) => state.handleModelChange(e.currentTarget.value)}+ disabled={state.isUpdatingSettings() || !state.patrolEnabledLocal()}+ selectBaseClass="w-full text-sm bg-base border border-border rounded-md py-2 pl-3 pr-8 text-base-content focus:ring-2 focus:ring-blue-500 focus:border-blue-500 disabled:opacity-50">- <XIcon class="w-4 h-4" />- </button>- </div>-- <div class="space-y-6">- <div class="grid grid-cols-2 gap-4">- <FormSelect- label="Provider model"- labelClass="text-xs font-semibold uppercase tracking-wider text-muted"- fieldClass="space-y-1.5"- ref={state.setPatrolModelSelectRef}- value={state.patrolModel()}- onChange={(e) => state.handleModelChange(e.currentTarget.value)}- disabled={state.isUpdatingSettings() || !state.patrolEnabledLocal()}- selectBaseClass="w-full text-sm bg-base border border-border rounded-md py-2 pl-3 pr-8 text-base-content focus:ring-2 focus:ring-blue-500 focus:border-blue-500 disabled:opacity-50"- >- <option value="">- Default ({state.defaultModel().split(':').pop() || 'not set'})+ <option value="">+ Default ({state.defaultModel().split(':').pop() || 'not set'})+ </option>+ <Show when={patrolModelStale()}>+ <option value={state.patrolModel()} disabled>+ {state.patrolModel().split(':').pop()} (unavailable)</option>- <Show when={patrolModelStale()}>- <option value={state.patrolModel()} disabled>- {state.patrolModel().split(':').pop()} (unavailable)- </option>- </Show>- {Array.from(groupModelsByProvider(state.availableModels()).entries()).map(- ([provider, models]) => (- <optgroup label={provider.charAt(0).toUpperCase() + provider.slice(1)}>- {models.map((model) => (- <option value={model.id}>- {model.name || model.id.split(':').pop()}- </option>- ))}- </optgroup>- ),- )}- </FormSelect>+ </Show>+ {Array.from(groupModelsByProvider(state.availableModels()).entries()).map(+ ([provider, models]) => (+ <optgroup label={provider.charAt(0).toUpperCase() + provider.slice(1)}>+ {models.map((model) => (+ <option value={model.id}>+ {model.name || model.id.split(':').pop()}+ </option>+ ))}+ </optgroup>+ ),+ )}+ </FormSelect>- <FormSelect- label="Run Every"- labelClass="text-xs font-semibold uppercase tracking-wider text-muted"- fieldClass="space-y-1.5"- value={state.patrolInterval()}- onChange={(e) =>- state.handleIntervalChange(parseInt(e.currentTarget.value, 10))- }- disabled={state.isUpdatingSettings() || !state.patrolEnabledLocal()}- selectBaseClass="w-full text-sm bg-base border border-border rounded-md py-2 pl-3 pr-8 text-base-content focus:ring-2 focus:ring-blue-500 focus:border-blue-500 disabled:opacity-50"- >- <For each={scheduleOptions()}>- {(preset) => <option value={preset.value}>{preset.label}</option>}- </For>- </FormSelect>- </div>+ <FormSelect+ label="Run Every"+ labelClass="text-xs font-semibold uppercase tracking-wider text-muted"+ fieldClass="space-y-1.5"+ value={state.patrolInterval()}+ onChange={(e) =>+ state.handleIntervalChange(parseInt(e.currentTarget.value, 10))+ }+ disabled={state.isUpdatingSettings() || !state.patrolEnabledLocal()}+ selectBaseClass="w-full text-sm bg-base border border-border rounded-md py-2 pl-3 pr-8 text-base-content focus:ring-2 focus:ring-blue-500 focus:border-blue-500 disabled:opacity-50"+ >+ <For each={scheduleOptions()}>+ {(preset) => <option value={preset.value}>{preset.label}</option>}+ </For>+ </FormSelect>+ </div>- <div class="space-y-2">- <div class="flex items-center justify-between">- <label class="text-xs font-semibold uppercase tracking-wider text-muted flex items-center gap-1.5">- Operational Mode- <div class="relative group">- <CircleHelpIcon class="w-3.5 h-3.5 cursor-help" />- <div class="absolute left-1/2 -translate-x-1/2 bottom-full mb-2 hidden group-hover:block w-64 p-3 bg-surface text-white rounded-md shadow-md text-xs z-50 pointer-events-none before:absolute before:top-full before:left-1/2 before:-translate-x-1/2 before:border-4 before:border-transparent before:border-t-slate-800">- <strong>Monitor:</strong> Detect only.- <br />- <strong>Investigate:</strong> Detect & propose fixes.- <br />- <strong>Remediate:</strong> Execute approved safe actions under- policy.- </div>+ <div class="space-y-2">+ <div class="flex items-center justify-between">+ <label class="text-xs font-semibold uppercase tracking-wider text-muted flex items-center gap-1.5">+ Operational Mode+ <div class="relative group">+ <CircleHelpIcon class="w-3.5 h-3.5 cursor-help" />+ <div class="absolute left-1/2 -translate-x-1/2 bottom-full mb-2 hidden group-hover:block w-64 p-3 bg-surface text-white rounded-md shadow-md text-xs z-50 pointer-events-none before:absolute before:top-full before:left-1/2 before:-translate-x-1/2 before:border-4 before:border-transparent before:border-t-slate-800">+ <strong>Monitor:</strong> Detect only.+ <br />+ <strong>Investigate:</strong> Detect & propose fixes.+ <br />+ <strong>Remediate:</strong> Execute approved safe actions under policy.</div>- </label>- </div>-- <div class="flex items-center bg-base rounded-md p-1 border shadow-inner">- <For each={['monitor', 'approval', 'assisted'] as const}>- {(level) => {- const isProLocked = () =>- state.autoFixLocked() &&- (level === 'approval' || level === 'assisted');- const isDisabled = () => !state.patrolEnabledLocal() || isProLocked();- const isActive = () =>- level === 'assisted'- ? state.autonomyLevel() === 'assisted' ||- state.autonomyLevel() === 'full'- : state.autonomyLevel() === level;-- return (- <button- onClick={() => state.handleAutonomyChange(level)}- disabled={isDisabled()}- title={- !presentationPolicyHidesUpgradePrompts() && isProLocked()- ? level === 'approval'- ? 'Investigation is not enabled on this plan'- : 'Safe remediation workflows are not enabled on this plan'- : undefined- }- class={`flex-1 py-1.5 px-2 text-xs font-semibold rounded-md transition-all duration-200 ${isActive() ? ' text-blue-600 dark:text-blue-400 shadow-[0_1px_3px_rgba(0,0,0,0.1)]' : isDisabled() ? ' ' : 'text-muted hover:text-base-content hover:bg-surface-hover'} ${isDisabled() ? 'opacity-50 cursor-not-allowed' : ''}`}- >- {level === 'monitor'- ? 'Monitor'- : level === 'approval'- ? 'Investigate'- : 'Remediate'}- </button>- );- }}- </For>- </div>- <Show- when={!presentationPolicyHidesUpgradePrompts() && state.autoFixLocked()}- >- <div class="pl-1 text-[11px] text-muted">- Investigation and safe remediation workflows are not enabled on this plan.</div>- </Show>+ </label></div>- <div class="space-y-4 pt-4 border-t border-border-subtle">- <div class="flex items-start justify-between gap-3">- <div class="flex-1">- <label class="text-sm font-medium text-base-content">- Alert-Triggered Analysis- </label>- <p class="text-[11px] text-muted mt-0.5 leading-tight">- Analyze infrastructure automatically when critical alerts fire.- </p>- </div>- <Toggle- checked={state.alertTriggeredAnalysis()}- onChange={(e) =>- state.handleAlertTriggeredAnalysisChange(e.currentTarget.checked)- }- disabled={state.isUpdatingSettings() || state.alertAnalysisLocked()}- />+ <div class="flex items-center bg-base rounded-md p-1 border shadow-inner">+ <For each={['monitor', 'approval', 'assisted'] as const}>+ {(level) => {+ const isProLocked = () =>+ state.autoFixLocked() && (level === 'approval' || level === 'assisted');+ const isDisabled = () => !state.patrolEnabledLocal() || isProLocked();+ const isActive = () =>+ level === 'assisted'+ ? state.autonomyLevel() === 'assisted' ||+ state.autonomyLevel() === 'full'+ : state.autonomyLevel() === level;++ return (+ <button+ onClick={() => state.handleAutonomyChange(level)}+ disabled={isDisabled()}+ title={+ !presentationPolicyHidesUpgradePrompts() && isProLocked()+ ? level === 'approval'+ ? 'Investigation is not enabled on this plan'+ : 'Safe remediation workflows are not enabled on this plan'+ : undefined+ }+ class={`flex-1 py-1.5 px-2 text-xs font-semibold rounded-md transition-all duration-200 ${isActive() ? ' text-blue-600 dark:text-blue-400 shadow-[0_1px_3px_rgba(0,0,0,0.1)]' : isDisabled() ? ' ' : 'text-muted hover:text-base-content hover:bg-surface-hover'} ${isDisabled() ? 'opacity-50 cursor-not-allowed' : ''}`}+ >+ {level === 'monitor'+ ? 'Monitor'+ : level === 'approval'+ ? 'Investigate'+ : 'Remediate'}+ </button>+ );+ }}+ </For>+ </div>+ <Show when={!presentationPolicyHidesUpgradePrompts() && state.autoFixLocked()}>+ <div class="pl-1 text-[11px] text-muted">+ Investigation and safe remediation workflows are not enabled on this plan.</div>+ </Show>+ </div>- <Show- when={- !presentationPolicyHidesUpgradePrompts() && state.alertAnalysisLocked()+ <div class="space-y-4 pt-4 border-t border-border-subtle">+ <div class="flex items-start justify-between gap-3">+ <div class="flex-1">+ <label class="text-sm font-medium text-base-content">+ Alert-Triggered Analysis+ </label>+ <p class="text-[11px] text-muted mt-0.5 leading-tight">+ Analyze infrastructure automatically when critical alerts fire.+ </p>+ </div>+ <Toggle+ checked={state.alertTriggeredAnalysis()}+ onChange={(e) =>+ state.handleAlertTriggeredAnalysisChange(e.currentTarget.checked)}- >- <div class="-my-1 pl-1 text-[11px]">- Alert-triggered analysis is not enabled on this plan.- </div>- </Show>+ disabled={state.isUpdatingSettings() || state.alertAnalysisLocked()}+ />+ </div>- <div class="rounded-md border border-border-subtle bg-surface-alt/60 px-3 py-2.5">- <p class="text-[11px] font-medium text-base-content">- {state.patrolInterval() === 0- ? 'Scheduled full patrols are off. Manual runs and alert/anomaly triggers still work.'- : `Full patrols run every ${selectedScheduleLabel().toLowerCase()}.`}- </p>- <p class="mt-1 text-[11px] leading-tight text-muted">- Alert and anomaly triggers run targeted scoped checks that update{' '}- <span class="font-medium text-base-content">Last activity</span> without- resetting{' '}- <span class="font-medium text-base-content">Last full patrol</span>.- </p>+ <Show+ when={!presentationPolicyHidesUpgradePrompts() && state.alertAnalysisLocked()}+ >+ <div class="-my-1 pl-1 text-[11px]">+ Alert-triggered analysis is not enabled on this plan.</div>+ </Show>- <div class="flex items-start justify-between gap-3">- <div class="flex-1">- <label class="text-sm font-medium text-base-content">- Alert-Triggered Patrols- </label>- <p class="text-[11px] text-muted mt-0.5 leading-tight">- Run scoped Patrol checks when alerts fire or clear.- </p>- </div>- <Toggle- checked={state.patrolAlertTriggers()}- onChange={(e) =>- state.handlePatrolAlertTriggersChange(e.currentTarget.checked)- }- disabled={state.isUpdatingSettings() || !state.patrolEnabledLocal()}- />+ <div class="rounded-md border border-border-subtle bg-surface-alt/60 px-3 py-2.5">+ <p class="text-[11px] font-medium text-base-content">+ {state.patrolInterval() === 0+ ? 'Scheduled full patrols are off. Manual runs and alert/anomaly triggers still work.'+ : `Full patrols run every ${selectedScheduleLabel().toLowerCase()}.`}+ </p>+ <p class="mt-1 text-[11px] leading-tight text-muted">+ Alert and anomaly triggers run targeted scoped checks that update{' '}+ <span class="font-medium text-base-content">Last activity</span> without+ resetting{' '}+ <span class="font-medium text-base-content">Last full patrol</span>.+ </p>+ </div>++ <div class="flex items-start justify-between gap-3">+ <div class="flex-1">+ <label class="text-sm font-medium text-base-content">+ Alert-Triggered Patrols+ </label>+ <p class="text-[11px] text-muted mt-0.5 leading-tight">+ Run scoped Patrol checks when alerts fire or clear.+ </p></div>+ <Toggle+ checked={state.patrolAlertTriggers()}+ onChange={(e) =>+ state.handlePatrolAlertTriggersChange(e.currentTarget.checked)+ }+ disabled={state.isUpdatingSettings() || !state.patrolEnabledLocal()}+ />+ </div>- <div class="flex items-start justify-between gap-3">- <div class="flex-1">- <label class="text-sm font-medium text-base-content">- Anomaly-Triggered Patrols- </label>- <p class="text-[11px] text-muted mt-0.5 leading-tight">- Run scoped Patrol checks when learned baselines detect high-signal- anomalies.- </p>- </div>- <Toggle- checked={state.patrolAnomalyTriggers()}- onChange={(e) =>- state.handlePatrolAnomalyTriggersChange(e.currentTarget.checked)- }- disabled={state.isUpdatingSettings() || !state.patrolEnabledLocal()}- />+ <div class="flex items-start justify-between gap-3">+ <div class="flex-1">+ <label class="text-sm font-medium text-base-content">+ Anomaly-Triggered Patrols+ </label>+ <p class="text-[11px] text-muted mt-0.5 leading-tight">+ Run scoped Patrol checks when learned baselines detect high-signal+ anomalies.+ </p></div>+ <Toggle+ checked={state.patrolAnomalyTriggers()}+ onChange={(e) =>+ state.handlePatrolAnomalyTriggersChange(e.currentTarget.checked)+ }+ disabled={state.isUpdatingSettings() || !state.patrolEnabledLocal()}+ />+ </div>- <div class="flex items-start justify-between gap-3">- <div class="flex-1">- <label class="text-sm font-medium text-red-600 dark:text-red-400">- Autonomous critical remediation- </label>- <p class="text-[11px] text-muted mt-0.5 leading-tight">- Permit Patrol to execute critical remediation actions without approval.- </p>- </div>- <Toggle- checked={!state.autoFixLocked() && state.fullModeUnlocked()}- onChange={(e) => state.setFullModeUnlocked(e.currentTarget.checked)}- disabled={- state.autoFixLocked() ||- !(- state.autonomyLevel() === 'assisted' ||- state.autonomyLevel() === 'full'- )- }- />+ <div class="flex items-start justify-between gap-3">+ <div class="flex-1">+ <label class="text-sm font-medium text-red-600 dark:text-red-400">+ Autonomous critical remediation+ </label>+ <p class="text-[11px] text-muted mt-0.5 leading-tight">+ Permit Patrol to execute critical remediation actions without approval.+ </p></div>+ <Toggle+ checked={!state.autoFixLocked() && state.fullModeUnlocked()}+ onChange={(e) => state.setFullModeUnlocked(e.currentTarget.checked)}+ disabled={+ state.autoFixLocked() ||+ !(+ state.autonomyLevel() === 'assisted' || state.autonomyLevel() === 'full'+ )+ }+ /></div>+ </div>- <div class="pt-4 border-t border-border-subtle">- <Show when={state.advancedSettingsError()}>- {(failure) => (- <div- role="alert"- data-testid="patrol-configuration-error"- class="mb-3 rounded-md border border-red-300 bg-red-50 px-3 py-2.5 text-red-950 dark:border-red-800 dark:bg-red-950/30 dark:text-red-100"+ <div class="pt-4 border-t border-border-subtle">+ <Show when={state.advancedSettingsError()}>+ {(failure) => (+ <div+ role="alert"+ data-testid="patrol-configuration-error"+ class="mb-3 rounded-md border border-red-300 bg-red-50 px-3 py-2.5 text-red-950 dark:border-red-800 dark:bg-red-950/30 dark:text-red-100"+ >+ <p class="text-xs font-semibold">+ {failure().saved+ ? 'Patrol configuration needs attention'+ : 'Patrol configuration was not saved'}+ </p>+ <p class="mt-1 text-xs leading-relaxed">{failure().message}</p>+ <Show+ when={getPatrolConfigurationFailureInlineDetails(failure()).length > 0}>- <p class="text-xs font-semibold">- {failure().saved- ? 'Patrol configuration needs attention'- : 'Patrol configuration was not saved'}- </p>- <p class="mt-1 text-xs leading-relaxed">{failure().message}</p>- <Show- when={- getPatrolConfigurationFailureInlineDetails(failure()).length > 0- }+ <ul class="mt-1 space-y-0.5 text-[11px] leading-relaxed opacity-80">+ <For each={getPatrolConfigurationFailureInlineDetails(failure())}>+ {(detail) => <li>{detail}</li>}+ </For>+ </ul>+ </Show>+ <div class="mt-2 flex flex-wrap items-center gap-2">+ <button+ type="button"+ data-testid="patrol-configuration-error-assistant-button"+ onClick={state.openAdvancedSettingsErrorInAssistant}+ class="inline-flex items-center gap-1.5 rounded-md border border-red-300 bg-white/80 px-2 py-1 text-xs font-medium text-red-950 transition-colors hover:bg-white dark:border-red-700 dark:bg-red-950/40 dark:text-red-100 dark:hover:bg-red-900/50"+ >+ <MessageSquareIcon class="h-3.5 w-3.5" />+ Discuss with Assistant+ </button>+ <a+ href={PATROL_PROVIDER_SETTINGS_ACTION.href}+ data-testid="patrol-configuration-error-settings-link"+ class="inline-flex items-center gap-1.5 rounded-md border border-red-300 bg-white/80 px-2 py-1 text-xs font-medium text-red-950 transition-colors hover:bg-white dark:border-red-700 dark:bg-red-950/40 dark:text-red-100 dark:hover:bg-red-900/50">- <ul class="mt-1 space-y-0.5 text-[11px] leading-relaxed opacity-80">- <For each={getPatrolConfigurationFailureInlineDetails(failure())}>- {(detail) => <li>{detail}</li>}- </For>- </ul>- </Show>- <div class="mt-2 flex flex-wrap items-center gap-2">- <button- type="button"- data-testid="patrol-configuration-error-assistant-button"- onClick={state.openAdvancedSettingsErrorInAssistant}- class="inline-flex items-center gap-1.5 rounded-md border border-red-300 bg-white/80 px-2 py-1 text-xs font-medium text-red-950 transition-colors hover:bg-white dark:border-red-700 dark:bg-red-950/40 dark:text-red-100 dark:hover:bg-red-900/50"- >- <MessageSquareIcon class="h-3.5 w-3.5" />- Discuss with Assistant- </button>- <a- href={PATROL_PROVIDER_SETTINGS_ACTION.href}- data-testid="patrol-configuration-error-settings-link"- class="inline-flex items-center gap-1.5 rounded-md border border-red-300 bg-white/80 px-2 py-1 text-xs font-medium text-red-950 transition-colors hover:bg-white dark:border-red-700 dark:bg-red-950/40 dark:text-red-100 dark:hover:bg-red-900/50"- >- <SettingsIcon class="h-3.5 w-3.5" />- {PATROL_PROVIDER_SETTINGS_ACTION.label}- </a>- </div>+ <SettingsIcon class="h-3.5 w-3.5" />+ {PATROL_PROVIDER_SETTINGS_ACTION.label}+ </a></div>- )}- </Show>+ </div>+ )}+ </Show>- <button- onClick={state.saveAdvancedSettings}- disabled={state.isSavingAdvanced()}- class="w-full py-2.5 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md shadow-sm transition-all focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-blue-300 disabled:hover:bg-blue-300 dark:disabled:bg-blue-900 flex items-center justify-center gap-2"- >- <Show when={state.isSavingAdvanced()}>- <div class="animate-spin w-4 h-4 border-2 border-current border-t-transparent rounded-full"></div>- </Show>- <Show when={!state.isSavingAdvanced()}>Apply Configuration</Show>- </button>- </div>+ <button+ onClick={state.saveAdvancedSettings}+ disabled={state.isSavingAdvanced()}+ class="w-full py-2.5 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md shadow-sm transition-all focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-blue-300 disabled:hover:bg-blue-300 dark:disabled:bg-blue-900 flex items-center justify-center gap-2"+ >+ <Show when={state.isSavingAdvanced()}>+ <div class="animate-spin w-4 h-4 border-2 border-current border-t-transparent rounded-full"></div>+ </Show>+ <Show when={!state.isSavingAdvanced()}>Apply Configuration</Show>+ </button></div></div>- </Show>- </div>+ </div>+ </Show></div></div>+ </div></div>);}diff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsxindex 25f2418c74..0b682db181 100644--- a/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx@@ -1,9 +1,7 @@-import { createMemo, For, Show } from 'solid-js';+import { createMemo, Show } from 'solid-js';import ActivityIcon from 'lucide-solid/icons/activity';import CheckCircleIcon from 'lucide-solid/icons/check-circle';import AlertCircleIcon from 'lucide-solid/icons/alert-circle';-import ChevronDownIcon from 'lucide-solid/icons/chevron-down';-import ChevronUpIcon from 'lucide-solid/icons/chevron-up';import MessageSquareIcon from 'lucide-solid/icons/message-square';import PlayIcon from 'lucide-solid/icons/play';import SettingsIcon from 'lucide-solid/icons/settings';@@ -14,14 +12,10 @@ import {getPatrolRecencyPresentation,getPatrolScoreChipLabel,getPatrolVerificationPresentation,- getPatrolSummaryPresentation,getPatrolSummaryMetricState,type PatrolRecommendedNextStepAction,} from '@/utils/patrolSummaryPresentation';-import {- getPatrolLatestRunPresentation,- getPatrolTriggerStatusSummary,-} from '@/utils/patrolRunPresentation';+import { getPatrolLatestRunPresentation } from '@/utils/patrolRunPresentation';import { getPatrolRuntimePresentation } from '@/utils/patrolRuntimePresentation';import { formatRelativeTime } from '@/utils/format';import { aiChatStore } from '@/stores/aiChat';@@ -86,9 +80,6 @@ export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceStatfixedCount: summaryStats().fixedCount,}),);- const warningSummaryPresentation = createMemo(() =>- getPatrolSummaryPresentation(metricState().secondarySeverity, metricState().secondaryValue > 0),- );const runtimePresentation = createMemo(() =>getPatrolRuntimePresentation(state.runtimeState(), state.blockedReason()),);@@ -115,9 +106,6 @@ export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceStatruns: state.patrolRunHistory.value() ?? [],}),);- const activeFindingsSummaryPresentation = createMemo(() =>- getPatrolSummaryPresentation(metricState().primarySeverity, metricState().primaryValue > 0),- );const verification = createMemo(() =>getPatrolVerificationPresentation({runs: state.patrolRunHistory.value() ?? [],@@ -132,33 +120,9 @@ export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceStatlastActivityAt: state.patrolStatus()?.last_activity_at,}),);- const fixedSummaryPresentation = createMemo(() =>- getPatrolSummaryPresentation('success', summaryStats().fixedCount > 0),- );const latestRun = createMemo(() =>getPatrolLatestRunPresentation(state.patrolRunHistory.value() ?? []),);- const triggerSummary = createMemo(() =>- getPatrolTriggerStatusSummary(state.patrolStatus()?.trigger_status),- );- const circuitBreakerPresentation = createMemo(() => {- const circuitBreaker = state.circuitBreakerStatus();- if (!circuitBreaker || circuitBreaker.state === 'closed') {- return undefined;- }-- if (circuitBreaker.state === 'open') {- return {- message: `Provider circuit breaker tripped after ${circuitBreaker.consecutive_failures} consecutive failures.`,- toneClass: 'text-red-600 dark:text-red-400',- };- }-- return {- message: 'Provider circuit breaker recovering; the next Patrol run is a live test.',- toneClass: 'text-amber-600 dark:text-amber-400',- };- });const scoreChipLabel = createMemo(() =>getPatrolScoreChipLabel({overallHealth: state.intelligenceSummary()?.overall_health,@@ -201,6 +165,21 @@ export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceStatreturn parts.join(' · ');});+ const compactAssessmentSummary = createMemo(() => {+ const overallHealth = state.intelligenceSummary()?.overall_health;+ const parts: string[] = [compactRiskSummary() || assessment().compactLabel];+ const regressedCount = state.patrolStatus()?.trust?.regressed_at_least_once ?? 0;++ if (regressedCount > 0) {+ parts.push(`${regressedCount} regressed`);+ }++ if (overallHealth) {+ parts.push(`${Math.round(overallHealth.score)}/100`);+ }++ return parts.join(' · ');+ });const recommendedNextStepAction = createMemo(() => recommendedNextStep().action);const recommendedNextStepActionDisabled = createMemo(() => {const action = recommendedNextStepAction();@@ -231,53 +210,6 @@ export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceStatreturn action.label;});- const showAssessmentAssistantButton = createMemo(- () => recommendedNextStepAction()?.kind !== 'discuss_assessment',- );- const hasAttentionMetrics = createMemo(- () => metricState().primaryValue > 0 || metricState().secondaryValue > 0,- );- const visibleMetrics = createMemo(() => {- const metrics: Array<{- key: string;- label: string;- presentation: ReturnType<typeof getPatrolSummaryPresentation>;- value: number;- }> = [];-- if (metricState().primaryValue > 0) {- metrics.push({- key: 'primary',- label: metricState().primaryLabel,- presentation: activeFindingsSummaryPresentation(),- value: metricState().primaryValue,- });- }-- if (- metricState().secondaryValue > 0 &&- (metricState().secondaryLabel === 'Runtime issues' ||- metricState().secondaryValue !== metricState().primaryValue)- ) {- metrics.push({- key: 'secondary',- label: metricState().secondaryLabel,- presentation: warningSummaryPresentation(),- value: metricState().secondaryValue,- });- }-- if (metricState().fixedValue > 0 && hasAttentionMetrics()) {- metrics.push({- key: 'fixed',- label: metricState().fixedLabel,- presentation: fixedSummaryPresentation(),- value: metricState().fixedValue,- });- }-- return metrics;- });const activeFindingsWithApprovalContext = createMemo<PatrolAssessmentAssistantFindingInput[]>(() => {const approvalsByFindingId = new Map(@@ -409,254 +341,71 @@ export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceStat<Show when={!showRuntimeSummary() && !showLoadingSummary()}><Show when={state.intelligenceSummary()}>- {(summary) => (- <section class="border-y border-border-subtle py-2">- <div class="flex flex-col gap-2 lg:flex-row lg:items-center lg:justify-between">- <div class="min-w-0 space-y-1">- <div class="flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1 text-sm">- <span class="text-[11px] font-semibold uppercase tracking-[0.14em] text-muted">- {assessment().eyebrow}- </span>- <span class="font-semibold text-base-content">- {scoreChipLabel()} {summary().overall_health.grade} ·{' '}- {Math.round(summary().overall_health.score)}/100- </span>- <span class="font-semibold text-base-content">{assessment().title}</span>- <Show when={compactRiskSummary()}>- {(riskSummary) => (- <>- <span class="text-muted" aria-hidden="true">- ·- </span>- <span class="text-muted">{riskSummary()}</span>- </>- )}- </Show>- </div>+ <section class="border-y border-border-subtle py-2">+ <div class="flex flex-col gap-2 lg:flex-row lg:items-center lg:justify-between">+ <div class="min-w-0 space-y-1">+ <div class="flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1 text-sm">+ <span class="text-[11px] font-semibold uppercase tracking-[0.14em] text-muted">+ {assessment().eyebrow}+ </span>+ <span class="font-semibold text-base-content">{compactAssessmentSummary()}</span>+ </div>- <div- data-testid="patrol-recommended-next-step"- class="flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted"- >- <span class="font-medium text-base-content">Next:</span>- <span class="font-medium text-base-content">{recommendedNextStep().title}</span>- </div>+ <div+ data-testid="patrol-recommended-next-step"+ class="flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted"+ >+ <span class="font-medium text-base-content">Next:</span>+ <span class="font-medium text-base-content">{recommendedNextStep().title}</span></div>+ </div>- <div class="flex shrink-0 flex-wrap items-center gap-2 lg:justify-end">- <Show when={recommendedNextStepAction()}>- {(action) => (- <Show- when={action().href}- fallback={- <button- type="button"- data-testid="patrol-recommended-next-step-action"- disabled={recommendedNextStepActionDisabled()}- title={- action().kind === 'run_patrol'- ? state.triggerPatrolDisabledReason()- : undefined- }- class="inline-flex shrink-0 items-center gap-1.5 rounded border border-border-subtle bg-transparent px-2.5 py-1.5 text-xs font-semibold text-base-content transition-colors hover:bg-surface-hover disabled:text-muted"- onClick={() => handleRecommendedNextStepAction(action())}- >- {renderRecommendedNextStepActionIcon(- action(),- state.isTriggeringPatrol() ||- state.manualRunRequested() ||- state.patrolStream.isStreaming(),- )}- <span>{recommendedNextStepActionLabel()}</span>- </button>- }- >- {(href) => (- <a- href={href()}- data-testid="patrol-recommended-next-step-action"- class="inline-flex shrink-0 items-center gap-1.5 rounded border border-border-subtle bg-transparent px-2.5 py-1.5 text-xs font-semibold text-base-content transition-colors hover:bg-surface-hover"- >- {renderRecommendedNextStepActionIcon(action(), false)}- <span>{action().label}</span>- </a>- )}- </Show>- )}- </Show>- <button- type="button"- data-testid="patrol-summary-details-toggle"- aria-expanded={state.summaryDetailsExpanded()}- aria-controls="patrol-summary-details"- onClick={() => state.setSummaryDetailsExpanded((value) => !value)}- class="inline-flex items-center gap-1 text-xs font-medium text-muted transition-colors hover:text-base-content focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/40"- >+ <div class="flex shrink-0 flex-wrap items-center gap-2 lg:justify-end">+ <Show when={recommendedNextStepAction()}>+ {(action) => (<Show- when={state.summaryDetailsExpanded()}- fallback={<ChevronDownIcon class="h-3.5 w-3.5" aria-hidden="true" />}+ when={action().href}+ fallback={+ <button+ type="button"+ data-testid="patrol-recommended-next-step-action"+ disabled={recommendedNextStepActionDisabled()}+ title={+ action().kind === 'run_patrol'+ ? state.triggerPatrolDisabledReason()+ : undefined+ }+ class="inline-flex shrink-0 items-center gap-1.5 rounded border border-border-subtle bg-transparent px-2.5 py-1.5 text-xs font-semibold text-base-content transition-colors hover:bg-surface-hover disabled:text-muted"+ onClick={() => handleRecommendedNextStepAction(action())}+ >+ {renderRecommendedNextStepActionIcon(+ action(),+ state.isTriggeringPatrol() ||+ state.manualRunRequested() ||+ state.patrolStream.isStreaming(),+ )}+ <span>{recommendedNextStepActionLabel()}</span>+ </button>+ }>- <ChevronUpIcon class="h-3.5 w-3.5" aria-hidden="true" />+ {(href) => (+ <a+ href={href()}+ data-testid="patrol-recommended-next-step-action"+ class="inline-flex shrink-0 items-center gap-1.5 rounded border border-border-subtle bg-transparent px-2.5 py-1.5 text-xs font-semibold text-base-content transition-colors hover:bg-surface-hover"+ >+ {renderRecommendedNextStepActionIcon(action(), false)}+ <span>{action().label}</span>+ </a>+ )}</Show>- <span>{state.summaryDetailsExpanded() ? 'Hide details' : 'Show details'}</span>- </button>- </div>+ )}+ </Show></div>-- <Show when={state.summaryDetailsExpanded()}>- <div- id="patrol-summary-details"- data-testid="patrol-summary-details"- class="mt-3 border-t border-border-subtle pt-3"- >- <div class="grid gap-4 lg:grid-cols-3">- <div>- <p class="text-xs font-semibold uppercase tracking-[0.16em] text-muted">- Assessment- </p>- <p class="mt-1 text-sm font-medium text-base-content">{assessment().title}</p>- <p class="mt-1 text-sm text-muted">{assessment().description}</p>- <div class="mt-3">- <p class="text-xs font-semibold uppercase tracking-[0.16em] text-muted">- Recommended next step- </p>- <p class="mt-1 text-sm font-medium text-base-content">- {recommendedNextStep().title}- </p>- <p class="mt-1 text-sm text-muted">{recommendedNextStep().description}</p>- </div>- </div>-- <div>- <p class="text-xs font-semibold uppercase tracking-[0.16em] text-muted">- Verification- </p>- <p class="mt-1 text-sm font-medium text-base-content">- {verification().title}- <Show when={verification().lastFullRunAt}>- <span class="text-muted">- {' '}- ·{' '}- {formatRelativeTime(verification().lastFullRunAt!, {- compact: true,- emptyText: 'never',- })}- </span>- </Show>- </p>- <p class="mt-1 text-sm text-muted">{verification().description}</p>- <Show when={verification().activityMixLabel}>- <p class="mt-2 text-xs font-medium text-base-content">- Recent activity mix: {verification().activityMixLabel}- </p>- </Show>- </div>-- <div>- <p class="text-xs font-semibold uppercase tracking-[0.16em] text-muted">- Latest activity- </p>- <Show- when={latestRun()}- fallback={- <p class="mt-1 text-sm text-muted">- Patrol has not completed recent activity yet.- </p>- }- >- {(latest) => (- <>- <div class="mt-1 flex flex-wrap items-center gap-2 text-sm">- <span class="font-medium text-base-content">- {latest().kindLabel}- </span>- <span- class={`inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-medium ${latest().status.badgeClass}`}- >- {latest().status.label}- </span>- <Show when={latest().timestamp}>- <span class="text-muted">- {formatRelativeTime(latest().timestamp!, {- compact: true,- emptyText: 'never',- })}- </span>- </Show>- </div>- <Show when={latest().coverageSummary}>- <p class="mt-1 text-sm text-muted">{latest().coverageSummary}</p>- </Show>- <Show when={!latest().findingsSnapshotAvailable}>- <p class="mt-1 text-xs text-muted">- Findings snapshot unavailable for this run.- </p>- </Show>- </>- )}- </Show>-- <Show when={triggerSummary()}>- <p class="mt-3 text-sm text-muted">- <span class="font-medium text-base-content">Trigger mode:</span>{' '}- {triggerSummary()}- </p>- </Show>-- <Show when={circuitBreakerPresentation()}>- {(circuitBreaker) => (- <p class={`mt-3 text-sm ${circuitBreaker().toneClass}`}>- {circuitBreaker().message}- </p>- )}- </Show>- </div>- </div>-- <Show when={showAssessmentAssistantButton()}>- <div class="mt-4">- <button- type="button"- data-testid="patrol-assessment-assistant-button"- class="inline-flex items-center gap-1.5 rounded border border-border-subtle bg-transparent px-2.5 py-1.5 text-xs font-semibold text-base-content transition-colors hover:bg-surface-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/40"- title="Discuss current Patrol assessment"- onClick={handleDiscussAssessment}- >- <MessageSquareIcon class="h-4 w-4" aria-hidden="true" />- <span>Discuss with Assistant</span>- </button>- </div>- </Show>- </div>- </Show>- </section>- )}+ </div>+ </section></Show></Show>-- <Show- when={- !showRuntimeSummary() &&- state.intelligenceSummary() &&- visibleMetrics().length > 0 &&- state.summaryDetailsExpanded()- }- >- <div class="flex flex-wrap items-center gap-x-5 gap-y-2 text-sm">- <For each={visibleMetrics()}>- {(metric) => {- return (- <p>- <span class="text-muted">{metric.label}</span>{' '}- <span class={`font-semibold ${metric.presentation.valueClass}`}>- {metric.value}- </span>- </p>- );- }}- </For>- </div>- </Show></>);}diff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsxindex cd2c70a460..fb29ecbe61 100644--- a/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx@@ -42,60 +42,6 @@ export function PatrolIntelligenceWorkspace(props: { state: PatrolIntelligenceSt}}/>- <Show- when={(() => {- const trust = state.patrolStatus()?.trust;- if (!trust) return false;- // Render only when at least one trust signal has non-zero value;- // fresh installs with no findings should not show an empty strip.- return (- trust.fix_verified > 0 ||- trust.auto_resolved > 0 ||- trust.dismissed_as_noise > 0 ||- trust.dismissed_as_expected > 0 ||- trust.currently_active > 0- );- })()}- >- {(() => {- const trust = state.patrolStatus()!.trust!;- return (- <div- class="flex flex-wrap items-center gap-x-3 gap-y-1 px-3 py-1.5 rounded-md border border-border bg-surface-alt/40 text-[11px] text-muted"- aria-label="Patrol trust summary"- >- <span class="font-medium uppercase tracking-[0.14em] text-[10px] text-muted/80">- Trust- </span>- <Show when={trust.fix_verified > 0}>- <span class="text-emerald-700 dark:text-emerald-300">- {trust.fix_verified} fix{trust.fix_verified === 1 ? '' : 'es'} verified- </span>- </Show>- <Show when={trust.auto_resolved > 0}>- <span>{trust.auto_resolved} auto-resolved</span>- </Show>- <Show when={trust.dismissed_as_noise > 0}>- <span class="text-amber-700 dark:text-amber-300">- {trust.dismissed_as_noise} dismissed as noise- </span>- </Show>- <Show when={trust.dismissed_as_expected > 0}>- <span>{trust.dismissed_as_expected} expected</span>- </Show>- <Show when={trust.currently_active > 0}>- <span>{trust.currently_active} active</span>- </Show>- <Show when={trust.regressed_at_least_once > 0}>- <span class="text-amber-700 dark:text-amber-300">- {trust.regressed_at_least_once} regressed- </span>- </Show>- </div>- );- })()}- </Show>-<div class="flex items-center gap-1 border-b border-border"><buttontype="button"diff --git a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceHeader.test.ts b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceHeader.test.tsindex 5ebc5cfa83..4fca2760d8 100644--- a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceHeader.test.ts+++ b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceHeader.test.ts@@ -42,21 +42,14 @@ describe('PatrolIntelligenceHeader', () => {).toEqual(['patrol_autonomy_pro_required · license_required']);});- it('renders a compact trust summary in the page header above the runtime status row', () => {- // Second wedge of the Patrol page IA reframe. The detailed Trust strip- // in PatrolIntelligenceWorkspace stays as the canonical breakdown, but- // operators should see "X active, Y regressed, Z fixes verified"- // immediately under the page title without scrolling into the- // workspace tabs. Pin the wiring so this trust-at-a-glance line cannot- // silently regress to an empty header during refactors.- expect(headerSource).toContain('aria-label="Patrol trust summary header"');- expect(headerSource).toContain('state.patrolStatus()?.trust');- expect(headerSource).toContain('trust.currently_active');- expect(headerSource).toContain('trust.regressed_at_least_once');- expect(headerSource).toContain('trust.fix_verified');- // Visibility must gate on at least one non-zero signal so fresh installs- // don't render an empty header strip.- expect(headerSource).toContain('trust.currently_active > 0');- expect(headerSource).toContain('trust.fix_verified > 0');+ it('keeps trust counters out of the page header chrome', () => {+ // The Patrol assessment strip owns the default status readout. The header+ // should stay focused on title, recency, and controls rather than adding+ // another active/regressed summary row.+ expect(headerSource).not.toContain('aria-label="Patrol trust summary header"');+ expect(headerSource).not.toContain('state.patrolStatus()?.trust');+ expect(headerSource).not.toContain('trust.currently_active');+ expect(headerSource).not.toContain('trust.regressed_at_least_once');+ expect(headerSource).not.toContain('trust.fix_verified');});});diff --git a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsxindex 15e267561c..ec851c5ba4 100644--- a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx+++ b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx@@ -1,7 +1,6 @@-import { cleanup, fireEvent, render, screen, waitFor } from '@solidjs/testing-library';+import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';import { afterEach, describe, expect, it, vi } from 'vitest';-import { aiChatStore } from '@/stores/aiChat';import { aiIntelligenceStore } from '@/stores/aiIntelligence';import type { PatrolRunRecord } from '@/api/patrol';import { PatrolIntelligenceSummary } from '../PatrolIntelligenceSummary';@@ -13,11 +12,7 @@ describe('PatrolIntelligenceSummary', () => {vi.restoreAllMocks();});- it('opens Assistant with model-only context for the current Patrol assessment', async () => {- const openWithPrompt = vi.spyOn(aiChatStore, 'openWithPrompt').mockImplementation(() => {});- const loadPendingApprovals = vi- .spyOn(aiIntelligenceStore, 'loadPendingApprovals')- .mockResolvedValue(undefined);+ it('routes pending approvals from the compact assessment strip', () => {vi.spyOn(aiIntelligenceStore, 'patrolPendingApprovals', 'get').mockReturnValue([{id: 'approval-1',@@ -46,97 +41,24 @@ describe('PatrolIntelligenceSummary', () => {},]);- const patrolState = {- ...createPatrolState(),- summaryDetailsExpanded: () => true,- };+ const patrolState = createPatrolState();render(() => <PatrolIntelligenceSummary state={patrolState} />);expect(screen.getByTestId('patrol-recommended-next-step').textContent).toContain('Review the pending Patrol approval',);- expect(screen.getByTestId('patrol-summary-details').textContent).toContain(- 'risk, dry-run posture, and expiry',- );+ expect(screen.queryByTestId('patrol-summary-details-toggle')).not.toBeInTheDocument();+ expect(screen.queryByTestId('patrol-summary-details')).not.toBeInTheDocument();+ expect(screen.queryByTestId('patrol-assessment-assistant-button')).not.toBeInTheDocument();fireEvent.click(screen.getByTestId('patrol-recommended-next-step-action'));expect(patrolState.setSelectedRun).toHaveBeenCalledWith(null);expect(patrolState.setActiveTab).toHaveBeenCalledWith('findings');expect(patrolState.setFindingsFilterOverride).toHaveBeenCalledWith('approvals');-- fireEvent.click(screen.getByTestId('patrol-assessment-assistant-button'));-- await waitFor(() => expect(openWithPrompt).toHaveBeenCalledTimes(1));- expect(loadPendingApprovals).toHaveBeenCalledTimes(1);- const [prompt, context] = openWithPrompt.mock.calls[0] as [string, Record<string, unknown>];- expect(prompt).toContain('Discuss the current Pulse Patrol assessment');- expect(prompt).toContain('Start by reviewing 1 pending governed approval');- expect(prompt).toContain('approval policy, dry-run posture');- expect(prompt).toContain('Do not infer, repeat, or execute raw command text');- expect(context.autonomousMode).toBe(false);- expect(context.handoffContext).toContain('[Patrol Assessment Context]');- expect(context.handoffContext).toContain('Source: Pulse Patrol current assessment');- expect(context.handoffContext).toContain('Supporting Context: 2 recent changes');- expect(context.handoffContext).toContain(- 'Recommended Next Step: Review the pending Patrol approval',- );- expect(context.handoffContext).toContain(- 'Recommended Next Step Action: Review approvals (review_approvals)',- );- expect(context.handoffContext).toContain('Recent Change 1: Metric anomaly');- expect(context.handoffContext).toContain('Correlation 1: Nightly backup job');- expect(context.handoffContext).toContain('Finding 1: High CPU usage');- expect(context.handoffContext).toContain('approval approval-1');- expect(context.handoffContext).toContain('live approval pending');- expect(context.handoffContext).toContain('high risk');- expect(context.handoffContext).toContain('approval target web-server');- expect(context.handoffContext).toContain('expires 2026-05-06T12:10:00Z');- expect(context.context).toMatchObject({- pendingApprovalCount: 1,- recommendedNextStepTitle: 'Review the pending Patrol approval',- recommendedNextStepActionKind: 'review_approvals',- });- expect(context.handoffResources).toEqual([- { id: 'vm-100', name: 'web-server', type: 'vm', node: 'pve-1' },- { id: 'backup-job', name: 'Nightly backup job', type: 'job', node: undefined },- ]);- expect(context.handoffActions).toHaveLength(1);- expect((context.handoffActions as Array<Record<string, unknown>>)[0]).toMatchObject({- findingId: 'finding-1',- approvalId: 'approval-1',- approvalStatus: 'pending',- approvalRequestedAt: '2026-05-06T12:00:00Z',- approvalExpiresAt: '2026-05-06T12:10:00Z',- actionId: 'action-1',- actionApprovalPolicy: 'admin',- actionRequiresApproval: true,- actionPlanExpiresAt: '2026-05-06T12:10:00Z',- actionPlanMessage: 'Restart after the backup window clears.',- actionPreflight: 'Restart workload service',- actionDryRunSummary: 'No provider-supported dry run is available for this action.',- });- expect(context.briefing).toMatchObject({- actionLabel: '1 pending governed approval attached',- safetyNote:- 'Review approvals in the governed flow; approval policy is attached; dry-run posture is attached; raw command payloads stay out of Assistant.',- suggestedPrompts: [- 'Prioritize findings and safest next step',- 'Explain recent changes and correlations',- 'Review pending approvals and safest next step',- ],- });- expect((context.briefing as { detailLines?: string[] }).detailLines).toEqual(- expect.arrayContaining([- expect.stringContaining('Recommended next step: Review the pending Patrol approval'),- ]),- );- expect(JSON.stringify(context)).not.toContain('systemctl restart workload.service');});- it('passes current run-action availability into assessment Assistant handoff', async () => {- const openWithPrompt = vi.spyOn(aiChatStore, 'openWithPrompt').mockImplementation(() => {});- vi.spyOn(aiIntelligenceStore, 'loadPendingApprovals').mockResolvedValue(undefined);+ it('keeps unavailable run actions on the compact assessment strip', () => {vi.spyOn(aiIntelligenceStore, 'patrolPendingApprovals', 'get').mockReturnValue([]);const patrolState = {@@ -210,7 +132,6 @@ describe('PatrolIntelligenceSummary', () => {errorMessage: () => '',},runtimeState: () => 'running',- summaryDetailsExpanded: () => true,summaryStats: () => ({criticalFindings: 0,warningFindings: 0,@@ -223,27 +144,11 @@ describe('PatrolIntelligenceSummary', () => {render(() => <PatrolIntelligenceSummary state={patrolState} />);- fireEvent.click(screen.getByTestId('patrol-assessment-assistant-button'));-- await waitFor(() => expect(openWithPrompt).toHaveBeenCalledTimes(1));- const [prompt, context] = openWithPrompt.mock.calls[0] as [string, Record<string, unknown>];-- expect(prompt).toContain(- 'Patrol-owned action "Run Patrol" is currently unavailable: Patrol is already running',- );- expect(context.handoffContext).toContain(- 'Recommended Next Step Action Status: unavailable - Patrol is already running',- );- expect(context.context).toMatchObject({- recommendedNextStepActionKind: 'run_patrol',- recommendedNextStepActionDisabledReason: 'Patrol is already running',- });- expect(context.briefing).toMatchObject({- actionLabel: 'Recommended: Run Patrol',- safetyNote: expect.stringContaining(- 'Run Patrol is currently unavailable: Patrol is already running.',- ),- });+ const action = screen.getByTestId('patrol-recommended-next-step-action');+ expect(action).toHaveTextContent('Running...');+ expect(action).toBeDisabled();+ expect(action).toHaveAttribute('title', 'Patrol is already running');+ expect(screen.queryByTestId('patrol-summary-details-toggle')).not.toBeInTheDocument();});});@@ -418,8 +323,6 @@ function createPatrolState(): PatrolIntelligenceState {setActiveTab: vi.fn(),setFindingsFilterOverride: vi.fn(),setSelectedRun: vi.fn(),- setSummaryDetailsExpanded: vi.fn(),- summaryDetailsExpanded: () => false,summaryStats: () => ({criticalFindings: 1,warningFindings: 0,diff --git a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceWorkspace.test.ts b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceWorkspace.test.tsindex 58447d1ad6..5eb3d80981 100644--- a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceWorkspace.test.ts+++ b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceWorkspace.test.ts@@ -8,21 +8,18 @@ const workspaceSource = readFileSync();describe('PatrolIntelligenceWorkspace trust strip', () => {- it('renders a Trust strip from state.patrolStatus().trust when at least one signal is non-zero', () => {- // The Trust strip is the first operator-visible surface for the trust- // metrics data layer (FindingsStore.GetTrustSummary). It must read from- // state.patrolStatus()?.trust and gate visibility on at least one- // non-zero signal so a fresh install does not show an empty strip.- expect(workspaceSource).toContain('state.patrolStatus()?.trust');- expect(workspaceSource).toContain('aria-label="Patrol trust summary"');- expect(workspaceSource).toContain('trust.fix_verified');- expect(workspaceSource).toContain('trust.auto_resolved');- expect(workspaceSource).toContain('trust.dismissed_as_noise');+ it('does not render a standalone Trust strip above the workspace tabs', () => {+ // The Patrol assessment strip owns the default active/regressed status+ // readout. The workspace should move directly into Findings/Runs instead+ // of repeating the same counters in a second strip.+ expect(workspaceSource).not.toContain('state.patrolStatus()?.trust');+ expect(workspaceSource).not.toContain('aria-label="Patrol trust summary"');+ expect(workspaceSource).not.toContain('trust.fix_verified');+ expect(workspaceSource).not.toContain('trust.auto_resolved');+ expect(workspaceSource).not.toContain('trust.dismissed_as_noise');});it('does not invent trust signals not on FindingsTrustSummary', () => {- // The strip must read only fields defined on FindingsTrustSummary so- // adding new strip categories goes through the contract update first.// No mention of arbitrary keys like "patrol_score" or "health_grade".expect(workspaceSource).not.toMatch(/trust\.patrol_score/);expect(workspaceSource).not.toMatch(/trust\.health_grade/);diff --git a/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts b/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.tsindex a188774d36..bd6b567e76 100644--- a/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts+++ b/frontend-modern/src/features/patrol/__tests__/patrolInvestigationContextModel.test.ts@@ -1697,9 +1697,7 @@ describe('patrolInvestigationContextModel', () => {expect(handoff.context.handoffContext).toContain('Patrol Next Step: Open Patrol provider settings',);- expect(handoff.context.handoffContext).toContain(- 'Patrol Next Step Route: /settings/system-ai',- );+ expect(handoff.context.handoffContext).toContain('Patrol Next Step Route: /settings/system-ai');expect(handoff.context.handoffContext).toContain('Operator Boundary: This Patrol finding handoff is model-only context',);@@ -1861,24 +1859,26 @@ describe('Patrol page header IA framing', () => {expect(headerSource).not.toContain('verified {recency().resourcesChecked}');});- it('hoists a trust-at-a-glance summary into the page header above the runtime row', () => {- // The compact trust summary on the Patrol page header is the second- // wedge of the IA reframe (the first being PATROL_PAGE_DESCRIPTION).- // It must read from the same FindingsTrustSummary block plumbed- // through state.patrolStatus()?.trust as the workspace strip — no- // duplicate data path — and surface the three highest-signal- // counts (active, regressed, fixes verified) so operators see the- // trust loop's own state before scrolling into the workspace tabs.+ it('keeps trust-at-a-glance state inside the primary assessment readout', () => {+ // The default Patrol scan path has one status owner: the assessment strip.+ // Regression trust counters may feed that compact readout, but the header+ // and workspace tabs should not repeat another active/regressed strip.+ const summarySource = readFileSync(+ resolve(__dirname, '..', 'PatrolIntelligenceSummary.tsx'),+ 'utf-8',+ );const headerSource = readFileSync(resolve(__dirname, '..', 'PatrolIntelligenceHeader.tsx'),'utf-8',);- expect(headerSource).toContain('aria-label="Patrol trust summary header"');- expect(headerSource).toContain('state.patrolStatus()?.trust');- expect(headerSource).toContain('trust.currently_active');- expect(headerSource).toContain('trust.regressed_at_least_once');- expect(headerSource).toContain('trust.fix_verified');- expect(headerSource).toContain('trust.currently_active > 0');+ const workspaceSource = readFileSync(+ resolve(__dirname, '..', 'PatrolIntelligenceWorkspace.tsx'),+ 'utf-8',+ );+ expect(summarySource).toContain('compactAssessmentSummary');+ expect(summarySource).toContain('state.patrolStatus()?.trust?.regressed_at_least_once');+ expect(headerSource).not.toContain('aria-label="Patrol trust summary header"');+ expect(workspaceSource).not.toContain('aria-label="Patrol trust summary"');});it('names the proactive trust loop on the canonical Patrol surface', async () => {diff --git a/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts b/frontend-modern/src/features/patrol/usePatrolIntelligenceState.tsindex 1143373807..9d9e7b1c8c 100644--- a/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts+++ b/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts@@ -142,7 +142,6 @@ export function usePatrolIntelligenceState() {const [initialSurfaceReady, setInitialSurfaceReady] = createSignal(false);const [activeTab, setActiveTab] = createSignal<PatrolTab>('findings');const [showInvestigationContext, setShowInvestigationContext] = createSignal(false);- const [summaryDetailsExpanded, setSummaryDetailsExpanded] = createSignal(false);const [findingsFilterOverride, setFindingsFilterOverride] = createSignal<'all' | 'active' | 'resolved' | 'approvals' | 'attention' | undefined>(undefined);@@ -171,8 +170,7 @@ export function usePatrolIntelligenceState() {const [patrolAlertTriggers, setPatrolAlertTriggers] = createSignal<boolean>(true);const [patrolAnomalyTriggers, setPatrolAnomalyTriggers] = createSignal<boolean>(true);const [selectedRun, setSelectedRun] = createSignal<PatrolRunRecord | null>(null);- const [patrolModelSelectElement, setPatrolModelSelectElement] =- createSignal<HTMLSelectElement>();+ const [patrolModelSelectElement, setPatrolModelSelectElement] = createSignal<HTMLSelectElement>();let advancedSettingsRef: HTMLDivElement | undefined;let safetyTimerRef: ReturnType<typeof setTimeout> | undefined;@@ -993,7 +991,6 @@ export function usePatrolIntelligenceState() {setSelectedRun,setShowAdvancedSettings,setShowInvestigationContext,- setSummaryDetailsExpanded,setFindingScrollTimer: (timer: ReturnType<typeof setTimeout> | undefined) => {findingScrollTimerRef = timer;},@@ -1005,7 +1002,6 @@ export function usePatrolIntelligenceState() {showReadinessBanner,showInvestigationContext,shouldSurfaceInvestigationContext,- summaryDetailsExpanded,summaryStats,supportingRecentChanges,triggerPatrolDisabledReason,diff --git a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsxindex e7bde28a35..24989994d0 100644--- a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx+++ b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx@@ -866,10 +866,11 @@ describe('AIIntelligence entitlement gating', () => {await waitFor(() => {expect(getPatrolStatusMock).toHaveBeenCalled();expect(screen.getByText('Patrol assessment')).toBeInTheDocument();- expect(screen.getByText('No active issues detected')).toBeInTheDocument();+ expect(screen.getByText(/No issues found · 91\/100/)).toBeInTheDocument();});- expect(screen.getByText(/Health A · 91\/100/)).toBeInTheDocument();+ expect(screen.queryByText('No active issues detected')).not.toBeInTheDocument();+ expect(screen.queryByText(/Health A · 91\/100/)).not.toBeInTheDocument();expect(screen.queryByText('Supporting context')).not.toBeInTheDocument();expect(screen.queryByText('1 recent change · 4 policy-covered resources'),@@ -996,7 +997,7 @@ describe('AIIntelligence entitlement gating', () => {});expect(screen.queryByText('Patrol quickstart exhausted')).not.toBeInTheDocument();- expect(screen.getByText(/Health A · 100\/100/)).toBeInTheDocument();+ expect(screen.getByText(/No issues found · 100\/100/)).toBeInTheDocument();});it('normalizes retired hosted availability copy on unactivated installs', async () => {@@ -1155,7 +1156,7 @@ describe('AIIntelligence entitlement gating', () => {render(() => <AIIntelligence />);await waitFor(() => {- expect(screen.getAllByText('Coverage incomplete').length).toBeGreaterThan(0);+ expect(screen.getByText(/Coverage incomplete · 70\/100/)).toBeInTheDocument();expect(screen.getByText('Next:')).toBeInTheDocument();expect(screen.getByText('Verify full coverage')).toBeInTheDocument();expect(screen.getByTestId('patrol-recommended-next-step-action')).toHaveTextContent(@@ -1164,20 +1165,10 @@ describe('AIIntelligence entitlement gating', () => {expect(findingsPanelState.latestProps).not.toBeNull();});- // Patrol summary verification + activity-mix copy live behind the- // "Show details" toggle since commit 174d2b04d. Expand the section so- // the deeper assertions can find the text.- fireEvent.click(screen.getByTestId('patrol-summary-details-toggle'));-- await waitFor(() => {- expect(screen.getByText('No recent full patrol')).toBeInTheDocument();- expect(screen.getAllByText(/Last activity/i)).toHaveLength(1);- });-+ expect(screen.queryByTestId('patrol-summary-details-toggle')).not.toBeInTheDocument();+ expect(screen.queryByTestId('patrol-summary-details')).not.toBeInTheDocument();+ expect(screen.queryByText('No recent full patrol')).not.toBeInTheDocument();expect(screen.queryByText('No issues found')).not.toBeInTheDocument();- expect(screen.getByTestId('patrol-summary-details')).toHaveTextContent(- 'Run a full Patrol sweep before treating this assessment as an all-clear; recent evidence is incomplete or limited to targeted activity.',- );expect(screen.queryByText(/Last patrol/i)).not.toBeInTheDocument();expect(screen.queryByText(/^Last:/i)).not.toBeInTheDocument();expect(screen.queryByText('Partial verification')).not.toBeInTheDocument();@@ -1185,10 +1176,10 @@ describe('AIIntelligence entitlement gating', () => {expect(screen.queryByText('Warnings')).not.toBeInTheDocument();expect(screen.queryByText('Critical')).not.toBeInTheDocument();expect(- screen.getAllByText(+ screen.queryByText('Patrol coverage is incomplete: recent activity was limited to scoped runs and ended with errors, so overall health is not fully verified.',),- ).toHaveLength(1);+ ).not.toBeInTheDocument();expect(findingsPanelState.latestProps?.nextPatrolAt).toBeUndefined();expect(findingsPanelState.latestProps?.lastPatrolAt).toBeUndefined();expect(findingsPanelState.latestProps?.lastPatrolLabel).toBeUndefined();@@ -1335,24 +1326,10 @@ describe('AIIntelligence entitlement gating', () => {render(() => <AIIntelligence />);await waitFor(() => {- expect(screen.getByText('Patrol runtime issue')).toBeInTheDocument();- });-- // "Runtime issues" and "Latest activity" both live in the collapsible- // Patrol summary detail section (commit 174d2b04d).- fireEvent.click(screen.getByTestId('patrol-summary-details-toggle'));-- await waitFor(() => {- expect(- screen.getByText(- 'Patrol has an active runtime issue: Provider billing or quota issue. Recent coverage is also incomplete, so the rest of your infrastructure is not fully verified.',- ),- ).toBeInTheDocument();- expect(screen.getByText('Runtime issues')).toBeInTheDocument();- expect(screen.getByText('Latest activity')).toBeInTheDocument();+ expect(screen.getByText(/1 runtime issue · 60\/100/)).toBeInTheDocument();});- expect(screen.getByText(/Assessment C · 60\/100/)).toBeInTheDocument();+ expect(screen.getByText(/1 runtime issue · 60\/100/)).toBeInTheDocument();expect(screen.getByRole('link', { name: 'Open Patrol provider settings' })).toHaveAttribute('href','/settings/system-ai',@@ -1363,8 +1340,11 @@ describe('AIIntelligence entitlement gating', () => {expect(assessmentShell!.className).not.toContain('rounded-md');expect(assessmentShell!.className).not.toContain('shadow-sm');expect(assessmentShell!.className).not.toContain('bg-amber-50');+ expect(screen.queryByTestId('patrol-summary-details-toggle')).not.toBeInTheDocument();+ expect(screen.queryByTestId('patrol-summary-details')).not.toBeInTheDocument();expect(screen.queryByText('Infrastructure findings')).not.toBeInTheDocument();expect(screen.queryByText('Warnings')).not.toBeInTheDocument();+ expect(screen.queryByText('Latest activity')).not.toBeInTheDocument();expect(screen.queryByTestId('patrol-status-bar')).not.toBeInTheDocument();expect(screen.getByRole('button', { name: 'Findings' }).textContent).toBe('Findings 1');@@ -1379,7 +1359,24 @@ describe('AIIntelligence entitlement gating', () => {it('does not repeat stale coverage caveats after a successful full patrol verified resources', async () => {hasFeatureMock.mockReturnValue(true);licenseStatusMock.mockReturnValue({ subscription_state: 'active' });- getPatrolStatusMock.mockResolvedValue(defaultPatrolStatus({ license_required: false }));+ getPatrolStatusMock.mockResolvedValue(+ defaultPatrolStatus({+ license_required: false,+ trust: {+ tracked: 3,+ currently_active: 1,+ resolved: 2,+ auto_resolved: 0,+ fix_verified: 0,+ fix_failed: 0,+ dismissed_as_noise: 0,+ dismissed_as_expected: 0,+ dismissed_as_later: 0,+ suppressed: 0,+ regressed_at_least_once: 2,+ },+ }),+ );getPatrolRunHistoryMock.mockResolvedValue([{id: 'run-full-success',@@ -1469,11 +1466,12 @@ describe('AIIntelligence entitlement gating', () => {await waitFor(() => {expect(screen.getByText(/verified 58 resources/i)).toBeInTheDocument();+ expect(screen.getByText(/1 warning · 2 regressed · 85\/100/)).toBeInTheDocument();});- fireEvent.click(screen.getByTestId('patrol-summary-details-toggle'));- expect(screen.getByTestId('patrol-summary-details')).toHaveTextContent(- 'Patrol surfaced 1 active warning finding in your infrastructure. Review the active findings for more detail.',- );+ expect(screen.queryByLabelText('Patrol trust summary header')).not.toBeInTheDocument();+ expect(screen.queryByLabelText('Patrol trust summary')).not.toBeInTheDocument();+ expect(screen.queryByTestId('patrol-summary-details-toggle')).not.toBeInTheDocument();+ expect(screen.queryByTestId('patrol-summary-details')).not.toBeInTheDocument();expect(screen.queryByText(@@ -1483,7 +1481,7 @@ describe('AIIntelligence entitlement gating', () => {expect(screen.queryByText(/Recent coverage is also incomplete/i)).not.toBeInTheDocument();});- it('surfaces the recent activity mix in the verification summary when scoped runs are creating noise', async () => {+ it('keeps recent activity mix out of the default Patrol assessment chrome', async () => {hasFeatureMock.mockReturnValue(true);licenseStatusMock.mockReturnValue({ subscription_state: 'active' });getPatrolStatusMock.mockResolvedValue(defaultPatrolStatus({ license_required: false }));@@ -1615,18 +1613,12 @@ describe('AIIntelligence entitlement gating', () => {render(() => <AIIntelligence />);- // "Recent activity mix" copy lives in the collapsible Patrol summary- // detail section (commit 174d2b04d). Expand before asserting.await waitFor(() => {- expect(screen.getByTestId('patrol-summary-details-toggle')).toBeInTheDocument();+ expect(screen.getByText(/No issues found · 100\/100/)).toBeInTheDocument();});- fireEvent.click(screen.getByTestId('patrol-summary-details-toggle'));- await waitFor(() => {- expect(- screen.getByText('Recent activity mix: 1 full, 1 alert-triggered, 1 anomaly-triggered'),- ).toBeInTheDocument();- });+ expect(screen.queryByTestId('patrol-summary-details-toggle')).not.toBeInTheDocument();+ expect(screen.queryByText(/Recent activity mix:/)).not.toBeInTheDocument();});it('treats a selected zero-finding run as an empty snapshot and uses effective scope ids', async () => {