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.

Surface resource action audit history

rcourtman535e623ad05e
diff --git a/docs/release-control/v6/internal/records/action-audit-resource-history-surface-2026-04-29.md b/docs/release-control/v6/internal/records/action-audit-resource-history-surface-2026-04-29.md
new file mode 100644
index 0000000000..96298e73bf
--- /dev/null
+++ b/docs/release-control/v6/internal/records/action-audit-resource-history-surface-2026-04-29.md
@@ -0,0 +1,24 @@
+# Action Audit Resource History Surface
+
+Date: 2026-04-29
+Lane: L20 action governance and auditability
+Follow-up: `action-governance-auditability-post-rc-hardening`
+
+## Outcome
+
+Resource-detail workflows now have a canonical action-history surface backed by
+the unified action audit API. The frontend reads `GET /api/audit/actions`
+through `frontend-modern/src/api/actionAudit.ts`, renders resource-scoped
+records through `ResourceActionHistory.tsx`, and treats gated or unavailable
+audit reads as absent instead of turning ordinary resource inspection into an
+upgrade prompt.
+
+## Proof
+
+- `npm --prefix frontend-modern test -- src/api/__tests__/actionAudit.test.ts src/utils/__tests__/actionAuditPresentation.test.ts src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx`
+- `npm --prefix frontend-modern run type-check`
+- `npm --prefix frontend-modern run lint:eslint -- --quiet`
+- In-browser resource drawer inspection on the local v6 app confirmed the
+ default self-hosted surface still renders the resource drawer without exposing
+ action-history upgrade pressure when the action-audit endpoint is unavailable
+ or empty.
diff --git a/docs/release-control/v6/internal/status.json b/docs/release-control/v6/internal/status.json
index db044eb4cc..0a392e6334 100644
--- a/docs/release-control/v6/internal/status.json
+++ b/docs/release-control/v6/internal/status.json
@@ -3665,7 +3665,7 @@
"status": "partial",
"completion": {
"state": "bounded-residual",
- "summary": "Action governance now has a first-class governed floor: tool capability declarations, approval-backed action plans, plan-level preflight and dry-run posture, fail-closed action-audit normalization, bounded lifecycle events, and API-visible action audit preflight are owned by the shared AI, API, security, Patrol, and unified-resource contracts. Broader enterprise policy execution, richer dry-run providers, multi-actor approvals, and surfaced action-history workflows remain a named post-RC hardening track.",
+ "summary": "Action governance now has a first-class governed floor: tool capability declarations, approval-backed action plans, plan-level preflight and dry-run posture, fail-closed action-audit normalization, bounded lifecycle events, API-visible action audit preflight, and a resource-scoped action-history surface are owned by the shared AI, API, security, Patrol, and unified-resource contracts. Broader enterprise policy execution, richer dry-run providers, multi-actor approvals, and deeper safe-execution contracts remain a named post-RC hardening track.",
"tracking": [
{
"kind": "lane-followup",
@@ -3676,6 +3676,11 @@
"blockers": [],
"subsystems": [],
"evidence": [
+ {
+ "repo": "pulse",
+ "path": "docs/release-control/v6/internal/records/action-audit-resource-history-surface-2026-04-29.md",
+ "kind": "file"
+ },
{
"repo": "pulse",
"path": "docs/release-control/v6/internal/subsystems/ai-runtime.md",
@@ -3706,6 +3711,46 @@
"path": "docs/release-control/v6/internal/V6_BRIDGE_RELEASE_FOUNDATION_SPEC.md",
"kind": "file"
},
+ {
+ "repo": "pulse",
+ "path": "frontend-modern/src/api/__tests__/actionAudit.test.ts",
+ "kind": "file"
+ },
+ {
+ "repo": "pulse",
+ "path": "frontend-modern/src/api/actionAudit.ts",
+ "kind": "file"
+ },
+ {
+ "repo": "pulse",
+ "path": "frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx",
+ "kind": "file"
+ },
+ {
+ "repo": "pulse",
+ "path": "frontend-modern/src/components/Infrastructure/ResourceActionHistory.tsx",
+ "kind": "file"
+ },
+ {
+ "repo": "pulse",
+ "path": "frontend-modern/src/components/Infrastructure/useResourceDetailDrawerHistoryState.ts",
+ "kind": "file"
+ },
+ {
+ "repo": "pulse",
+ "path": "frontend-modern/src/types/actionAudit.ts",
+ "kind": "file"
+ },
+ {
+ "repo": "pulse",
+ "path": "frontend-modern/src/utils/__tests__/actionAuditPresentation.test.ts",
+ "kind": "file"
+ },
+ {
+ "repo": "pulse",
+ "path": "frontend-modern/src/utils/actionAuditPresentation.ts",
+ "kind": "file"
+ },
{
"repo": "pulse",
"path": "internal/ai/approval/store.go",
@@ -4750,7 +4795,7 @@
},
{
"id": "action-governance-auditability-post-rc-hardening",
- "summary": "Track broader action-governance hardening beyond the current canonical action-audit floor, including richer provider dry-runs, enterprise policy execution, multi-actor or MFA approval chains, surfaced action-history workflows, and deeper safe-execution contracts for future controlled operations.",
+ "summary": "Track broader action-governance hardening beyond the current canonical action-audit and resource-scoped action-history floor, including richer provider dry-runs, enterprise policy execution, multi-actor or MFA approval chains, and deeper safe-execution contracts for future controlled operations.",
"owner": "project-owner",
"status": "planned",
"recorded_at": "2026-04-25",
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index cfff9e7d1b..ad6e7ebd72 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -28,6 +28,8 @@ Own canonical runtime payload shapes between backend and frontend.
3. `internal/api/alerts.go`
4. `internal/api/activity_audit_handlers.go`
5. `frontend-modern/src/types/api.ts`
+6. `frontend-modern/src/types/actionAudit.ts`
+7. `frontend-modern/src/api/actionAudit.ts`
6. `frontend-modern/src/api/responseUtils.ts`
7. `frontend-modern/src/components/Settings/APITokenManager.tsx`
8. `frontend-modern/src/components/Settings/apiTokenManagerModel.ts`
@@ -1602,6 +1604,11 @@ Unified action audit payloads must also expose the normalized action plan
preflight through `plan.preflight`: API consumers should see whether a dry-run
was available, what safety checks were recorded, and what verification steps
remain, instead of inferring action safety from free-form result text.
+The frontend action-audit client in `frontend-modern/src/api/actionAudit.ts`
+and its typed payload mirror in `frontend-modern/src/types/actionAudit.ts` are
+the canonical browser-side reader for `GET /api/audit/actions`; resource
+workflow surfaces must consume that client instead of rebuilding audit query
+URLs or silently ignoring the endpoint's gated-unavailable state.
Those relationship and timeline payloads now also carry `lastSeenAt` freshness
and optional metadata through the same owned contract, so the drawer can
preserve provenance without inventing a separate relationship-detail schema.
diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.json
index 6d1f6f8d10..44dc240df8 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -1488,6 +1488,7 @@
"frontend-modern/src/components/Settings/useInfrastructureInstallState.tsx",
"frontend-modern/src/components/Settings/useInfrastructureOperationsState.tsx",
"frontend-modern/src/components/Settings/useNodeModalState.ts",
+ "frontend-modern/src/types/actionAudit.ts",
"frontend-modern/src/types/api.ts",
"frontend-modern/src/utils/agentInstallCommand.ts",
"frontend-modern/src/utils/apiTokenPresentation.ts",
@@ -1722,6 +1723,19 @@
"frontend-modern/src/types/api.ts"
]
},
+ {
+ "id": "frontend-action-audit-types",
+ "label": "frontend action audit type proof",
+ "match_prefixes": [],
+ "match_files": [
+ "frontend-modern/src/types/actionAudit.ts"
+ ],
+ "allow_same_subsystem_tests": false,
+ "test_prefixes": [],
+ "exact_files": [
+ "frontend-modern/src/api/__tests__/actionAudit.test.ts"
+ ]
+ },
{
"id": "frontend-install-command-helper",
"label": "frontend install transport contract proof",
@@ -4887,6 +4901,7 @@
"frontend-modern/src/components/Infrastructure/infrastructureSelectors.ts",
"frontend-modern/src/components/Infrastructure/InfrastructureSummary.tsx",
"frontend-modern/src/components/Infrastructure/infrastructureSummaryModel.ts",
+ "frontend-modern/src/components/Infrastructure/ResourceActionHistory.tsx",
"frontend-modern/src/components/Infrastructure/resourceBadges.ts",
"frontend-modern/src/components/Infrastructure/ResourceChangeSummary.tsx",
"frontend-modern/src/components/Infrastructure/ResourceCorrelationSummary.tsx",
@@ -4925,6 +4940,7 @@
"frontend-modern/src/pages/Infrastructure.tsx",
"frontend-modern/src/routing/resourceLinks.ts",
"frontend-modern/src/types/resource.ts",
+ "frontend-modern/src/utils/actionAuditPresentation.ts",
"frontend-modern/src/utils/agentResources.ts",
"frontend-modern/src/utils/canonicalResourceTypes.ts",
"frontend-modern/src/utils/platformSupportManifest.generated.ts",
@@ -5006,6 +5022,7 @@
"frontend-modern/src/components/Infrastructure/infrastructureSelectors.ts",
"frontend-modern/src/components/Infrastructure/InfrastructureSummary.tsx",
"frontend-modern/src/components/Infrastructure/infrastructureSummaryModel.ts",
+ "frontend-modern/src/components/Infrastructure/ResourceActionHistory.tsx",
"frontend-modern/src/components/Infrastructure/ResourceChangeSummary.tsx",
"frontend-modern/src/components/Infrastructure/ResourceCorrelationSummary.tsx",
"frontend-modern/src/components/Infrastructure/resourceDetailDiscoveryModel.ts",
@@ -5073,6 +5090,19 @@
"internal/unifiedresources/code_standards_test.go"
]
},
+ {
+ "id": "resource-action-audit-presentation-helper",
+ "label": "resource action audit presentation helper proof",
+ "match_prefixes": [],
+ "match_files": [
+ "frontend-modern/src/utils/actionAuditPresentation.ts"
+ ],
+ "allow_same_subsystem_tests": false,
+ "test_prefixes": [],
+ "exact_files": [
+ "frontend-modern/src/utils/__tests__/actionAuditPresentation.test.ts"
+ ]
+ },
{
"id": "resource-change-presentation-helper",
"label": "resource change presentation helper proof",
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index c12b68ac53..775cbdf58d 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -9,7 +9,9 @@
"contract_file": "docs/release-control/v6/internal/subsystems/unified-resources.md",
"status_file": "docs/release-control/v6/internal/status.json",
"registry_file": "docs/release-control/v6/internal/subsystems/registry.json",
- "dependency_subsystem_ids": []
+ "dependency_subsystem_ids": [
+ "api-contracts"
+ ]
}
```
@@ -50,6 +52,7 @@ cross-source deduplication.
28. `frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx`
29. `frontend-modern/src/components/Infrastructure/ResourceDetailDrawerDebugTab.tsx`
30. `frontend-modern/src/components/Infrastructure/ResourceDetailDrawerSupportDisclosure.tsx`
+31. `frontend-modern/src/components/Infrastructure/ResourceActionHistory.tsx`
31. `frontend-modern/src/components/Infrastructure/ResourceFacetSummary.tsx`
32. `frontend-modern/src/components/Infrastructure/ResourceChangeSummary.tsx`
33. `frontend-modern/src/components/Infrastructure/ResourceCorrelationSummary.tsx`
@@ -84,6 +87,7 @@ cross-source deduplication.
62. `frontend-modern/src/utils/canonicalResourceTypes.ts`
63. `frontend-modern/src/utils/resourceBadgePresentation.ts`
64. `frontend-modern/src/utils/resourceChangePresentation.ts`
+65. `frontend-modern/src/utils/actionAuditPresentation.ts`
65. `frontend-modern/src/utils/resourceCorrelationPresentation.ts`
66. `frontend-modern/src/utils/resourcePlatformData.ts`
67. `frontend-modern/src/utils/resourcePolicyPresentation.ts`
@@ -215,7 +219,7 @@ AI-only summary payloads, or page-local heuristics.
generic disk-count aggregate, so resource drawers and incidents do not hide
the actual protection boundary behind a broader count phrase.
6. Add canonical governed name-resolution or policy-aware resource lookup behavior through `internal/unifiedresources/resolve.go` and `internal/unifiedresources/resolve_context.go`
-7. Add or change resource drawer timeline/facet presentation through `frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx`, `frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx`, `frontend-modern/src/components/Infrastructure/ResourceDetailDrawerDebugTab.tsx`, `frontend-modern/src/components/Infrastructure/useResourceDetailDrawerState.ts`, `frontend-modern/src/components/Infrastructure/ResourceFacetSummary.tsx`, `frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts`, and the governed `internal/api/resources.go` facet/timeline contract together
+7. Add or change resource drawer timeline/facet/action-history presentation through `frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx`, `frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx`, `frontend-modern/src/components/Infrastructure/ResourceDetailDrawerDebugTab.tsx`, `frontend-modern/src/components/Infrastructure/ResourceActionHistory.tsx`, `frontend-modern/src/components/Infrastructure/useResourceDetailDrawerState.ts`, `frontend-modern/src/components/Infrastructure/ResourceFacetSummary.tsx`, `frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts`, and the governed `internal/api/resources.go` facet/timeline plus `internal/api/activity_audit_handlers.go` action-audit contracts together
8. Add or change discovery-support runtime under the resource drawer through `frontend-modern/src/components/Discovery/DiscoveryTab.tsx` for shell/presentation ownership and `frontend-modern/src/components/Discovery/useDiscoveryTabState.ts` for fetch, websocket-progress, and notes-mutation ownership
9. Keep dashboard and infrastructure freshness on the canonical unified-resource
ownership path. `frontend-modern/src/stores/websocket.ts`,
@@ -439,6 +443,12 @@ verification steps through `preflight`, and `RecordActionAudit` plus
`RecordActionLifecycleEvent` must normalize action id, request id, resource,
capability, approval policy, timestamps, lifecycle state, and requester before
records reach durable audit history.
+`ResourceActionHistory.tsx` now surfaces that same normalized action audit
+trail inside the resource-detail workflow through the canonical
+`frontend-modern/src/api/actionAudit.ts` client and shared
+`frontend-modern/src/utils/actionAuditPresentation.ts` labels. The resource
+drawer must treat gated action-audit reads as unavailable rather than turning
+ordinary infrastructure inspection into an upgrade-prompt path.
`InfrastructureSummary.tsx` and `infrastructureSummaryModel.ts` now surface
`degraded` and `alerting` resource counts alongside the existing `online` and
diff --git a/frontend-modern/src/api/__tests__/actionAudit.test.ts b/frontend-modern/src/api/__tests__/actionAudit.test.ts
new file mode 100644
index 0000000000..6008766cca
--- /dev/null
+++ b/frontend-modern/src/api/__tests__/actionAudit.test.ts
@@ -0,0 +1,76 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+vi.mock('@/utils/apiClient', () => ({
+ apiFetchJSON: vi.fn(),
+}));
+
+import { ActionAuditAPI } from '@/api/actionAudit';
+import { apiFetchJSON } from '@/utils/apiClient';
+
+describe('ActionAuditAPI', () => {
+ const apiFetchJSONMock = vi.mocked(apiFetchJSON);
+
+ beforeEach(() => {
+ apiFetchJSONMock.mockReset();
+ });
+
+ it('builds the canonical resource-scoped action audit query', async () => {
+ apiFetchJSONMock.mockResolvedValueOnce({
+ audits: [
+ {
+ id: 'action-1',
+ createdAt: '2026-04-29T12:00:00Z',
+ updatedAt: '2026-04-29T12:01:00Z',
+ state: 'completed',
+ request: {
+ requestId: 'req-1',
+ resourceId: 'vm:42',
+ capabilityName: 'restart',
+ reason: 'Restart after patching',
+ requestedBy: 'agent:ops',
+ },
+ plan: {
+ actionId: 'action-1',
+ requestId: 'req-1',
+ allowed: true,
+ requiresApproval: true,
+ approvalPolicy: 'admin',
+ rollbackAvailable: true,
+ },
+ },
+ ],
+ count: 1,
+ resourceId: 'vm:42',
+ });
+
+ const response = await ActionAuditAPI.listActionAudits({
+ resourceId: ' vm:42 ',
+ since: '2026-04-29T11:00:00Z',
+ limit: 5,
+ });
+
+ expect(apiFetchJSONMock).toHaveBeenCalledWith(
+ '/api/audit/actions?resourceId=vm%3A42&since=2026-04-29T11%3A00%3A00.000Z&limit=5',
+ { cache: 'no-store' },
+ );
+ expect(response).toMatchObject({
+ available: true,
+ count: 1,
+ resourceId: 'vm:42',
+ });
+ expect(response.audits).toHaveLength(1);
+ });
+
+ it('treats gated action audit endpoints as unavailable instead of throwing', async () => {
+ apiFetchJSONMock.mockRejectedValueOnce(
+ Object.assign(new Error('Payment Required'), { status: 402 }),
+ );
+
+ await expect(ActionAuditAPI.listActionAudits({ resourceId: 'vm:42' })).resolves.toEqual({
+ audits: [],
+ available: false,
+ count: 0,
+ resourceId: 'vm:42',
+ });
+ });
+});
diff --git a/frontend-modern/src/api/actionAudit.ts b/frontend-modern/src/api/actionAudit.ts
new file mode 100644
index 0000000000..bb7ce55de0
--- /dev/null
+++ b/frontend-modern/src/api/actionAudit.ts
@@ -0,0 +1,91 @@
+import { apiFetchJSON } from '@/utils/apiClient';
+import { apiErrorStatus, objectArrayFieldOrEmpty } from './responseUtils';
+import type { ActionAuditListResponse, ActionAuditRecord } from '@/types/actionAudit';
+
+export interface ListActionAuditsOptions {
+ resourceId?: string;
+ since?: string | number | Date;
+ limit?: number;
+}
+
+type RawActionAuditListResponse = Partial<
+ Omit<ActionAuditListResponse, 'audits' | 'available'> & {
+ audits?: unknown;
+ }
+>;
+
+const ACTION_AUDIT_UNAVAILABLE_STATUSES = new Set([401, 402, 403]);
+
+const unavailableActionAuditResponse = (resourceId?: string): ActionAuditListResponse => ({
+ audits: [],
+ count: 0,
+ resourceId,
+ available: false,
+});
+
+const normalizeLimit = (limit: number | undefined): number | undefined => {
+ if (!Number.isFinite(limit ?? NaN) || (limit ?? 0) <= 0) return undefined;
+ return Math.trunc(limit ?? 0);
+};
+
+const normalizeSince = (since: string | number | Date | undefined): string | undefined => {
+ if (since === undefined || since === null || `${since}`.trim() === '') return undefined;
+ const date = since instanceof Date ? since : new Date(since);
+ return Number.isFinite(date.getTime()) ? date.toISOString() : undefined;
+};
+
+const buildActionAuditQuery = (options?: ListActionAuditsOptions): string => {
+ const params = new URLSearchParams();
+ const resourceId = options?.resourceId?.trim();
+ if (resourceId) params.set('resourceId', resourceId);
+
+ const since = normalizeSince(options?.since);
+ if (since) params.set('since', since);
+
+ const limit = normalizeLimit(options?.limit);
+ if (limit) params.set('limit', String(limit));
+
+ const query = params.toString();
+ return query ? `?${query}` : '';
+};
+
+const normalizeActionAuditListResponse = (
+ raw: RawActionAuditListResponse | null | undefined,
+ fallbackResourceId?: string,
+): ActionAuditListResponse => {
+ const audits = objectArrayFieldOrEmpty<ActionAuditRecord>(raw, 'audits');
+ const count = Number.isFinite(raw?.count) ? Number(raw?.count) : audits.length;
+ const resourceId =
+ typeof raw?.resourceId === 'string' && raw.resourceId.trim()
+ ? raw.resourceId.trim()
+ : fallbackResourceId;
+
+ return {
+ audits,
+ count,
+ resourceId,
+ available: true,
+ };
+};
+
+export class ActionAuditAPI {
+ static async listActionAudits(
+ options?: ListActionAuditsOptions,
+ ): Promise<ActionAuditListResponse> {
+ const resourceId = options?.resourceId?.trim() || undefined;
+
+ try {
+ const raw = await apiFetchJSON<RawActionAuditListResponse>(
+ `/api/audit/actions${buildActionAuditQuery(options)}`,
+ { cache: 'no-store' },
+ );
+ return normalizeActionAuditListResponse(raw, resourceId);
+ } catch (error) {
+ const status = apiErrorStatus(error);
+ if (status !== null && ACTION_AUDIT_UNAVAILABLE_STATUSES.has(status)) {
+ return unavailableActionAuditResponse(resourceId);
+ }
+ throw error;
+ }
+ }
+}
diff --git a/frontend-modern/src/components/Infrastructure/ResourceActionHistory.tsx b/frontend-modern/src/components/Infrastructure/ResourceActionHistory.tsx
new file mode 100644
index 0000000000..dbece6ea71
--- /dev/null
+++ b/frontend-modern/src/components/Infrastructure/ResourceActionHistory.tsx
@@ -0,0 +1,140 @@
+import { For, Show } from 'solid-js';
+import type { Component } from 'solid-js';
+import type { ActionAuditRecord } from '@/types/actionAudit';
+import { formatRelativeTime } from '@/utils/format';
+import {
+ formatActionApprovalPolicyLabel,
+ formatActionCapabilityLabel,
+ getActionAuditStatePresentation,
+} from '@/utils/actionAuditPresentation';
+
+interface ResourceActionHistoryProps {
+ audits: ActionAuditRecord[];
+ count: number;
+ loadingLabel: string;
+ error: string;
+ onRetry: () => void | Promise<unknown>;
+}
+
+const ActionHistoryRow: Component<{ audit: ActionAuditRecord }> = (props) => {
+ const state = () => getActionAuditStatePresentation(props.audit.state);
+ const preflight = () => props.audit.plan?.preflight;
+ const result = () => props.audit.result;
+
+ return (
+ <div class="rounded border border-border bg-surface-hover px-2 py-1.5 text-[10px]">
+ <div class="flex items-start justify-between gap-3">
+ <div class="min-w-0">
+ <div class="font-medium text-base-content">
+ {formatActionCapabilityLabel(props.audit.request?.capabilityName)}
+ </div>
+ <div class="mt-0.5 text-muted">
+ {formatRelativeTime(props.audit.updatedAt || props.audit.createdAt)}
+ <Show when={props.audit.request?.requestedBy}>
+ <span class="mx-1">•</span>
+ <span>{props.audit.request.requestedBy}</span>
+ </Show>
+ </div>
+ </div>
+ <span class={`shrink-0 rounded border px-1.5 py-0.5 font-medium ${state().className}`}>
+ {state().label}
+ </span>
+ </div>
+
+ <div class="mt-1 space-y-1">
+ <Show when={props.audit.request?.reason}>
+ <div class="text-base-content">{props.audit.request.reason}</div>
+ </Show>
+ <div class="flex items-center justify-between gap-2">
+ <span class="text-muted">Approval</span>
+ <span class="font-medium text-base-content">
+ {formatActionApprovalPolicyLabel(props.audit.plan?.approvalPolicy)}
+ </span>
+ </div>
+ <Show when={preflight()}>
+ <div class="flex items-center justify-between gap-2">
+ <span class="text-muted">Dry run</span>
+ <span class="font-medium text-base-content">
+ {preflight()?.dryRunAvailable ? 'Available' : 'Not available'}
+ </span>
+ </div>
+ </Show>
+ <Show when={preflight()?.intendedChange}>
+ <div class="flex items-start justify-between gap-2">
+ <span class="text-muted">Intent</span>
+ <span class="max-w-[70%] text-right font-medium text-base-content">
+ {preflight()?.intendedChange}
+ </span>
+ </div>
+ </Show>
+ <Show when={(preflight()?.safetyChecks || []).length > 0}>
+ <div class="space-y-1">
+ <div class="text-muted">Safety checks</div>
+ <ul class="space-y-0.5 pl-3 text-base-content">
+ <For each={preflight()?.safetyChecks || []}>
+ {(check) => <li class="list-disc">{check}</li>}
+ </For>
+ </ul>
+ </div>
+ </Show>
+ <Show when={result()}>
+ <div class="rounded border border-border bg-surface px-2 py-1 text-[10px]">
+ <div class="font-medium text-base-content">
+ {result()?.success ? 'Result' : 'Failure'}
+ </div>
+ <Show when={result()?.output || result()?.errorMessage}>
+ <div class="mt-0.5 text-muted">{result()?.output || result()?.errorMessage}</div>
+ </Show>
+ </div>
+ </Show>
+ </div>
+ </div>
+ );
+};
+
+export const ResourceActionHistory: Component<ResourceActionHistoryProps> = (props) => (
+ <div
+ data-testid="resource-action-history-section"
+ class="w-full rounded border border-border bg-surface p-3 shadow-sm"
+ >
+ <div class="flex items-center justify-between gap-3">
+ <div>
+ <div class="text-[11px] font-medium uppercase tracking-wide text-base-content">
+ Action history
+ </div>
+ <Show when={props.count > 0}>
+ <div class="mt-1 text-[10px] text-muted">Actions {props.count}</div>
+ </Show>
+ </div>
+ <div class="text-right text-[10px] text-muted">{props.loadingLabel}</div>
+ </div>
+
+ <Show when={props.error}>
+ <div class="mt-2 rounded border border-amber-200 bg-amber-50 px-2 py-1.5 text-[10px] text-amber-700 dark:border-amber-700 dark:bg-amber-900 dark:text-amber-200">
+ <div class="flex items-start justify-between gap-2">
+ <span>{props.error}</span>
+ <button
+ type="button"
+ class="shrink-0 font-medium text-amber-700 underline dark:text-amber-200"
+ onClick={() => void props.onRetry()}
+ >
+ Retry
+ </button>
+ </div>
+ </div>
+ </Show>
+
+ <Show
+ when={props.audits.length > 0}
+ fallback={
+ <div class="mt-3 rounded border border-dashed border-border bg-surface-hover px-2 py-2 text-[10px] text-muted">
+ No actions yet.
+ </div>
+ }
+ >
+ <div class="mt-3 space-y-2">
+ <For each={props.audits}>{(audit) => <ActionHistoryRow audit={audit} />}</For>
+ </div>
+ </Show>
+ </div>
+);
diff --git a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx
index 384525e0d6..16afc961eb 100644
--- a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx
+++ b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx
@@ -27,6 +27,7 @@ import {
import { ResourceCorrelationSummary } from './ResourceCorrelationSummary';
import { ResourceChangeSummary } from './ResourceChangeSummary';
import { ResourceFacetSummary } from './ResourceFacetSummary';
+import { ResourceActionHistory } from './ResourceActionHistory';
import {
RESOURCE_CHANGE_KIND_ORDER,
RESOURCE_CHANGE_SOURCE_ADAPTER_ORDER,
@@ -45,9 +46,7 @@ import {
RESOURCE_SAFE_SUMMARY_LABEL,
} from '@/utils/resourceAnalysisPresentation';
import { formatInteger } from './resourceDetailMappers';
-import {
- ResourceDetailDrawerSupportDisclosure as SupportDisclosure,
-} from './ResourceDetailDrawerSupportDisclosure';
+import { ResourceDetailDrawerSupportDisclosure as SupportDisclosure } from './ResourceDetailDrawerSupportDisclosure';
import type { UseResourceDetailDrawerStateResult } from './useResourceDetailDrawerState';
interface ResourceDetailDrawerOverviewTabProps {
@@ -164,7 +163,10 @@ export const ResourceDetailDrawerOverviewTab: Component<ResourceDetailDrawerOver
<Show when={showPlatformId}>
<div class="flex items-center justify-between gap-2">
<span class="text-muted">Platform ID</span>
- <span class="font-medium text-base-content truncate" title={resource.platformId}>
+ <span
+ class="font-medium text-base-content truncate"
+ title={resource.platformId}
+ >
{resource.platformId}
</span>
</div>
@@ -276,10 +278,7 @@ export const ResourceDetailDrawerOverviewTab: Component<ResourceDetailDrawerOver
</Card>
</div>
- <div
- data-testid="resource-secondary-sections"
- class="space-y-3"
- >
+ <div data-testid="resource-secondary-sections" class="space-y-3">
<div
data-testid="resource-change-history-section"
class="w-full rounded border border-border bg-surface p-3 shadow-sm"
@@ -523,6 +522,16 @@ export const ResourceDetailDrawerOverviewTab: Component<ResourceDetailDrawerOver
</Show>
</div>
+ <Show when={drawer.actionAuditAvailable()}>
+ <ResourceActionHistory
+ audits={drawer.sortedActionAudits()}
+ count={drawer.actionAuditCount()}
+ loadingLabel={drawer.actionAuditLoadingLabel()}
+ error={drawer.actionAuditError()}
+ onRetry={drawer.refetchActionAudits}
+ />
+ </Show>
+
<Show
when={
drawer.hasServiceDetails() ||
@@ -536,748 +545,769 @@ export const ResourceDetailDrawerOverviewTab: Component<ResourceDetailDrawerOver
data-testid="resource-support-sections"
class="flex flex-wrap gap-3 [&>*]:flex-1 [&>*]:basis-[calc(50%-0.375rem)] [&>*]:min-w-[260px] [&>*]:max-w-full [&>*]:overflow-hidden"
>
-
- <Show when={drawer.hasAccessContext()}>
- <SupportDisclosure
- title="Access"
- summary={drawer.accessSummary()}
- expanded={drawer.showAccessContext()}
- onToggle={() => drawer.setShowAccessContext((value) => !value)}
- showLabel="Show access"
- hideLabel="Hide access"
- class="h-full"
- contentClass="mt-3 space-y-3"
- dataTestId="resource-access-section"
- >
- <Show when={drawer.relatedLinks().length > 0}>
- <div class="space-y-1">
- <div class="text-[10px] font-medium uppercase tracking-wide text-base-content">
- Links
- </div>
- <div class="flex flex-wrap gap-2">
- <For each={drawer.relatedLinks()}>
- {(link) => (
- <a
- href={link.href}
- aria-label={link.ariaLabel}
- class="inline-flex items-center rounded border border-blue-200 bg-blue-50 px-2.5 py-1 text-[11px] font-medium text-blue-700 transition-colors hover:bg-blue-100 dark:border-blue-700 dark:bg-blue-900 dark:text-blue-200 dark:hover:bg-blue-900"
- >
- {link.compactLabel}
- </a>
- )}
- </For>
- </div>
- </div>
- </Show>
-
- <Show when={drawer.discoveryConfig()}>
- {(config) => (
- <div class="space-y-3">
- <WebInterfaceUrlField
- metadataKind={config().metadataKind}
- metadataId={config().metadataId}
- targetLabel={config().targetLabel}
- title="Web interface"
- embedded
- />
-
- <div class="space-y-2 border-t border-border pt-3" data-testid="resource-access-analysis">
- <div class="flex flex-wrap items-start justify-between gap-3">
- <div>
- <div class="text-[10px] font-medium uppercase tracking-wide text-base-content">
- Analysis
- </div>
- <Show when={drawer.discoveryContextSummary()}>
- <div class="mt-1 text-[10px] text-base-content">
- {drawer.discoveryContextSummary()}
- </div>
- </Show>
- </div>
- <button
- type="button"
- onClick={() => drawer.setShowDiscoveryContext((value) => !value)}
- class="inline-flex items-center rounded-md border border-border bg-surface px-2.5 py-1 text-[10px] font-medium text-base-content transition-colors hover:bg-base"
- >
- {drawer.showDiscoveryContext() ? 'Hide analysis' : 'Open analysis'}
- </button>
- </div>
-
- <Show when={drawer.showDiscoveryContext()}>
- <Suspense
- fallback={
- <div class="flex items-center justify-center py-8">
- <div class="animate-spin h-6 w-6 border-2 border-blue-500 border-t-transparent rounded-full" />
- <span class="ml-2 text-sm text-muted">{getDiscoveryLoadingState().text}</span>
- </div>
- }
- >
- <DiscoveryTab
- resourceType={config().resourceType}
- agentId={config().agentId}
- resourceId={config().resourceId}
- hostname={config().hostname}
- />
- </Suspense>
- </Show>
- </div>
- </div>
- )}
- </Show>
- </SupportDisclosure>
- </Show>
-
- <Show when={drawer.hasInvestigationContext()}>
- <SupportDisclosure
- title="Context"
- summary={drawer.investigationContextSummary()}
- expanded={drawer.showInvestigationContext()}
- onToggle={() => drawer.setShowInvestigationContext((value) => !value)}
- showLabel="Show context"
- hideLabel="Hide context"
- class="h-full"
- contentClass="mt-3 space-y-3"
- dataTestId="resource-investigation-context"
- >
- <Show when={drawer.resourceIntelligence()}>
- {(intel) => (
- <div class="space-y-1.5 text-[11px]">
- <div class="flex items-center justify-between gap-2">
- <span class="text-muted uppercase tracking-wide">{RESOURCE_ANALYSIS_LABEL}</span>
- </div>
- <div class="flex items-center justify-between gap-2">
- <span class="text-muted">Health</span>
- <span class="font-semibold text-base-content">
- {intel().health.grade} · {Math.round(intel().health.score)}/100
- </span>
- </div>
- <div class="flex items-center justify-between gap-2">
- <span class="text-muted">Trend</span>
- <span class="font-semibold capitalize text-base-content">
- {intel().health.trend}
- </span>
- </div>
- <div class="flex items-center justify-between gap-2">
- <span class="text-muted">Notes</span>
- <span class="font-semibold text-base-content">{intel().note_count}</span>
- </div>
- <ResourceChangeSummary
- class="space-y-0"
- title="Latest canonical change"
- changes={intel().recent_changes}
- resolveResourceLabel={drawer.resolveResourceLabel}
- maxChanges={1}
- compact
- />
- <Show when={drawer.hasCorrelationContext()}>
- <div data-testid="resource-correlation-context" class="space-y-1.5">
- <div class="flex flex-wrap items-center justify-between gap-2">
- <span class="text-[10px] font-medium uppercase tracking-wide text-base-content">
- Correlations
- </span>
- <button
- type="button"
- onClick={() => drawer.setShowCorrelationContext((value) => !value)}
- class="inline-flex items-center rounded-md border border-border bg-surface px-2.5 py-1 text-[10px] font-medium text-base-content transition-colors hover:bg-surface-hover"
- >
- {drawer.showCorrelationContext() ? 'Hide correlations' : 'Show correlations'}
- </button>
- </div>
-
- <Show when={drawer.showCorrelationContext()}>
- <div class="pt-1">
- <ResourceCorrelationSummary
- title="Correlations"
- dependencies={drawer.resourceDependencies()}
- dependents={drawer.resourceDependents()}
- correlations={drawer.resourceCorrelations()}
- resolveResourceLabel={drawer.resolveResourceLabel}
- showLastSeen
- />
- </div>
- </Show>
+ <Show when={drawer.hasAccessContext()}>
+ <SupportDisclosure
+ title="Access"
+ summary={drawer.accessSummary()}
+ expanded={drawer.showAccessContext()}
+ onToggle={() => drawer.setShowAccessContext((value) => !value)}
+ showLabel="Show access"
+ hideLabel="Hide access"
+ class="h-full"
+ contentClass="mt-3 space-y-3"
+ dataTestId="resource-access-section"
+ >
+ <Show when={drawer.relatedLinks().length > 0}>
+ <div class="space-y-1">
+ <div class="text-[10px] font-medium uppercase tracking-wide text-base-content">
+ Links
</div>
- </Show>
- </div>
- )}
- </Show>
-
- <Show when={drawer.hasGovernanceData()}>
- <div class="space-y-1.5 text-[11px]">
- <div class="flex items-center justify-between gap-2">
- <span class="text-muted uppercase tracking-wide">Governance</span>
- </div>
- <Show when={resource.policy}>
- <div class="flex items-center justify-between gap-2">
- <span class="text-muted">Sensitivity</span>
- <span class="font-semibold text-base-content">
- {getResourceSensitivityLabel(resource.policy?.sensitivity)}
- </span>
- </div>
- <div class="flex items-center justify-between gap-2">
- <span class="text-muted">Routing</span>
- <span class="font-semibold text-base-content">
- {getResourceRoutingScopeLabel(resource.policy?.routing.scope)}
- </span>
- </div>
- </Show>
- <Show when={drawer.policyRedactions().length > 0 || drawer.governanceSummary()}>
- <div class="flex items-center justify-between gap-2">
- <span class="text-muted">Redactions</span>
- <span class="font-semibold text-base-content">
- {drawer.policyRedactions().length}
- </span>
- </div>
- </Show>
- <Show when={drawer.policyRedactions().length > 0}>
- <div class="flex flex-col gap-1">
- <span class="text-muted">Redaction labels</span>
- <div class="flex flex-wrap gap-1">
- <For each={drawer.policyRedactions()}>
- {(label) => (
- <span class="inline-flex items-center rounded bg-surface-alt px-1.5 py-0.5 text-[10px]">
- {label}
- </span>
+ <div class="flex flex-wrap gap-2">
+ <For each={drawer.relatedLinks()}>
+ {(link) => (
+ <a
+ href={link.href}
+ aria-label={link.ariaLabel}
+ class="inline-flex items-center rounded border border-blue-200 bg-blue-50 px-2.5 py-1 text-[11px] font-medium text-blue-700 transition-colors hover:bg-blue-100 dark:border-blue-700 dark:bg-blue-900 dark:text-blue-200 dark:hover:bg-blue-900"
+ >
+ {link.compactLabel}
+ </a>
)}
</For>
</div>
</div>
</Show>
- <Show when={drawer.governanceSummary()}>
- <div class="flex flex-col gap-1">
- <span class="text-muted">{RESOURCE_SAFE_SUMMARY_LABEL}</span>
- <div class="rounded border border-border bg-surface-hover px-2 py-1.5 text-[10px] text-base-content">
- {drawer.governanceSummary()}
- </div>
- </div>
- </Show>
- </div>
- </Show>
- </SupportDisclosure>
- </Show>
- <Show when={drawer.hasServiceDetails()}>
- <SupportDisclosure
- title="Service"
- summary={drawer.serviceDetailsSummary()}
- expanded={drawer.showServiceDetails()}
- onToggle={() => drawer.setShowServiceDetails((value) => !value)}
- showLabel="Show service"
- hideLabel="Hide service"
- class="h-full"
- contentClass="mt-3 space-y-3"
- dataTestId="resource-service-details-section"
- >
- <Show when={resource.type === 'docker-host'}>
- <div class="rounded border border-sky-200 bg-sky-50 p-3 dark:border-sky-700 dark:bg-sky-900">
- <div class="mb-2 flex items-center justify-between gap-2">
- <div class="text-[11px] font-medium uppercase tracking-wide text-sky-700 dark:text-sky-300">
- Docker runtime
- </div>
- <Show when={drawer.dockerHostData()?.runtime}>
- <span
- class="max-w-[55%] truncate text-[10px] text-sky-700 dark:text-sky-300"
- title={drawer.dockerHostData()?.runtime}
- >
- {drawer.dockerHostData()?.runtime}
- </span>
- </Show>
- </div>
+ <Show when={drawer.discoveryConfig()}>
+ {(config) => (
+ <div class="space-y-3">
+ <WebInterfaceUrlField
+ metadataKind={config().metadataKind}
+ metadataId={config().metadataId}
+ targetLabel={config().targetLabel}
+ title="Web interface"
+ embedded
+ />
- <div class="space-y-1.5 text-[11px]">
- <div class="flex items-center justify-between gap-2">
- <span class="text-muted">Containers</span>
- <span class="font-medium text-base-content">
- {formatInteger(drawer.dockerContainerCount())}
- </span>
- </div>
- <div class="flex items-center justify-between gap-2">
- <span class="text-muted">Updates</span>
- <span
- class={`font-medium ${drawer.dockerUpdatesAvailable() > 0 ? 'text-sky-700 dark:text-sky-300' : 'text-base-content'}`}
- >
- {formatInteger(drawer.dockerUpdatesAvailable())}
- </span>
- </div>
- <Show when={drawer.dockerUpdatesCheckedRelative()}>
- <div class="flex items-center justify-between gap-2">
- <span class="text-muted">Checked</span>
- <span class="font-medium text-base-content">
- {drawer.dockerUpdatesCheckedRelative()}
- </span>
+ <div
+ class="space-y-2 border-t border-border pt-3"
+ data-testid="resource-access-analysis"
+ >
+ <div class="flex flex-wrap items-start justify-between gap-3">
+ <div>
+ <div class="text-[10px] font-medium uppercase tracking-wide text-base-content">
+ Analysis
+ </div>
+ <Show when={drawer.discoveryContextSummary()}>
+ <div class="mt-1 text-[10px] text-base-content">
+ {drawer.discoveryContextSummary()}
+ </div>
+ </Show>
+ </div>
+ <button
+ type="button"
+ onClick={() => drawer.setShowDiscoveryContext((value) => !value)}
+ class="inline-flex items-center rounded-md border border-border bg-surface px-2.5 py-1 text-[10px] font-medium text-base-content transition-colors hover:bg-base"
+ >
+ {drawer.showDiscoveryContext() ? 'Hide analysis' : 'Open analysis'}
+ </button>
+ </div>
+
+ <Show when={drawer.showDiscoveryContext()}>
+ <Suspense
+ fallback={
+ <div class="flex items-center justify-center py-8">
+ <div class="animate-spin h-6 w-6 border-2 border-blue-500 border-t-transparent rounded-full" />
+ <span class="ml-2 text-sm text-muted">
+ {getDiscoveryLoadingState().text}
+ </span>
+ </div>
+ }
+ >
+ <DiscoveryTab
+ resourceType={config().resourceType}
+ agentId={config().agentId}
+ resourceId={config().resourceId}
+ hostname={config().hostname}
+ />
+ </Suspense>
+ </Show>
+ </div>
</div>
- </Show>
+ )}
+ </Show>
+ </SupportDisclosure>
+ </Show>
- <Show when={drawer.showDockerUpdateControls()}>
- <div class="space-y-1.5 border-t border-sky-200 pt-2 dark:border-sky-700">
- <Show when={drawer.dockerHostCommand()?.type || drawer.dockerHostCommand()?.status}>
- <div class="rounded border border-sky-200 bg-surface px-2 py-1.5 text-[10px] dark:border-sky-700">
- <div class="flex items-center justify-between gap-2">
- <span class="text-muted">Action</span>
- <span class="font-medium text-base-content">
- {formatIdentifierLabel(drawer.dockerHostCommand()?.type, {
- fallback: 'command',
- })}
+ <Show when={drawer.hasInvestigationContext()}>
+ <SupportDisclosure
+ title="Context"
+ summary={drawer.investigationContextSummary()}
+ expanded={drawer.showInvestigationContext()}
+ onToggle={() => drawer.setShowInvestigationContext((value) => !value)}
+ showLabel="Show context"
+ hideLabel="Hide context"
+ class="h-full"
+ contentClass="mt-3 space-y-3"
+ dataTestId="resource-investigation-context"
+ >
+ <Show when={drawer.resourceIntelligence()}>
+ {(intel) => (
+ <div class="space-y-1.5 text-[11px]">
+ <div class="flex items-center justify-between gap-2">
+ <span class="text-muted uppercase tracking-wide">
+ {RESOURCE_ANALYSIS_LABEL}
+ </span>
+ </div>
+ <div class="flex items-center justify-between gap-2">
+ <span class="text-muted">Health</span>
+ <span class="font-semibold text-base-content">
+ {intel().health.grade} · {Math.round(intel().health.score)}/100
+ </span>
+ </div>
+ <div class="flex items-center justify-between gap-2">
+ <span class="text-muted">Trend</span>
+ <span class="font-semibold capitalize text-base-content">
+ {intel().health.trend}
+ </span>
+ </div>
+ <div class="flex items-center justify-between gap-2">
+ <span class="text-muted">Notes</span>
+ <span class="font-semibold text-base-content">{intel().note_count}</span>
+ </div>
+ <ResourceChangeSummary
+ class="space-y-0"
+ title="Latest canonical change"
+ changes={intel().recent_changes}
+ resolveResourceLabel={drawer.resolveResourceLabel}
+ maxChanges={1}
+ compact
+ />
+ <Show when={drawer.hasCorrelationContext()}>
+ <div data-testid="resource-correlation-context" class="space-y-1.5">
+ <div class="flex flex-wrap items-center justify-between gap-2">
+ <span class="text-[10px] font-medium uppercase tracking-wide text-base-content">
+ Correlations
</span>
- </div>
- <div class="mt-1 flex items-center justify-between gap-2">
- <span class="text-muted">State</span>
- <span
- class={`font-medium ${drawer.dockerHostCommandActive() ? 'text-sky-700 dark:text-sky-300' : 'text-base-content'}`}
+ <button
+ type="button"
+ onClick={() => drawer.setShowCorrelationContext((value) => !value)}
+ class="inline-flex items-center rounded-md border border-border bg-surface px-2.5 py-1 text-[10px] font-medium text-base-content transition-colors hover:bg-surface-hover"
>
- {formatIdentifierLabel(drawer.dockerHostCommand()?.status, {
- fallback: 'unknown',
- })}
- </span>
+ {drawer.showCorrelationContext()
+ ? 'Hide correlations'
+ : 'Show correlations'}
+ </button>
</div>
- <Show when={drawer.dockerHostCommand()?.message}>
- <div
- class="mt-1 text-muted truncate"
- title={drawer.dockerHostCommand()?.message}
- >
- {drawer.dockerHostCommand()?.message}
- </div>
- </Show>
- <Show when={drawer.dockerHostCommand()?.failureReason}>
- <div
- class="mt-1 text-red-700 dark:text-red-300 truncate"
- title={drawer.dockerHostCommand()?.failureReason}
- >
- {drawer.dockerHostCommand()?.failureReason}
+
+ <Show when={drawer.showCorrelationContext()}>
+ <div class="pt-1">
+ <ResourceCorrelationSummary
+ title="Correlations"
+ dependencies={drawer.resourceDependencies()}
+ dependents={drawer.resourceDependents()}
+ correlations={drawer.resourceCorrelations()}
+ resolveResourceLabel={drawer.resolveResourceLabel}
+ showLastSeen
+ />
</div>
</Show>
</div>
</Show>
+ </div>
+ )}
+ </Show>
- <Show when={drawer.dockerActionError()}>
- <div class="rounded border border-red-200 bg-red-50 px-2 py-1.5 text-[10px] text-red-700 dark:border-red-700 dark:bg-red-900 dark:text-red-200">
- {drawer.dockerActionError()}
+ <Show when={drawer.hasGovernanceData()}>
+ <div class="space-y-1.5 text-[11px]">
+ <div class="flex items-center justify-between gap-2">
+ <span class="text-muted uppercase tracking-wide">Governance</span>
+ </div>
+ <Show when={resource.policy}>
+ <div class="flex items-center justify-between gap-2">
+ <span class="text-muted">Sensitivity</span>
+ <span class="font-semibold text-base-content">
+ {getResourceSensitivityLabel(resource.policy?.sensitivity)}
+ </span>
+ </div>
+ <div class="flex items-center justify-between gap-2">
+ <span class="text-muted">Routing</span>
+ <span class="font-semibold text-base-content">
+ {getResourceRoutingScopeLabel(resource.policy?.routing.scope)}
+ </span>
+ </div>
+ </Show>
+ <Show when={drawer.policyRedactions().length > 0 || drawer.governanceSummary()}>
+ <div class="flex items-center justify-between gap-2">
+ <span class="text-muted">Redactions</span>
+ <span class="font-semibold text-base-content">
+ {drawer.policyRedactions().length}
+ </span>
+ </div>
+ </Show>
+ <Show when={drawer.policyRedactions().length > 0}>
+ <div class="flex flex-col gap-1">
+ <span class="text-muted">Redaction labels</span>
+ <div class="flex flex-wrap gap-1">
+ <For each={drawer.policyRedactions()}>
+ {(label) => (
+ <span class="inline-flex items-center rounded bg-surface-alt px-1.5 py-0.5 text-[10px]">
+ {label}
+ </span>
+ )}
+ </For>
</div>
- </Show>
- <Show when={drawer.dockerActionNote()}>
- <div class="rounded border border-sky-200 bg-surface px-2 py-1.5 text-[10px] text-base-content dark:border-sky-700">
- {drawer.dockerActionNote()}
+ </div>
+ </Show>
+ <Show when={drawer.governanceSummary()}>
+ <div class="flex flex-col gap-1">
+ <span class="text-muted">{RESOURCE_SAFE_SUMMARY_LABEL}</span>
+ <div class="rounded border border-border bg-surface-hover px-2 py-1.5 text-[10px] text-base-content">
+ {drawer.governanceSummary()}
</div>
- </Show>
-
- <div class="flex flex-wrap items-center gap-2">
- <button
- type="button"
- disabled={
- drawer.dockerActionBusy() ||
- drawer.dockerUpdateActionsLoading() ||
- drawer.dockerHostCommandActive() ||
- drawer.dockerHostSourceId() === null
- }
- onClick={drawer.queueDockerUpdateCheck}
- class="rounded-md border border-border bg-surface px-2.5 py-1 text-[11px] font-semibold text-base-content hover:bg-surface-hover disabled:opacity-60"
- title={
- drawer.dockerUpdateActionsLoading() ? 'Loading settings...' : undefined
- }
- >
- Check now
- </button>
-
- <button
- type="button"
- disabled={
- drawer.dockerActionBusy() ||
- drawer.dockerUpdateActionsLoading() ||
- drawer.dockerUpdateActionsDisabled() ||
- drawer.dockerHostCommandActive() ||
- drawer.dockerHostSourceId() === null ||
- drawer.dockerUpdatesAvailable() <= 0
- }
- onClick={drawer.queueDockerUpdateAll}
- class="rounded-md border border-sky-200 bg-sky-600 px-2.5 py-1 text-[11px] font-semibold text-white hover:bg-sky-700 disabled:opacity-60 disabled:hover:bg-sky-600 dark:border-sky-700 dark:bg-sky-600 dark:hover:bg-sky-500 dark:disabled:hover:bg-sky-600"
- title={
- drawer.dockerUpdateActionsDisabled()
- ? 'Updates disabled by server settings.'
- : undefined
- }
- >
- {drawer.confirmUpdateAll()
- ? 'Confirm update'
- : `Update all${drawer.dockerUpdatesAvailable() > 0 ? ` (${drawer.dockerUpdatesAvailable()})` : ''}`}
- </button>
</div>
- </div>
- </Show>
-
- <button
- type="button"
- onClick={drawer.toggleDockerUpdateControls}
- class="inline-flex items-center rounded-md border border-sky-200 bg-surface px-2.5 py-1 text-[10px] font-medium text-sky-700 transition-colors hover:bg-base dark:border-sky-700 dark:text-sky-300"
- >
- {drawer.showDockerUpdateControls() ? 'Hide actions' : 'Show actions'}
- </button>
- </div>
- </div>
+ </Show>
+ </div>
+ </Show>
+ </SupportDisclosure>
</Show>
- <Show when={drawer.pbsData()}>
- {(pbs) => {
- const connection = getServiceHealthPresentation(resource.status, pbs().connectionHealth);
- return (
- <div class="rounded border border-indigo-200 bg-indigo-50 p-3 dark:border-indigo-700 dark:bg-indigo-900">
+ <Show when={drawer.hasServiceDetails()}>
+ <SupportDisclosure
+ title="Service"
+ summary={drawer.serviceDetailsSummary()}
+ expanded={drawer.showServiceDetails()}
+ onToggle={() => drawer.setShowServiceDetails((value) => !value)}
+ showLabel="Show service"
+ hideLabel="Hide service"
+ class="h-full"
+ contentClass="mt-3 space-y-3"
+ dataTestId="resource-service-details-section"
+ >
+ <Show when={resource.type === 'docker-host'}>
+ <div class="rounded border border-sky-200 bg-sky-50 p-3 dark:border-sky-700 dark:bg-sky-900">
<div class="mb-2 flex items-center justify-between gap-2">
- <div class="text-[11px] font-medium uppercase tracking-wide text-indigo-700 dark:text-indigo-300">
- PBS
+ <div class="text-[11px] font-medium uppercase tracking-wide text-sky-700 dark:text-sky-300">
+ Docker runtime
</div>
- <Show when={pbs().hostname}>
+ <Show when={drawer.dockerHostData()?.runtime}>
<span
- class="max-w-[55%] truncate text-[10px] text-indigo-700 dark:text-indigo-300"
- title={pbs().hostname}
+ class="max-w-[55%] truncate text-[10px] text-sky-700 dark:text-sky-300"
+ title={drawer.dockerHostData()?.runtime}
>
- {pbs().hostname}
+ {drawer.dockerHostData()?.runtime}
</span>
</Show>
</div>
+
<div class="space-y-1.5 text-[11px]">
<div class="flex items-center justify-between gap-2">
- <span class="text-muted">State</span>
- <span class={`font-medium ${connection.text}`}>{connection.label}</span>
+ <span class="text-muted">Containers</span>
+ <span class="font-medium text-base-content">
+ {formatInteger(drawer.dockerContainerCount())}
+ </span>
</div>
- <Show when={pbs().version}>
- <div class="flex items-center justify-between gap-2">
- <span class="text-muted">Version</span>
- <span class="font-medium text-base-content">{pbs().version}</span>
- </div>
- </Show>
- <Show when={pbs().uptimeSeconds || resource.uptime}>
+ <div class="flex items-center justify-between gap-2">
+ <span class="text-muted">Updates</span>
+ <span
+ class={`font-medium ${drawer.dockerUpdatesAvailable() > 0 ? 'text-sky-700 dark:text-sky-300' : 'text-base-content'}`}
+ >
+ {formatInteger(drawer.dockerUpdatesAvailable())}
+ </span>
+ </div>
+ <Show when={drawer.dockerUpdatesCheckedRelative()}>
<div class="flex items-center justify-between gap-2">
- <span class="text-muted">Uptime</span>
+ <span class="text-muted">Checked</span>
<span class="font-medium text-base-content">
- {formatUptime(pbs().uptimeSeconds ?? resource.uptime ?? 0)}
- </span>
- </div>
- </Show>
- <Show when={drawer.pbsActiveTaskCount() > 0}>
- <div class="flex items-center justify-between gap-2">
- <span class="text-muted">Active tasks</span>
- <span class="font-medium text-emerald-700 dark:text-emerald-300">
- {formatInteger(drawer.pbsActiveTaskCount())}
+ {drawer.dockerUpdatesCheckedRelative()}
</span>
</div>
</Show>
- <Show when={drawer.showPbsJobDetail()}>
- <div class="space-y-1.5 border-t border-indigo-200 pt-2 dark:border-indigo-700">
- <div class="grid grid-cols-2 gap-2 md:grid-cols-3">
- <div class="rounded border border-indigo-200 bg-surface px-2 py-1.5 dark:border-indigo-700">
- <div class="text-[10px] text-muted">Datastores</div>
- <div class="text-sm font-semibold text-base-content">
- {formatInteger(pbs().datastoreCount)}
- </div>
- </div>
- <div class="rounded border border-indigo-200 bg-surface px-2 py-1.5 dark:border-indigo-700">
- <div class="text-[10px] text-muted">Jobs</div>
- <div class="text-sm font-semibold text-base-content">
- {formatInteger(drawer.pbsJobTotal())}
- </div>
- </div>
- <Show when={drawer.pbsActiveTaskCount() > 0}>
- <div class="rounded border border-emerald-200 bg-emerald-50 px-2 py-1.5 dark:border-emerald-700 dark:bg-emerald-950/40">
- <div class="text-[10px] text-muted">Active</div>
- <div class="text-sm font-semibold text-emerald-700 dark:text-emerald-300">
- {formatInteger(drawer.pbsActiveTaskCount())}
- </div>
- </div>
- </Show>
- </div>
- <Show when={drawer.pbsActiveTaskCount() > 0}>
- <div
- data-testid="pbs-active-tasks"
- class="rounded border border-emerald-200 bg-surface px-2 py-1.5 dark:border-emerald-700"
- >
+
+ <Show when={drawer.showDockerUpdateControls()}>
+ <div class="space-y-1.5 border-t border-sky-200 pt-2 dark:border-sky-700">
+ <Show
+ when={
+ drawer.dockerHostCommand()?.type || drawer.dockerHostCommand()?.status
+ }
+ >
+ <div class="rounded border border-sky-200 bg-surface px-2 py-1.5 text-[10px] dark:border-sky-700">
<div class="flex items-center justify-between gap-2">
- <span class="text-[10px] font-medium uppercase tracking-wide text-muted">
- Active tasks
- </span>
- <span class="text-[10px] font-semibold text-emerald-700 dark:text-emerald-300">
- {formatInteger(drawer.pbsActiveTaskCount())}
+ <span class="text-muted">Action</span>
+ <span class="font-medium text-base-content">
+ {formatIdentifierLabel(drawer.dockerHostCommand()?.type, {
+ fallback: 'command',
+ })}
</span>
</div>
- <div class="mt-2 space-y-2 border-t border-emerald-200 pt-2 dark:border-emerald-700">
- <For each={drawer.pbsActiveTasks()}>
- {(task) => (
- <div class="flex items-start justify-between gap-2 text-[10px]">
- <div class="min-w-0">
- <div
- class="truncate font-medium text-base-content"
- title={task.label}
- >
- {task.label}
- </div>
- <Show when={task.context}>
- <div
- class="truncate text-muted"
- title={task.context ?? undefined}
- >
- {task.context}
- </div>
- </Show>
- <Show when={task.error}>
- <div
- class="truncate text-rose-700 dark:text-rose-300"
- title={task.error}
- >
- {task.error}
- </div>
- </Show>
- </div>
- <span class="shrink-0 rounded-full border border-emerald-200 bg-emerald-50 px-2 py-0.5 font-medium text-emerald-700 dark:border-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-300">
- {task.statusLabel}
- </span>
- </div>
- )}
- </For>
+ <div class="mt-1 flex items-center justify-between gap-2">
+ <span class="text-muted">State</span>
+ <span
+ class={`font-medium ${drawer.dockerHostCommandActive() ? 'text-sky-700 dark:text-sky-300' : 'text-base-content'}`}
+ >
+ {formatIdentifierLabel(drawer.dockerHostCommand()?.status, {
+ fallback: 'unknown',
+ })}
+ </span>
</div>
+ <Show when={drawer.dockerHostCommand()?.message}>
+ <div
+ class="mt-1 text-muted truncate"
+ title={drawer.dockerHostCommand()?.message}
+ >
+ {drawer.dockerHostCommand()?.message}
+ </div>
+ </Show>
+ <Show when={drawer.dockerHostCommand()?.failureReason}>
+ <div
+ class="mt-1 text-red-700 dark:text-red-300 truncate"
+ title={drawer.dockerHostCommand()?.failureReason}
+ >
+ {drawer.dockerHostCommand()?.failureReason}
+ </div>
+ </Show>
</div>
</Show>
- <details class="rounded border border-indigo-200 bg-surface px-2 py-1.5 dark:border-indigo-700">
- <summary class="flex cursor-pointer list-none items-center justify-between text-[10px] font-medium text-muted">
- <span>Types</span>
- <span class="text-muted">{drawer.pbsVisibleJobBreakdown().length}</span>
- </summary>
- <div class="mt-2 grid grid-cols-2 gap-x-3 gap-y-1 border-t border-indigo-200 pt-2 text-[10px] dark:border-indigo-700">
- <For each={drawer.pbsVisibleJobBreakdown()}>
- {(entry) => (
- <span class="text-muted">
- {entry.label}:{' '}
- <span class="font-medium text-base-content">
- {formatInteger(entry.value)}
- </span>
- </span>
- )}
- </For>
+
+ <Show when={drawer.dockerActionError()}>
+ <div class="rounded border border-red-200 bg-red-50 px-2 py-1.5 text-[10px] text-red-700 dark:border-red-700 dark:bg-red-900 dark:text-red-200">
+ {drawer.dockerActionError()}
</div>
- </details>
+ </Show>
+ <Show when={drawer.dockerActionNote()}>
+ <div class="rounded border border-sky-200 bg-surface px-2 py-1.5 text-[10px] text-base-content dark:border-sky-700">
+ {drawer.dockerActionNote()}
+ </div>
+ </Show>
+
+ <div class="flex flex-wrap items-center gap-2">
+ <button
+ type="button"
+ disabled={
+ drawer.dockerActionBusy() ||
+ drawer.dockerUpdateActionsLoading() ||
+ drawer.dockerHostCommandActive() ||
+ drawer.dockerHostSourceId() === null
+ }
+ onClick={drawer.queueDockerUpdateCheck}
+ class="rounded-md border border-border bg-surface px-2.5 py-1 text-[11px] font-semibold text-base-content hover:bg-surface-hover disabled:opacity-60"
+ title={
+ drawer.dockerUpdateActionsLoading()
+ ? 'Loading settings...'
+ : undefined
+ }
+ >
+ Check now
+ </button>
+
+ <button
+ type="button"
+ disabled={
+ drawer.dockerActionBusy() ||
+ drawer.dockerUpdateActionsLoading() ||
+ drawer.dockerUpdateActionsDisabled() ||
+ drawer.dockerHostCommandActive() ||
+ drawer.dockerHostSourceId() === null ||
+ drawer.dockerUpdatesAvailable() <= 0
+ }
+ onClick={drawer.queueDockerUpdateAll}
+ class="rounded-md border border-sky-200 bg-sky-600 px-2.5 py-1 text-[11px] font-semibold text-white hover:bg-sky-700 disabled:opacity-60 disabled:hover:bg-sky-600 dark:border-sky-700 dark:bg-sky-600 dark:hover:bg-sky-500 dark:disabled:hover:bg-sky-600"
+ title={
+ drawer.dockerUpdateActionsDisabled()
+ ? 'Updates disabled by server settings.'
+ : undefined
+ }
+ >
+ {drawer.confirmUpdateAll()
+ ? 'Confirm update'
+ : `Update all${drawer.dockerUpdatesAvailable() > 0 ? ` (${drawer.dockerUpdatesAvailable()})` : ''}`}
+ </button>
+ </div>
</div>
</Show>
+
<button
type="button"
- onClick={() => drawer.setShowPbsJobDetail((value) => !value)}
- class="inline-flex items-center rounded-md border border-indigo-200 bg-surface px-2.5 py-1 text-[10px] font-medium text-indigo-700 transition-colors hover:bg-base dark:border-indigo-700 dark:text-indigo-300"
+ onClick={drawer.toggleDockerUpdateControls}
+ class="inline-flex items-center rounded-md border border-sky-200 bg-surface px-2.5 py-1 text-[10px] font-medium text-sky-700 transition-colors hover:bg-base dark:border-sky-700 dark:text-sky-300"
>
- {drawer.showPbsJobDetail() ? 'Hide jobs' : 'Show jobs'}
+ {drawer.showDockerUpdateControls() ? 'Hide actions' : 'Show actions'}
</button>
</div>
</div>
- );
- }}
- </Show>
+ </Show>
- <Show when={drawer.pmgData()}>
- {(pmg) => {
- const connection = getServiceHealthPresentation(resource.status, pmg().connectionHealth);
- return (
- <div class="rounded border border-rose-200 bg-rose-50 p-3 dark:border-rose-700 dark:bg-rose-900">
- <div class="mb-2 flex items-center justify-between gap-2">
- <div class="text-[11px] font-medium uppercase tracking-wide text-rose-700 dark:text-rose-300">
- PMG
- </div>
- <Show when={pmg().hostname}>
- <span
- class="max-w-[55%] truncate text-[10px] text-rose-700 dark:text-rose-300"
- title={pmg().hostname}
- >
- {pmg().hostname}
- </span>
- </Show>
- </div>
- <div class="space-y-1.5 text-[11px]">
- <div class="flex items-center justify-between gap-2">
- <span class="text-muted">State</span>
- <span class={`font-medium ${connection.text}`}>{connection.label}</span>
- </div>
- <Show when={pmg().version}>
- <div class="flex items-center justify-between gap-2">
- <span class="text-muted">Version</span>
- <span class="font-medium text-base-content">{pmg().version}</span>
- </div>
- </Show>
- <Show when={pmg().uptimeSeconds || resource.uptime}>
- <div class="flex items-center justify-between gap-2">
- <span class="text-muted">Uptime</span>
- <span class="font-medium text-base-content">
- {formatUptime(pmg().uptimeSeconds ?? resource.uptime ?? 0)}
- </span>
+ <Show when={drawer.pbsData()}>
+ {(pbs) => {
+ const connection = getServiceHealthPresentation(
+ resource.status,
+ pbs().connectionHealth,
+ );
+ return (
+ <div class="rounded border border-indigo-200 bg-indigo-50 p-3 dark:border-indigo-700 dark:bg-indigo-900">
+ <div class="mb-2 flex items-center justify-between gap-2">
+ <div class="text-[11px] font-medium uppercase tracking-wide text-indigo-700 dark:text-indigo-300">
+ PBS
+ </div>
+ <Show when={pbs().hostname}>
+ <span
+ class="max-w-[55%] truncate text-[10px] text-indigo-700 dark:text-indigo-300"
+ title={pbs().hostname}
+ >
+ {pbs().hostname}
+ </span>
+ </Show>
</div>
- </Show>
- <Show when={drawer.showPmgMailFlowDetail()}>
- <div class="space-y-1.5 border-t border-rose-200 pt-2 dark:border-rose-700">
- <div class="grid grid-cols-2 gap-2">
- <div class="rounded border border-rose-200 bg-surface px-2 py-1.5 dark:border-rose-700">
- <div class="text-[10px] text-muted">Queue</div>
- <div
- class={`text-sm font-semibold ${drawer.pmgQueueBacklog() > 0 ? 'text-amber-600 dark:text-amber-400' : 'text-base-content'}`}
- >
- {formatInteger(pmg().queueTotal)}
- </div>
+ <div class="space-y-1.5 text-[11px]">
+ <div class="flex items-center justify-between gap-2">
+ <span class="text-muted">State</span>
+ <span class={`font-medium ${connection.text}`}>{connection.label}</span>
+ </div>
+ <Show when={pbs().version}>
+ <div class="flex items-center justify-between gap-2">
+ <span class="text-muted">Version</span>
+ <span class="font-medium text-base-content">{pbs().version}</span>
</div>
- <div class="rounded border border-rose-200 bg-surface px-2 py-1.5 dark:border-rose-700">
- <div class="text-[10px] text-muted">Backlog</div>
- <div
- class={`text-sm font-semibold ${drawer.pmgQueueBacklog() > 0 ? 'text-amber-600 dark:text-amber-400' : 'text-base-content'}`}
- >
- {formatInteger(drawer.pmgQueueBacklog())}
- </div>
+ </Show>
+ <Show when={pbs().uptimeSeconds || resource.uptime}>
+ <div class="flex items-center justify-between gap-2">
+ <span class="text-muted">Uptime</span>
+ <span class="font-medium text-base-content">
+ {formatUptime(pbs().uptimeSeconds ?? resource.uptime ?? 0)}
+ </span>
</div>
- </div>
- <Show when={pmg().nodeCount || drawer.pmgUpdatedRelative()}>
- <div
- data-testid="pmg-support-context"
- class="space-y-1.5 rounded border border-dashed border-rose-200 bg-surface px-2 py-1.5 text-[10px] dark:border-rose-700"
- >
- <Show when={pmg().nodeCount}>
- <div class="flex items-center justify-between gap-2">
- <span class="text-muted">Nodes</span>
- <span class="font-medium text-base-content">
- {formatInteger(pmg().nodeCount)}
- </span>
+ </Show>
+ <Show when={drawer.pbsActiveTaskCount() > 0}>
+ <div class="flex items-center justify-between gap-2">
+ <span class="text-muted">Active tasks</span>
+ <span class="font-medium text-emerald-700 dark:text-emerald-300">
+ {formatInteger(drawer.pbsActiveTaskCount())}
+ </span>
+ </div>
+ </Show>
+ <Show when={drawer.showPbsJobDetail()}>
+ <div class="space-y-1.5 border-t border-indigo-200 pt-2 dark:border-indigo-700">
+ <div class="grid grid-cols-2 gap-2 md:grid-cols-3">
+ <div class="rounded border border-indigo-200 bg-surface px-2 py-1.5 dark:border-indigo-700">
+ <div class="text-[10px] text-muted">Datastores</div>
+ <div class="text-sm font-semibold text-base-content">
+ {formatInteger(pbs().datastoreCount)}
+ </div>
</div>
- </Show>
- <Show when={drawer.pmgUpdatedRelative()}>
+ <div class="rounded border border-indigo-200 bg-surface px-2 py-1.5 dark:border-indigo-700">
+ <div class="text-[10px] text-muted">Jobs</div>
+ <div class="text-sm font-semibold text-base-content">
+ {formatInteger(drawer.pbsJobTotal())}
+ </div>
+ </div>
+ <Show when={drawer.pbsActiveTaskCount() > 0}>
+ <div class="rounded border border-emerald-200 bg-emerald-50 px-2 py-1.5 dark:border-emerald-700 dark:bg-emerald-950/40">
+ <div class="text-[10px] text-muted">Active</div>
+ <div class="text-sm font-semibold text-emerald-700 dark:text-emerald-300">
+ {formatInteger(drawer.pbsActiveTaskCount())}
+ </div>
+ </div>
+ </Show>
+ </div>
+ <Show when={drawer.pbsActiveTaskCount() > 0}>
<div
- class={`flex items-center justify-between gap-2 ${pmg().nodeCount ? 'border-t border-rose-200 pt-1.5 dark:border-rose-700' : ''}`}
+ data-testid="pbs-active-tasks"
+ class="rounded border border-emerald-200 bg-surface px-2 py-1.5 dark:border-emerald-700"
>
- <span class="text-muted">Updated</span>
- <span class="font-medium text-base-content">
- {drawer.pmgUpdatedRelative()}
- </span>
- </div>
- </Show>
- </div>
- </Show>
- <details class="rounded border border-rose-200 bg-surface px-2 py-1.5 dark:border-rose-700">
- <summary class="cursor-pointer list-none text-[10px] font-medium text-muted">
- Queue detail
- </summary>
- <div class="mt-2 space-y-1.5 border-t border-rose-200 pt-2 text-[10px] dark:border-rose-700">
- <For each={drawer.pmgVisibleQueueBreakdown()}>
- {(entry) => (
- <div class="flex items-center justify-between gap-2 text-muted">
- <span>{entry.label}</span>
- <span
- class={`font-medium ${entry.warn ? 'text-amber-600 dark:text-amber-400' : 'text-base-content'}`}
- >
- {formatInteger(entry.value)}
+ <div class="flex items-center justify-between gap-2">
+ <span class="text-[10px] font-medium uppercase tracking-wide text-muted">
+ Active tasks
</span>
- </div>
- )}
- </For>
- </div>
- </details>
- <details class="rounded border border-rose-200 bg-surface px-2 py-1.5 dark:border-rose-700">
- <summary class="cursor-pointer list-none text-[10px] font-medium text-muted">
- Mail detail
- </summary>
- <div class="mt-2 space-y-1.5 border-t border-rose-200 pt-2 text-[10px] dark:border-rose-700">
- <For each={drawer.pmgVisibleMailBreakdown()}>
- {(entry) => (
- <div class="flex items-center justify-between gap-2 text-muted">
- <span>{entry.label}</span>
- <span class="font-medium text-base-content">
- {formatInteger(entry.value)}
+ <span class="text-[10px] font-semibold text-emerald-700 dark:text-emerald-300">
+ {formatInteger(drawer.pbsActiveTaskCount())}
</span>
</div>
- )}
- </For>
+ <div class="mt-2 space-y-2 border-t border-emerald-200 pt-2 dark:border-emerald-700">
+ <For each={drawer.pbsActiveTasks()}>
+ {(task) => (
+ <div class="flex items-start justify-between gap-2 text-[10px]">
+ <div class="min-w-0">
+ <div
+ class="truncate font-medium text-base-content"
+ title={task.label}
+ >
+ {task.label}
+ </div>
+ <Show when={task.context}>
+ <div
+ class="truncate text-muted"
+ title={task.context ?? undefined}
+ >
+ {task.context}
+ </div>
+ </Show>
+ <Show when={task.error}>
+ <div
+ class="truncate text-rose-700 dark:text-rose-300"
+ title={task.error}
+ >
+ {task.error}
+ </div>
+ </Show>
+ </div>
+ <span class="shrink-0 rounded-full border border-emerald-200 bg-emerald-50 px-2 py-0.5 font-medium text-emerald-700 dark:border-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-300">
+ {task.statusLabel}
+ </span>
+ </div>
+ )}
+ </For>
+ </div>
+ </div>
+ </Show>
+ <details class="rounded border border-indigo-200 bg-surface px-2 py-1.5 dark:border-indigo-700">
+ <summary class="flex cursor-pointer list-none items-center justify-between text-[10px] font-medium text-muted">
+ <span>Types</span>
+ <span class="text-muted">
+ {drawer.pbsVisibleJobBreakdown().length}
+ </span>
+ </summary>
+ <div class="mt-2 grid grid-cols-2 gap-x-3 gap-y-1 border-t border-indigo-200 pt-2 text-[10px] dark:border-indigo-700">
+ <For each={drawer.pbsVisibleJobBreakdown()}>
+ {(entry) => (
+ <span class="text-muted">
+ {entry.label}:{' '}
+ <span class="font-medium text-base-content">
+ {formatInteger(entry.value)}
+ </span>
+ </span>
+ )}
+ </For>
+ </div>
+ </details>
</div>
- </details>
+ </Show>
+ <button
+ type="button"
+ onClick={() => drawer.setShowPbsJobDetail((value) => !value)}
+ class="inline-flex items-center rounded-md border border-indigo-200 bg-surface px-2.5 py-1 text-[10px] font-medium text-indigo-700 transition-colors hover:bg-base dark:border-indigo-700 dark:text-indigo-300"
+ >
+ {drawer.showPbsJobDetail() ? 'Hide jobs' : 'Show jobs'}
+ </button>
</div>
- </Show>
- <button
- type="button"
- onClick={() => drawer.setShowPmgMailFlowDetail((value) => !value)}
- class="inline-flex items-center rounded-md border border-rose-200 bg-surface px-2.5 py-1 text-[10px] font-medium text-rose-700 transition-colors hover:bg-base dark:border-rose-700 dark:text-rose-300"
- >
- {drawer.showPmgMailFlowDetail() ? 'Hide mail flow' : 'Show mail flow'}
- </button>
- </div>
- </div>
- );
- }}
- </Show>
- </SupportDisclosure>
- </Show>
+ </div>
+ );
+ }}
+ </Show>
- <Show when={drawer.hasVMwareDetails()}>
- <SupportDisclosure
- title="vSphere"
- summary={drawer.vmwareDetailsSummary()}
- expanded={drawer.showVMwareDetails()}
- onToggle={() => drawer.setShowVMwareDetails((value) => !value)}
- showLabel="Show vSphere"
- hideLabel="Hide vSphere"
- class="h-full"
- contentClass="mt-3 space-y-3"
- dataTestId="resource-vmware-details-section"
- >
- <div class="space-y-3">
- <For each={drawer.vmwareDetailSections()}>
- {(section) => (
- <div class="rounded border border-sky-200 bg-sky-50 p-3 dark:border-sky-700 dark:bg-sky-900">
- <div class="mb-2 text-[10px] font-medium uppercase tracking-wide text-sky-700 dark:text-sky-300">
- {section.label}
- </div>
- <div class="space-y-1.5 text-[11px]">
- <For each={section.rows}>
- {(row) => (
- <div class="flex items-center justify-between gap-2">
- <span class="text-muted">{row.label}</span>
+ <Show when={drawer.pmgData()}>
+ {(pmg) => {
+ const connection = getServiceHealthPresentation(
+ resource.status,
+ pmg().connectionHealth,
+ );
+ return (
+ <div class="rounded border border-rose-200 bg-rose-50 p-3 dark:border-rose-700 dark:bg-rose-900">
+ <div class="mb-2 flex items-center justify-between gap-2">
+ <div class="text-[11px] font-medium uppercase tracking-wide text-rose-700 dark:text-rose-300">
+ PMG
+ </div>
+ <Show when={pmg().hostname}>
<span
- class={`max-w-[60%] truncate text-right font-medium ${vmwareRowToneClass(row.tone)}`}
- title={row.value}
+ class="max-w-[55%] truncate text-[10px] text-rose-700 dark:text-rose-300"
+ title={pmg().hostname}
>
- {row.value}
+ {pmg().hostname}
</span>
+ </Show>
+ </div>
+ <div class="space-y-1.5 text-[11px]">
+ <div class="flex items-center justify-between gap-2">
+ <span class="text-muted">State</span>
+ <span class={`font-medium ${connection.text}`}>{connection.label}</span>
</div>
- )}
- </For>
- </div>
- </div>
- )}
- </For>
- </div>
- </SupportDisclosure>
- </Show>
-
- <Show when={drawer.hasHostDetails()}>
- <SupportDisclosure
- title="Host"
- summary={drawer.hostDetailSummary()}
- expanded={drawer.showHostDetails()}
- onToggle={() => drawer.setShowHostDetails((value) => !value)}
- showLabel="Show host"
- hideLabel="Hide host"
- class="h-full"
- contentClass="mt-3 flex flex-wrap gap-3 [&>*]:flex-1 [&>*]:basis-[calc(50%-0.375rem)] [&>*]:min-w-[220px] [&>*]:max-w-full [&>*]:overflow-hidden"
- dataTestId="resource-host-details-section"
- >
- <Show when={drawer.proxmoxNode()}>
- {(node) => (
- <>
- <SystemInfoCard variant="node" node={node()} />
- <HardwareCard variant="node" node={node()} />
- <RootDiskCard node={node()} />
- </>
- )}
+ <Show when={pmg().version}>
+ <div class="flex items-center justify-between gap-2">
+ <span class="text-muted">Version</span>
+ <span class="font-medium text-base-content">{pmg().version}</span>
+ </div>
+ </Show>
+ <Show when={pmg().uptimeSeconds || resource.uptime}>
+ <div class="flex items-center justify-between gap-2">
+ <span class="text-muted">Uptime</span>
+ <span class="font-medium text-base-content">
+ {formatUptime(pmg().uptimeSeconds ?? resource.uptime ?? 0)}
+ </span>
+ </div>
+ </Show>
+ <Show when={drawer.showPmgMailFlowDetail()}>
+ <div class="space-y-1.5 border-t border-rose-200 pt-2 dark:border-rose-700">
+ <div class="grid grid-cols-2 gap-2">
+ <div class="rounded border border-rose-200 bg-surface px-2 py-1.5 dark:border-rose-700">
+ <div class="text-[10px] text-muted">Queue</div>
+ <div
+ class={`text-sm font-semibold ${drawer.pmgQueueBacklog() > 0 ? 'text-amber-600 dark:text-amber-400' : 'text-base-content'}`}
+ >
+ {formatInteger(pmg().queueTotal)}
+ </div>
+ </div>
+ <div class="rounded border border-rose-200 bg-surface px-2 py-1.5 dark:border-rose-700">
+ <div class="text-[10px] text-muted">Backlog</div>
+ <div
+ class={`text-sm font-semibold ${drawer.pmgQueueBacklog() > 0 ? 'text-amber-600 dark:text-amber-400' : 'text-base-content'}`}
+ >
+ {formatInteger(drawer.pmgQueueBacklog())}
+ </div>
+ </div>
+ </div>
+ <Show when={pmg().nodeCount || drawer.pmgUpdatedRelative()}>
+ <div
+ data-testid="pmg-support-context"
+ class="space-y-1.5 rounded border border-dashed border-rose-200 bg-surface px-2 py-1.5 text-[10px] dark:border-rose-700"
+ >
+ <Show when={pmg().nodeCount}>
+ <div class="flex items-center justify-between gap-2">
+ <span class="text-muted">Nodes</span>
+ <span class="font-medium text-base-content">
+ {formatInteger(pmg().nodeCount)}
+ </span>
+ </div>
+ </Show>
+ <Show when={drawer.pmgUpdatedRelative()}>
+ <div
+ class={`flex items-center justify-between gap-2 ${pmg().nodeCount ? 'border-t border-rose-200 pt-1.5 dark:border-rose-700' : ''}`}
+ >
+ <span class="text-muted">Updated</span>
+ <span class="font-medium text-base-content">
+ {drawer.pmgUpdatedRelative()}
+ </span>
+ </div>
+ </Show>
+ </div>
+ </Show>
+ <details class="rounded border border-rose-200 bg-surface px-2 py-1.5 dark:border-rose-700">
+ <summary class="cursor-pointer list-none text-[10px] font-medium text-muted">
+ Queue detail
+ </summary>
+ <div class="mt-2 space-y-1.5 border-t border-rose-200 pt-2 text-[10px] dark:border-rose-700">
+ <For each={drawer.pmgVisibleQueueBreakdown()}>
+ {(entry) => (
+ <div class="flex items-center justify-between gap-2 text-muted">
+ <span>{entry.label}</span>
+ <span
+ class={`font-medium ${entry.warn ? 'text-amber-600 dark:text-amber-400' : 'text-base-content'}`}
+ >
+ {formatInteger(entry.value)}
+ </span>
+ </div>
+ )}
+ </For>
+ </div>
+ </details>
+ <details class="rounded border border-rose-200 bg-surface px-2 py-1.5 dark:border-rose-700">
+ <summary class="cursor-pointer list-none text-[10px] font-medium text-muted">
+ Mail detail
+ </summary>
+ <div class="mt-2 space-y-1.5 border-t border-rose-200 pt-2 text-[10px] dark:border-rose-700">
+ <For each={drawer.pmgVisibleMailBreakdown()}>
+ {(entry) => (
+ <div class="flex items-center justify-between gap-2 text-muted">
+ <span>{entry.label}</span>
+ <span class="font-medium text-base-content">
+ {formatInteger(entry.value)}
+ </span>
+ </div>
+ )}
+ </For>
+ </div>
+ </details>
+ </div>
+ </Show>
+ <button
+ type="button"
+ onClick={() => drawer.setShowPmgMailFlowDetail((value) => !value)}
+ class="inline-flex items-center rounded-md border border-rose-200 bg-surface px-2.5 py-1 text-[10px] font-medium text-rose-700 transition-colors hover:bg-base dark:border-rose-700 dark:text-rose-300"
+ >
+ {drawer.showPmgMailFlowDetail() ? 'Hide mail flow' : 'Show mail flow'}
+ </button>
+ </div>
+ </div>
+ );
+ }}
+ </Show>
+ </SupportDisclosure>
</Show>
- <Show when={drawer.agentInfo()}>
- {(agent) => (
- <>
- <SystemInfoCard variant="agent" agent={agent()} />
- <HardwareCard variant="agent" agent={agent()} />
- <NetworkInterfacesCard interfaces={agent().networkInterfaces} />
- <DisksCard disks={agent().disks} />
- <RaidCard arrays={drawer.agentMeta()?.raid} />
- <TemperaturesCard rows={drawer.temperatureRows()} />
- </>
- )}
+
+ <Show when={drawer.hasVMwareDetails()}>
+ <SupportDisclosure
+ title="vSphere"
+ summary={drawer.vmwareDetailsSummary()}
+ expanded={drawer.showVMwareDetails()}
+ onToggle={() => drawer.setShowVMwareDetails((value) => !value)}
+ showLabel="Show vSphere"
+ hideLabel="Hide vSphere"
+ class="h-full"
+ contentClass="mt-3 space-y-3"
+ dataTestId="resource-vmware-details-section"
+ >
+ <div class="space-y-3">
+ <For each={drawer.vmwareDetailSections()}>
+ {(section) => (
+ <div class="rounded border border-sky-200 bg-sky-50 p-3 dark:border-sky-700 dark:bg-sky-900">
+ <div class="mb-2 text-[10px] font-medium uppercase tracking-wide text-sky-700 dark:text-sky-300">
+ {section.label}
+ </div>
+ <div class="space-y-1.5 text-[11px]">
+ <For each={section.rows}>
+ {(row) => (
+ <div class="flex items-center justify-between gap-2">
+ <span class="text-muted">{row.label}</span>
+ <span
+ class={`max-w-[60%] truncate text-right font-medium ${vmwareRowToneClass(row.tone)}`}
+ title={row.value}
+ >
+ {row.value}
+ </span>
+ </div>
+ )}
+ </For>
+ </div>
+ </div>
+ )}
+ </For>
+ </div>
+ </SupportDisclosure>
</Show>
- </SupportDisclosure>
- </Show>
+ <Show when={drawer.hasHostDetails()}>
+ <SupportDisclosure
+ title="Host"
+ summary={drawer.hostDetailSummary()}
+ expanded={drawer.showHostDetails()}
+ onToggle={() => drawer.setShowHostDetails((value) => !value)}
+ showLabel="Show host"
+ hideLabel="Hide host"
+ class="h-full"
+ contentClass="mt-3 flex flex-wrap gap-3 [&>*]:flex-1 [&>*]:basis-[calc(50%-0.375rem)] [&>*]:min-w-[220px] [&>*]:max-w-full [&>*]:overflow-hidden"
+ dataTestId="resource-host-details-section"
+ >
+ <Show when={drawer.proxmoxNode()}>
+ {(node) => (
+ <>
+ <SystemInfoCard variant="node" node={node()} />
+ <HardwareCard variant="node" node={node()} />
+ <RootDiskCard node={node()} />
+ </>
+ )}
+ </Show>
+ <Show when={drawer.agentInfo()}>
+ {(agent) => (
+ <>
+ <SystemInfoCard variant="agent" agent={agent()} />
+ <HardwareCard variant="agent" agent={agent()} />
+ <NetworkInterfacesCard interfaces={agent().networkInterfaces} />
+ <DisksCard disks={agent().disks} />
+ <RaidCard arrays={drawer.agentMeta()?.raid} />
+ <TemperaturesCard rows={drawer.temperatureRows()} />
+ </>
+ )}
+ </Show>
+ </SupportDisclosure>
+ </Show>
</div>
</Show>
</div>
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx
index f754d229ca..3b8aef451b 100644
--- a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx
+++ b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx
@@ -6,6 +6,7 @@ import discoveryTabSource from '@/components/Discovery/DiscoveryTab.tsx?raw';
import discoveryTabStateSource from '@/components/Discovery/useDiscoveryTabState.ts?raw';
import resourceDetailDrawerShellSource from '@/components/Infrastructure/ResourceDetailDrawer.tsx?raw';
import resourceDetailDrawerOverviewSource from '@/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx?raw';
+import resourceActionHistorySource from '@/components/Infrastructure/ResourceActionHistory.tsx?raw';
import resourceDetailDrawerHistoryStateSource from '@/components/Infrastructure/useResourceDetailDrawerHistoryState.ts?raw';
import createNonSuspendingQuerySource from '@/hooks/createNonSuspendingQuery.ts?raw';
import resourceDetailDrawerDerivedStateSource from '@/components/Infrastructure/useResourceDetailDrawerDerivedState.ts?raw';
@@ -16,6 +17,8 @@ import resourceDetailDrawerServiceModelSource from '@/components/Infrastructure/
import resourceDetailDrawerVmwareModelSource from '@/components/Infrastructure/resourceDetailDrawerVmwareModel.ts?raw';
import resourceDetailDrawerDockerActionsStateSource from '@/components/Infrastructure/useResourceDetailDrawerDockerActionsState.ts?raw';
import resourceDetailDrawerStateSource from '@/components/Infrastructure/useResourceDetailDrawerState.ts?raw';
+import actionAuditApiSource from '@/api/actionAudit.ts?raw';
+import actionAuditPresentationSource from '@/utils/actionAuditPresentation.ts?raw';
import type { Resource } from '@/types/resource';
import { ResourceDetailDrawer } from '@/components/Infrastructure/ResourceDetailDrawer';
@@ -56,6 +59,14 @@ const aiIntelligenceMock = vi.hoisted(() => ({
}),
}));
+const actionAuditMock = vi.hoisted(() => ({
+ listActionAudits: vi.fn().mockResolvedValue({
+ audits: [],
+ count: 0,
+ available: false,
+ }),
+}));
+
vi.mock('@/contexts/appRuntime', () => ({
useWebSocket: () => ({
state: { pmg: [] as any[] },
@@ -83,6 +94,12 @@ vi.mock('@/api/ai', () => ({
},
}));
+vi.mock('@/api/actionAudit', () => ({
+ ActionAuditAPI: {
+ listActionAudits: actionAuditMock.listActionAudits,
+ },
+}));
+
class ResizeObserverMock {
constructor(_callback: ResizeObserverCallback) {}
observe() {}
@@ -129,21 +146,25 @@ describe('ResourceDetailDrawer change history section', () => {
expect(resourceDetailDrawerOverviewSource).not.toContain(
"from '@/components/Dashboard/TagBadges'",
);
- expect(resourceDetailDrawerShellSource).toContain(
- "from './ResourceDetailDrawerOverviewTab'",
- );
+ expect(resourceDetailDrawerShellSource).toContain("from './ResourceDetailDrawerOverviewTab'");
expect(resourceDetailDrawerShellSource).toContain("from './ResourceDetailDrawerDebugTab'");
expect(resourceDetailDrawerShellSource).toContain('data-testid="resource-header-badges"');
expect(resourceDetailDrawerShellSource).toContain('drawer.headerBadges()');
expect(resourceDetailDrawerShellSource).not.toContain('drawer.headerIdentity()');
expect(resourceDetailDrawerShellSource).not.toContain('drawer.unifiedSourceBadges()');
expect(resourceDetailDrawerShellSource).not.toContain('Change history');
- expect(resourceDetailDrawerStateSource).toContain("from './useResourceDetailDrawerHistoryState'");
- expect(resourceDetailDrawerStateSource).toContain("from './useResourceDetailDrawerDerivedState'");
+ expect(resourceDetailDrawerStateSource).toContain(
+ "from './useResourceDetailDrawerHistoryState'",
+ );
+ expect(resourceDetailDrawerStateSource).toContain(
+ "from './useResourceDetailDrawerDerivedState'",
+ );
expect(resourceDetailDrawerStateSource).toContain(
"from './useResourceDetailDrawerDockerActionsState'",
);
- expect(resourceDetailDrawerStateSource).toContain('const [showHistoryFilters, setShowHistoryFilters]');
+ expect(resourceDetailDrawerStateSource).toContain(
+ 'const [showHistoryFilters, setShowHistoryFilters]',
+ );
expect(resourceDetailDrawerStateSource).not.toContain('createResource(');
expect(resourceDetailDrawerStateSource).not.toContain('MonitoringAPI.');
expect(resourceDetailDrawerHistoryStateSource).toContain(
@@ -153,6 +174,13 @@ describe('ResourceDetailDrawer change history section', () => {
expect(resourceDetailDrawerHistoryStateSource).not.toContain('createResource(');
expect(resourceDetailDrawerHistoryStateSource).toContain('ResourceAPI.getFacetBundle');
expect(resourceDetailDrawerHistoryStateSource).toContain('AIAPI.getResourceIntelligence');
+ expect(resourceDetailDrawerHistoryStateSource).toContain('ActionAuditAPI.listActionAudits');
+ expect(resourceDetailDrawerOverviewSource).toContain("from './ResourceActionHistory'");
+ expect(resourceActionHistorySource).toContain('getActionAuditStatePresentation');
+ expect(resourceActionHistorySource).toContain('formatActionApprovalPolicyLabel');
+ expect(actionAuditApiSource).toContain('/api/audit/actions');
+ expect(actionAuditApiSource).toContain('ACTION_AUDIT_UNAVAILABLE_STATUSES');
+ expect(actionAuditPresentationSource).toContain('pending_approval');
expect(resourceDetailDrawerDerivedStateSource).toContain('toDiscoveryConfig');
expect(resourceDetailDrawerDerivedStateSource).toContain(
"from '@/components/Infrastructure/resourceDetailDiscoveryModel'",
@@ -197,9 +225,13 @@ describe('ResourceDetailDrawer change history section', () => {
'export const buildKubernetesCapabilityBadges',
);
expect(resourceDetailDrawerOperationalModelSource).toContain('export const buildSourceSummary');
- expect(resourceDetailDrawerOperationalModelSource).toContain('export const buildHostDetailCards');
+ expect(resourceDetailDrawerOperationalModelSource).toContain(
+ 'export const buildHostDetailCards',
+ );
expect(resourceDetailDrawerOperationalModelSource).toContain('export const buildRelatedLinks');
- expect(resourceDetailDrawerServiceModelSource).toContain('export const getServiceDetailsSummary');
+ expect(resourceDetailDrawerServiceModelSource).toContain(
+ 'export const getServiceDetailsSummary',
+ );
expect(resourceDetailDrawerServiceModelSource).toContain(
'export const buildPbsVisibleJobBreakdown',
);
@@ -209,7 +241,9 @@ describe('ResourceDetailDrawer change history section', () => {
expect(resourceDetailDrawerServiceModelSource).toContain(
'export const buildPmgVisibleMailBreakdown',
);
- expect(resourceDetailDrawerServiceModelSource).toContain("formatCount(pmg.queueTotal || 0, 'queued message')");
+ expect(resourceDetailDrawerServiceModelSource).toContain(
+ "formatCount(pmg.queueTotal || 0, 'queued message')",
+ );
expect(resourceDetailDrawerServiceModelSource).toContain("'delayed message'");
expect(resourceDetailDrawerOverviewSource).not.toContain('MonitoringAPI.');
expect(resourceDetailDrawerOverviewSource).toContain('drawer.queueDockerUpdateCheck');
@@ -218,14 +252,18 @@ describe('ResourceDetailDrawer change history section', () => {
expect(resourceDetailDrawerOverviewSource).not.toContain(
'const modeLabel = formatSourceType(resource.sourceType);',
);
- expect(resourceDetailDrawerOverviewSource).not.toContain('<span class="text-muted">Mode</span>');
+ expect(resourceDetailDrawerOverviewSource).not.toContain(
+ '<span class="text-muted">Mode</span>',
+ );
expect(createNonSuspendingQuerySource).toContain('const retainedQueryCache = new Map<');
expect(createNonSuspendingQuerySource).toContain(
'export function resetCreateNonSuspendingQueryCacheForTest()',
);
expect(createNonSuspendingQuerySource).toContain('setResolvedOnce(true);');
expect(createNonSuspendingQuerySource).toContain('setResolvedOnce(false);');
- expect(resourceDetailDrawerDockerActionsStateSource).toContain('MonitoringAPI.checkDockerUpdates');
+ expect(resourceDetailDrawerDockerActionsStateSource).toContain(
+ 'MonitoringAPI.checkDockerUpdates',
+ );
expect(resourceDetailDrawerDockerActionsStateSource).toContain(
'MonitoringAPI.updateAllDockerContainers',
);
@@ -431,10 +469,7 @@ describe('ResourceDetailDrawer change history section', () => {
Array.from(screen.getByTestId('resource-support-sections').children).map((node) =>
node.getAttribute('data-testid'),
),
- ).toEqual([
- 'resource-access-section',
- 'resource-investigation-context',
- ]);
+ ).toEqual(['resource-access-section', 'resource-investigation-context']);
expect(screen.getAllByText('Restart 2')).toHaveLength(1);
expect(screen.getAllByText('Anomaly 1')).toHaveLength(1);
expect(screen.getAllByText('Platform event 1')).toHaveLength(1);
@@ -546,8 +581,12 @@ describe('ResourceDetailDrawer change history section', () => {
render(() => <ResourceDetailDrawer resource={resource} />);
- expect(within(screen.getByTestId('resource-identity-section')).getByText('Aliases')).toBeInTheDocument();
- expect(within(screen.getByTestId('resource-current-state-section')).queryByText('Aliases')).toBeNull();
+ expect(
+ within(screen.getByTestId('resource-identity-section')).getByText('Aliases'),
+ ).toBeInTheDocument();
+ expect(
+ within(screen.getByTestId('resource-current-state-section')).queryByText('Aliases'),
+ ).toBeNull();
});
it('renders timeline history without surfacing unsupported capability or relationship facets', async () => {
@@ -661,6 +700,89 @@ describe('ResourceDetailDrawer change history section', () => {
expect(panel.queryByText('Runs on')).toBeNull();
});
+ it('surfaces resource-scoped action history from the canonical action audit API', async () => {
+ actionAuditMock.listActionAudits.mockResolvedValueOnce({
+ available: true,
+ count: 1,
+ resourceId: 'vm:action-42',
+ audits: [
+ {
+ id: 'action-1',
+ createdAt: '2026-04-29T12:00:00Z',
+ updatedAt: '2026-04-29T12:05:00Z',
+ state: 'completed',
+ request: {
+ requestId: 'req-1',
+ resourceId: 'vm:action-42',
+ capabilityName: 'restart_service',
+ reason: 'Restart nginx after patching',
+ requestedBy: 'agent:oncall-helper',
+ },
+ plan: {
+ actionId: 'action-1',
+ requestId: 'req-1',
+ allowed: true,
+ requiresApproval: true,
+ approvalPolicy: 'admin',
+ rollbackAvailable: true,
+ preflight: {
+ target: 'agent:node-1',
+ currentState: 'nginx active',
+ intendedChange: 'Restart nginx',
+ dryRunAvailable: false,
+ dryRunSummary: 'No provider-supported dry run is available for this action.',
+ safetyChecks: ['Approval scoped to this resource.'],
+ verificationSteps: ['Read back service state after execution.'],
+ generatedAt: '2026-04-29T12:01:00Z',
+ },
+ },
+ result: {
+ success: true,
+ output: 'nginx restarted',
+ },
+ },
+ ],
+ });
+
+ facetBundleMock.getFacetBundle.mockResolvedValueOnce({
+ capabilities: [],
+ relationships: [],
+ recentChanges: [],
+ counts: { recentChanges: 0 },
+ });
+
+ render(() => (
+ <ResourceDetailDrawer
+ resource={baseResource({
+ id: 'vm:action-42',
+ type: 'vm',
+ name: 'action-vm',
+ displayName: 'Action VM',
+ platformType: 'proxmox-pve',
+ })}
+ />
+ ));
+
+ const actionHistory = within(await screen.findByTestId('resource-action-history-section'));
+
+ expect(actionAuditMock.listActionAudits).toHaveBeenCalledWith({
+ resourceId: 'vm:action-42',
+ limit: 5,
+ });
+ expect(actionHistory.getByText('Action history')).toBeInTheDocument();
+ expect(actionHistory.getByText('Actions 1')).toBeInTheDocument();
+ expect(actionHistory.getByText('Actions loaded')).toBeInTheDocument();
+ expect(actionHistory.getByText('Restart Service')).toBeInTheDocument();
+ expect(actionHistory.getByText('Completed')).toBeInTheDocument();
+ expect(actionHistory.getByText('agent:oncall-helper')).toBeInTheDocument();
+ expect(actionHistory.getByText('Restart nginx after patching')).toBeInTheDocument();
+ expect(actionHistory.getByText('Admin approval')).toBeInTheDocument();
+ expect(actionHistory.getByText('Not available')).toBeInTheDocument();
+ expect(actionHistory.getByText('Restart nginx')).toBeInTheDocument();
+ expect(actionHistory.getByText('Approval scoped to this resource.')).toBeInTheDocument();
+ expect(actionHistory.getByText('nginx restarted')).toBeInTheDocument();
+ });
+
it('keeps service details summary-first until the service-local reveal is opened', () => {
facetBundleMock.getFacetBundle.mockResolvedValueOnce({
capabilities: [],
@@ -693,10 +815,7 @@ describe('ResourceDetailDrawer change history section', () => {
Array.from(screen.getByTestId('resource-support-sections').children).map((node) =>
node.getAttribute('data-testid'),
),
- ).toEqual([
- 'resource-access-section',
- 'resource-service-details-section',
- ]);
+ ).toEqual(['resource-access-section', 'resource-service-details-section']);
fireEvent.click(screen.getByRole('button', { name: 'Show service' }));
const serviceDetails = within(screen.getByTestId('resource-service-details-section'));
expect(
diff --git a/frontend-modern/src/components/Infrastructure/useResourceDetailDrawerHistoryState.ts b/frontend-modern/src/components/Infrastructure/useResourceDetailDrawerHistoryState.ts
index 80e92bce24..bd29854a17 100644
--- a/frontend-modern/src/components/Infrastructure/useResourceDetailDrawerHistoryState.ts
+++ b/frontend-modern/src/components/Infrastructure/useResourceDetailDrawerHistoryState.ts
@@ -7,14 +7,20 @@ import type {
} from '@/types/resource';
import type { ResourceIntelligence } from '@/types/aiIntelligence';
import { AIAPI } from '@/api/ai';
+import { ActionAuditAPI } from '@/api/actionAudit';
import { ResourceAPI } from '@/api/resources';
import { createNonSuspendingQuery } from '@/hooks/createNonSuspendingQuery';
+import type { ActionAuditListResponse } from '@/types/actionAudit';
interface UseResourceDetailDrawerHistoryStateOptions {
resource: Resource;
}
type ResourceFacetBundle = Awaited<ReturnType<typeof ResourceAPI.getFacetBundle>> | null;
+type ActionAuditRequest = {
+ id: string;
+ limit: number;
+};
type TimelineFacetRequest = {
id: string;
@@ -53,7 +59,10 @@ export const useResourceDetailDrawerHistoryState = (
const resourceFacets = resourceFacetsState.value;
const refetchResourceFacets = resourceFacetsState.refetch;
- const resourceIntelligenceState = createNonSuspendingQuery<ResourceIntelligence | null, { id: string }>({
+ const resourceIntelligenceState = createNonSuspendingQuery<
+ ResourceIntelligence | null,
+ { id: string }
+ >({
source: resourceFacetRequest,
fetcher: async (request) => {
if (!request?.id) return null;
@@ -63,6 +72,24 @@ export const useResourceDetailDrawerHistoryState = (
});
const resourceIntelligence = resourceIntelligenceState.value;
+ const actionAuditRequest = createMemo(() => {
+ const id = resourceFacetId();
+ return id ? { id, limit: 5 } : null;
+ });
+
+ const actionAuditState = createNonSuspendingQuery<ActionAuditListResponse, ActionAuditRequest>({
+ source: actionAuditRequest,
+ fetcher: async (request) =>
+ ActionAuditAPI.listActionAudits({ resourceId: request.id, limit: request.limit }),
+ initialValue: {
+ audits: [],
+ count: 0,
+ resourceId: resourceFacetId() || undefined,
+ available: false,
+ },
+ });
+ const actionAuditResponse = actionAuditState.value;
+
const timelineFacetRequest = createMemo(() => {
const id = resourceFacetId();
if (!id) return null;
@@ -128,6 +155,25 @@ export const useResourceDetailDrawerHistoryState = (
);
}),
);
+ const resourceActionAudits = createMemo(() => actionAuditResponse().audits ?? []);
+ const actionAuditCount = createMemo(
+ () => actionAuditResponse().count ?? resourceActionAudits().length,
+ );
+ const actionAuditAvailable = createMemo(() =>
+ Boolean(actionAuditResponse().available || resourceActionAudits().length > 0),
+ );
+ const actionAuditLoadingLabel = createMemo(() =>
+ actionAuditState.loading() ? 'Refreshing actions...' : 'Actions loaded',
+ );
+ const sortedActionAudits = createMemo(() =>
+ [...resourceActionAudits()].sort((left, right) => {
+ const leftTime = Date.parse(left.updatedAt || left.createdAt || '');
+ const rightTime = Date.parse(right.updatedAt || right.createdAt || '');
+ return (
+ (Number.isFinite(rightTime) ? rightTime : 0) - (Number.isFinite(leftTime) ? leftTime : 0)
+ );
+ }),
+ );
const facetBundleError = createMemo(() => {
const error = timelineFacetRequest()
? timelineFacetsState.error()
@@ -135,6 +181,11 @@ export const useResourceDetailDrawerHistoryState = (
if (!error) return '';
return (error as Error)?.message || 'Failed to load resource history';
});
+ const actionAuditError = createMemo(() => {
+ const error = actionAuditState.error();
+ if (!error || !actionAuditAvailable()) return '';
+ return (error as Error)?.message || 'Failed to load action history';
+ });
const refetchHistoryFacets = () => {
if (timelineFacetRequest()) {
@@ -158,9 +209,17 @@ export const useResourceDetailDrawerHistoryState = (
historyLoadingLabel,
resourceTimelineCount,
sortedResourceTimeline,
+ actionAuditAvailable,
+ actionAuditCount,
+ actionAuditError,
+ actionAuditLoadingLabel,
+ sortedActionAudits,
facetBundleError,
+ refetchActionAudits: actionAuditState.refetch,
refetchHistoryFacets,
};
};
-export type ResourceDetailDrawerHistoryState = ReturnType<typeof useResourceDetailDrawerHistoryState>;
+export type ResourceDetailDrawerHistoryState = ReturnType<
+ typeof useResourceDetailDrawerHistoryState
+>;
diff --git a/frontend-modern/src/types/actionAudit.ts b/frontend-modern/src/types/actionAudit.ts
new file mode 100644
index 0000000000..d882e12977
--- /dev/null
+++ b/frontend-modern/src/types/actionAudit.ts
@@ -0,0 +1,79 @@
+export type ActionAuditState =
+ | 'planned'
+ | 'pending_approval'
+ | 'approved'
+ | 'rejected'
+ | 'executing'
+ | 'completed'
+ | 'failed';
+
+export type ActionAuditApprovalPolicy = 'none' | 'dry_run_only' | 'admin' | 'mfa' | string;
+
+export interface ActionAuditRequest {
+ requestId: string;
+ resourceId: string;
+ capabilityName: string;
+ params?: Record<string, unknown>;
+ reason: string;
+ requestedBy: string;
+}
+
+export interface ActionAuditPreflight {
+ target?: string;
+ currentState?: string;
+ intendedChange?: string;
+ dryRunAvailable: boolean;
+ dryRunSummary?: string;
+ safetyChecks?: string[];
+ verificationSteps?: string[];
+ generatedAt?: string;
+}
+
+export interface ActionAuditPlan {
+ actionId: string;
+ requestId: string;
+ allowed: boolean;
+ requiresApproval: boolean;
+ approvalPolicy: ActionAuditApprovalPolicy;
+ predictedBlastRadius?: string[];
+ rollbackAvailable: boolean;
+ message?: string;
+ plannedAt?: string;
+ expiresAt?: string;
+ resourceVersion?: string;
+ policyVersion?: string;
+ planHash?: string;
+ preflight?: ActionAuditPreflight;
+}
+
+export interface ActionAuditApprovalRecord {
+ actor: string;
+ method: string;
+ timestamp: string;
+ outcome: 'approved' | 'rejected' | string;
+ reason?: string;
+}
+
+export interface ActionAuditExecutionResult {
+ success: boolean;
+ output?: string;
+ errorMessage?: string;
+}
+
+export interface ActionAuditRecord {
+ id: string;
+ createdAt: string;
+ updatedAt: string;
+ state: ActionAuditState;
+ request: ActionAuditRequest;
+ plan: ActionAuditPlan;
+ approvals?: ActionAuditApprovalRecord[];
+ result?: ActionAuditExecutionResult;
+}
+
+export interface ActionAuditListResponse {
+ audits: ActionAuditRecord[];
+ count: number;
+ resourceId?: string;
+ available: boolean;
+}
diff --git a/frontend-modern/src/utils/__tests__/actionAuditPresentation.test.ts b/frontend-modern/src/utils/__tests__/actionAuditPresentation.test.ts
new file mode 100644
index 0000000000..e87341bf8c
--- /dev/null
+++ b/frontend-modern/src/utils/__tests__/actionAuditPresentation.test.ts
@@ -0,0 +1,27 @@
+import { describe, expect, it } from 'vitest';
+
+import {
+ formatActionApprovalPolicyLabel,
+ formatActionCapabilityLabel,
+ getActionAuditStatePresentation,
+} from '@/utils/actionAuditPresentation';
+
+describe('actionAuditPresentation', () => {
+ it('formats canonical action lifecycle states', () => {
+ expect(getActionAuditStatePresentation('pending_approval')).toMatchObject({
+ label: 'Pending approval',
+ });
+ expect(getActionAuditStatePresentation('completed')).toMatchObject({ label: 'Completed' });
+ expect(getActionAuditStatePresentation('failed')).toMatchObject({ label: 'Failed' });
+ expect(getActionAuditStatePresentation('unknown')).toMatchObject({ label: 'Unknown' });
+ });
+
+ it('formats capability and approval policy labels for operator history', () => {
+ expect(formatActionCapabilityLabel('restart_service')).toBe('Restart Service');
+ expect(formatActionCapabilityLabel('docker.update-container')).toBe('Docker Update Container');
+ expect(formatActionCapabilityLabel('')).toBe('Action');
+ expect(formatActionApprovalPolicyLabel('admin')).toBe('Admin approval');
+ expect(formatActionApprovalPolicyLabel('dry_run_only')).toBe('Dry run only');
+ expect(formatActionApprovalPolicyLabel('mfa')).toBe('MFA approval');
+ });
+});
diff --git a/frontend-modern/src/utils/actionAuditPresentation.ts b/frontend-modern/src/utils/actionAuditPresentation.ts
new file mode 100644
index 0000000000..3fa7b8ecef
--- /dev/null
+++ b/frontend-modern/src/utils/actionAuditPresentation.ts
@@ -0,0 +1,78 @@
+import type { ActionAuditState } from '@/types/actionAudit';
+
+export interface ActionAuditStatePresentation {
+ label: string;
+ className: string;
+}
+
+const ACTION_STATE_PRESENTATION: Record<ActionAuditState, ActionAuditStatePresentation> = {
+ planned: {
+ label: 'Planned',
+ className: 'bg-surface-alt text-muted border-border',
+ },
+ pending_approval: {
+ label: 'Pending approval',
+ className:
+ 'bg-amber-100 text-amber-800 border-amber-200 dark:bg-amber-900 dark:text-amber-200 dark:border-amber-700',
+ },
+ approved: {
+ label: 'Approved',
+ className:
+ 'bg-blue-100 text-blue-800 border-blue-200 dark:bg-blue-900 dark:text-blue-200 dark:border-blue-700',
+ },
+ rejected: {
+ label: 'Rejected',
+ className:
+ 'bg-red-100 text-red-800 border-red-200 dark:bg-red-900 dark:text-red-200 dark:border-red-700',
+ },
+ executing: {
+ label: 'Executing',
+ className:
+ 'bg-sky-100 text-sky-800 border-sky-200 dark:bg-sky-900 dark:text-sky-200 dark:border-sky-700',
+ },
+ completed: {
+ label: 'Completed',
+ className:
+ 'bg-emerald-100 text-emerald-800 border-emerald-200 dark:bg-emerald-900 dark:text-emerald-200 dark:border-emerald-700',
+ },
+ failed: {
+ label: 'Failed',
+ className:
+ 'bg-red-100 text-red-800 border-red-200 dark:bg-red-900 dark:text-red-200 dark:border-red-700',
+ },
+};
+
+export const getActionAuditStatePresentation = (
+ state: ActionAuditState | string | undefined,
+): ActionAuditStatePresentation =>
+ ACTION_STATE_PRESENTATION[state as ActionAuditState] ?? {
+ label: 'Unknown',
+ className: 'bg-surface-alt text-muted border-border',
+ };
+
+export const formatActionCapabilityLabel = (capabilityName: string | undefined): string => {
+ const normalized = (capabilityName || '').trim();
+ if (!normalized) return 'Action';
+
+ return normalized
+ .replace(/[._-]+/g, ' ')
+ .split(/\s+/)
+ .filter(Boolean)
+ .map((word) => `${word.slice(0, 1).toUpperCase()}${word.slice(1)}`)
+ .join(' ');
+};
+
+export const formatActionApprovalPolicyLabel = (policy: string | undefined): string => {
+ switch ((policy || '').trim()) {
+ case 'none':
+ return 'No approval';
+ case 'dry_run_only':
+ return 'Dry run only';
+ case 'admin':
+ return 'Admin approval';
+ case 'mfa':
+ return 'MFA approval';
+ default:
+ return formatActionCapabilityLabel(policy || 'Policy');
+ }
+};
diff --git a/scripts/release_control/subsystem_lookup_test.py b/scripts/release_control/subsystem_lookup_test.py
index 09da9a8272..eaaad19a33 100644
--- a/scripts/release_control/subsystem_lookup_test.py
+++ b/scripts/release_control/subsystem_lookup_test.py
@@ -3673,8 +3673,8 @@ class SubsystemLookupTest(unittest.TestCase):
{
"heading": "## Shared Boundaries",
"path": "internal/api/access_control_handlers.go",
- "line": 125,
- "heading_line": 86,
+ "line": 127,
+ "heading_line": 88,
}
],
)