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
Scope the Patrol Open work summary to the browsed resource
rcourtman85621feabe24
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 739388fdc4..fbba03d3d0 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -4827,6 +4827,11 @@ inventory does not bind keeps that reference as its subject. Before24 October 2026 the item carried the reference, which no finding matched. Thefield's name, type and presence are unchanged for the relay mobile surface.Proof: `TestAttentionHandlersNameTheInventorySubjectOfEachAlert`.+The Patrol page's resource scope is presentation over those same payloads:+when it narrows the findings list to that ID, the `Open work` summary, work+groups and filter counts above the list count the findings whose `resource_id`+matches and the pending approvals that target them. It adds no request,+parameter or count field (24 October 2026).The Patrol workbench may project the summary counts into its fixed lifecyclefilter labels at either desktop or narrow widths, but changing presentationdoes not create a parallel count or filter vocabulary: every selection stilldiff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex 5cd32a7864..e087037215 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -2447,6 +2447,12 @@ For Patrol, that includes the Open work description: it may use conciserow-level guidance such as review evidence, approve a change, inspect automaticactions, or review verification results, but it must remain descriptive copyrather than another card, strip, or proof counter above the findings list.+A findings list scoped to one resource keeps that description, the work-group+chips and the filter counts on that resource: the description names it and+counts its open findings, each count reads only its findings, the approval+banner shows only their approvals, and the estate-wide check-health and+coverage-stale chips stay in the unscoped queue, so nothing above the rows+counts another resource's work.Watch-only forward-path guidance follows the same rule: the finding-row`Switch to Ask first` nudge and the Actions inbox Watch-only calm-state copylive in their governed presentation helpersdiff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.mdindex 7d70cd70d9..0ddcde083b 100644--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md@@ -2628,6 +2628,21 @@ subject is the unified resource ID findings carry (see ai-runtime, 24 October2026); before, a Docker container alert's raw `docker:<host>/<container>`reference scoped the list to nothing and the detail denied a finding Patrolhad raised on that container.+The scope carries the resource's name with its ID, and nothing above the+scoped list counts another resource's work: the `Open work` description names+the resource and counts its open findings (`Patrol found 2 issues on <name>`,+the rows the Active filter shows), the work groups count its approvals, failed+actions and recurring issues, and the findings filter's Needs Attention,+Approvals and Overdue chips each count that resource's findings in their own+subset. The approval banner shows only the approvals for the resource's+findings, so one about to expire keeps its countdown in the scope. The latest+check's health and coverage-stale groups describe every resource, so they stay+in the unscoped queue, and the page header keeps the last check. Before+24 October 2026 the scoped list sat under the whole queue's summary and+groups, so two rows read as `3 issues on 2 affected resources`. Proof:+`PatrolIntelligenceWorkspace.resourceScope.test.tsx`, the+`FindingsPanel resource scope` cases in `FindingsPanel.links.test.tsx`,+`ApprovalBanner.test.tsx` and `patrolControlPresentation.test.ts`.The temporary controls state in one visible line that acknowledgement andsuppression are short-term; the former `More ways to manage this issue`disclosure is gone.diff --git a/frontend-modern/browser-verification/4c5b985630a42042.json b/frontend-modern/browser-verification/4c5b985630a42042.jsonnew file mode 100644index 0000000000..6fa4670dc1--- /dev/null+++ b/frontend-modern/browser-verification/4c5b985630a42042.json@@ -0,0 +1,54 @@+{+ "version": 1,+ "base_sha": "52457777c432420ae348822c13ddba3b0244096a",+ "verified_at": "2026-10-24T10:10:07Z",+ "result": "passed",+ "changed_paths": [+ "frontend-modern/src/components/AI/FindingsPanel.tsx",+ "frontend-modern/src/components/patrol/ApprovalBanner.tsx",+ "frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx",+ "frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx",+ "frontend-modern/src/features/patrol/patrolControlPresentation.ts"+ ],+ "content_sha256": {+ "frontend-modern/src/components/AI/FindingsPanel.tsx": "82205372c7f7e3c42949566043d424233f668a4e176dabb9a2c2cb7b3cfaef36",+ "frontend-modern/src/components/patrol/ApprovalBanner.tsx": "deace86580cb3b820d08a7ac321e28e6deacf71dfa093137aa69c853ad2591ea",+ "frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx": "6a4f573342c7379fe63620f830f0f0df4029336dcd72b089510cec373c3e29f7",+ "frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx": "e1cad1da45244adf4e41277cccbf670c2651481b10633ab382700cabd6d293a8",+ "frontend-modern/src/features/patrol/patrolControlPresentation.ts": "6c88f32efbc5222220886b27ebd0da1a59c7d399567d7a8a5d4444c59c0427a8"+ },+ "routes": [+ "/patrol",+ "/patrol/activity"+ ],+ "viewports": [+ {+ "width": 1440,+ "height": 900+ },+ {+ "width": 390,+ "height": 844+ }+ ],+ "states": [+ "private mock-mode Pulse stack: backend cross-built from origin/main (OSS cmd/pulse) with this commit's frontend served by Vite from the landing clone (sha256 of the five changed runtime files matched this receipt); plaintext ai_findings.json seed: two recurring findings on postgres-replica-01 (unified vm-2e08698ae7c9c5b5, whose powered-off alert is an Inbox item), a cannot_fix finding on west-a-iso-library, a Pulse Patrol runtime finding, plus mock mode's demo findings: 10 open findings on 9 resources",+ "Inbox detail for postgres-replica-01 Powered off: 'Patrol also raised 2 findings for this resource' with Browse Patrol findings for this resource",+ "scoped Activity after Browse (fixed): 'Showing Patrol findings for postgres-replica-01', Open work 'Patrol found 2 issues on postgres-replica-01 — 2 recurring', one work group '2 recurring issues', chips Active/All/Resolved, two rows, at 1440 and 390; both rows and their Finding options visible on the phone landing screen",+ "same scope on origin/main's frontend (HMR swap of the four files, same stack): 'Patrol found 10 issues on 9 affected resources — 1 failed fix, 3 recurring', work groups '1 failed action' and '3 recurring issues', and a 'Needs Attention (1)' chip whose finding is on another resource, above the same two rows; at 390 the second row was pushed below the first screen",+ "scoped All filter: summary unchanged (open work) and the same two rows",+ "unscoped after Show all finding options: 'Patrol found 10 issues on 9 affected resources — 1 failed fix, 3 recurring', '1 failed action', '3 recurring issues', 'Needs Attention (1)', unchanged from main (12 on 10 by the final pass, as mock mode's demo cycle added findings; the scope still read 2 on postgres-replica-01)",+ "approvals pass: the headless run answered GET /api/ai/approvals with two pending investigation_fix approvals (one on postgres-replica-01's WAL finding, expiring in 9 minutes; one on west-a-iso-library), because pending Patrol approvals need the Pro orchestrator. Scoped (fixed): banner 'Action awaiting approval · medium risk · expires 8m 58s · Grow the WAL volume on postgres-replica-01 by 20 GiB', work groups '1 approval waiting' and '2 recurring issues', chips Active/All/Resolved/Approvals (1), two rows. Unscoped: '2 actions awaiting your approval', 'Approvals (2)'. Same scope on main: '2 actions awaiting your approval', 'Patrol found 12 issues on 10 affected resources — 1 failed fix, 6 recurring', '2 approvals waiting', '1 failed action', '6 recurring issues', Needs Attention (1), Approvals (2) above the two rows",+ "390 px: the single-approval banner's context line overflowed the banner (clipped at the screen edge); after adding min-w-0 to its flex items it ends in an ellipsis inside the banner",+ "headless Chromium on pulse-dev through a reverse tunnel (the in-app pane was hidden; its DOM reads at 1440 matched); dark theme; zero page errors at either width; final pass on these exact bytes (the five changed runtime files)"+ ],+ "interactions": [+ "opened the postgres-replica-01 Powered off item from the Patrol Inbox at each width",+ "clicked Browse Patrol findings for this resource; the view switched to Activity with Finding options and history open and scoped; read the scope line, Open work line, work groups, filter chips and rows, and screenshotted the landing screen and the whole panel",+ "opened the first row's review and its Finding options inside the scope",+ "switched the scoped filter to All and re-read the summary and rows",+ "clicked Show all finding options, returned to Active and re-read the unscoped summary, groups, chips and rows",+ "repeated the whole pass with origin/main's copies of the five runtime files served by the same Vite, with and without injected approvals, then restored this change",+ "component tests: PatrolIntelligenceWorkspace.resourceScope.test.tsx (real workspace, FindingsPanel and ApprovalBanner, including a findings refresh and the end of the scope), the FindingsPanel resource scope cases, the ApprovalBanner targetIds cases and the two patrolControlPresentation cases fail on origin/main and pass here; unscoped controls pass on both"+ ]+}diff --git a/frontend-modern/src/components/AI/FindingsPanel.tsx b/frontend-modern/src/components/AI/FindingsPanel.tsxindex e4ab96878d..9ad675b098 100644--- a/frontend-modern/src/components/AI/FindingsPanel.tsx+++ b/frontend-modern/src/components/AI/FindingsPanel.tsx@@ -263,6 +263,10 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {? aiIntelligenceStore.patrolFindingsWithPendingApprovals: aiIntelligenceStore.findingsWithPendingApprovals,);+ // A resource scope narrows the rows to one resource, so the filter counts+ // read only its findings: a chip never counts rows it cannot show.+ const isInResourceScope = (finding: UnifiedFinding) =>+ !props.resourceId || finding.resourceId === props.resourceId;// Load findings on mountcreateEffect(() => {@@ -305,6 +309,7 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {const nowMs = now();return sourceFindings().filter((f) => {+ if (!isInResourceScope(f)) return false;if (f.dismissedReason !== 'will_fix_later' || !f.remindAt) return false;const due = Date.parse(f.remindAt);return Number.isFinite(due) && due <= nowMs;@@ -426,21 +431,23 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {const useRunSnapshotScopedControls = createMemo(() => props.runSnapshot !== undefined);const scopedNeedsAttentionCount = createMemo(() => {const attentionIds = new Set(sourceFindingsNeedingAttention().map((f) => f.id));- return runSnapshotScopedPatrolFindings().filter((finding) => attentionIds.has(finding.id))- .length;+ return runSnapshotScopedPatrolFindings().filter(+ (finding) => isInResourceScope(finding) && attentionIds.has(finding.id),+ ).length;});const scopedPendingApprovalCount = createMemo(() => {const approvalIds = new Set(sourceFindingsWithPendingApprovals().map((finding) => finding.id));- return runSnapshotScopedPatrolFindings().filter((finding) => approvalIds.has(finding.id))- .length;+ return runSnapshotScopedPatrolFindings().filter(+ (finding) => isInResourceScope(finding) && approvalIds.has(finding.id),+ ).length;});const filterCounts = createMemo(() => ({needsAttentionCount: useRunSnapshotScopedControls()? scopedNeedsAttentionCount()- : sourceFindingsNeedingAttention().length,+ : sourceFindingsNeedingAttention().filter(isInResourceScope).length,pendingApprovalCount: useRunSnapshotScopedControls()? scopedPendingApprovalCount()- : sourceFindingsWithPendingApprovals().length,+ : sourceFindingsWithPendingApprovals().filter(isInResourceScope).length,}));// Drives the Overdue commitments chip below.const overdueCount = createMemo(() => overdueFindingIds().length);diff --git a/frontend-modern/src/components/AI/__tests__/FindingsPanel.links.test.tsx b/frontend-modern/src/components/AI/__tests__/FindingsPanel.links.test.tsxindex 39ba34a2f5..3f4f38fa6e 100644--- a/frontend-modern/src/components/AI/__tests__/FindingsPanel.links.test.tsx+++ b/frontend-modern/src/components/AI/__tests__/FindingsPanel.links.test.tsx@@ -1,6 +1,6 @@import { fireEvent, render, screen, waitFor } from '@solidjs/testing-library';import { createSignal, type JSX } from 'solid-js';-import { beforeEach, describe, expect, it, vi } from 'vitest';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import { FindingsPanel } from '../FindingsPanel';import { RELATIVE_TIME_TICK_MS } from '@/utils/relativeTimeClock';@@ -80,6 +80,8 @@ const mockState = vi.hoisted(() => {targetId: string;expiresAt?: string;}>,+ attentionFindingIds: [] as string[],+ approvalFindingIds: [] as string[],getResource,loadFindings,loadPatrolFindings,@@ -141,13 +143,17 @@ vi.mock('@/stores/aiIntelligence', () => ({return [];},get patrolFindingsNeedingAttention() {- return [];+ return mockState.patrolFindings.filter((finding) =>+ mockState.attentionFindingIds.includes(finding.id as string),+ );},get findingsWithPendingApprovals() {return [];},get patrolFindingsWithPendingApprovals() {- return [];+ return mockState.patrolFindings.filter((finding) =>+ mockState.approvalFindingIds.includes(finding.id as string),+ );},get needsAttentionCount() {return 0;@@ -925,3 +931,86 @@ describe('FindingsPanel future times', () => {}});});++describe('FindingsPanel resource scope', () => {+ const finding = (+ id: string,+ title: string,+ resource: { resourceId: string; resourceName: string },+ extra: Record<string, unknown> = {},+ ) => ({ ...mockState.initialPatrolFindings[0], id, title, ...resource, ...extra });+ const web = { resourceId: 'docker:host-1/web', resourceName: 'afs-web' };+ const db = { resourceId: 'vm-db', resourceName: 'db-01' };+ const overdue = {+ status: 'dismissed',+ dismissedReason: 'will_fix_later',+ remindAt: '2026-01-01T00:00:00Z',+ };+ const reviewButtons = () =>+ screen+ .getAllByRole('button', { name: /^Review issue for / })+ .map((button) => button.getAttribute('aria-label') ?? button.textContent);++ beforeEach(() => {+ mockState.patrolFindingsLoading = false;+ mockState.patrolFindingsError = null;+ mockState.patrolPendingApprovals = [];+ mockState.patrolFindings = [+ finding('web-disk', 'Web disk is filling', web),+ finding('web-restart', 'Web container keeps restarting', web),+ finding('web-later', 'Web certificate renewal slipping', web, overdue),+ finding('db-backup', 'Database backup is stale', db),+ finding('db-later', 'Database patching slipping', db, overdue),+ ];+ mockState.attentionFindingIds = ['web-disk', 'web-restart', 'db-backup'];+ mockState.approvalFindingIds = ['web-restart', 'db-backup'];+ });++ afterEach(() => {+ mockState.attentionFindingIds = [];+ mockState.approvalFindingIds = [];+ });++ it("counts only the scoped resource's findings in the filter chips", () => {+ render(() => (+ <FindingsPanel+ findingsSource="patrol"+ resourceId="docker:host-1/web"+ filterOverride="active"+ />+ ));++ expect(reviewButtons()).toHaveLength(2);+ expect(screen.getByRole('button', { name: /^Needs Attention \(2\)$/ })).toBeInTheDocument();+ expect(screen.getByRole('button', { name: /^Overdue commitments \(1\)$/ })).toBeInTheDocument();++ // Each chip opens exactly the rows it counted.+ fireEvent.click(screen.getByRole('button', { name: /^Approvals \(1\)$/ }));+ expect(reviewButtons()).toEqual(['Review issue for Web container keeps restarting']);+ fireEvent.click(screen.getByRole('button', { name: /^Overdue commitments \(1\)$/ }));+ expect(reviewButtons()).toEqual(['Review issue for Web certificate renewal slipping']);+ });++ it('counts every finding when the panel is not scoped to a resource', () => {+ render(() => <FindingsPanel findingsSource="patrol" filterOverride="active" />);++ expect(screen.getByRole('button', { name: /^Needs Attention \(3\)$/ })).toBeInTheDocument();+ expect(screen.getByRole('button', { name: /^Approvals \(2\)$/ })).toBeInTheDocument();+ expect(screen.getByRole('button', { name: /^Overdue commitments \(2\)$/ })).toBeInTheDocument();+ });++ it('keeps the filter bar for a scoped resource with no findings', () => {+ render(() => (+ <FindingsPanel findingsSource="patrol" resourceId="vm-quiet" filterOverride="active" />+ ));++ expect(screen.queryAllByRole('button', { name: /^Review issue for / })).toHaveLength(0);+ // Resolved and All stay reachable; no chip counts another resource's work.+ for (const name of [/^Active$/, /^All$/, /^Resolved$/]) {+ expect(screen.getByRole('button', { name })).toBeInTheDocument();+ }+ expect(screen.queryByRole('button', { name: /^Needs Attention/ })).not.toBeInTheDocument();+ expect(screen.queryByRole('button', { name: /^Approvals/ })).not.toBeInTheDocument();+ expect(screen.queryByRole('button', { name: /^Overdue commitments/ })).not.toBeInTheDocument();+ });+});diff --git a/frontend-modern/src/components/patrol/ApprovalBanner.tsx b/frontend-modern/src/components/patrol/ApprovalBanner.tsxindex a5f6b52be4..cfde919e1c 100644--- a/frontend-modern/src/components/patrol/ApprovalBanner.tsx+++ b/frontend-modern/src/components/patrol/ApprovalBanner.tsx@@ -7,6 +7,8 @@* - Hidden when no pending approvals* - Single approval: deep-links to the exact governed action when available* - Multiple approvals: links to the open Actions inbox+ * - Given targetIds (a findings list scoped to one resource), only the+ * approvals for those findings*/import { Component, Show, createMemo, createSignal, createEffect, onCleanup } from 'solid-js';@@ -23,10 +25,14 @@ import ArrowRightIcon from 'lucide-solid/icons/arrow-right';const APPROVAL_BANNER_BADGE_PROPS = { size: 'xs', shape: 'rounded' } as const;-export const ApprovalBanner: Component = () => {+export const ApprovalBanner: Component<{ targetIds?: ReadonlySet<string> }> = (props) => {const [tick, setTick] = createSignal(Date.now());- const pending = createMemo(() => aiIntelligenceStore.patrolPendingApprovals);+ const pending = createMemo(() => {+ const approvals = aiIntelligenceStore.patrolPendingApprovals;+ const targetIds = props.targetIds;+ return targetIds ? approvals.filter((approval) => targetIds.has(approval.targetId)) : approvals;+ });// Only tick when there are pending approvals to avoid unnecessary workcreateEffect(() => {@@ -53,11 +59,11 @@ export const ApprovalBanner: Component = () => {<Show when={pending().length > 0}><div class="bg-amber-50 dark:bg-amber-900/25 border border-amber-200 dark:border-amber-800 rounded-md px-4 py-3"><div class="flex items-center justify-between gap-3 flex-wrap">- <div class="flex items-center gap-3">+ <div class="flex min-w-0 items-center gap-3"><div class="shrink-0 p-1.5 border border-amber-200 bg-amber-50 dark:border-amber-800 dark:bg-amber-900/25 rounded-md"><ShieldAlertIcon class="w-4 h-4 text-amber-500 dark:text-amber-400" /></div>- <div>+ <div class="min-w-0"><Show when={pending().length === 1 && firstApproval()}><div class="flex items-center gap-2 flex-wrap"><span class="text-sm font-medium text-amber-900 dark:text-amber-100">diff --git a/frontend-modern/src/components/patrol/__tests__/ApprovalBanner.test.tsx b/frontend-modern/src/components/patrol/__tests__/ApprovalBanner.test.tsxindex b98aa73740..53cc07622e 100644--- a/frontend-modern/src/components/patrol/__tests__/ApprovalBanner.test.tsx+++ b/frontend-modern/src/components/patrol/__tests__/ApprovalBanner.test.tsx@@ -36,7 +36,7 @@ describe('ApprovalBanner', () => {const renderBanner = () =>render(() => (<Router>- <Route path="/" component={ApprovalBanner} />+ <Route path="/" component={() => <ApprovalBanner />} /></Router>));@@ -106,6 +106,57 @@ describe('ApprovalBanner', () => {);});+ it("shows only the approvals for a scoped resource's findings", () => {+ state.pendingApprovals = [+ approvalRequest({+ id: 'approval-elsewhere',+ targetId: 'finding-elsewhere',+ context: 'Restart elsewhere',+ }),+ approvalRequest({+ id: 'approval-here',+ targetId: 'finding-here',+ context: 'Restart here',+ expiresAt: '2026-03-01T00:04:00Z',+ plan: { actionId: 'action-here' },+ }),+ ] as ApprovalRequest[];++ render(() => (+ <Router>+ <Route+ path="/"+ component={() => <ApprovalBanner targetIds={new Set(['finding-here'])} />}+ />+ </Router>+ ));++ // The resource's own approval keeps its countdown and exact action.+ expect(screen.getByText('Action awaiting approval')).toBeInTheDocument();+ expect(screen.getByText('Restart here')).toBeInTheDocument();+ expect(screen.getByText('expires 4m 0s')).toBeInTheDocument();+ expect(screen.queryByText(/actions awaiting your approval/)).not.toBeInTheDocument();+ expect(screen.getByRole('link', { name: 'Review in Actions' })).toHaveAttribute(+ 'href',+ '/actions?action=action-here',+ );+ });++ it('stays hidden when no approval waits on the scoped findings', () => {+ state.pendingApprovals = [approvalRequest()];++ render(() => (+ <Router>+ <Route+ path="/"+ component={() => <ApprovalBanner targetIds={new Set(['finding-other'])} />}+ />+ </Router>+ ));++ expect(screen.queryByRole('link', { name: 'Review in Actions' })).not.toBeInTheDocument();+ });+it('renders a deterministic countdown label for a valid single approval expiry', () => {state.pendingApprovals = [approvalRequest({ expiresAt: '2026-03-01T00:06:00Z' })];diff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsxindex 90ca3c1306..18dee1240b 100644--- a/frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx@@ -289,6 +289,7 @@ export function PatrolIntelligenceSurface() {<PatrolIntelligenceWorkspacestate={state}findingResourceId={findingResourceScope()?.id}+ findingResourceName={findingResourceScope()?.name}/></div></details>diff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsxindex e45988ff4f..a2a33ca65e 100644--- a/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx@@ -5,6 +5,7 @@ import ShieldAlertIcon from 'lucide-solid/icons/shield-alert';import ListChecksIcon from 'lucide-solid/icons/list-checks';import { FindingsPanel } from '@/components/AI/FindingsPanel';import { ApprovalBanner, RunHistoryPanel } from '@/components/patrol';+import { aiIntelligenceStore } from '@/stores/aiIntelligence';import {getFindingTitlePresentation,buildPatrolFindingDisplayGroups,@@ -61,23 +62,48 @@ const PatrolSetupPanel = lazy(() => import('./PatrolSetupPanel'));export function PatrolIntelligenceWorkspace(props: {state: PatrolIntelligenceState;findingResourceId?: string;+ findingResourceName?: string;}) {const state = props.state;// The selected run stays as picked when run history is re-read, so its start// age reads the shared clock instead of freezing at selection.const now = useRelativeTimeNow();- const queueDisplayGroups = createMemo(() =>- buildPatrolFindingDisplayGroups(state.findingsTabBadgeFindings()),- );- const queueIssueCount = createMemo(- () => state.findingsTabBadgeCount() ?? state.findingsTabBadgeFindings().length,+ // An Inbox item's "Browse Patrol findings for this resource" narrows the+ // findings list to that resource, so the summary and work groups above it+ // count the same findings.+ const queueFindings = createMemo(() => {+ const findings = state.findingsTabBadgeFindings();+ const resourceId = props.findingResourceId;+ return resourceId ? findings.filter((finding) => finding.resourceId === resourceId) : findings;+ });+ const queueDisplayGroups = createMemo(() => buildPatrolFindingDisplayGroups(queueFindings()));+ const queueIssueCount = createMemo(() =>+ props.findingResourceId+ ? queueFindings().length+ : (state.findingsTabBadgeCount() ?? queueFindings().length),);const queueAffectedResourceCount = createMemo(() =>queueDisplayGroups().reduce((count, group) => count + group.affectedResourceCount, 0),);- const workTypeComposition = createMemo(() =>- getPatrolWorkTypeComposition(state.findingsTabBadgeFindings()),- );+ const workTypeComposition = createMemo(() => getPatrolWorkTypeComposition(queueFindings()));+ // The scoped resource's findings: its work group and the approval banner+ // count and show only the approvals waiting on them.+ const scopedFindingIds = createMemo(() => {+ const resourceId = props.findingResourceId;+ if (!resourceId) return undefined;+ return new Set(+ aiIntelligenceStore.patrolFindings+ .filter((finding) => finding.resourceId === resourceId)+ .map((finding) => finding.id),+ );+ });+ const queuePendingApprovalCount = createMemo(() => {+ const findingIds = scopedFindingIds();+ if (!findingIds) return state.patrolPendingApprovalCount();+ return aiIntelligenceStore.patrolPendingApprovals.filter((approval) =>+ findingIds.has(approval.targetId),+ ).length;+ });const isHistoryOpen = () => state.activeTab() === 'history';// Once the operator starts the setup panel it stays until they finish:// polling flips the readiness cause mid-setup (no provider, then model@@ -132,6 +158,7 @@ export function PatrolIntelligenceWorkspace(props: {autonomyLocked: state.autoFixLocked(),affectedResourceCount: queueAffectedResourceCount(),findingCount: queueIssueCount(),+ resourceName: props.findingResourceId ? props.findingResourceName : undefined,workTypeComposition: workTypeComposition(),});const openHistory = () => {@@ -161,7 +188,8 @@ export function PatrolIntelligenceWorkspace(props: {getPatrolWorkspaceWorkGroups({latestRun: latestCompletedRun(),patrolStatus: state.patrolStatus(),- pendingApprovalCount: state.patrolPendingApprovalCount(),+ pendingApprovalCount: queuePendingApprovalCount(),+ resourceScoped: Boolean(props.findingResourceId),workTypeComposition: workTypeComposition(),}),);@@ -178,7 +206,7 @@ export function PatrolIntelligenceWorkspace(props: {return (<>- <ApprovalBanner />+ <ApprovalBanner targetIds={scopedFindingIds()} /><div class="flex flex-wrap items-start justify-between gap-3 border-b border-border pb-3"><div class="min-w-0">diff --git a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSurface.test.tsx b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSurface.test.tsxindex 91b1ff2c1f..11f3c0d0c7 100644--- a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSurface.test.tsx+++ b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSurface.test.tsx@@ -44,8 +44,15 @@ vi.mock('../PatrolAttentionWorkbench', () => ({}));vi.mock('../PatrolIntelligenceWorkspace', () => ({- PatrolIntelligenceWorkspace: (props: { findingResourceId?: string }) => (- <div data-testid="patrol-workspace" data-resource-id={props.findingResourceId ?? ''} />+ PatrolIntelligenceWorkspace: (props: {+ findingResourceId?: string;+ findingResourceName?: string;+ }) => (+ <div+ data-testid="patrol-workspace"+ data-resource-id={props.findingResourceId ?? ''}+ data-resource-name={props.findingResourceName ?? ''}+ />),}));@@ -119,10 +126,15 @@ describe('PatrolIntelligenceSurface finding handoff', () => {expect(window.location.pathname).toBe('/patrol/activity');expect(screen.getByText(/Showing Patrol findings for Database VM/i)).toBeInTheDocument();expect(screen.getByTestId('patrol-workspace')).toHaveAttribute('data-resource-id', 'vm-101');+ expect(screen.getByTestId('patrol-workspace')).toHaveAttribute(+ 'data-resource-name',+ 'Database VM',+ );fireEvent.click(screen.getByRole('button', { name: 'Show all finding options' }));expect(screen.getByTestId('patrol-workspace')).toHaveAttribute('data-resource-id', '');+ expect(screen.getByTestId('patrol-workspace')).toHaveAttribute('data-resource-name', '');expect(screen.queryByText(/Showing Patrol findings for Database VM/i)).not.toBeInTheDocument();});diff --git a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceWorkspace.resourceScope.test.tsx b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceWorkspace.resourceScope.test.tsxnew file mode 100644index 0000000000..762662fea4--- /dev/null+++ b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceWorkspace.resourceScope.test.tsx@@ -0,0 +1,307 @@+import { cleanup, render, screen, within } from '@solidjs/testing-library';+import { createSignal, type JSX } from 'solid-js';+import { afterEach, describe, expect, it, vi } from 'vitest';++import { PatrolIntelligenceWorkspace } from '../PatrolIntelligenceWorkspace';+import type { PatrolIntelligenceState } from '../usePatrolIntelligenceState';++const fixture = vi.hoisted(() => {+ const finding = (+ id: string,+ title: string,+ resource: { resourceId: string; resourceName: string },+ extra: Record<string, unknown> = {},+ ) => ({+ id,+ title,+ ...resource,+ source: 'ai-patrol',+ resourceType: 'app-container',+ category: 'reliability',+ severity: 'warning',+ description: `${title}.`,+ detectedAt: '2026-10-24T08:00:00Z',+ lastSeenAt: '2026-10-24T09:00:00Z',+ status: 'active',+ ...extra,+ });+ const web = { resourceId: 'app-container:host-1:web', resourceName: 'afs-web' };+ const findings = [+ finding('web-disk', 'Web volume is filling', web, { timesRaised: 3 }),+ finding('web-restart', 'Web container keeps restarting', web, {+ investigationOutcome: 'fix_queued',+ }),+ finding(+ 'db-backup',+ 'Database backup is stale',+ { resourceId: 'vm-db-01', resourceName: 'db-01' },+ { investigationOutcome: 'fix_queued' },+ ),+ finding(+ 'cache-evictions',+ 'Cache evicts hot keys',+ { resourceId: 'vm-cache-01', resourceName: 'cache-01' },+ { investigationOutcome: 'fix_failed' },+ ),+ ];+ return {+ finding,+ web,+ findings,+ // Tests that change the findings swap in a signal accessor.+ read: () => findings,+ attentionIds: ['web-disk', 'web-restart', 'db-backup', 'cache-evictions'],+ approvalIds: ['web-restart', 'db-backup'],+ };+});++vi.mock('@solidjs/router', () => ({+ A: (props: { href: string; children?: JSX.Element }) => <a href={props.href}>{props.children}</a>,+ useLocation: () => ({ hash: '' }),+}));++vi.mock('@/components/patrol', async () => {+ const { ApprovalBanner } = await vi.importActual<+ typeof import('@/components/patrol/ApprovalBanner')+ >('@/components/patrol/ApprovalBanner');+ return {+ ApprovalBanner,+ ApprovalSection: () => null,+ InvestigationSection: () => null,+ RunHistoryPanel: () => null,+ };+});++vi.mock('@/stores/notifications', () => ({+ notificationStore: { success: vi.fn(), error: vi.fn() },+}));++vi.mock('@/hooks/useResources', () => ({+ useResources: () => ({ get: () => undefined }),+}));++vi.mock('../usePatrolIntelligenceState', () => ({+ resolvePatrolBlockedActionCause: (blocked?: string, readiness?: string) =>+ blocked || readiness || undefined,+}));++vi.mock('@/stores/aiIntelligence', () => ({+ aiIntelligenceStore: {+ get findings() {+ return [];+ },+ get patrolFindings() {+ return fixture.read();+ },+ findingsLoading: false,+ patrolFindingsLoading: false,+ findingsError: null,+ patrolFindingsError: null,+ get findingsNeedingAttention() {+ return [];+ },+ get patrolFindingsNeedingAttention() {+ return fixture.read().filter((finding) => fixture.attentionIds.includes(finding.id));+ },+ get findingsWithPendingApprovals() {+ return [];+ },+ get patrolFindingsWithPendingApprovals() {+ return fixture.read().filter((finding) => fixture.approvalIds.includes(finding.id));+ },+ get patrolPendingApprovals() {+ return fixture.approvalIds.map((targetId) => ({+ id: `approval-${targetId}`,+ status: 'pending',+ toolId: 'investigation_fix',+ targetId,+ context: `Apply the fix for ${targetId}`,+ riskLevel: 'medium',+ expiresAt: '2099-01-01T00:00:00Z',+ }));+ },+ findingsSignal: () => [],+ patrolFindingsSignal: () => fixture.read(),+ loadFindings: vi.fn(),+ loadPatrolFindings: vi.fn(),+ },+}));++// Like the Patrol state hook, the queue holds only active findings.+const activeFindings = () => fixture.read().filter((finding) => finding.status === 'active');++// The latest check failed and its evidence is stale, so the unscoped queue+// shows both Patrol check groups.+const makeState = () =>+ ({+ activeTab: () => 'findings',+ autoFixLocked: () => false,+ autonomyLevel: () => 'monitor',+ blockedCause: () => '',+ blockedReason: () => '',+ displayRunHistory: () => [],+ findingsFilterOverride: () => 'active',+ findingsTabBadgeCount: () => activeFindings().length,+ findingsTabBadgeFindings: () => activeFindings(),+ handleAutonomyChange: vi.fn(),+ handleRefreshPatrol: vi.fn(),+ handleRunPatrol: vi.fn(),+ historicalRegressionCount: () => 0,+ intelligenceSummary: () => null,+ isUpdatingAutonomy: () => false,+ patrolPendingApprovalCount: () => fixture.approvalIds.length,+ patrolReadiness: () => null,+ patrolRunHistory: {+ value: () => [+ {+ completed_at: '2026-10-20T08:00:00Z',+ error_count: 2,+ resources_checked: 12,+ status: 'error',+ },+ ],+ loading: () => false,+ },+ patrolStatus: () => ({+ error_count: 2,+ next_patrol_at: '2026-10-20T14:00:00Z',+ running: false,+ }),+ patrolStream: {},+ runtimeState: () => 'active',+ selectedRun: () => null,+ selectedRunFindingIds: () => undefined,+ selectedRunHasFindingsSnapshot: () => undefined,+ selectedRunScopeResourceIds: () => [],+ setActiveTab: vi.fn(),+ setFindingsFilterOverride: vi.fn(),+ setSelectedRun: vi.fn(),+ shouldShowPatrolSetupOnly: () => false,+ triggerPatrolDisabledReason: () => '',+ }) as unknown as PatrolIntelligenceState;++const workGroupLabels = () =>+ within(screen.getByRole('list', { name: 'Patrol work groups' }))+ .getAllByRole('listitem')+ .map((item) => item.querySelector('span')?.textContent?.trim());+const reviewRows = () =>+ screen+ .getAllByRole('button', { name: /^Review issue for / })+ .map((button) => button.getAttribute('aria-label'));++describe('PatrolIntelligenceWorkspace resource scope', () => {+ afterEach(() => {+ cleanup();+ fixture.read = () => fixture.findings;+ });++ it('describes the scoped resource with the counts its rows show', () => {+ render(() => (+ <PatrolIntelligenceWorkspace+ state={makeState()}+ findingResourceId="app-container:host-1:web"+ findingResourceName="afs-web"+ />+ ));++ expect(+ screen.getByText(+ 'Patrol found 2 issues on afs-web — 1 needs approval, 1 recurring. Open a row to review evidence and record the outcome.',+ ),+ ).toBeInTheDocument();+ expect(workGroupLabels()).toEqual(['1 approval waiting', '1 recurring issue']);+ // The banner shows the resource's own approval, not every pending approval.+ expect(screen.getByText('Action awaiting approval')).toBeInTheDocument();+ expect(screen.getByText('Apply the fix for web-restart')).toBeInTheDocument();+ expect(screen.queryByText(/actions awaiting your approval/)).not.toBeInTheDocument();+ expect(screen.getByRole('button', { name: /^Needs Attention \(2\)$/ })).toBeInTheDocument();+ expect(screen.getByRole('button', { name: /^Approvals \(1\)$/ })).toBeInTheDocument();+ expect(reviewRows()).toEqual([+ 'Review issue for Web container keeps restarting',+ 'Review issue for Web volume is filling',+ ]);+ });++ it('keeps the whole-queue summary without a resource scope', () => {+ render(() => <PatrolIntelligenceWorkspace state={makeState()} />);++ expect(+ screen.getByText(+ 'Patrol found 4 issues on 3 affected resources — 2 need approval, 1 failed fix, 1 recurring. Open a row to review evidence and record the outcome.',+ ),+ ).toBeInTheDocument();+ expect(workGroupLabels()).toEqual([+ '2 approvals waiting',+ '1 failed action',+ 'Latest check needs review',+ '1 recurring issue',+ 'Coverage stale',+ ]);+ expect(screen.getByText('2 actions awaiting your approval')).toBeInTheDocument();+ expect(screen.getByRole('button', { name: /^Needs Attention \(4\)$/ })).toBeInTheDocument();+ expect(screen.getByRole('button', { name: /^Approvals \(2\)$/ })).toBeInTheDocument();+ });++ it('follows a findings refresh and the end of the scope', () => {+ const [findings, setFindings] = createSignal(fixture.findings);+ fixture.read = findings;+ const [scoped, setScoped] = createSignal(true);+ render(() => (+ <PatrolIntelligenceWorkspace+ state={makeState()}+ findingResourceId={scoped() ? fixture.web.resourceId : undefined}+ findingResourceName={scoped() ? fixture.web.resourceName : undefined}+ />+ ));+ expect(+ screen.getByText(/^Patrol found 2 issues on afs-web — 1 needs approval, 1 recurring\./),+ ).toBeInTheDocument();++ // A refresh that raises another finding on the resource moves every scoped count.+ setFindings([+ ...fixture.findings,+ fixture.finding('web-cert', 'Web certificate renewal keeps slipping', fixture.web, {+ timesRaised: 2,+ }),+ ]);+ expect(+ screen.getByText(/^Patrol found 3 issues on afs-web — 1 needs approval, 2 recurring\./),+ ).toBeInTheDocument();+ expect(workGroupLabels()).toEqual(['1 approval waiting', '2 recurring issues']);+ expect(reviewRows()).toHaveLength(3);++ // web-restart drops out of the loaded findings while its approval is still+ // pending: nothing ties that approval to the resource, so the banner and the+ // approvals group go together.+ const withCert = findings();+ setFindings(withCert.filter((finding) => finding.id !== 'web-restart'));+ expect(screen.queryByText('Action awaiting approval')).not.toBeInTheDocument();+ expect(workGroupLabels()).toEqual(['2 recurring issues']);++ // It returns resolved with the approval still pending: both come back, while+ // the open work stays at the two active findings.+ setFindings([...findings(), { ...fixture.findings[1], status: 'resolved' }]);+ expect(screen.getByText('Action awaiting approval')).toBeInTheDocument();+ expect(workGroupLabels()).toEqual(['1 approval waiting', '2 recurring issues']);+ expect(+ screen.getByText(/^Patrol found 2 issues on afs-web — 2 recurring\./),+ ).toBeInTheDocument();+ expect(reviewRows()).toHaveLength(2);++ // Show all finding options ends the scope: the whole queue again.+ setScoped(false);+ expect(+ screen.getByText(+ /^Patrol found 4 issues on 3 affected resources — 1 needs approval, 1 failed fix, 2 recurring\./,+ ),+ ).toBeInTheDocument();+ expect(workGroupLabels()).toEqual([+ '2 approvals waiting',+ '1 failed action',+ 'Latest check needs review',+ '2 recurring issues',+ 'Coverage stale',+ ]);+ expect(screen.getByText('2 actions awaiting your approval')).toBeInTheDocument();+ });+});diff --git a/frontend-modern/src/features/patrol/__tests__/patrolControlPresentation.test.ts b/frontend-modern/src/features/patrol/__tests__/patrolControlPresentation.test.tsindex 2bcaa9e491..c89626f30e 100644--- a/frontend-modern/src/features/patrol/__tests__/patrolControlPresentation.test.ts+++ b/frontend-modern/src/features/patrol/__tests__/patrolControlPresentation.test.ts@@ -347,6 +347,84 @@ describe('patrolControlPresentation', () => {]);});+ it('names the scoped resource instead of counting affected resources', () => {+ expect(+ getPatrolQueueWorkspaceDescription({+ autonomyLevel: 'monitor',+ findingCount: 2,+ affectedResourceCount: 1,+ resourceName: 'afs-web',+ workTypeComposition: {+ total: 2,+ approval: 0,+ failed: 0,+ inProgress: 0,+ recurring: 2,+ newIssues: 0,+ },+ }),+ ).toBe(+ 'Patrol found 2 issues on afs-web — 2 recurring. Open a row to review evidence and record the outcome.',+ );+ // A blank name keeps the count; a scope with no open findings keeps the+ // empty queue copy.+ expect(+ getPatrolQueueWorkspaceDescription({+ autonomyLevel: 'monitor',+ findingCount: 2,+ affectedResourceCount: 1,+ resourceName: ' ',+ }),+ ).toBe(+ 'Patrol found 2 issues on 1 affected resource. Open a row to review evidence and record the outcome.',+ );+ expect(+ getPatrolQueueWorkspaceDescription({+ autonomyLevel: 'monitor',+ findingCount: 0,+ affectedResourceCount: 0,+ resourceName: 'afs-web',+ }),+ ).toBe('Current Patrol issues appear here.');+ });++ it('leaves Patrol check health out of a resource-scoped queue', () => {+ const input: Parameters<typeof getPatrolWorkspaceWorkGroups>[0] = {+ latestRun: {+ error_count: 1,+ resources_checked: 4,+ status: 'error',+ },+ nowMs: Date.parse('2026-06-30T15:00:00Z'),+ patrolStatus: {+ error_count: 1,+ next_patrol_at: '2026-06-30T14:05:00Z',+ running: false,+ },+ pendingApprovalCount: 1,+ workTypeComposition: {+ total: 3,+ approval: 1,+ failed: 1,+ inProgress: 0,+ recurring: 1,+ newIssues: 0,+ },+ };++ expect(+ getPatrolWorkspaceWorkGroups({ ...input, resourceScoped: true }).map((group) => group.id),+ ).toEqual(['approvals', 'failed-actions', 'recurring']);+ // The same evidence without a resource scope still reports the check.+ expect(getPatrolWorkspaceWorkGroups(input).map((group) => group.id)).toEqual([+ 'approvals',+ 'failed-actions',+ 'failed-check',+ 'recurring',+ 'stale-protection',+ ]);+ });+it('treats old Patrol evidence as stale relative to the configured interval', () => {const nowMs = Date.parse('2026-06-30T15:00:00Z');diff --git a/frontend-modern/src/features/patrol/patrolControlPresentation.ts b/frontend-modern/src/features/patrol/patrolControlPresentation.tsindex 13c92a2618..84d099d6b8 100644--- a/frontend-modern/src/features/patrol/patrolControlPresentation.ts+++ b/frontend-modern/src/features/patrol/patrolControlPresentation.ts@@ -182,6 +182,9 @@ interface PatrolControlCopyInput {interface PatrolQueueCountInput {affectedResourceCount?: number;findingCount?: number;+ // Set when the queue lists one resource's findings: the summary names it+ // instead of counting affected resources.+ resourceName?: string;workTypeComposition?: PatrolWorkTypeComposition;}@@ -210,6 +213,9 @@ interface PatrolWorkspaceWorkGroupsInput {Partial<Pick<PatrolStatus, 'interval_ms' | 'last_patrol_at'>>)| null;pendingApprovalCount?: number;+ // One resource's findings. The latest check's health and coverage describe+ // every resource, so their groups stay in the unscoped queue.+ resourceScoped?: boolean;workTypeComposition?: PatrolWorkTypeComposition;}@@ -407,14 +413,13 @@ export function getPatrolQueueWorkspaceDescription(): string {const findingCount = normalizeCount(input.findingCount);const affectedResourceCount = normalizeCount(input.affectedResourceCount);- if (findingCount > 0 && affectedResourceCount > 0) {+ const resourceName = normalizeText(input.resourceName);+ if (findingCount > 0 && (resourceName || affectedResourceCount > 0)) {const compositionClause = input.workTypeComposition? getPatrolWorkTypeCompositionClause(input.workTypeComposition): '';- return `Patrol found ${getPatrolFindingIssueCountLabel(findingCount)} on ${formatCount(- affectedResourceCount,- 'affected resource',- )}${compositionClause}. ${getPatrolQueueActionDetail(input)}`;+ const subject = resourceName || formatCount(affectedResourceCount, 'affected resource');+ return `Patrol found ${getPatrolFindingIssueCountLabel(findingCount)} on ${subject}${compositionClause}. ${getPatrolQueueActionDetail(input)}`;}if (input.autonomyLocked) {@@ -464,7 +469,7 @@ export function getPatrolWorkspaceWorkGroups(});}- if (latestRunFailed || statusErrorCount > 0) {+ if (!input.resourceScoped && (latestRunFailed || statusErrorCount > 0)) {const checkedResources = normalizeCount(latestRun?.resources_checked);groups.push({id: 'failed-check',@@ -487,6 +492,7 @@ export function getPatrolWorkspaceWorkGroups(}if (+ !input.resourceScoped &&isPatrolCoverageStale({latestRun,nowMs: input.nowMs,