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.

Connect Patrol action handoffs to Actions

rcourtman7b114f4d5a5a
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 81ed665730..0d0c38df42 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -1700,6 +1700,12 @@ tracks the durable inbox/detail, policy provenance, dispatch, and
`frontend-modern/src/api/patrol.ts` owns Autopilot acknowledgement create,
activation, effective-mode, and revocation consumption. These mirrors must use
backend JSON names and closed enums rather than frontend authority dialects.
+The route-backed Actions review consumes an exact typed action id through its
+browser query state and resolves lifecycle state from `GET /api/actions/{id}`;
+Patrol may link to that identity but must not infer Open versus History from
+finding copy or create a second mutation client. Approve, reject, and execute
+remain bound to the canonical Actions review and the exact displayed
+`planHash`.
Patrol Open work copy in the browser may clarify row-level evidence, approval,
automatic-action, and verification-result review as presentation over existing
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 776985a0b8..48a0e692de 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -4977,3 +4977,10 @@ expired actionable reviews.
Its action controls are also plan-identity-bound: a missing reviewed `planHash`
renders explicit replan guidance and hides approve, reject, and run controls,
while an actionable record sends the exact displayed hash on every mutation.
+The dialog is also route-backed through the canonical `action` query parameter.
+Contextual surfaces use the shared button-link primitive to hand off an exact
+typed action id; the Actions route opens that durable review directly, selects
+the matching Open or History subtab from server-authored lifecycle state, and
+removes the query when the dialog closes. Feature pages may summarize action
+context, but they must not recreate approve, reject, run, progress, or outcome
+controls outside the shared Actions review.
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index 48a7e08af4..470970e24d 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -697,7 +697,7 @@ clear`, `Found N new issues`, `Fixed N issues`, `N issues still open`, or
current finding status, recurrence, investigation record facts, evidence,
verification, approval state, dry-run posture, existing action artifact
summary, target resource references, and governed action references without
- raw command payloads. Inline Patrol approval actions in
+ raw command payloads. Patrol action summaries in
`frontend-modern/src/components/patrol/ApprovalSection.tsx` that open
Assistant must follow that same Patrol-owned handoff model rather than a
prompt-only local shortcut: pass approval ID/status/risk/target plus safe
@@ -1682,7 +1682,11 @@ owning finding must return to the needs-attention path. If malformed approval
records still reach presentation helpers, they must sort after valid timestamps
and must not produce non-deterministic comparator results. Patrol approval
banners must apply the same fail-closed timestamp posture to visible countdown
-copy instead of rendering invalid math such as `NaN`.
+copy instead of rendering invalid math such as `NaN`. The banner is a
+contextual handoff, not a second decision surface: one pending approval
+deep-links to the exact typed action when its canonical action id is present,
+while multiple or legacy approvals lead to the open Actions inbox. It must not
+approve, reject, or execute an action inside Patrol.
Patrol fix approvals also inherit the unified action-governance preflight
contract: queued fixes must keep their plan-level dry-run availability, safety
checks, verification steps, approval policy, and action id in the shared
@@ -1991,12 +1995,16 @@ stricter approved-and-verified detail after the loop also has an approved
governed decision and verified outcome evidence.
The typed `ActionReference` is the primary Patrol workflow model in both the
-finding row and expanded action review. Pending actions say approve or reject;
-planned or approved actions say run; executing actions say running; terminal
-actions present verified, failed, or honestly inconclusive verification. The
-expanded `ApprovalSection` renders the canonical plan, approval floor,
-preflight, safety checks, verification steps, and rollback availability, then
-uses only `/api/actions` decision/execute calls. Legacy `ProposedFix` and
+finding row and expanded action summary. Pending actions identify required
+review; planned or approved actions identify runnable work; executing actions
+say running; terminal actions present verified, failed, or honestly
+inconclusive verification. Patrol owns that detection and investigation
+context, while the dedicated Actions route is the canonical operator hub for
+decision, execution, progress, and durable outcome history. The expanded
+`ApprovalSection` renders the bounded plan, preflight, safety checks,
+verification steps, and rollback availability, then deep-links by exact action
+id into the shared Actions review. It must not call `/api/actions` decision or
+execute mutations itself. Legacy `ProposedFix` and
`ApprovalID` data may explain historical records but must never reveal a raw
command, present an approve/run control, or reconstruct an executable action;
when the typed reference is absent the UI says action details are unavailable
@@ -2004,11 +2012,12 @@ and offers an Assistant handoff. Collapsed-row attention state must consult the
same investigation action reference, so it cannot claim there is no approval
while the expanded panel has one. Browser proof must exercise pending,
terminal-verified, and legacy-history states rather than judging only source.
-The typed reference must also carry the exact reviewed `planHash` before
-`ApprovalSection` exposes approve, reject, or run controls. Decision and
-execution requests pass that same hash through the canonical browser client;
-missing identity is an explicit replan-required state and never falls back to
-action id alone.
+The typed reference must retain the exact reviewed `planHash` so Patrol can
+surface missing identity as an explicit replan-required state before handing
+off. The Actions review remains the only browser surface that may expose
+approve, reject, or run controls, and every mutation there passes the same
+displayed hash through the canonical browser client; missing identity never
+falls back to action id alone.
Backend Patrol finding reconciliation now reads `ActionResultV2`: execution
failed or known-not-run maps to fix failure; confirmed verification maps to
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 08a7d0ccb1..ab7a86ed58 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -161,6 +161,7 @@ temperature, capacity, health, and identity enrichment.
116. `frontend-modern/src/features/actions/ActionDecisionPacket.tsx`
117. `frontend-modern/src/features/actions/ActionReviewDialog.tsx`
118. `frontend-modern/src/features/actions/actionPresentation.ts`
+118a. `frontend-modern/src/features/actions/actionRouting.ts`
119. `frontend-modern/src/pages/Actions.tsx`
120. `frontend-modern/src/routing/navigation.ts`
121. `frontend-modern/src/routing/routePreload.ts`
@@ -616,6 +617,14 @@ into one outcome. Docker lifecycle controls may create a canonical plan and
open this shared review, but may not auto-approve, auto-execute, or use a
second-click local confirmation. Proof is owned by the colocated action tests,
`DockerNativeTables.test.tsx`, and desktop journeys 81 and 83.
+Patrol findings may retain bounded action status and safety context, but exact
+typed action ids hand off to the route-backed Actions review through
+`frontend-modern/src/features/actions/actionRouting.ts`. The `action` query
+parameter is the canonical shareable review identity: opening it fetches the
+durable action directly, selects Open or History from the returned lifecycle
+state, and clearing the dialog removes the query without discarding the inbox.
+Patrol must not create a parallel decision or execution client around that
+handoff.
The shared review may offer decision or execution controls only when the
current record carries a non-empty `planHash`; every mutation passes that exact
displayed identity through the canonical resource-action client. Legacy or
@@ -1757,7 +1766,9 @@ policy evidence, lifecycle, authority, and outcome truth. Its first layer keeps
intent plus safety/authority facts visible while the immutable planning-time
policy sources, revisions, and reason codes sit behind an explicit disclosure;
missing provenance remains an immediate fail-closed warning rather than hidden
-detail.
+detail. Actions is the canonical browser hub for action review, execution
+progress, and recorded outcomes; contextual sources such as Patrol link into an
+exact action review instead of duplicating those mutations locally.
APT review presents server-recorded policy provenance and distinguishes the
elevated update posture from low-risk-eligible cache cleanup. Both typed actions
diff --git a/frontend-modern/src/components/patrol/ApprovalBanner.tsx b/frontend-modern/src/components/patrol/ApprovalBanner.tsx
index 4092aa884e..24801a2916 100644
--- a/frontend-modern/src/components/patrol/ApprovalBanner.tsx
+++ b/frontend-modern/src/components/patrol/ApprovalBanner.tsx
@@ -1,36 +1,29 @@
/**
* ApprovalBanner
*
- * Sticky amber banner at top of page content area.
- * Surfaces pending investigation fix approvals (5-min expiry).
+ * Contextual handoff from Patrol to the canonical Actions inbox.
+ * Surfaces pending investigation fix approvals without creating a second
+ * approval or execution surface inside Patrol.
* - Hidden when no pending approvals
- * - Single approval: inline approve/deny
- * - Multiple: count + "Review" button to scroll to first finding
+ * - Single approval: deep-links to the exact governed action when available
+ * - Multiple approvals: links to the open Actions inbox
*/
import { Component, Show, createMemo, createSignal, createEffect, onCleanup } from 'solid-js';
import { aiIntelligenceStore } from '@/stores/aiIntelligence';
-import { notificationStore } from '@/stores/notifications';
-import type { ApprovalRequest } from '@/api/ai';
import {
getApprovalExpiryStatusLabel,
getApprovalRiskPresentation,
} from '@/utils/approvalRiskPresentation';
-import { Button } from '@/components/shared/Button';
-import { LoadingSpinner } from '@/components/shared/LoadingSpinner';
+import { ButtonLink } from '@/components/shared/Button';
import { MetadataBadge } from '@/components/shared/MetadataBadge';
+import { buildActionReviewPath } from '@/features/actions/actionRouting';
import ShieldAlertIcon from 'lucide-solid/icons/shield-alert';
-import CheckIcon from 'lucide-solid/icons/check';
-import XIcon from 'lucide-solid/icons/x';
-
-interface ApprovalBannerProps {
- onScrollToFinding?: (findingId: string) => void;
-}
+import ArrowRightIcon from 'lucide-solid/icons/arrow-right';
const APPROVAL_BANNER_BADGE_PROPS = { size: 'xs', shape: 'rounded' } as const;
-export const ApprovalBanner: Component<ApprovalBannerProps> = (props) => {
- const [actionLoading, setActionLoading] = createSignal<string | null>(null);
+export const ApprovalBanner: Component = () => {
const [tick, setTick] = createSignal(Date.now());
const pending = createMemo(() => aiIntelligenceStore.patrolPendingApprovals);
@@ -49,44 +42,12 @@ export const ApprovalBanner: Component<ApprovalBannerProps> = (props) => {
return getApprovalExpiryStatusLabel(expiresAt, tick());
};
- const handleApprove = async (approval: ApprovalRequest) => {
- setActionLoading(approval.id);
- try {
- const result = await aiIntelligenceStore.approveInvestigationFix(approval.id);
- if (result?.success) {
- notificationStore.success('Fix executed successfully');
- } else {
- notificationStore.error(result?.error || 'Fix execution failed');
- }
- } catch (err) {
- notificationStore.error((err as Error).message || 'Failed to execute fix');
- } finally {
- setActionLoading(null);
- }
- };
-
- const handleDeny = async (approval: ApprovalRequest) => {
- setActionLoading(approval.id);
- try {
- await aiIntelligenceStore.denyInvestigationFix(approval.id);
- notificationStore.success('Fix rejected');
- } catch (err) {
- notificationStore.error((err as Error).message || 'Failed to reject fix');
- } finally {
- setActionLoading(null);
- }
- };
-
- const handleReview = () => {
- const findings = aiIntelligenceStore.findingsWithPendingApprovals;
- if (findings.length > 0) {
- props.onScrollToFinding?.(findings[0].id);
- }
- };
-
const firstApprovalRisk = createMemo(() =>
firstApproval() ? getApprovalRiskPresentation(firstApproval()!.riskLevel) : null,
);
+ const reviewPath = createMemo(() =>
+ buildActionReviewPath(pending().length === 1 ? firstApproval()?.plan?.actionId : undefined),
+ );
return (
<Show when={pending().length > 0}>
@@ -100,7 +61,7 @@ export const ApprovalBanner: Component<ApprovalBannerProps> = (props) => {
<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">
- Fix awaiting approval
+ Action awaiting approval
</span>
<MetadataBadge
{...APPROVAL_BANNER_BADGE_PROPS}
@@ -121,53 +82,17 @@ export const ApprovalBanner: Component<ApprovalBannerProps> = (props) => {
</Show>
<Show when={pending().length > 1}>
<span class="text-sm font-medium text-amber-900 dark:text-amber-100">
- {pending().length} fixes awaiting your approval
+ {pending().length} actions awaiting your approval
</span>
</Show>
</div>
</div>
<div class="flex items-center gap-2">
- <Show when={pending().length === 1 && firstApproval()}>
- <Button
- type="button"
- variant="success"
- size="sm"
- onClick={() => handleApprove(firstApproval()!)}
- disabled={actionLoading() === firstApproval()!.id}
- class="gap-1.5"
- >
- <Show when={actionLoading() === firstApproval()!.id}>
- <LoadingSpinner size="sm" tone="inverse" />
- </Show>
- <Show when={actionLoading() !== firstApproval()!.id}>
- <CheckIcon class="w-3.5 h-3.5" />
- </Show>
- Approve fix
- </Button>
- <Button
- type="button"
- variant="secondary"
- size="sm"
- onClick={() => handleDeny(firstApproval()!)}
- disabled={actionLoading() === firstApproval()!.id}
- class="gap-1.5"
- >
- <XIcon class="w-3.5 h-3.5" />
- Reject
- </Button>
- </Show>
- <Show when={pending().length > 1}>
- <Button
- type="button"
- variant="warningSolid"
- size="sm"
- onClick={handleReview}
- class="gap-1.5"
- >
- Review
- </Button>
- </Show>
+ <ButtonLink href={reviewPath()} variant="warningSolid" size="sm" class="gap-1.5">
+ Review in Actions
+ <ArrowRightIcon class="h-3.5 w-3.5" aria-hidden="true" />
+ </ButtonLink>
</div>
</div>
</div>
diff --git a/frontend-modern/src/components/patrol/ApprovalSection.tsx b/frontend-modern/src/components/patrol/ApprovalSection.tsx
index 6a791871d1..58f932e387 100644
--- a/frontend-modern/src/components/patrol/ApprovalSection.tsx
+++ b/frontend-modern/src/components/patrol/ApprovalSection.tsx
@@ -6,29 +6,20 @@
* become executable UI authority.
*/
-import CheckIcon from 'lucide-solid/icons/check';
+import ArrowRightIcon from 'lucide-solid/icons/arrow-right';
import MessageSquareIcon from 'lucide-solid/icons/message-square';
-import PlayIcon from 'lucide-solid/icons/play';
-import XIcon from 'lucide-solid/icons/x';
-import { Component, For, Show, createMemo, createResource, createSignal } from 'solid-js';
+import { Component, For, Show, createMemo, createResource } from 'solid-js';
import { AIAPI } from '@/api/ai';
-import { ResourceActionsAPI } from '@/api/resourceActions';
-import { Button } from '@/components/shared/Button';
+import { Button, ButtonLink } from '@/components/shared/Button';
import { LoadingSpinner } from '@/components/shared/LoadingSpinner';
import { MetadataBadge } from '@/components/shared/MetadataBadge';
+import { buildActionReviewPath } from '@/features/actions/actionRouting';
import {
buildPatrolAssistantFindingHandoff,
buildPatrolAssistantProposedFixBriefingInput,
} from '@/features/patrol/patrolInvestigationContextModel';
import { aiChatStore } from '@/stores/aiChat';
-import { aiIntelligenceStore } from '@/stores/aiIntelligence';
-import { hasFeature } from '@/stores/license';
-import { notificationStore } from '@/stores/notifications';
-import type {
- ActionAuditRecord,
- ActionAuditState,
- PatrolActionReference,
-} from '@/types/actionAudit';
+import type { ActionAuditState, PatrolActionReference } from '@/types/actionAudit';
interface ApprovalSectionProps {
findingId: string;
@@ -51,17 +42,6 @@ const FIX_RELATED_OUTCOMES = new Set([
const BADGE_PROPS = { size: 'xs', shape: 'rounded' } as const;
-function actionReferenceFromAudit(audit: ActionAuditRecord): PatrolActionReference {
- return {
- action_id: audit.id,
- proposal_id: audit.origin?.proposalId,
- resource_id: audit.request.resourceId,
- capability_name: audit.request.capabilityName,
- state: audit.state,
- plan: audit.plan,
- };
-}
-
function statePresentation(state: ActionAuditState): {
label: string;
tone: 'neutral' | 'info' | 'warning' | 'success' | 'danger';
@@ -86,15 +66,28 @@ function statePresentation(state: ActionAuditState): {
}
}
+function actionHubLabel(state: ActionAuditState): string {
+ switch (state) {
+ case 'executing':
+ return 'Track in Actions';
+ case 'rejected':
+ case 'expired':
+ case 'completed':
+ case 'failed':
+ return 'View outcome in Actions';
+ case 'planned':
+ case 'pending_approval':
+ case 'approved':
+ return 'Review in Actions';
+ }
+}
+
function capabilityLabel(value: string): string {
return value.replace(/[._-]+/g, ' ').replace(/\b\w/g, (character) => character.toUpperCase());
}
export const ApprovalSection: Component<ApprovalSectionProps> = (props) => {
- const [busyAction, setBusyAction] = createSignal<string | null>(null);
- const [latestAudit, setLatestAudit] = createSignal<ActionAuditRecord | null>(null);
-
- const [investigation, { refetch }] = createResource(
+ const [investigation] = createResource(
() => ({ findingId: props.findingId, outcome: props.investigationOutcome }),
async ({ findingId, outcome }) => {
if (!outcome || !FIX_RELATED_OUTCOMES.has(outcome)) return null;
@@ -106,15 +99,8 @@ export const ApprovalSection: Component<ApprovalSectionProps> = (props) => {
},
);
- const action = createMemo<PatrolActionReference | null>(() => {
- const audit = latestAudit();
- if (audit) return actionReferenceFromAudit(audit);
- return investigation()?.action ?? null;
- });
- const canManageAction = createMemo(() => hasFeature('ai_autofix'));
+ const action = createMemo<PatrolActionReference | null>(() => investigation()?.action ?? null);
const verificationStatus = createMemo(() => {
- const auditedStatus = latestAudit()?.verificationOutcome?.status;
- if (auditedStatus) return auditedStatus;
switch (investigation()?.outcome) {
case 'fix_verified':
return 'verified';
@@ -130,90 +116,6 @@ export const ApprovalSection: Component<ApprovalSectionProps> = (props) => {
Boolean(props.investigationOutcome && FIX_RELATED_OUTCOMES.has(props.investigationOutcome)),
);
- const refreshPatrol = async () => {
- await refetch();
- await aiIntelligenceStore.loadFindings();
- };
-
- const execute = async (actionId: string, planHash: string) => {
- const result = await ResourceActionsAPI.executeAction(
- actionId,
- planHash,
- 'Operator requested execution from the Patrol action review',
- );
- setLatestAudit(result.audit);
- const verification = result.audit.verificationOutcome?.status;
- if (result.state === 'completed' && verification === 'verified') {
- notificationStore.success('Action completed and verified');
- } else if (result.state === 'completed') {
- notificationStore.warning('Action completed, but verification was inconclusive');
- } else {
- notificationStore.error(result.result?.errorMessage || 'Action failed');
- }
- };
-
- const handleApproveAndRun = async (event: Event) => {
- event.stopPropagation();
- const current = action();
- const planHash = current?.plan.planHash?.trim();
- if (!current || !planHash) return;
- setBusyAction('approve');
- try {
- const decision = await ResourceActionsAPI.decideAction(
- current.action_id,
- 'approved',
- planHash,
- 'Approved from the Patrol action review',
- );
- setLatestAudit(decision.audit);
- await execute(current.action_id, planHash);
- await refreshPatrol();
- } catch (error) {
- notificationStore.error((error as Error).message || 'Failed to approve and run action');
- } finally {
- setBusyAction(null);
- }
- };
-
- const handleRun = async (event: Event) => {
- event.stopPropagation();
- const current = action();
- const planHash = current?.plan.planHash?.trim();
- if (!current || !planHash) return;
- setBusyAction('execute');
- try {
- await execute(current.action_id, planHash);
- await refreshPatrol();
- } catch (error) {
- notificationStore.error((error as Error).message || 'Failed to run action');
- } finally {
- setBusyAction(null);
- }
- };
-
- const handleReject = async (event: Event) => {
- event.stopPropagation();
- const current = action();
- const planHash = current?.plan.planHash?.trim();
- if (!current || !planHash) return;
- setBusyAction('reject');
- try {
- const decision = await ResourceActionsAPI.decideAction(
- current.action_id,
- 'rejected',
- planHash,
- 'Rejected from the Patrol action review',
- );
- setLatestAudit(decision.audit);
- notificationStore.success('Action rejected');
- await refreshPatrol();
- } catch (error) {
- notificationStore.error((error as Error).message || 'Failed to reject action');
- } finally {
- setBusyAction(null);
- }
- };
-
const handleDiscuss = (event: Event) => {
event.stopPropagation();
const current = action();
@@ -354,8 +256,7 @@ export const ApprovalSection: Component<ApprovalSectionProps> = (props) => {
</Show>
<Show when={currentAction().state === 'failed'}>
<div class="text-sm font-medium text-red-600 dark:text-red-400">
- {latestAudit()?.result?.errorMessage ||
- 'The action failed before verification.'}
+ The action failed before verification.
</div>
</Show>
@@ -370,63 +271,15 @@ export const ApprovalSection: Component<ApprovalSectionProps> = (props) => {
</Show>
<div class="flex flex-wrap items-center gap-2 border-t border-border-subtle pt-3">
- <Show
- when={
- reviewedPlanHash() &&
- canManageAction() &&
- currentAction().state === 'pending_approval'
- }
+ <ButtonLink
+ href={buildActionReviewPath(currentAction().action_id)}
+ variant="primary"
+ size="sm"
+ class="gap-1.5"
>
- <Button
- type="button"
- variant="success"
- size="sm"
- onClick={handleApproveAndRun}
- disabled={busyAction() !== null}
- >
- <Show
- when={busyAction() === 'approve'}
- fallback={<CheckIcon class="h-3.5 w-3.5" />}
- >
- <LoadingSpinner size="sm" tone="inverse" />
- </Show>
- Approve and run
- </Button>
- <Button
- type="button"
- variant="ghost"
- size="sm"
- onClick={handleReject}
- disabled={busyAction() !== null}
- >
- <XIcon class="h-3.5 w-3.5" />
- Reject
- </Button>
- </Show>
- <Show
- when={
- canManageAction() &&
- reviewedPlanHash() &&
- (currentAction().state === 'planned' ||
- currentAction().state === 'approved')
- }
- >
- <Button
- type="button"
- variant="success"
- size="sm"
- onClick={handleRun}
- disabled={busyAction() !== null}
- >
- <Show
- when={busyAction() === 'execute'}
- fallback={<PlayIcon class="h-3.5 w-3.5" />}
- >
- <LoadingSpinner size="sm" tone="inverse" />
- </Show>
- Run action
- </Button>
- </Show>
+ {actionHubLabel(currentAction().state)}
+ <ArrowRightIcon class="h-3.5 w-3.5" aria-hidden="true" />
+ </ButtonLink>
<Button type="button" variant="ghost" size="sm" onClick={handleDiscuss}>
<MessageSquareIcon class="h-3.5 w-3.5" />
Discuss with Assistant
diff --git a/frontend-modern/src/components/patrol/__tests__/ApprovalBanner.test.tsx b/frontend-modern/src/components/patrol/__tests__/ApprovalBanner.test.tsx
index b1d7aa07a4..b98aa73740 100644
--- a/frontend-modern/src/components/patrol/__tests__/ApprovalBanner.test.tsx
+++ b/frontend-modern/src/components/patrol/__tests__/ApprovalBanner.test.tsx
@@ -1,13 +1,12 @@
-import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
+import { cleanup, render, screen } from '@solidjs/testing-library';
+import { Route, Router } from '@solidjs/router';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import approvalBannerSource from '../ApprovalBanner.tsx?raw';
import ApprovalBanner from '../ApprovalBanner';
import type { ApprovalRequest } from '@/api/ai';
-import type { UnifiedFinding } from '@/stores/aiIntelligence';
const state = vi.hoisted(() => ({
pendingApprovals: [] as ApprovalRequest[],
- findingsWithPendingApprovals: [] as UnifiedFinding[],
}));
vi.mock('@/stores/aiIntelligence', () => ({
@@ -18,66 +17,58 @@ vi.mock('@/stores/aiIntelligence', () => ({
get patrolPendingApprovals() {
return state.pendingApprovals;
},
- get findingsWithPendingApprovals() {
- return state.findingsWithPendingApprovals;
- },
- approveInvestigationFix: vi.fn(),
- denyInvestigationFix: vi.fn(),
- },
-}));
-
-vi.mock('@/stores/notifications', () => ({
- notificationStore: {
- success: vi.fn(),
- error: vi.fn(),
},
}));
describe('ApprovalBanner', () => {
beforeEach(() => {
state.pendingApprovals = [];
- state.findingsWithPendingApprovals = [];
vi.useFakeTimers();
vi.setSystemTime(new Date('2026-03-01T00:00:00Z'));
});
afterEach(() => {
cleanup();
+ window.history.replaceState({}, '', '/');
vi.useRealTimers();
});
+ const renderBanner = () =>
+ render(() => (
+ <Router>
+ <Route path="/" component={ApprovalBanner} />
+ </Router>
+ ));
+
it('keeps approval risk chips on the shared MetadataBadge primitive', () => {
expect(approvalBannerSource).toContain('MetadataBadge');
- expect(approvalBannerSource).toContain('LoadingSpinner');
expect(approvalBannerSource).toContain('APPROVAL_BANNER_BADGE_PROPS');
expect(approvalBannerSource).toContain('firstApprovalRisk()!.badgeTone');
expect(approvalBannerSource).not.toContain('firstApprovalRisk()!.badgeClass');
expect(approvalBannerSource).not.toMatch(/px-1\.5 py-0\.5 text-\[10px\] font-medium rounded/);
});
- it('keeps approval action controls on the shared Button primitive', () => {
+ it('keeps the Actions handoff on the shared ButtonLink primitive', () => {
expect(approvalBannerSource).toContain('@/components/shared/Button');
- expect(approvalBannerSource).toContain('<Button');
- expect(approvalBannerSource).toContain('variant="success"');
- expect(approvalBannerSource).toContain('variant="secondary"');
+ expect(approvalBannerSource).toContain('<ButtonLink');
expect(approvalBannerSource).toContain('variant="warningSolid"');
- expect(approvalBannerSource).not.toContain('px-3 py-1.5 bg-green-600 hover:bg-green-700');
- expect(approvalBannerSource).not.toContain('px-3 py-1.5 bg-surface-alt hover:bg-surface-hover');
- expect(approvalBannerSource).not.toContain('px-3 py-1.5 bg-amber-600 hover:bg-amber-700');
+ expect(approvalBannerSource).not.toContain('approveInvestigationFix');
+ expect(approvalBannerSource).not.toContain('denyInvestigationFix');
});
- it('uses governed decision wording for a single approval', () => {
- state.pendingApprovals = [approvalRequest()];
+ it('deep-links a single approval to its exact governed action review', () => {
+ state.pendingApprovals = [approvalRequest({ plan: { actionId: 'action-single' } })];
- render(() => <ApprovalBanner />);
+ renderBanner();
- expect(screen.getByRole('button', { name: 'Approve fix' })).toBeInTheDocument();
- expect(screen.getByRole('button', { name: 'Reject' })).toBeInTheDocument();
- expect(screen.queryByText('Approve & Execute')).not.toBeInTheDocument();
- expect(screen.queryByText('Deny')).not.toBeInTheDocument();
+ expect(screen.getByRole('link', { name: 'Review in Actions' })).toHaveAttribute(
+ 'href',
+ '/actions?action=action-single',
+ );
+ expect(screen.queryByRole('button', { name: /approve|reject/i })).not.toBeInTheDocument();
});
- it('reviews the first approval-linked finding in canonical urgency order', () => {
+ it('routes multiple approvals to the open Actions inbox', () => {
state.pendingApprovals = [
{
id: 'approval-sooner',
@@ -107,23 +98,18 @@ describe('ApprovalBanner', () => {
},
] as ApprovalRequest[];
- state.findingsWithPendingApprovals = [
- { id: 'finding-sooner' },
- { id: 'finding-later' },
- ] as UnifiedFinding[];
-
- const onScrollToFinding = vi.fn();
- render(() => <ApprovalBanner onScrollToFinding={onScrollToFinding} />);
-
- fireEvent.click(screen.getByRole('button', { name: 'Review' }));
+ renderBanner();
- expect(onScrollToFinding).toHaveBeenCalledWith('finding-sooner');
+ expect(screen.getByRole('link', { name: 'Review in Actions' })).toHaveAttribute(
+ 'href',
+ '/actions',
+ );
});
it('renders a deterministic countdown label for a valid single approval expiry', () => {
state.pendingApprovals = [approvalRequest({ expiresAt: '2026-03-01T00:06:00Z' })];
- render(() => <ApprovalBanner />);
+ renderBanner();
expect(screen.getByText('expires 6m 0s')).toBeInTheDocument();
});
@@ -131,7 +117,7 @@ describe('ApprovalBanner', () => {
it('fails closed instead of rendering NaN when a single approval expiry is malformed', () => {
state.pendingApprovals = [approvalRequest({ expiresAt: 'not-a-date' })];
- render(() => <ApprovalBanner />);
+ renderBanner();
expect(screen.getByText('expiry unavailable')).toBeInTheDocument();
expect(screen.queryByText(/NaN/)).not.toBeInTheDocument();
@@ -142,7 +128,7 @@ describe('ApprovalBanner', () => {
approvalRequest({ expiresAt: undefined } as Partial<ApprovalRequest>),
];
- render(() => <ApprovalBanner />);
+ renderBanner();
expect(screen.getByText('expiry unavailable')).toBeInTheDocument();
expect(screen.queryByText(/NaN/)).not.toBeInTheDocument();
diff --git a/frontend-modern/src/components/patrol/__tests__/ApprovalSection.test.tsx b/frontend-modern/src/components/patrol/__tests__/ApprovalSection.test.tsx
index a762d526b2..5f19b2f97c 100644
--- a/frontend-modern/src/components/patrol/__tests__/ApprovalSection.test.tsx
+++ b/frontend-modern/src/components/patrol/__tests__/ApprovalSection.test.tsx
@@ -1,57 +1,32 @@
-import { cleanup, fireEvent, render, screen, waitFor } from '@solidjs/testing-library';
+import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
+import { Route, Router } from '@solidjs/router';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import type { InvestigationSession } from '@/api/ai';
-import type { ActionAuditRecord, PatrolActionReference } from '@/types/actionAudit';
+import type { PatrolActionReference } from '@/types/actionAudit';
import approvalSectionSource from '../ApprovalSection.tsx?raw';
import ApprovalSection from '../ApprovalSection';
-const state = vi.hoisted(() => ({ hasAutoFix: true }));
const getInvestigationMock = vi.hoisted(() => vi.fn());
-const decideActionMock = vi.hoisted(() => vi.fn());
-const executeActionMock = vi.hoisted(() => vi.fn());
-const loadFindingsMock = vi.hoisted(() => vi.fn().mockResolvedValue(undefined));
-const notificationSuccessMock = vi.hoisted(() => vi.fn());
-const notificationWarningMock = vi.hoisted(() => vi.fn());
-const notificationErrorMock = vi.hoisted(() => vi.fn());
const openMock = vi.hoisted(() => vi.fn());
vi.mock('@/api/ai', () => ({ AIAPI: { getInvestigation: getInvestigationMock } }));
-vi.mock('@/api/resourceActions', () => ({
- ResourceActionsAPI: {
- decideAction: (...args: unknown[]) => decideActionMock(...args),
- executeAction: (...args: unknown[]) => executeActionMock(...args),
- },
-}));
-vi.mock('@/stores/aiIntelligence', () => ({
- aiIntelligenceStore: { loadFindings: (...args: unknown[]) => loadFindingsMock(...args) },
-}));
-vi.mock('@/stores/notifications', () => ({
- notificationStore: {
- success: (...args: unknown[]) => notificationSuccessMock(...args),
- warning: (...args: unknown[]) => notificationWarningMock(...args),
- error: (...args: unknown[]) => notificationErrorMock(...args),
- },
-}));
vi.mock('@/stores/aiChat', () => ({
aiChatStore: { open: (...args: unknown[]) => openMock(...args) },
}));
-vi.mock('@/stores/license', () => ({
- hasFeature: (feature: string) => feature === 'ai_autofix' && state.hasAutoFix,
-}));
-function actionReference(stateValue: PatrolActionReference['state']): PatrolActionReference {
+function actionReference(state: PatrolActionReference['state']): PatrolActionReference {
return {
action_id: 'act-1',
proposal_id: 'proposal-1',
resource_id: 'vm:42',
capability_name: 'restart',
- state: stateValue,
+ state,
plan: {
actionId: 'act-1',
requestId: 'proposal-1',
allowed: true,
- requiresApproval: stateValue === 'pending_approval',
- approvalPolicy: stateValue === 'pending_approval' ? 'admin' : 'none',
+ requiresApproval: state === 'pending_approval',
+ approvalPolicy: state === 'pending_approval' ? 'admin' : 'none',
rollbackAvailable: true,
planHash: 'sha256:reviewed-plan',
message: 'Restart the unhealthy workload',
@@ -76,160 +51,80 @@ function investigation(action?: PatrolActionReference): InvestigationSession {
status: 'completed',
started_at: '2026-07-10T10:00:00Z',
turn_count: 2,
- outcome: 'fix_queued',
+ outcome: action?.state === 'completed' ? 'fix_verified' : 'fix_queued',
action,
};
}
-function audit(
- stateValue: ActionAuditRecord['state'],
- verification = 'unknown',
-): ActionAuditRecord {
- const action = actionReference(stateValue);
- return {
- id: action.action_id,
- createdAt: '2026-07-10T10:00:00Z',
- updatedAt: '2026-07-10T10:01:00Z',
- state: stateValue,
- request: {
- requestId: 'proposal-1',
- resourceId: action.resource_id,
- capabilityName: action.capability_name,
- reason: 'Recover the unhealthy workload',
- requestedBy: 'pulse_patrol',
- },
- plan: action.plan,
- origin: {
- surface: 'patrol',
- findingId: 'finding-1',
- investigationId: 'investigation-1',
- proposalId: 'proposal-1',
- },
- verificationOutcome: { status: verification as never },
- };
-}
-
-describe('ApprovalSection typed action lifecycle', () => {
+describe('ApprovalSection typed action handoff', () => {
beforeEach(() => {
- state.hasAutoFix = true;
getInvestigationMock.mockReset();
- decideActionMock.mockReset();
- executeActionMock.mockReset();
- loadFindingsMock.mockClear();
- notificationSuccessMock.mockReset();
- notificationWarningMock.mockReset();
- notificationErrorMock.mockReset();
openMock.mockReset();
});
- afterEach(() => cleanup());
+ afterEach(() => {
+ cleanup();
+ window.history.replaceState({}, '', '/');
+ });
- it('contains no live dependency on retired command-fix approval routes or raw commands', () => {
- expect(approvalSectionSource).toContain('@/api/resourceActions');
- expect(approvalSectionSource).not.toContain('reapproveInvestigationFix');
+ const renderSection = (investigationOutcome: string) =>
+ render(() => (
+ <Router>
+ <Route
+ path="/"
+ component={() => (
+ <ApprovalSection findingId="finding-1" investigationOutcome={investigationOutcome} />
+ )}
+ />
+ </Router>
+ ));
+
+ it('keeps Patrol contextual while routing mutations to the canonical Actions review', () => {
+ expect(approvalSectionSource).toContain('@/features/actions/actionRouting');
+ expect(approvalSectionSource).toContain('buildActionReviewPath');
+ expect(approvalSectionSource).not.toContain('@/api/resourceActions');
+ expect(approvalSectionSource).not.toContain('decideAction');
+ expect(approvalSectionSource).not.toContain('executeAction');
expect(approvalSectionSource).not.toContain('approveInvestigationFix');
- expect(approvalSectionSource).not.toContain('denyInvestigationFix');
- expect(approvalSectionSource).not.toContain('approval.command');
expect(approvalSectionSource).not.toContain('proposed_fix.commands');
});
- it('approves and executes a pending typed action through the canonical lifecycle', async () => {
- getInvestigationMock.mockResolvedValue(investigation(actionReference('pending_approval')));
- decideActionMock.mockResolvedValue({
- actionId: 'act-1',
- state: 'approved',
- approval: {
- actor: 'operator',
- method: 'api',
- timestamp: '2026-07-10T10:01:00Z',
- outcome: 'approved',
- },
- audit: audit('approved'),
- });
- executeActionMock.mockResolvedValue({
- actionId: 'act-1',
- state: 'completed',
- audit: audit('completed', 'verified'),
- result: { success: true },
- });
-
- render(() => <ApprovalSection findingId="finding-1" investigationOutcome="fix_queued" />);
- fireEvent.click(await screen.findByRole('button', { name: /approve and run/i }));
-
- await waitFor(() => {
- expect(decideActionMock).toHaveBeenCalledWith(
- 'act-1',
- 'approved',
- 'sha256:reviewed-plan',
- 'Approved from the Patrol action review',
- );
- expect(executeActionMock).toHaveBeenCalledWith(
- 'act-1',
- 'sha256:reviewed-plan',
- 'Operator requested execution from the Patrol action review',
- );
- });
- expect(notificationSuccessMock).toHaveBeenCalledWith('Action completed and verified');
- });
-
- it('rejects without executing', async () => {
+ it('deep-links a pending action to its exact governed review', async () => {
getInvestigationMock.mockResolvedValue(investigation(actionReference('pending_approval')));
- decideActionMock.mockResolvedValue({
- actionId: 'act-1',
- state: 'rejected',
- approval: {
- actor: 'operator',
- method: 'api',
- timestamp: '2026-07-10T10:01:00Z',
- outcome: 'rejected',
- },
- audit: audit('rejected'),
- });
- render(() => <ApprovalSection findingId="finding-1" investigationOutcome="fix_queued" />);
- fireEvent.click(await screen.findByRole('button', { name: /^reject$/i }));
+ renderSection('fix_queued');
- await waitFor(() =>
- expect(decideActionMock).toHaveBeenCalledWith(
- 'act-1',
- 'rejected',
- 'sha256:reviewed-plan',
- 'Rejected from the Patrol action review',
- ),
- );
- expect(executeActionMock).not.toHaveBeenCalled();
+ const link = await screen.findByRole('link', { name: /review in actions/i });
+ expect(link).toHaveAttribute('href', '/actions?action=act-1');
+ expect(screen.getByText('Approval required')).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: /approve/i })).not.toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: /^reject$/i })).not.toBeInTheDocument();
});
- it('runs a no-approval plan without fabricating a decision', async () => {
- getInvestigationMock.mockResolvedValue(investigation(actionReference('planned')));
- executeActionMock.mockResolvedValue({
- actionId: 'act-1',
- state: 'completed',
- audit: audit('completed', 'unverified'),
- result: { success: true },
- });
+ it('routes terminal action history to the exact recorded outcome', async () => {
+ getInvestigationMock.mockResolvedValue(investigation(actionReference('completed')));
- render(() => <ApprovalSection findingId="finding-1" investigationOutcome="fix_queued" />);
- fireEvent.click(await screen.findByRole('button', { name: /run action/i }));
+ renderSection('fix_verified');
- await waitFor(() => expect(executeActionMock).toHaveBeenCalledTimes(1));
- expect(decideActionMock).not.toHaveBeenCalled();
- expect(notificationWarningMock).toHaveBeenCalledWith(
- 'Action completed, but verification was inconclusive',
+ expect(await screen.findByRole('link', { name: /view outcome in actions/i })).toHaveAttribute(
+ 'href',
+ '/actions?action=act-1',
);
+ expect(screen.getByText('Outcome verified')).toBeInTheDocument();
});
- it('fails closed when the typed action has no reviewed plan identity', async () => {
+ it('keeps missing plan identity visible while leaving replan guidance to Actions', async () => {
const action = actionReference('pending_approval');
delete action.plan.planHash;
getInvestigationMock.mockResolvedValue(investigation(action));
- render(() => <ApprovalSection findingId="finding-1" investigationOutcome="fix_queued" />);
+ renderSection('fix_queued');
expect(await screen.findByRole('alert')).toHaveTextContent('no reviewed plan identity');
- expect(screen.queryByRole('button', { name: /approve and run/i })).not.toBeInTheDocument();
- expect(screen.queryByRole('button', { name: /^reject$/i })).not.toBeInTheDocument();
- expect(screen.queryByRole('button', { name: /run action/i })).not.toBeInTheDocument();
+ expect(screen.getByRole('link', { name: /review in actions/i })).toHaveAttribute(
+ 'href',
+ '/actions?action=act-1',
+ );
});
it('fails closed when only a legacy investigation artifact remains', async () => {
@@ -244,11 +139,13 @@ describe('ApprovalSection typed action lifecycle', () => {
approval_id: 'legacy-approval',
});
- render(() => <ApprovalSection findingId="finding-1" investigationOutcome="fix_queued" />);
+ renderSection('fix_queued');
expect(await screen.findByText('Action details unavailable')).toBeInTheDocument();
expect(screen.queryByText('rm -rf /should-never-render')).not.toBeInTheDocument();
- expect(screen.queryByRole('button', { name: /approve/i })).not.toBeInTheDocument();
- expect(screen.queryByRole('button', { name: /run action/i })).not.toBeInTheDocument();
+ expect(screen.queryByRole('link', { name: /actions/i })).not.toBeInTheDocument();
+
+ fireEvent.click(screen.getByRole('button', { name: /discuss with assistant/i }));
+ expect(openMock).toHaveBeenCalledTimes(1);
});
});
diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
index 0fadb51d07..756344ef8e 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -2804,7 +2804,6 @@ describe('shared primitive guardrails', () => {
for (const source of [
findingsPanelSource,
- approvalBannerSource,
approvalSectionSource,
investigationMessagesSource,
investigationSectionSource,
@@ -3374,16 +3373,14 @@ describe('shared primitive guardrails', () => {
'px-2 py-1 text-xs rounded-md border border-border bg-surface hover:bg-surface-hover',
);
expect(approvalBannerSource).toContain('@/components/shared/Button');
- expect(approvalBannerSource).toContain('<Button');
- expect(approvalBannerSource).toContain('variant="success"');
- expect(approvalBannerSource).toContain('variant="secondary"');
+ expect(approvalBannerSource).toContain('<ButtonLink');
expect(approvalBannerSource).toContain('variant="warningSolid"');
expect(approvalBannerSource).not.toContain('px-3 py-1.5 bg-green-600 hover:bg-green-700');
expect(approvalBannerSource).not.toContain('px-3 py-1.5 bg-surface-alt hover:bg-surface-hover');
expect(approvalBannerSource).not.toContain('px-3 py-1.5 bg-amber-600 hover:bg-amber-700');
expect(approvalSectionSource).toContain('@/components/shared/Button');
expect(approvalSectionSource).toContain('<Button');
- expect(approvalSectionSource).toContain('variant="success"');
+ expect(approvalSectionSource).toContain('<ButtonLink');
expect(approvalSectionSource).toContain('variant="primary"');
expect(approvalSectionSource).toContain('variant="ghost"');
expect(approvalSectionSource).not.toContain('px-3 py-1.5 bg-green-600 hover:bg-green-700');
diff --git a/frontend-modern/src/features/actions/__tests__/actionRouting.test.ts b/frontend-modern/src/features/actions/__tests__/actionRouting.test.ts
new file mode 100644
index 0000000000..84a3eccf10
--- /dev/null
+++ b/frontend-modern/src/features/actions/__tests__/actionRouting.test.ts
@@ -0,0 +1,24 @@
+import { describe, expect, it } from 'vitest';
+import {
+ ACTION_REVIEW_QUERY_PARAM,
+ buildActionReviewPath,
+ parseActionReviewId,
+} from '../actionRouting';
+
+describe('action review routing', () => {
+ it('builds an exact URL-safe action review handoff', () => {
+ expect(buildActionReviewPath(' action/with spaces ')).toBe(
+ `/actions?${ACTION_REVIEW_QUERY_PARAM}=action%2Fwith+spaces`,
+ );
+ });
+
+ it('falls back to the Actions inbox when no exact action is available', () => {
+ expect(buildActionReviewPath()).toBe('/actions');
+ expect(buildActionReviewPath(' ')).toBe('/actions');
+ });
+
+ it('parses and normalizes the exact action review identity', () => {
+ expect(parseActionReviewId('?action=%20action-1%20')).toBe('action-1');
+ expect(parseActionReviewId('?view=settled')).toBe('');
+ });
+});
diff --git a/frontend-modern/src/features/actions/actionRouting.ts b/frontend-modern/src/features/actions/actionRouting.ts
new file mode 100644
index 0000000000..195ab5fc09
--- /dev/null
+++ b/frontend-modern/src/features/actions/actionRouting.ts
@@ -0,0 +1,17 @@
+import { ACTIONS_PATH } from '@/routing/resourceLinks';
+
+export const ACTION_REVIEW_QUERY_PARAM = 'action';
+
+const normalizeActionId = (value: string | null | undefined): string => (value || '').trim();
+
+export function buildActionReviewPath(actionId?: string | null): string {
+ const normalizedActionId = normalizeActionId(actionId);
+ if (!normalizedActionId) return ACTIONS_PATH;
+
+ const search = new URLSearchParams({ [ACTION_REVIEW_QUERY_PARAM]: normalizedActionId });
+ return `${ACTIONS_PATH}?${search.toString()}`;
+}
+
+export function parseActionReviewId(search: string): string {
+ return normalizeActionId(new URLSearchParams(search).get(ACTION_REVIEW_QUERY_PARAM));
+}
diff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx
index 943c8fd766..47f89dd1a2 100644
--- a/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx
+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx
@@ -137,21 +137,7 @@ export function PatrolIntelligenceWorkspace(props: { state: PatrolIntelligenceSt
return (
<>
- <ApprovalBanner
- onScrollToFinding={(findingId) => {
- state.setActiveTab('findings');
- state.setFindingsFilterOverride('approvals');
- state.clearScrollToFindingTimer();
- state.setScrollToFindingTimer(
- setTimeout(() => {
- state.setScrollToFindingTimer(undefined);
- const el = document.getElementById(`finding-${findingId}`);
- el?.scrollIntoView({ behavior: 'smooth', block: 'start' });
- state.setFindingScrollTimer(undefined);
- }, 100),
- );
- }}
- />
+ <ApprovalBanner />
<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/usePatrolIntelligenceState.ts b/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts
index d7b1a49962..7c083cffd5 100644
--- a/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts
+++ b/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts
@@ -250,7 +250,6 @@ export function usePatrolIntelligenceState() {
const [patrolLoadError, setPatrolLoadError] = createSignal('');
let safetyTimerRef: ReturnType<typeof setTimeout> | undefined;
- let scrollToFindingTimerRef: ReturnType<typeof setTimeout> | undefined;
let findingScrollTimerRef: ReturnType<typeof setTimeout> | undefined;
let refreshTimeoutRef: ReturnType<typeof setTimeout> | undefined;
let manualRefreshTimeoutRef: ReturnType<typeof setTimeout> | undefined;
@@ -266,13 +265,6 @@ export function usePatrolIntelligenceState() {
}
};
- const clearScrollToFindingTimer = () => {
- if (scrollToFindingTimerRef !== undefined) {
- clearTimeout(scrollToFindingTimerRef);
- scrollToFindingTimerRef = undefined;
- }
- };
-
const clearRefreshTimeout = () => {
if (refreshTimeoutRef !== undefined) {
clearTimeout(refreshTimeoutRef);
@@ -988,7 +980,6 @@ export function usePatrolIntelligenceState() {
onCleanup(() => {
stopPolling();
clearSafetyTimer();
- clearScrollToFindingTimer();
clearManualRefreshTimeout();
if (findingScrollTimerRef !== undefined) {
clearTimeout(findingScrollTimerRef);
@@ -1012,7 +1003,6 @@ export function usePatrolIntelligenceState() {
blockedReason,
canTriggerPatrol,
circuitBreakerStatus,
- clearScrollToFindingTimer,
displayRunHistory,
findingsTabBadgeCount,
findingsTabBadgeFindings,
@@ -1065,9 +1055,6 @@ export function usePatrolIntelligenceState() {
setFindingScrollTimer: (timer: ReturnType<typeof setTimeout> | undefined) => {
findingScrollTimerRef = timer;
},
- setScrollToFindingTimer: (timer: ReturnType<typeof setTimeout> | undefined) => {
- scrollToFindingTimerRef = timer;
- },
showBlockedBanner,
showReadinessBanner,
shouldShowPatrolSetupOnly,
diff --git a/frontend-modern/src/pages/Actions.tsx b/frontend-modern/src/pages/Actions.tsx
index e18b323b9a..154119ca8d 100644
--- a/frontend-modern/src/pages/Actions.tsx
+++ b/frontend-modern/src/pages/Actions.tsx
@@ -1,4 +1,5 @@
import { For, Show, createEffect, createMemo, createSignal } 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';
@@ -9,16 +10,29 @@ import { MetadataBadge } from '@/components/shared/MetadataBadge';
import { PageHeader } from '@/components/shared/PageHeader';
import { Subtabs } from '@/components/shared/Subtabs';
import { ActionReviewDialog } from '@/features/actions/ActionReviewDialog';
+import { ACTION_REVIEW_QUERY_PARAM, parseActionReviewId } from '@/features/actions/actionRouting';
import {
formatActionName,
getActionInboxStatePresentation,
getActionResourcePresentation,
sortOpenActionsForReview,
} from '@/features/actions/actionPresentation';
-import type { ActionAuditRecord, ActionDetailResponse, ActionInboxView } from '@/types/actionAudit';
+import type {
+ ActionAuditRecord,
+ ActionAuditState,
+ ActionDetailResponse,
+ ActionInboxView,
+} from '@/types/actionAudit';
import { formatRelativeTime } from '@/utils/format';
+const getInboxViewForState = (state: ActionAuditState): ActionInboxView =>
+ state === 'rejected' || state === 'expired' || state === 'completed' || state === 'failed'
+ ? 'settled'
+ : 'pending';
+
export function Actions() {
+ const location = useLocation();
+ const [, setSearchParams] = useSearchParams();
const [view, setView] = createSignal<ActionInboxView>('pending');
const [selected, setSelected] = createSignal<ActionDetailResponse | null>(null);
const [detailError, setDetailError] = createSignal('');
@@ -43,11 +57,6 @@ export function Actions() {
}
};
- createEffect(() => {
- view();
- void loadActions();
- });
-
const queueSummary = createMemo(() => {
const count = actions().length;
if (view() === 'settled') {
@@ -64,15 +73,38 @@ export function Actions() {
view() === 'pending' ? sortOpenActionsForReview(actions()) : actions(),
);
- const openAction = async (record: ActionAuditRecord) => {
+ const openActionById = async (actionId: string) => {
setDetailError('');
try {
- setSelected(await ResourceActionsAPI.getAction(record.id));
+ const detail = await ResourceActionsAPI.getAction(actionId);
+ setSelected(detail);
+ setView(getInboxViewForState(detail.audit.state));
} catch (cause) {
+ setSelected(null);
setDetailError(cause instanceof Error ? cause.message : 'Action details are unavailable.');
}
};
+ const openAction = (record: ActionAuditRecord) => {
+ setSearchParams({ [ACTION_REVIEW_QUERY_PARAM]: record.id }, { replace: true });
+ };
+
+ const closeAction = () => {
+ setSelected(null);
+ setDetailError('');
+ setSearchParams({ [ACTION_REVIEW_QUERY_PARAM]: null }, { replace: true });
+ };
+
+ createEffect(() => {
+ view();
+ void loadActions();
+ });
+
+ createEffect(() => {
+ const actionId = parseActionReviewId(location.search);
+ if (actionId) void openActionById(actionId);
+ });
+
return (
<div class="w-full space-y-4 px-3 py-4 sm:px-5">
<PageHeader
@@ -169,7 +201,7 @@ export function Actions() {
type="button"
aria-label={`Review ${title()} on ${action.request.resourceId}, ${state().label}`}
class={`group w-full border-l-2 px-3 py-3 text-left transition-colors hover:bg-surface-hover/70 focus-visible:outline focus-visible:outline-2 focus-visible:outline-blue-500 sm:px-4 ${state().accentClass}`}
- onClick={() => void openAction(action)}
+ onClick={() => openAction(action)}
>
<div class="flex items-center gap-3">
<div class="min-w-0 flex-1">
@@ -217,9 +249,10 @@ export function Actions() {
</Show>
<ActionReviewDialog
detail={selected()}
- onClose={() => setSelected(null)}
+ onClose={closeAction}
onChanged={async (detail) => {
setSelected(detail);
+ setView(getInboxViewForState(detail.audit.state));
await loadActions();
}}
/>
diff --git a/tests/integration/tests/78-monitor-first-patrol-workbench.spec.ts b/tests/integration/tests/78-monitor-first-patrol-workbench.spec.ts
index 7e68c50149..74ad1a5e2f 100644
--- a/tests/integration/tests/78-monitor-first-patrol-workbench.spec.ts
+++ b/tests/integration/tests/78-monitor-first-patrol-workbench.spec.ts
@@ -448,6 +448,10 @@ async function mockMonitorFirstPatrolWorkbench(
status: "pending",
requestedAt: "2026-06-30T08:06:00Z",
expiresAt: "2099-06-30T08:11:00Z",
+ plan: {
+ actionId: "action-finding-active-work",
+ planHash: "sha256:patrol-review",
+ },
},
]
: [];
@@ -632,6 +636,9 @@ test.describe("Monitor-first Patrol workbench browser contract", () => {
).toHaveCount(0);
await expect(page.getByText("High CPU pressure on pve-main")).toBeVisible();
await expect(page.getByText("Approval required")).toBeVisible();
+ await expect(
+ page.getByRole("link", { name: "Review in Actions" }),
+ ).toHaveAttribute("href", "/actions?action=action-finding-active-work");
await expect(
page.getByText(
"Sustained CPU pressure can slow hosted workloads on this Proxmox host.",
diff --git a/tests/integration/tests/81-actions-inbox.spec.ts b/tests/integration/tests/81-actions-inbox.spec.ts
index c70d4e4c9a..b7af19610f 100644
--- a/tests/integration/tests/81-actions-inbox.spec.ts
+++ b/tests/integration/tests/81-actions-inbox.spec.ts
@@ -412,8 +412,13 @@ test("Actions inbox exposes the canonical decision packet and durable calm histo
body: JSON.stringify({ audit: action, events: [] }),
}),
);
- await page.goto("/actions", { waitUntil: "domcontentloaded" });
+ await page.goto("/actions?action=action-1", {
+ waitUntil: "domcontentloaded",
+ });
await expect(page.getByRole("heading", { name: "Actions" })).toBeVisible();
+ await expect(page.getByRole("dialog", { name: "Restart" })).toBeVisible();
+ await page.getByRole("button", { name: "Close action review" }).click();
+ await expect(page).toHaveURL(/\/actions$/);
await expect(
page.getByRole("tab", { name: "Open", exact: true }),
).toHaveAttribute("aria-selected", "true");
@@ -429,6 +434,7 @@ test("Actions inbox exposes the canonical decision packet and durable calm histo
await page
.getByRole("button", { name: /Restart.*docker:container:edge/ })
.click();
+ await expect(page).toHaveURL(/\/actions\?action=action-1$/);
await expect(page.getByRole("dialog", { name: "Restart" })).toBeVisible();
await expect(
page.getByText(