Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Correct Patrol mode selector and dialog contract prose

rcourtman9f738144b79e
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index c109654346..0ec4e56316 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -3323,9 +3323,11 @@ a new API state machine, queue contract, or verification-accounting field.
operator-readable even when internal Assistant handoff metadata still uses
assessment terminology
and the Patrol findings empty-state behavior, so `0 active findings` only renders as a healthy frontend conclusion when the same governed AI summary contract still reports healthy overall health; degraded or not-fully-verified health predictions must flow through to the Patrol findings surface instead of being replaced by page-local "looks healthy" copy
- and the Patrol control presentation boundary, so the always-visible Patrol
- control selector owns the selected autonomy level, plan-locked installs keep
- watch-only as the current capability and the free Patrol working surface must
+ and the Patrol control presentation boundary, so the Patrol mode selector
+ inside the header's collapsed `Mode and automation` disclosure owns the
+ selected autonomy level, plan-locked installs get no selector or disclosure
+ and keep watch-only as the current capability in one inline `Patrol mode`
+ line, and the free Patrol working surface must
not render a disabled paid-level matrix, compact Pro badges, or any paid-mode
disclosure. The free surface stays clean of paid-feature surfacing; Pro
discovery belongs in Settings, website/docs, and contextual at-need prompts,
@@ -3371,10 +3373,15 @@ a new API state machine, queue contract, or verification-accounting field.
what Patrol may do under the selected control level, and what to run or
review next, not activation-loop proof, queue internals, or verification
accounting
- and the Patrol control dialog plus restored Patrol mode Assistant session copy, so API
- compatibility identifiers such as `patrol_configuration_failure` may remain
- stable while user-facing and model-facing labels describe setting, saving,
- and reviewing Patrol control rather than a generic configuration/apply flow
+ and the restored Patrol mode Assistant session copy, so the API
+ compatibility kind `patrol_configuration_failure`, which only sessions saved
+ by earlier builds carry, may remain stable while the restored drawer title,
+ subject, and action label (`Patrol mode save failure`, `Patrol mode`,
+ `Review Patrol mode issue`) describe saving and reviewing Patrol mode rather
+ than a generic configuration/apply flow. The Patrol header has no Patrol
+ control or configuration dialog: choosing `Watch only`, `Ask first`, or
+ `Safe auto-fix` in its mode selector saves that mode directly, and its one
+ dialog is the Autopilot acknowledgement opened by choosing `Autopilot`
and the Patrol main-surface treatment itself, so the same governed summary contract lands inside the existing workspace and Current work surfaces while severity travels through compact header accents and icon badges instead of a page-local full-width verdict strip
and the Patrol workspace badge treatment, so the API-owned finding,
runtime, and run-history counts remain semantic input only while visible
@@ -3523,8 +3530,9 @@ a new API state machine, queue contract, or verification-accounting field.
customer-facing copy must name the visible choices as `Watch only`, `Ask first`,
`Safe auto-fix`, and `Autopilot` rather than leaking compatibility terminology.
policy rather than changing the compatibility API boundary; setup-only
- readiness may hide those run/configuration affordances, but the visible
- Patrol mode selector remains the primary policy boundary during setup
+ readiness may hide those run/configuration affordances, but the Patrol mode
+ selector stays in the header's `Mode and automation` disclosure as the
+ primary policy boundary during setup
and the Patrol mode presentation boundary, so `frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx` routes active Patrol findings into the Patrol-owned findings workflow, renders the first-party loop as check/investigate/act-under-policy/verify/record, uses `Patrol mode` as the human-facing name for the governed autonomy selector while preserving `patrol_control`, `patrolControl*`, and `patrol_autonomy` only for compatibility route and wire identifiers, and demotes Assistant and external-agent readiness out of the primary operator loop without introducing a new API request shape, frontend-authored tool route, serialized remediation plan, or page-local MCP setup contract; direct single-finding CTAs must derive from existing finding-presentation helpers and canonical routes such as the Patrol provider-settings route, selected findings, approvals, and history rows may still open contextual Assistant handoffs through their governed owners, the user-facing `Patrol` route title and `Open work` queue title must remain presentation labels over the same current-work status contract rather than new payload states, setup-only Patrol runtime failures must use existing finding/runtime fields to render the Patrol-owned `Fix Patrol setup` framing, a dedicated setup task, and one direct `Open Provider & Models` action while suppressing the readiness banner, generic issue-row chips, filter chrome, and run-history action chrome that would compete with provider setup, but recent changes, correlations, and policy-coverage payloads must not render as a generic first-party Details/evidence console on the Patrol page, and raw finding lifecycle telemetry must be reserved for explicit all/resolved/history or selected-run review states instead of default active current-issue expansion
The Patrol page may consume server-authored readiness and preflight-backed
status, but it must translate that transport state into `Patrol setup issue`
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 351562de65..4732537065 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -3279,7 +3279,10 @@ Agent`), with the plain-language source phrase available through accessible
single finding-level Pulse Pro capability line in the expanded finding
primary-action area for plan-locked installs on active critical or warning
findings, with its upgrade action gated by the upgrade-prompt policy. Visible product copy calls the selector `Patrol mode`; compatibility route and wire identifiers may keep stable names
- such as `patrol_control` and `patrolControl*`. The always-visible Patrol mode selector must stay on
+ such as `patrol_control` and `patrolControl*`. The Patrol header keeps the
+ Patrol mode selector inside its collapsed `Mode and automation` disclosure
+ and, for plan-locked installs, shows one inline `Patrol mode` line with the
+ watch-only summary instead of a selector. The selector must stay on
the selected mode and one plain summary, without a separate `Limits`
disclosure or hard-limit matrix beside the picker. Shared feature shells must not invent their own Patrol safety
thresholds, policy labels, or disabled-control explanations. The Patrol page
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index 1ae129831b..8689baf269 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -821,8 +821,10 @@ attention`, `approval needed`, `outcome verified`, `no active work`) instead
`Running`/`Patrol running` copy.
`PatrolIntelligenceHeader.tsx` owns the `patrol-control` route target and
the `operations-loop` compatibility anchor used by Patrol mode entry-point
- handoffs; the page must keep those anchors on the actual always-visible
- Patrol mode selector rather than on a separate onboarding banner or
+ handoffs; the page must keep those anchors on the header's Patrol control
+ section, which holds the Patrol on/off toggle and the `Mode and automation`
+ disclosure with the Patrol mode selector (or, for plan-locked installs, the
+ inline `Patrol mode` line), rather than on a separate onboarding banner or
generic Patrol container. The Patrol surface must preserve the
issue-evidence rule: Patrol mode can start from a generic Patrol run
state, but investigation, approval, verification, and external-agent parity
diff --git a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceHeader.render.test.tsx b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceHeader.render.test.tsx
new file mode 100644
index 0000000000..cc9377c369
--- /dev/null
+++ b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceHeader.render.test.tsx
@@ -0,0 +1,131 @@
+import { Route, Router } from '@solidjs/router';
+import { cleanup, fireEvent, render, screen, within } from '@solidjs/testing-library';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+
+import type { PatrolAutonomyLevel } from '@/api/patrol';
+import { PatrolIntelligenceHeader } from '../PatrolIntelligenceHeader';
+import type { PatrolIntelligenceState } from '../usePatrolIntelligenceState';
+
+const WATCH_ONLY_DETAIL =
+ 'Patrol checks infrastructure and reports issues only. It does not start fixes.';
+
+interface HeaderStateOptions {
+ autonomyLevel?: PatrolAutonomyLevel;
+ autoFixLocked?: boolean;
+ setupOnly?: boolean;
+ autopilotDialogOpen?: boolean;
+}
+
+const createState = (options: HeaderStateOptions = {}) => {
+ const autonomyLevel = options.autonomyLevel ?? 'approval';
+ const handleAutonomyChange = vi.fn();
+ const state = {
+ autopilotStatus: () => null,
+ autonomyLevel: () => autonomyLevel,
+ requestedAutonomyLevel: () => autonomyLevel,
+ autoFixLocked: () => options.autoFixLocked ?? false,
+ autoFixCapabilityBlock: () => undefined,
+ licenseRuntimeIdentity: () => undefined,
+ patrolRunHistory: { value: () => [] },
+ patrolStatus: () => null,
+ patrolReadiness: () => null,
+ blockedCause: () => null,
+ runtimeState: () => 'active',
+ canTriggerPatrol: () => true,
+ triggerPatrolDisabledReason: () => '',
+ isTriggeringPatrol: () => false,
+ manualRunRequested: () => false,
+ patrolStream: { isStreaming: () => false },
+ patrolEnabledLocal: () => true,
+ isTogglingPatrol: () => false,
+ isUpdatingAutonomy: () => false,
+ shouldShowPatrolSetupOnly: () => options.setupOnly ?? false,
+ autopilotDialogOpen: () => options.autopilotDialogOpen ?? false,
+ setAutopilotDialogOpen: vi.fn(),
+ acknowledgeAndActivateAutopilot: vi.fn(),
+ revokeAutopilot: vi.fn(),
+ handleRunPatrol: vi.fn(),
+ handleTogglePatrol: vi.fn(),
+ handleAutonomyChange,
+ } as unknown as PatrolIntelligenceState;
+ return { state, handleAutonomyChange };
+};
+
+const renderHeader = (state: PatrolIntelligenceState) =>
+ render(() => (
+ <Router>
+ <Route path="*" component={() => <PatrolIntelligenceHeader state={state} />} />
+ </Router>
+ ));
+
+const modeDisclosure = () => {
+ const summary = screen.getByText('Mode and automation');
+ const details = summary.closest('details');
+ expect(details).not.toBeNull();
+ expect(summary.tagName).toBe('SUMMARY');
+ return details!;
+};
+
+// These pin the Patrol header facts that the api-contracts, frontend-primitives,
+// and patrol-intelligence contracts state about the Patrol mode selector.
+describe('PatrolIntelligenceHeader Patrol mode placement', () => {
+ afterEach(cleanup);
+
+ it('keeps the Patrol mode selector inside the collapsed Mode and automation disclosure', () => {
+ const { state, handleAutonomyChange } = createState();
+ renderHeader(state);
+
+ const details = modeDisclosure();
+ expect(details.open).toBe(false);
+ expect(details.hasAttribute('open')).toBe(false);
+
+ const selector = screen.getByRole('group', { name: 'Patrol mode' });
+ expect(details.contains(selector)).toBe(true);
+ expect(selector.closest('#patrol-control')).not.toBeNull();
+ expect(
+ within(selector)
+ .getAllByRole('button')
+ .map((button) => button.getAttribute('aria-label')),
+ ).toEqual(['Watch only', 'Ask first', 'Safe auto-fix', 'Autopilot']);
+
+ fireEvent.click(within(selector).getByRole('button', { name: 'Safe auto-fix' }));
+ expect(handleAutonomyChange).toHaveBeenCalledWith('assisted');
+ });
+
+ it('shows plan-locked installs one inline Patrol mode line instead of a selector', () => {
+ const { state } = createState({ autonomyLevel: 'approval', autoFixLocked: true });
+ renderHeader(state);
+
+ expect(screen.queryByText('Mode and automation')).toBeNull();
+ expect(screen.queryByRole('group', { name: 'Patrol mode' })).toBeNull();
+ expect(document.querySelector('details')).toBeNull();
+
+ const label = screen.getByText('Patrol mode');
+ const line = label.parentElement!;
+ expect(line.textContent).toContain(WATCH_ONLY_DETAIL);
+ expect(line.closest('#patrol-control')).not.toBeNull();
+ });
+
+ it('keeps the Mode and automation disclosure while setup hides the run and settings controls', () => {
+ const { state } = createState({ setupOnly: true });
+ renderHeader(state);
+
+ expect(screen.queryByText('Check now')).toBeNull();
+ expect(screen.queryByRole('link', { name: 'Open Patrol settings' })).toBeNull();
+ const details = modeDisclosure();
+ expect(details.contains(screen.getByRole('group', { name: 'Patrol mode' }))).toBe(true);
+ });
+
+ it('opens no Patrol control dialog; the Autopilot acknowledgement is its only dialog', () => {
+ const closed = createState();
+ renderHeader(closed.state);
+ expect(screen.queryAllByRole('dialog')).toHaveLength(0);
+ cleanup();
+
+ const opened = createState({ autopilotDialogOpen: true });
+ renderHeader(opened.state);
+ const dialogs = screen.getAllByRole('dialog');
+ expect(dialogs).toHaveLength(1);
+ expect(dialogs[0]).toHaveAccessibleName('Activate Autopilot');
+ });
+});