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.

feat(patrol,actions): route Watch-only installs toward their first governed action

rcourtman83909bd19a36
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 9f1538641f..9120d496a4 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -2364,6 +2364,7 @@ a new API state machine, queue contract, or verification-accounting field.
and the Patrol header support drawer in `frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx`, so API-owned Patrol status and trigger facts can feed a secondary Schedule & model surface without turning provider model, schedule, trigger tuning, or background-only runtime-policy pauses into the primary Patrol control decision
and the shared `frontend-modern/src/components/Infrastructure/ResourcePolicySummary.tsx` card, so the AI summary page renders the governed policy-posture counts while the resource drawer stays on per-resource policy lines instead of carrying duplicate posture UI loops
and the dedicated `frontend-modern/src/features/patrol/patrolInvestigationContextModel.ts` owner, so recent-change, learned-correlation, and policy-coverage summary text stays derived from the canonical AI payload in one place instead of as hook-local count and pluralization logic
+ and the Watch-only forward-path handoffs owned by `frontend-modern/src/features/patrol/patrolControlPresentation.ts` together with the Actions inbox empty-state read of `GET /api/ai/patrol/autonomy`, so finding-level and inbox-level mode guidance consumes the canonical Patrol autonomy read/save contract through the Patrol state hook (`handleAutonomyChange`) instead of introducing a second mode mutation path or a page-local autonomy dialect
and that same Patrol investigation-context owner, so the current Patrol
assessment summary may open Assistant with bounded model-only assessment,
verification, latest-run, supporting-context, active-finding, and
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 56ab2b704a..68687b3e69 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -681,6 +681,13 @@ For Patrol, that includes the Open work description: it may use concise
row-level guidance such as review evidence, approve a change, inspect automatic
actions, or review verification results, but it must remain descriptive copy
rather than another card, strip, or proof counter above the findings list.
+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 copy
+live in their governed presentation helpers
+(`patrolControlPresentation.getPatrolWatchOnlyInvestigationNudge`,
+`actionPresentation.getActionsWatchOnlyEmptyState`) and render as descriptive
+copy plus a single shared-primitive action inside the existing expanded-row
+and calm-state layouts rather than as new cards, banners, or proof strips.
Feature-owned runtime hooks may also own non-visual side effects when those
effects are part of the governed feature workflow. For Patrol, current-work
action chrome must keep active findings in the Patrol findings workflow first;
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index 470970e24d..5ac0668be7 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -836,6 +836,19 @@ fix`, or `Explain` based on current finding state), while secondary
per-finding "Create rule from this" action must remain disabled unless the
finding has both a concrete resource and category for a scoped suppression
rule.
+ An actionable active finding must always expose a forward path into the
+ governed action loop at its own expanded row. Above Watch only, that is the
+ inline `Investigate` intent. In Watch only, the same expanded-row slot
+ instead carries a mode handoff owned by `patrolControlPresentation.ts`:
+ `getPatrolProInvestigationHandoff` for plan-locked installs, and
+ `getPatrolWatchOnlyInvestigationNudge` for installs whose paid Patrol modes
+ are already unlocked. The unlocked nudge names the Watch only boundary and
+ offers a one-click `Switch to Ask first` that routes through the same
+ `handleAutonomyChange` save path as the header mode selector, never a
+ second mode mutation surface. Both handoffs stay limited to active
+ critical/warning findings, are mutually exclusive by lock state, and the
+ unlocked nudge must yield to the `Investigate` intent once the effective
+ mode leaves `monitor`.
The Patrol store owns the sticky expanded-history state for Resolved/All
views and must keep that data bounded: once resolved findings are requested,
subsequent Patrol finding loads continue to request include-resolved history
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 48a8e788e2..89ecd42c96 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -1811,6 +1811,16 @@ remain in the row's accessible name and title, while the visual row prefers the
API-supplied name and type and falls back to the bounded ID-derived type plus
short suffix only when the resource projection is unavailable. Read-only demo
posture is quiet supporting context rather than a page-level callout. The
+empty Open queue must explain producer state rather than promising content:
+when the effective Patrol mode is Watch only (read via the canonical
+`/api/ai/patrol/autonomy` settings read, failing closed to the generic calm
+copy when that read is unavailable), the calm state names that Watch only
+never queues proposed fixes and routes unlocked installs to the Patrol mode
+switch, while plan-locked installs get the presentation-policy-aware Pro
+capability line from `actionPresentation.getActionsWatchOnlyEmptyState` with
+the upgrade action suppressed whenever upgrade prompts are hidden. That
+guidance is presentation-only: Actions must not gain a second Patrol mode
+mutation surface. The
governed review dialog continues to own the full exact resource ID, plan,
policy evidence, lifecycle, authority, and outcome truth. Its first layer keeps
intent plus safety/authority facts visible while the immutable planning-time
diff --git a/frontend-modern/src/components/AI/FindingsPanel.tsx b/frontend-modern/src/components/AI/FindingsPanel.tsx
index 41a65842aa..2c8bfb68ac 100644
--- a/frontend-modern/src/components/AI/FindingsPanel.tsx
+++ b/frontend-modern/src/components/AI/FindingsPanel.tsx
@@ -147,6 +147,11 @@ interface FindingsPanelProps {
patrolProHandoff?: (
finding: UnifiedFinding,
) => { detail: string; actionLabel?: string; destination?: UpgradeDestination } | undefined;
+ patrolModeNudge?: (
+ finding: UnifiedFinding,
+ ) => { detail: string; actionLabel: string } | undefined;
+ onPatrolModeNudgeAction?: () => void;
+ patrolModeNudgeBusy?: boolean;
runSnapshot?: Pick<
PatrolRunRecord,
| 'resources_checked'
@@ -1371,6 +1376,7 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
const shouldShowAssistantPrimaryAction = !isPatrolFindingsSource();
const shouldShowAssistantManageAction = isPatrolFindingsSource() && !primaryAction;
const proHandoff = !primaryAction ? props.patrolProHandoff?.(finding) : undefined;
+ const modeNudge = !primaryAction ? props.patrolModeNudge?.(finding) : undefined;
const shouldShowExpandedManageMenu =
!primaryAction ||
manualControls.acknowledge ||
@@ -1656,6 +1662,23 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
</Show>
</div>
</Show>
+ <Show when={modeNudge}>
+ <div class="flex flex-wrap items-center gap-2">
+ <span class="text-muted">{modeNudge!.detail}</span>
+ <button
+ type="button"
+ onClick={(e) => {
+ e.stopPropagation();
+ props.onPatrolModeNudgeAction?.();
+ }}
+ disabled={props.patrolModeNudgeBusy}
+ class="inline-flex items-center gap-1 rounded bg-blue-600 px-3 py-1.5 font-semibold text-white transition-colors hover:bg-blue-700 disabled:opacity-50"
+ title="Switch Patrol to Ask first so it can investigate and prepare fixes for your approval"
+ >
+ {props.patrolModeNudgeBusy ? 'Switching…' : modeNudge!.actionLabel}
+ </button>
+ </div>
+ </Show>
<Show when={shouldShowExpandedManageMenu}>
<details onClick={(e) => e.stopPropagation()}>
diff --git a/frontend-modern/src/components/AI/__tests__/FindingsPanel.links.test.tsx b/frontend-modern/src/components/AI/__tests__/FindingsPanel.links.test.tsx
index 274402bdb0..aad0c5a22e 100644
--- a/frontend-modern/src/components/AI/__tests__/FindingsPanel.links.test.tsx
+++ b/frontend-modern/src/components/AI/__tests__/FindingsPanel.links.test.tsx
@@ -660,4 +660,48 @@ describe('FindingsPanel investigate action gating', () => {
expandRow();
expect(screen.queryByRole('button', { name: /^Investigate$/ })).toBeNull();
});
+
+ it('renders the Watch-only mode nudge in the expanded row and fires its switch callback', async () => {
+ const onSwitch = vi.fn();
+ render(() => (
+ <FindingsPanel
+ findingsSource="patrol"
+ autonomyLevel="monitor"
+ patrolModeNudge={() => ({
+ detail:
+ 'Watch only reports issues without preparing fixes. In Ask first mode, Patrol investigates and queues each fix for your approval.',
+ actionLabel: 'Switch to Ask first',
+ })}
+ onPatrolModeNudgeAction={onSwitch}
+ />
+ ));
+ await waitFor(() => expect(mockState.loadPatrolFindings).toHaveBeenCalled());
+ expandRow();
+ const switchButton = screen.getByRole('button', { name: 'Switch to Ask first' });
+ expect(
+ screen.getByText(
+ 'Watch only reports issues without preparing fixes. In Ask first mode, Patrol investigates and queues each fix for your approval.',
+ ),
+ ).toBeInTheDocument();
+ fireEvent.click(switchButton);
+ expect(onSwitch).toHaveBeenCalledTimes(1);
+ });
+
+ it('disables the Watch-only mode nudge button while the switch is in flight', async () => {
+ render(() => (
+ <FindingsPanel
+ findingsSource="patrol"
+ autonomyLevel="monitor"
+ patrolModeNudge={() => ({
+ detail: 'Watch only reports issues without preparing fixes.',
+ actionLabel: 'Switch to Ask first',
+ })}
+ patrolModeNudgeBusy
+ />
+ ));
+ await waitFor(() => expect(mockState.loadPatrolFindings).toHaveBeenCalled());
+ expandRow();
+ const busyButton = screen.getByRole('button', { name: 'Switching…' });
+ expect(busyButton).toBeDisabled();
+ });
});
diff --git a/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts b/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
index e102e65b5d..0b61023fe2 100644
--- a/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
+++ b/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
@@ -418,6 +418,21 @@ describe('FindingsPanel assistant handoff', () => {
});
});
+describe('FindingsPanel Watch-only mode nudge slot', () => {
+ // An actionable active finding on an unlocked Watch-only install must offer
+ // a forward path into the governed action loop from its own expanded row.
+ // The nudge lives in the same slot as the plan-locked Pro handoff, and the
+ // switch must reuse the canonical autonomy save path (handleAutonomyChange)
+ // rather than introducing a second mode mutation surface.
+ it('renders the mode nudge in the expanded row and keeps the switch on the shared autonomy save path', () => {
+ expect(findingsPanelSource).toContain('props.patrolModeNudge?.(finding)');
+ expect(findingsPanelSource).toContain('props.onPatrolModeNudgeAction?.()');
+ expect(findingsPanelSource).toContain("'Switching…'");
+ expect(patrolWorkspaceSource).toContain('getPatrolWatchOnlyInvestigationNudge');
+ expect(patrolWorkspaceSource).toContain("handleAutonomyChange('approval')");
+ });
+});
+
describe('aiFindingPresentation', () => {
describe('severity presentation', () => {
it('has correct sort order for critical', () => {
diff --git a/frontend-modern/src/features/actions/__tests__/actionsWatchOnlyEmptyState.test.ts b/frontend-modern/src/features/actions/__tests__/actionsWatchOnlyEmptyState.test.ts
new file mode 100644
index 0000000000..34bf45b0bf
--- /dev/null
+++ b/frontend-modern/src/features/actions/__tests__/actionsWatchOnlyEmptyState.test.ts
@@ -0,0 +1,56 @@
+import { describe, expect, it } from 'vitest';
+
+import { getActionsWatchOnlyEmptyState } from '../actionPresentation';
+
+const base = {
+ patrolWatchOnly: true,
+ patrolModesUnlocked: false,
+ commercialSurfacesHidden: false,
+ upgradePromptsHidden: false,
+ upgradeDestination: { href: '/settings/billing', external: false },
+};
+
+describe('getActionsWatchOnlyEmptyState', () => {
+ it('returns nothing when Patrol is not in Watch only', () => {
+ expect(
+ getActionsWatchOnlyEmptyState({ ...base, patrolWatchOnly: false }),
+ ).toBeUndefined();
+ expect(
+ getActionsWatchOnlyEmptyState({
+ ...base,
+ patrolWatchOnly: false,
+ patrolModesUnlocked: true,
+ }),
+ ).toBeUndefined();
+ });
+
+ it('points unlocked installs at the Ask first switch on the Patrol page', () => {
+ expect(getActionsWatchOnlyEmptyState({ ...base, patrolModesUnlocked: true })).toEqual({
+ kind: 'switch',
+ body: 'Patrol runs in Watch only mode, so it reports issues without preparing fixes. Switch Patrol to Ask first and proposed fixes will wait here for your approval.',
+ actionLabel: 'Open Patrol',
+ });
+ });
+
+ it('explains the Pro capability for locked installs with an upgrade action', () => {
+ expect(getActionsWatchOnlyEmptyState(base)).toEqual({
+ kind: 'upgrade',
+ body: 'Patrol runs in Watch only mode. Pulse Pro lets Patrol investigate issues and prepare fixes that wait here for your approval.',
+ actionLabel: 'Learn about Pulse Pro',
+ destination: base.upgradeDestination,
+ });
+ });
+
+ it('keeps the explanation but drops the upgrade action when upgrade prompts are hidden', () => {
+ const presentation = getActionsWatchOnlyEmptyState({ ...base, upgradePromptsHidden: true });
+ expect(presentation).toMatchObject({ kind: 'upgrade' });
+ expect(presentation).not.toHaveProperty('actionLabel');
+ expect(presentation).not.toHaveProperty('destination');
+ });
+
+ it('stays silent for locked installs when commercial surfaces are hidden', () => {
+ expect(
+ getActionsWatchOnlyEmptyState({ ...base, commercialSurfacesHidden: true }),
+ ).toBeUndefined();
+ });
+});
diff --git a/frontend-modern/src/features/actions/actionPresentation.ts b/frontend-modern/src/features/actions/actionPresentation.ts
index ed89939308..0994f2c2fa 100644
--- a/frontend-modern/src/features/actions/actionPresentation.ts
+++ b/frontend-modern/src/features/actions/actionPresentation.ts
@@ -8,6 +8,7 @@ import type {
ActionVerificationTruthStatus,
} from '@/types/actionAudit';
import type { MetadataBadgeTone } from '@/components/shared/MetadataBadge';
+import type { UpgradeDestination } from '@/utils/upgradeNavigation';
export const formatActionName = (value: string): string =>
value === 'install_os_updates'
@@ -80,6 +81,44 @@ export const getActionApprovalBadgePresentation = (
};
};
+export interface ActionsWatchOnlyEmptyStateInput {
+ patrolWatchOnly: boolean;
+ patrolModesUnlocked: boolean;
+ commercialSurfacesHidden: boolean;
+ upgradePromptsHidden: boolean;
+ upgradeDestination: UpgradeDestination;
+}
+
+export type ActionsWatchOnlyEmptyStatePresentation =
+ | { kind: 'switch'; body: string; actionLabel: string }
+ | { kind: 'upgrade'; body: string; actionLabel?: string; destination?: UpgradeDestination };
+
+// Guidance for the empty Open inbox: while Patrol runs Watch only nothing ever
+// lands here, so the calm state has to name the mode that keeps the queue empty
+// and point at the dial (or the entitlement) that changes it.
+export const getActionsWatchOnlyEmptyState = (
+ input: ActionsWatchOnlyEmptyStateInput,
+): ActionsWatchOnlyEmptyStatePresentation | undefined => {
+ if (!input.patrolWatchOnly) return undefined;
+ if (input.patrolModesUnlocked) {
+ return {
+ kind: 'switch',
+ body: 'Patrol runs in Watch only mode, so it reports issues without preparing fixes. Switch Patrol to Ask first and proposed fixes will wait here for your approval.',
+ actionLabel: 'Open Patrol',
+ };
+ }
+ if (input.commercialSurfacesHidden) return undefined;
+ const presentation: ActionsWatchOnlyEmptyStatePresentation = {
+ kind: 'upgrade',
+ body: 'Patrol runs in Watch only mode. Pulse Pro lets Patrol investigate issues and prepare fixes that wait here for your approval.',
+ };
+ if (!input.upgradePromptsHidden) {
+ presentation.actionLabel = 'Learn about Pulse Pro';
+ presentation.destination = input.upgradeDestination;
+ }
+ return presentation;
+};
+
export interface ActionResourcePresentation {
detail: string;
label: string;
diff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx
index 47f89dd1a2..ecc156bae2 100644
--- a/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx
+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx
@@ -24,6 +24,7 @@ import { StatusIndicatorBadge } from '@/components/shared/StatusIndicatorBadge';
import { getPatrolSetupAction, getPatrolSetupHint } from '@/utils/patrolRuntimeActions';
import {
getPatrolProInvestigationHandoff,
+ getPatrolWatchOnlyInvestigationNudge,
getPatrolQueueWorkspaceDescription,
getPatrolWorkspaceWorkGroups,
isPatrolCoverageStale,
@@ -274,6 +275,16 @@ export function PatrolIntelligenceWorkspace(props: { state: PatrolIntelligenceSt
status: finding.status,
})
}
+ patrolModeNudge={(finding) =>
+ getPatrolWatchOnlyInvestigationNudge({
+ autoFixLocked: state.autoFixLocked(),
+ autonomyLevel: state.autonomyLevel(),
+ severity: finding.severity,
+ status: finding.status,
+ })
+ }
+ onPatrolModeNudgeAction={() => void state.handleAutonomyChange('approval')}
+ patrolModeNudgeBusy={state.isUpdatingAutonomy()}
/>
}
>
diff --git a/frontend-modern/src/features/patrol/__tests__/patrolControlPresentation.test.ts b/frontend-modern/src/features/patrol/__tests__/patrolControlPresentation.test.ts
index 2df3b42426..9472c388cc 100644
--- a/frontend-modern/src/features/patrol/__tests__/patrolControlPresentation.test.ts
+++ b/frontend-modern/src/features/patrol/__tests__/patrolControlPresentation.test.ts
@@ -4,6 +4,7 @@ import type { PatrolAutonomyLevel } from '@/api/patrol';
import {
getPatrolProInvestigationHandoff,
getPatrolQueueWorkspaceDescription,
+ getPatrolWatchOnlyInvestigationNudge,
getMonitorContextPatrolProtectionPosture,
getPatrolReadyWorkDetail,
getPatrolSetupIssueReason,
@@ -471,4 +472,45 @@ describe('patrolControlPresentation', () => {
expect(handoff).not.toHaveProperty('actionLabel');
expect(handoff).not.toHaveProperty('destination');
});
+
+ it('nudges unlocked Watch only installs toward Ask first on actionable findings', () => {
+ const nudge = getPatrolWatchOnlyInvestigationNudge({
+ autoFixLocked: false,
+ autonomyLevel: 'monitor',
+ severity: 'critical',
+ status: 'active',
+ });
+ expect(nudge).toEqual({
+ detail:
+ 'Watch only reports issues without preparing fixes. In Ask first mode, Patrol investigates and queues each fix for your approval.',
+ actionLabel: 'Switch to Ask first',
+ });
+ expect(
+ getPatrolWatchOnlyInvestigationNudge({
+ autoFixLocked: false,
+ autonomyLevel: 'monitor',
+ severity: 'warning',
+ status: 'active',
+ }),
+ ).toBeDefined();
+ });
+
+ it('keeps the Ask first nudge out of locked installs, non-monitor modes, and non-actionable findings', () => {
+ const base = {
+ autoFixLocked: false,
+ autonomyLevel: 'monitor' as PatrolAutonomyLevel,
+ severity: 'critical',
+ status: 'active',
+ };
+ expect(getPatrolWatchOnlyInvestigationNudge({ ...base, autoFixLocked: true })).toBeUndefined();
+ expect(
+ getPatrolWatchOnlyInvestigationNudge({ ...base, autonomyLevel: 'approval' }),
+ ).toBeUndefined();
+ expect(
+ getPatrolWatchOnlyInvestigationNudge({ ...base, autonomyLevel: undefined }),
+ ).toBeUndefined();
+ expect(getPatrolWatchOnlyInvestigationNudge({ ...base, severity: 'info' })).toBeUndefined();
+ expect(getPatrolWatchOnlyInvestigationNudge({ ...base, severity: undefined })).toBeUndefined();
+ expect(getPatrolWatchOnlyInvestigationNudge({ ...base, status: 'resolved' })).toBeUndefined();
+ });
});
diff --git a/frontend-modern/src/features/patrol/patrolControlPresentation.ts b/frontend-modern/src/features/patrol/patrolControlPresentation.ts
index 4199482cb1..0c1fa5c806 100644
--- a/frontend-modern/src/features/patrol/patrolControlPresentation.ts
+++ b/frontend-modern/src/features/patrol/patrolControlPresentation.ts
@@ -503,3 +503,37 @@ export function getPatrolProInvestigationHandoff(
}
return handoff;
}
+
+export interface PatrolWatchOnlyInvestigationNudge {
+ detail: string;
+ actionLabel: string;
+}
+
+export interface PatrolWatchOnlyInvestigationNudgeInput {
+ autoFixLocked: boolean;
+ autonomyLevel?: PatrolAutonomyLevel;
+ severity?: string;
+ status?: string;
+}
+
+// Counterpart to the Pro handoff for installs where Patrol modes are already
+// unlocked but the install still runs Watch only: without this, an actionable
+// finding offers no forward path at all (the Investigate button requires a
+// non-monitor mode), so the detect → investigate → propose → approve loop can
+// never start.
+export function getPatrolWatchOnlyInvestigationNudge(
+ input: PatrolWatchOnlyInvestigationNudgeInput,
+): PatrolWatchOnlyInvestigationNudge | undefined {
+ if (input.autoFixLocked) return undefined;
+ if (input.autonomyLevel !== 'monitor') return undefined;
+ if (input.status && input.status !== 'active') return undefined;
+ if (!input.severity || !PATROL_PRO_HANDOFF_ACTIONABLE_SEVERITIES.has(input.severity)) {
+ return undefined;
+ }
+
+ return {
+ detail:
+ 'Watch only reports issues without preparing fixes. In Ask first mode, Patrol investigates and queues each fix for your approval.',
+ actionLabel: 'Switch to Ask first',
+ };
+}
diff --git a/frontend-modern/src/pages/Actions.tsx b/frontend-modern/src/pages/Actions.tsx
index 154119ca8d..a337ebb296 100644
--- a/frontend-modern/src/pages/Actions.tsx
+++ b/frontend-modern/src/pages/Actions.tsx
@@ -1,11 +1,21 @@
-import { For, Show, createEffect, createMemo, createSignal } from 'solid-js';
+import { For, Show, createEffect, createMemo, createSignal, onMount } from 'solid-js';
import { useLocation, useSearchParams } from '@solidjs/router';
import ChevronRightIcon from 'lucide-solid/icons/chevron-right';
import EyeIcon from 'lucide-solid/icons/eye';
import RefreshCwIcon from 'lucide-solid/icons/refresh-cw';
+import { getPatrolAutonomySettings } from '@/api/patrol';
import { ResourceActionsAPI } from '@/api/resourceActions';
-import { Button } from '@/components/shared/Button';
+import { Button, ButtonLink } from '@/components/shared/Button';
import { Card } from '@/components/shared/Card';
+import { UpgradeButtonLink } from '@/components/shared/UpgradeLink';
+import { PATROL_AUTONOMY_FEATURE_KEY } from '@/features/patrol/patrolAutonomyAvailability';
+import { PATROL_PATH } from '@/routing/resourceLinks';
+import { hasFeature } from '@/stores/license';
+import { getUpgradeActionDestination } from '@/stores/licenseCommercial';
+import {
+ presentationPolicyHidesCommercialSurfaces,
+ presentationPolicyHidesUpgradePrompts,
+} from '@/stores/sessionPresentationPolicy';
import { MetadataBadge } from '@/components/shared/MetadataBadge';
import { PageHeader } from '@/components/shared/PageHeader';
import { Subtabs } from '@/components/shared/Subtabs';
@@ -15,6 +25,7 @@ import {
formatActionName,
getActionInboxStatePresentation,
getActionResourcePresentation,
+ getActionsWatchOnlyEmptyState,
sortOpenActionsForReview,
} from '@/features/actions/actionPresentation';
import type {
@@ -40,6 +51,26 @@ export function Actions() {
const [loading, setLoading] = createSignal(true);
const [loadError, setLoadError] = createSignal('');
const [readOnly, setReadOnly] = createSignal(false);
+ const [patrolWatchOnly, setPatrolWatchOnly] = createSignal(false);
+
+ // The Open tab is where users land wondering why nothing is queued. When
+ // Patrol runs Watch only it never proposes fixes, so the calm state must say
+ // that instead of implying actions will eventually show up on their own.
+ onMount(() => {
+ void getPatrolAutonomySettings()
+ .then((settings) => setPatrolWatchOnly(settings.effective_autonomy_level === 'monitor'))
+ .catch(() => {});
+ });
+
+ const watchOnlyGuidance = createMemo(() =>
+ getActionsWatchOnlyEmptyState({
+ patrolWatchOnly: patrolWatchOnly(),
+ patrolModesUnlocked: hasFeature(PATROL_AUTONOMY_FEATURE_KEY),
+ commercialSurfacesHidden: presentationPolicyHidesCommercialSurfaces(),
+ upgradePromptsHidden: presentationPolicyHidesUpgradePrompts(),
+ upgradeDestination: getUpgradeActionDestination('ai_autofix'),
+ }),
+ );
const loadActions = async () => {
setLoading(true);
@@ -176,11 +207,41 @@ export function Actions() {
<h2 class="text-lg font-semibold">
{view() === 'pending' ? 'No actions need attention' : 'No action history yet'}
</h2>
- <p class="mt-2 text-sm text-muted">
- {view() === 'pending'
- ? 'Pulse will place proposed or in-progress changes here for review.'
- : 'Completed, rejected, expired, and failed actions will appear here.'}
- </p>
+ <Show
+ when={view() === 'pending' ? watchOnlyGuidance() : undefined}
+ keyed
+ fallback={
+ <p class="mt-2 text-sm text-muted">
+ {view() === 'pending'
+ ? 'Pulse will place proposed or in-progress changes here for review.'
+ : 'Completed, rejected, expired, and failed actions will appear here.'}
+ </p>
+ }
+ >
+ {(guidance) => (
+ <>
+ <p class="mx-auto mt-2 max-w-xl text-sm text-muted">{guidance.body}</p>
+ <Show when={guidance.kind === 'switch'}>
+ <ButtonLink href={PATROL_PATH} variant="primary" size="sm" class="mt-4">
+ {guidance.actionLabel}
+ </ButtonLink>
+ </Show>
+ <Show when={guidance.kind === 'upgrade' ? guidance.destination : undefined} keyed>
+ {(destination) => (
+ <div class="mt-4 flex justify-center">
+ <UpgradeButtonLink
+ destination={destination}
+ size="sm"
+ mobileFullWidth={false}
+ >
+ {guidance.actionLabel}
+ </UpgradeButtonLink>
+ </div>
+ )}
+ </Show>
+ </>
+ )}
+ </Show>
</div>
</Show>
<Show when={actions().length > 0}>