Skip to content

armgit / Pulse

Public Imported from GitHub
0

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

feat(patrol): add canonical finding resource handoffs

rcourtmana742c43a6954
diff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.md
index a9150623df..f1d359b8dc 100644
--- a/docs/release-control/v6/internal/subsystems/alerts.md
+++ b/docs/release-control/v6/internal/subsystems/alerts.md
@@ -402,6 +402,13 @@ shared workloads, storage, and recovery surfaces through
`frontend-modern/src/routing/resourceLinks.ts` rather than leaving the panel
as a dead-end investigation card or rebuilding provider-local route strings for
platforms such as TrueNAS.
+That same alert handoff must now stay on the shared resolved-resource link
+builder. `AlertResourceIncidentsPanel.tsx` must resolve its chip set through
+`buildResolvedResourceSurfaceLinks(...)`, which owns exact unified-resource
+handoffs plus the infrastructure fallback when alert history still references a
+resource ID before the backing unified record has hydrated. Future incident-link
+work must not reintroduce local infrastructure-link assembly, local dedupe, or
+provider-local route strings inside the alert feature shell.
Alert configuration load/save state, notification config reloads, and threshold
override normalization now route through
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index bd1a1d6591..70c10b88f5 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -208,12 +208,18 @@ work extends shared components instead of creating new local variants.
connections` visible as the API-backed alternative for Proxmox and
TrueNAS, and expose the same first-host next step instead of falling back
to passive “nothing here yet” wording.
-13. Keep the authenticated app root aligned with that same first-session path.
+13. Keep cross-surface investigation handoffs on shared route ownership.
+ Feature shells such as Alerts and Patrol may decide which governed
+ destination chips to render, but canonical href, label, dedupe, and
+ infrastructure-fallback truth must stay in
+ `frontend-modern/src/routing/resourceLinks.ts` instead of freezing raw
+ route strings or provider-local link builders inside feature panels.
+14. Keep the authenticated app root aligned with that same first-session path.
`frontend-modern/src/App.tsx` must land `/` on the dashboard shell and let
the governed dashboard empty state route first-time operators into
Infrastructure Install, instead of preserving a separate root-only jump to
`/infrastructure` that drifts from the rest of the onboarding contract.
-14. Keep relay settings shell copy on the shared presentation owner in
+15. Keep relay settings shell copy on the shared presentation owner in
`frontend-modern/src/utils/relayPresentation.ts`. The route metadata in
`settingsHeaderMeta.ts` and the leading `SettingsPanel` in
`RelaySettingsPanel.tsx` must reuse the same description and availability
@@ -1514,6 +1520,14 @@ must keep platform-service recovery links on canonical recovery-events
framing and route state, so upstream service surfaces do not drift back to
PBS-backup wording or inherit the page-default inventory workspace when they
are actually deep-linking into recovery activity.
+That same shared primitive boundary also owns resource handoff chip framing for
+cross-surface investigation UI. Alerts, Patrol, and similar feature shells may
+choose which governed surfaces to show, but they must build those links through
+the shared resolved-resource route helpers in
+`frontend-modern/src/routing/resourceLinks.ts` instead of freezing raw route
+strings, local link dedupe, or provider-specific link chips inside feature
+panels. Shared chip styling belongs in the feature shell; canonical href and
+label truth belongs in the shared route helper.
That same shared primitive boundary now also owns persisted column-identity
migration for governed surfaces. When a v6 surface canonicalizes saved column
IDs, `frontend-modern/src/hooks/useColumnVisibility.ts` must accept explicit
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index a80694727e..1abc11857d 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -537,3 +537,10 @@ Patrol finding dismissal reasons and Patrol status labels now also route
through the shared frontend identifier-label helper, so the Patrol surfaces
do not keep their own underscore-stripping behavior separate from the rest
of the governed presentation helpers.
+That same Patrol findings surface must also stop being a route dead end.
+Expanded finding rows should resolve the backing unified resource and surface
+canonical `Infrastructure`, `Workloads`, `Storage`, and `Recovery` handoffs
+through `frontend-modern/src/routing/resourceLinks.ts` where those surfaces
+exist, rather than forcing operators to pivot manually through search or
+assistant prompts to continue investigating API-backed platforms such as
+TrueNAS.
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index ef76b64b3f..471e2d0513 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -368,6 +368,13 @@ falling back to page-local UI state. Focused recovery routes with an active
`rollupId` or `day` remain recovery-events-first by default, but the explicit
workspace selection must still serialize through the owned recovery URL model
whenever an operator overrides that implied default.
+That same shared route-helper contract now also has to preserve exact storage
+and recovery handoffs for unified resources discovered outside the storage or
+recovery pages. When alerts, Patrol, or infrastructure drawers route a
+TrueNAS-backed disk, app, or system into `/storage` or `/recovery`, the shared
+helper must keep the owned `source`, `node`, `platform`, `view`, and exact
+`resource` semantics intact instead of collapsing those handoffs back to
+provider-local URLs or generic top-level tabs.
That history table layout now also derives its minimum width from the same
canonical column-width spec that owns the header sizing in
`frontend-modern/src/utils/recoveryTablePresentation.ts`, so longer governed
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index d8f05d1555..9163616736 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -531,6 +531,12 @@ then into shared workloads, storage, and recovery surfaces via
`frontend-modern/src/routing/resourceLinks.ts`, instead of treating alert
investigation as a provider-local dead end or freezing per-surface route
strings outside the unified-resource contract.
+That same routing contract also owns Patrol finding handoffs. Expanded
+Patrol-finding rows and scoped-run finding snapshots must resolve the backing
+unified resource and surface the same canonical infrastructure/workloads/
+storage/recovery links there, including exact workload and physical-disk route
+state when the selected resource is itself the workload or disk, instead of
+stopping at finding text or rebuilding patrol-local route strings.
That drawer shell now routes its canonical timeline filter, facet-bundle, and
resource-intelligence state through
`frontend-modern/src/components/Infrastructure/useResourceDetailDrawerHistoryState.ts`,
diff --git a/frontend-modern/src/components/AI/FindingsPanel.tsx b/frontend-modern/src/components/AI/FindingsPanel.tsx
index e4bb8b9267..047509840d 100644
--- a/frontend-modern/src/components/AI/FindingsPanel.tsx
+++ b/frontend-modern/src/components/AI/FindingsPanel.tsx
@@ -11,14 +11,16 @@
*/
import { Component, createSignal, createEffect, Show, For, createMemo } from 'solid-js';
-import { useLocation } from '@solidjs/router';
+import { A, useLocation } from '@solidjs/router';
import { Card } from '@/components/shared/Card';
import { aiIntelligenceStore, type UnifiedFinding } from '@/stores/aiIntelligence';
import { notificationStore } from '@/stores/notifications';
import { aiChatStore } from '@/stores/aiChat';
+import { useResources } from '@/hooks/useResources';
import { InvestigationSection, ApprovalSection } from '@/components/patrol';
import { AIAPI, type RemediationPlan } from '@/api/ai';
import type { PatrolRunRecord, PatrolRuntimeState } from '@/api/patrol';
+import { buildResolvedResourceSurfaceLinks } from '@/routing/resourceLinks';
import { getApprovalRiskPresentation } from '@/utils/approvalRiskPresentation';
import { formatRelativeTime } from '@/utils/format';
import { getFindingAlertIdentifier, hasTriggeringAlert } from '@/utils/findingAlertIdentity';
@@ -85,6 +87,7 @@ interface FindingsPanelProps {
export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
const location = useLocation();
+ const { get: getResource } = useResources();
const [filter, setFilter] = createSignal<
'all' | 'active' | 'resolved' | 'approvals' | 'attention'
>(props.filterOverride ?? 'active');
@@ -465,6 +468,11 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
const title = getFindingTitlePresentation(finding);
const manualControls = getFindingManualControlsPresentation(finding);
const severityPresentation = getFindingSeverityPresentation(finding);
+ const surfaceLinks = buildResolvedResourceSurfaceLinks({
+ resourceId: finding.resourceId,
+ displayName: String(finding.resourceName || '').trim() || subject.label,
+ resource: getResource(finding.resourceId),
+ });
return (
<div
@@ -711,45 +719,63 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
</div>
{/* Expanded content */}
- <Show when={expandedId() === finding.id}>{renderExpandedContent(finding)}</Show>
+ <Show when={expandedId() === finding.id}>{renderExpandedContent(finding, surfaceLinks)}</Show>
</div>
);
};
// Render expanded content for a finding
- const renderExpandedContent = (finding: UnifiedFinding) => (
- <div class="mt-3 pt-3 border-t border-border-subtle">
- {(() => {
- const primaryAction = getFindingPrimaryActionPresentation(finding);
- return (
- <Show when={primaryAction}>
- {(action) => (
- <div class="mb-3">
- <a
- href={action().href}
+ const renderExpandedContent = (
+ finding: UnifiedFinding,
+ surfaceLinks: ReturnType<typeof buildResolvedResourceSurfaceLinks>,
+ ) => {
+ const primaryAction = getFindingPrimaryActionPresentation(finding);
+ const manualControls = getFindingManualControlsPresentation(finding);
+
+ return (
+ <div class="mt-3 pt-3 border-t border-border-subtle">
+ <Show when={primaryAction}>
+ {(action) => (
+ <div class="mb-3">
+ <a
+ href={action().href}
+ onClick={(e) => e.stopPropagation()}
+ class="inline-flex items-center rounded border border-border bg-surface px-2.5 py-1.5 text-xs font-semibold text-base-content transition-colors hover:bg-surface-hover"
+ >
+ {action().label}
+ </a>
+ </div>
+ )}
+ </Show>
+ <Show when={surfaceLinks.length > 0}>
+ <div class="mb-3 flex flex-wrap gap-2">
+ <For each={surfaceLinks}>
+ {(link) => (
+ <A
+ href={link.href}
+ aria-label={link.ariaLabel}
onClick={(e) => e.stopPropagation()}
- class="inline-flex items-center rounded border border-border bg-surface px-2.5 py-1.5 text-xs font-semibold text-base-content transition-colors hover:bg-surface-hover"
+ class="inline-flex items-center rounded-md border border-border px-2 py-1 text-xs text-muted transition-colors hover:bg-surface-hover hover:text-base-content"
>
- {action().label}
- </a>
- </div>
- )}
- </Show>
- );
- })()}
- <Show when={hasTriggeringAlert(finding)}>
+ {link.compactLabel}
+ </A>
+ )}
+ </For>
+ </div>
+ </Show>
+ <Show when={hasTriggeringAlert(finding)}>
<div class="text-xs text-amber-700 dark:text-amber-300 mb-2">
Triggered by alert{finding.alertType ? ` (${finding.alertType})` : ''} • Identifier{' '}
{getFindingAlertIdentifier(finding)}
</div>
- </Show>
- <p class="text-sm text-muted">{finding.description}</p>
- <Show when={finding.recommendation}>
+ </Show>
+ <p class="text-sm text-muted">{finding.description}</p>
+ <Show when={finding.recommendation}>
<p class="text-sm text-base-content mt-2">
<span class="font-medium">Recommendation:</span> {finding.recommendation}
</p>
- </Show>
- <Show when={(finding.regressionCount || 0) > 0}>
+ </Show>
+ <Show when={(finding.regressionCount || 0) > 0}>
<p class="text-xs text-amber-700 dark:text-amber-300 mt-2">
Regressions: {finding.regressionCount}
<Show when={finding.lastRegressionAt}>
@@ -757,7 +783,7 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
(last {formatRelativeTime(finding.lastRegressionAt)})
</Show>
</p>
- </Show>
+ </Show>
<Show when={finding.lifecycle && finding.lifecycle.length > 0}>
<div class="mt-3 p-2 rounded border border-border bg-surface-alt">
@@ -790,7 +816,7 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
</Show>
{/* User note display / editor */}
- <Show when={editingNoteId() === finding.id}>
+ <Show when={editingNoteId() === finding.id}>
<div
class="mt-3 p-2 rounded border border-blue-200 dark:border-blue-800 bg-blue-50 dark:bg-blue-900"
onClick={(e) => e.stopPropagation()}
@@ -820,8 +846,8 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
</button>
</div>
</div>
- </Show>
- <Show when={editingNoteId() !== finding.id && finding.userNote}>
+ </Show>
+ <Show when={editingNoteId() !== finding.id && finding.userNote}>
<div class="mt-3 p-2 rounded border border-border bg-surface-alt flex items-start gap-2">
<svg
class="w-4 h-4 text-muted mt-0.5 flex-shrink-0"
@@ -853,11 +879,11 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
</svg>
</button>
</div>
- </Show>
+ </Show>
- {/* Add Note / Discuss with Assistant buttons */}
- <div class="mt-3 flex flex-wrap gap-2 text-xs">
- <Show when={editingNoteId() !== finding.id && !finding.userNote}>
+ {/* Add Note / Discuss with Assistant buttons */}
+ <div class="mt-3 flex flex-wrap gap-2 text-xs">
+ <Show when={editingNoteId() !== finding.id && !finding.userNote}>
<button
type="button"
onClick={(e) => handleStartEditNote(finding, e)}
@@ -873,8 +899,8 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
</svg>
Add Note
</button>
- </Show>
- <button
+ </Show>
+ <button
type="button"
onClick={(e) => handleDiscussWithAssistant(finding, e)}
class="px-2 py-1 rounded bg-blue-50 text-blue-700 dark:bg-blue-900 dark:text-blue-300 hover:bg-blue-100 dark:hover:bg-blue-900 flex items-center gap-1 transition-colors"
@@ -888,10 +914,10 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
/>
</svg>
Discuss with Assistant
- </button>
- </div>
+ </button>
+ </div>
- <Show when={finding.status === 'active'}>
+ <Show when={finding.status === 'active'}>
<div class="mt-3 flex flex-wrap gap-2 text-xs">
<Show when={manualControls.acknowledge && !finding.acknowledgedAt}>
<button
@@ -960,9 +986,9 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
</>
</Show>
</div>
- </Show>
- {/* Inline dismiss confirmation */}
- <Show when={dismissingId() === finding.id}>
+ </Show>
+ {/* Inline dismiss confirmation */}
+ <Show when={dismissingId() === finding.id}>
<div class="mt-2 p-2 rounded border border-red-200 dark:border-red-800 bg-red-50 dark:bg-red-900">
<div class="flex items-center gap-2 mb-1.5">
<span class="text-xs font-medium text-red-700 dark:text-red-300">
@@ -995,25 +1021,25 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
</button>
</div>
</div>
- </Show>
- <Show when={finding.correlatedFindingIds && finding.correlatedFindingIds.length > 0}>
+ </Show>
+ <Show when={finding.correlatedFindingIds && finding.correlatedFindingIds.length > 0}>
<div class="mt-2 text-xs text-muted">
Related findings: {finding.correlatedFindingIds?.length}
</div>
- </Show>
+ </Show>
- {/* Inline Investigation Section (replaces drawer) */}
- <Show when={hasFindingInvestigationDetails(finding)}>
+ {/* Inline Investigation Section (replaces drawer) */}
+ <Show when={hasFindingInvestigationDetails(finding)}>
<InvestigationSection
findingId={finding.id}
investigationStatus={finding.investigationStatus}
investigationOutcome={finding.investigationOutcome}
investigationAttempts={finding.investigationAttempts}
/>
- </Show>
+ </Show>
- {/* Inline Approval Section (replaces manual approval JSX) */}
- <Show
+ {/* Inline Approval Section (replaces manual approval JSX) */}
+ <Show
when={
finding.status === 'active' &&
(finding.investigationOutcome === 'fix_queued' ||
@@ -1023,7 +1049,7 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
finding.investigationOutcome === 'fix_verification_failed' ||
finding.investigationOutcome === 'fix_verification_unknown')
}
- >
+ >
<ApprovalSection
findingId={finding.id}
investigationOutcome={finding.investigationOutcome}
@@ -1032,10 +1058,10 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
resourceType={finding.resourceType}
resourceId={finding.resourceId}
/>
- </Show>
+ </Show>
- {/* Remediation Plan artifact (generated by Patrol and/or an investigation) */}
- <Show when={finding.status === 'active' && plansByFindingId().get(finding.id)}>
+ {/* Remediation Plan artifact (generated by Patrol and/or an investigation) */}
+ <Show when={finding.status === 'active' && plansByFindingId().get(finding.id)}>
{(plan) => (
<div class="mt-3 pt-3 border-t border-border-subtle">
{(() => {
@@ -1117,9 +1143,10 @@ export const FindingsPanel: Component<FindingsPanelProps> = (props) => {
})()}
</div>
)}
- </Show>
- </div>
- );
+ </Show>
+ </div>
+ );
+ };
return (
<div class="space-y-4">
diff --git a/frontend-modern/src/components/AI/__tests__/FindingsPanel.links.test.tsx b/frontend-modern/src/components/AI/__tests__/FindingsPanel.links.test.tsx
new file mode 100644
index 0000000000..fc93707c0d
--- /dev/null
+++ b/frontend-modern/src/components/AI/__tests__/FindingsPanel.links.test.tsx
@@ -0,0 +1,158 @@
+import { fireEvent, render, screen, waitFor } from '@solidjs/testing-library';
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+import { FindingsPanel } from '../FindingsPanel';
+
+const mockState = vi.hoisted(() => {
+ const loadFindings = vi.fn();
+ const getRemediationPlans = vi.fn().mockResolvedValue({ plans: [] });
+ const getResource = vi.fn((resourceId: string) =>
+ resourceId === 'app-container:truenas-main:nextcloud'
+ ? ({
+ id: 'app-container:truenas-main:nextcloud',
+ type: 'app-container',
+ name: 'nextcloud',
+ displayName: 'Nextcloud',
+ parentId: 'truenas-main',
+ parentName: 'TrueNAS Main',
+ platformId: 'truenas-main',
+ platformType: 'truenas',
+ sourceType: 'api',
+ status: 'running',
+ lastSeen: Date.now(),
+ platformData: {
+ sources: ['truenas'],
+ },
+ } as const)
+ : undefined,
+ );
+
+ const findings = [
+ {
+ id: 'finding-truenas-app',
+ source: 'ai-patrol',
+ resourceId: 'app-container:truenas-main:nextcloud',
+ resourceName: 'Nextcloud',
+ resourceType: 'app-container',
+ category: 'reliability',
+ severity: 'warning',
+ title: 'Nextcloud failed readiness checks',
+ description: 'Pulse Patrol detected repeated readiness probe failures.',
+ detectedAt: '2026-03-30T10:00:00Z',
+ lastSeenAt: '2026-03-30T10:05:00Z',
+ status: 'active',
+ },
+ ];
+
+ return {
+ findings,
+ getResource,
+ getRemediationPlans,
+ loadFindings,
+ };
+});
+
+vi.mock('@solidjs/router', () => ({
+ A: (props: { href: string; children: unknown; [key: string]: unknown }) => (
+ <a href={props.href} aria-label={props['aria-label'] as string} onClick={props.onClick as any}>
+ {props.children}
+ </a>
+ ),
+ useLocation: () => ({ hash: '' }),
+}));
+
+vi.mock('@/components/shared/Card', () => ({
+ Card: (props: { children: unknown }) => <div>{props.children}</div>,
+}));
+
+vi.mock('@/components/patrol', () => ({
+ InvestigationSection: () => null,
+ ApprovalSection: () => null,
+}));
+
+vi.mock('@/stores/notifications', () => ({
+ notificationStore: {
+ success: vi.fn(),
+ error: vi.fn(),
+ },
+}));
+
+vi.mock('@/stores/aiChat', () => ({
+ aiChatStore: {
+ openWithPrompt: vi.fn(),
+ },
+}));
+
+vi.mock('@/api/ai', () => ({
+ AIAPI: {
+ getRemediationPlans: mockState.getRemediationPlans,
+ },
+}));
+
+vi.mock('@/hooks/useResources', () => ({
+ useResources: () => ({
+ get: mockState.getResource,
+ }),
+}));
+
+vi.mock('@/stores/aiIntelligence', () => ({
+ aiIntelligenceStore: {
+ get findings() {
+ return mockState.findings;
+ },
+ get findingsLoading() {
+ return false;
+ },
+ get findingsError() {
+ return null;
+ },
+ get findingsNeedingAttention() {
+ return [];
+ },
+ get findingsWithPendingApprovals() {
+ return [];
+ },
+ get needsAttentionCount() {
+ return 0;
+ },
+ get pendingApprovalCount() {
+ return 0;
+ },
+ findingsSignal: () => mockState.findings,
+ loadFindings: mockState.loadFindings,
+ },
+}));
+
+describe('FindingsPanel resource links', () => {
+ beforeEach(() => {
+ mockState.loadFindings.mockClear();
+ mockState.getRemediationPlans.mockClear();
+ mockState.getResource.mockClear();
+
+ if (typeof window.requestAnimationFrame !== 'function') {
+ window.requestAnimationFrame = ((callback: FrameRequestCallback) =>
+ window.setTimeout(() => callback(performance.now()), 0)) as typeof window.requestAnimationFrame;
+ }
+ });
+
+ it('surfaces canonical handoff links for TrueNAS workload findings', async () => {
+ render(() => <FindingsPanel />);
+
+ await waitFor(() => expect(mockState.loadFindings).toHaveBeenCalled());
+
+ fireEvent.click(screen.getByText('Nextcloud failed readiness checks'));
+
+ expect(
+ screen.getByRole('link', { name: 'Open related infrastructure for Nextcloud' }),
+ ).toHaveAttribute(
+ 'href',
+ '/infrastructure?resource=app-container%3Atruenas-main%3Anextcloud',
+ );
+ expect(
+ screen.getByRole('link', { name: 'Open related workloads for Nextcloud' }),
+ ).toHaveAttribute(
+ 'href',
+ '/workloads?type=app-container&platform=truenas&agent=truenas-main&resource=app-container%3Atruenas-main%3Anextcloud',
+ );
+ });
+});
diff --git a/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts b/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
index c51f9b7da5..4d9f677eb1 100644
--- a/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
+++ b/frontend-modern/src/components/AI/__tests__/FindingsPanel.test.ts
@@ -443,6 +443,17 @@ describe('aiFindingPresentation', () => {
expect(findingsPanelSource).toContain("href={action().href}");
});
+ it('resolves unified resources and shared route links for expanded finding handoffs', () => {
+ expect(findingsPanelSource).toContain("import { useResources } from '@/hooks/useResources';");
+ expect(findingsPanelSource).toContain(
+ "import { buildResolvedResourceSurfaceLinks } from '@/routing/resourceLinks';",
+ );
+ expect(findingsPanelSource).toContain('const { get: getResource } = useResources();');
+ expect(findingsPanelSource).toContain('buildResolvedResourceSurfaceLinks({');
+ expect(findingsPanelSource).toContain('resource: getResource(finding.resourceId)');
+ expect(findingsPanelSource).toContain("{link.compactLabel}");
+ });
+
it('routes generic finding controls through the shared manual-controls helper', () => {
expect(findingsPanelSource).toContain('getFindingManualControlsPresentation(finding)');
expect(findingsPanelSource).toContain('manualControls.acknowledge');
diff --git a/frontend-modern/src/features/alerts/AlertResourceIncidentsPanel.tsx b/frontend-modern/src/features/alerts/AlertResourceIncidentsPanel.tsx
index ed1a93f712..2ef87a9b4e 100644
--- a/frontend-modern/src/features/alerts/AlertResourceIncidentsPanel.tsx
+++ b/frontend-modern/src/features/alerts/AlertResourceIncidentsPanel.tsx
@@ -5,8 +5,7 @@ import { IncidentEventFilters } from '@/components/Alerts/IncidentEventFilters';
import { IncidentTimelineEventCard } from '@/components/Alerts/IncidentTimelineEventCard';
import { Card } from '@/components/shared/Card';
import {
- buildInfrastructureResourceLink,
- buildResourceSurfaceLinksForResource,
+ buildResolvedResourceSurfaceLinks,
type ResourceSurfaceLink,
} from '@/routing/resourceLinks';
import type { Resource } from '@/types/resource';
@@ -57,22 +56,11 @@ export function AlertResourceIncidentsPanel(props: AlertResourceIncidentsPanelPr
return selection().resourceName;
};
const links = (): ResourceSurfaceLink[] => {
- const nextLinks: ResourceSurfaceLink[] = [];
- const infrastructure = buildInfrastructureResourceLink(resourceId, resourceDisplayName());
- if (infrastructure) {
- nextLinks.push(infrastructure);
- }
-
- const current = resource();
- if (current) {
- nextLinks.push(...buildResourceSurfaceLinksForResource(current, resourceDisplayName()));
- }
-
- const seen = new Set<string>();
- return nextLinks.filter((link) => {
- if (seen.has(link.href)) return false;
- seen.add(link.href);
- return true;
+ return buildResolvedResourceSurfaceLinks({
+ resourceId,
+ displayName: resourceDisplayName(),
+ resource: resource(),
+ allowInfrastructureFallback: true,
});
};
diff --git a/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts b/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts
index 3dc760c5f1..7066650608 100644
--- a/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts
+++ b/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts
@@ -361,10 +361,11 @@ describe('tab path helpers', () => {
expect(alertResourceIncidentsPanelSource).toContain('export function AlertResourceIncidentsPanel');
expect(alertResourceIncidentsPanelSource).toContain('IncidentEventFilters');
expect(alertResourceIncidentsPanelSource).toContain('IncidentTimelineEventCard');
- expect(alertResourceIncidentsPanelSource).toContain('buildInfrastructureResourceLink');
- expect(alertResourceIncidentsPanelSource).toContain('buildResourceSurfaceLinksForResource');
- expect(alertResourceIncidentsPanelSource).toContain(
- 'buildInfrastructureResourceLink(resourceId, resourceDisplayName())',
+ expect(alertResourceIncidentsPanelSource).toContain('buildResolvedResourceSurfaceLinks');
+ expect(alertResourceIncidentsPanelSource).toContain('allowInfrastructureFallback: true');
+ expect(alertResourceIncidentsPanelSource).not.toContain('buildInfrastructureResourceLink');
+ expect(alertResourceIncidentsPanelSource).not.toContain(
+ 'buildResourceSurfaceLinksForResource',
);
expect(alertResourceIncidentsPanelSource).toContain('{link.compactLabel}');
expect(alertHistoryTableSectionSource).toContain('export function AlertHistoryTableSection');
@@ -463,11 +464,14 @@ describe('tab path helpers', () => {
expect(alertScheduleTabSource).not.toContain('ALERT_CONFIG_QUIET_HOURS_TITLE');
expect(alertScheduleTabSource).not.toContain('ALERT_CONFIG_ESCALATION_TITLE');
expect(alertThresholdsTabSource).toContain('ThresholdsTable');
- expect(alertThresholdsTabSource).toContain('buildThresholdsTableProps');
- expect(alertThresholdsTabSource).not.toContain('pmgThresholds={props.pmgThresholds}');
+ expect(alertThresholdsTabSource).toContain('pmgThresholds={props.pmgThresholds}');
+ expect(alertThresholdsTabSource).toContain('guestDefaults={props.guestDefaults()}');
+ expect(alertThresholdsTabSource).not.toContain('buildThresholdsTableProps');
expect(thresholdsTabModelSource).toContain('export interface ThresholdsTabProps');
- expect(thresholdsTabModelSource).toContain('export function buildThresholdsTableProps');
- expect(thresholdsTabModelSource).toContain('guestDefaults: props.guestDefaults()');
+ expect(thresholdsTabModelSource).toContain('extends Omit<');
+ expect(thresholdsTabModelSource).toContain(
+ "guestDefaults: Accessor<ThresholdsTableProps['guestDefaults']>;",
+ );
expect(thresholdsTabModelSource).not.toContain('hasUnsavedChanges');
expect(thresholdsTableSource).toContain(
"import { useThresholdsTableState } from '@/features/alerts/thresholds/hooks/useThresholdsTableState';",
diff --git a/frontend-modern/src/routing/__tests__/resourceLinks.test.ts b/frontend-modern/src/routing/__tests__/resourceLinks.test.ts
index 7bd050f648..b8953c9eca 100644
--- a/frontend-modern/src/routing/__tests__/resourceLinks.test.ts
+++ b/frontend-modern/src/routing/__tests__/resourceLinks.test.ts
@@ -9,6 +9,7 @@ import {
buildRecoveryHrefForResource,
buildInfrastructurePath,
buildInfrastructureResourceHref,
+ buildResolvedResourceSurfaceLinks,
buildResourceSurfaceLinksForResource,
buildStorageHrefForResource,
buildStoragePath,
@@ -189,6 +190,25 @@ describe('resource link routing contract', () => {
).toBe('/workloads?type=app-container&platform=truenas&agent=truenas-main');
});
+ it('builds exact workloads links for TrueNAS app-container resources', () => {
+ expect(
+ buildWorkloadsHrefForResource({
+ id: 'app-container:truenas-main:nextcloud',
+ type: 'app-container',
+ name: 'nextcloud',
+ displayName: 'Nextcloud',
+ parentId: 'truenas-main',
+ platformId: 'truenas-main',
+ platformType: 'truenas',
+ sourceType: 'api',
+ status: 'running',
+ lastSeen: Date.now(),
+ } as any),
+ ).toBe(
+ '/workloads?type=app-container&platform=truenas&agent=truenas-main&resource=app-container%3Atruenas-main%3Anextcloud',
+ );
+ });
+
it('maps pod workloads to kubernetes infrastructure source with cluster query', () => {
const href = buildInfrastructureHrefForWorkload(
baseGuest({
@@ -264,6 +284,28 @@ describe('resource link routing contract', () => {
expect(href).toBe('/storage?source=truenas&resource=storage-truenas-display');
});
+ it('builds storage deep links for TrueNAS physical disks on the disks tab', () => {
+ const href = buildStorageHrefForResource({
+ id: 'disk:truenas-main:sda',
+ type: 'physical_disk',
+ name: 'sda',
+ displayName: 'Seagate IronWolf',
+ parentId: 'truenas-main',
+ platformId: 'truenas-main',
+ platformType: 'truenas',
+ sourceType: 'api',
+ status: 'online',
+ lastSeen: Date.now(),
+ physicalDisk: {
+ serial: '',
+ },
+ } as any);
+
+ expect(href).toBe(
+ '/storage?tab=disks&source=truenas&node=truenas-main&resource=disk%3Atruenas-main%3Asda',
+ );
+ });
+
it('builds storage deep links for top-level TrueNAS systems', () => {
const href = buildStorageHrefForResource({
id: 'truenas-main',
@@ -373,6 +415,40 @@ describe('resource link routing contract', () => {
]);
});
+ it('builds canonical surface links for exact TrueNAS app-container resources', () => {
+ expect(
+ buildResolvedResourceSurfaceLinks({
+ resourceId: 'app-container:truenas-main:nextcloud',
+ displayName: 'Nextcloud',
+ resource: {
+ id: 'app-container:truenas-main:nextcloud',
+ type: 'app-container',
+ name: 'nextcloud',
+ displayName: 'Nextcloud',
+ parentId: 'truenas-main',
+ platformId: 'truenas-main',
+ platformType: 'truenas',
+ sourceType: 'api',
+ status: 'running',
+ lastSeen: Date.now(),
+ } as any,
+ }),
+ ).toEqual([
+ {
+ href: '/infrastructure?resource=app-container%3Atruenas-main%3Anextcloud',
+ label: 'Open in Infrastructure',
+ compactLabel: 'Infrastructure',
+ ariaLabel: 'Open related infrastructure for Nextcloud',
+ },
+ {
+ href: '/workloads?type=app-container&platform=truenas&agent=truenas-main&resource=app-container%3Atruenas-main%3Anextcloud',
+ label: 'Open in Workloads',
+ compactLabel: 'Workloads',
+ ariaLabel: 'Open related workloads for Nextcloud',
+ },
+ ]);
+ });
+
it('canonicalizes legacy storage source aliases when parsing links', () => {
expect(parseStorageLinkSearch('?source=pbs')).toMatchObject({ source: 'proxmox-pbs' });
expect(parseStorageLinkSearch('?source=proxmox')).toMatchObject({ source: 'proxmox-pve' });
diff --git a/frontend-modern/src/routing/resourceLinks.ts b/frontend-modern/src/routing/resourceLinks.ts
index a96731f8cd..d719ae3db2 100644
--- a/frontend-modern/src/routing/resourceLinks.ts
+++ b/frontend-modern/src/routing/resourceLinks.ts
@@ -100,6 +100,15 @@ const firstNonEmpty = (values: Array<string | undefined | null>): string | undef
return undefined;
};
+const dedupeResourceSurfaceLinks = (links: ResourceSurfaceLink[]): ResourceSurfaceLink[] => {
+ const seen = new Set<string>();
+ return links.filter((link) => {
+ if (seen.has(link.href)) return false;
+ seen.add(link.href);
+ return true;
+ });
+};
+
type WorkloadsLinkOptions = {
type?: string | null;
platform?: string | null;
@@ -153,6 +162,13 @@ export type ResourceSurfaceLink = {
ariaLabel: string;
};
+type ResolvedResourceSurfaceLinkOptions = {
+ resourceId: string;
+ displayName: string;
+ resource?: Resource | null;
+ allowInfrastructureFallback?: boolean;
+};
+
const RECOVERY_LEGACY_PLATFORM_QUERY_PARAM = 'provider';
export const parseWorkloadsLinkSearch = (search: string) => {
@@ -269,6 +285,9 @@ const resolveKubernetesContextForResource = (resource: Resource): string | undef
if (resource.type === 'k8s-node') {
return kubernetesContext;
}
+ if (resource.type === 'pod') {
+ return kubernetesContext;
+ }
return undefined;
};
@@ -315,6 +334,47 @@ export const buildWorkloadsHrefForResource = (resource: Resource): string | null
return buildWorkloadsPath({ agent });
}
+ if (
+ resource.type === 'vm' ||
+ resource.type === 'system-container' ||
+ resource.type === 'oci-container' ||
+ resource.type === 'jail'
+ ) {
+ return buildWorkloadsPath({
+ type: resource.type,
+ platform: resource.platformType,
+ agent: firstNonEmpty([resource.parentId, resource.platformId]),
+ resource: resource.id,
+ });
+ }
+
+ if (resource.type === 'app-container') {
+ const isTrueNAS = resource.platformType === 'truenas' || hasMergedSource(resource, 'truenas');
+ const isDocker = resource.platformType === 'docker' || hasMergedSource(resource, 'docker');
+ return buildWorkloadsPath({
+ type: 'app-container',
+ platform: isTrueNAS ? 'truenas' : isDocker ? 'docker' : resource.platformType,
+ agent: isDocker
+ ? firstNonEmpty([
+ getActionableDockerRuntimeIdFromResource(resource),
+ resource.parentId,
+ resource.platformId,
+ ])
+ : firstNonEmpty([resource.parentId, resource.platformId]),
+ resource: resource.id,
+ });
+ }
+
+ if (resource.type === 'pod') {
+ return buildWorkloadsPath({
+ type: 'pod',
+ platform: 'kubernetes',
+ context: resolveKubernetesContextForResource(resource),
+ namespace: firstNonEmpty([resource.kubernetes?.namespace, resource.labels?.namespace]),
+ resource: resource.id,
+ });
+ }
+
return null;
};
@@ -356,12 +416,7 @@ export const buildResourceSurfaceLinksForResource = (
});
}
- const seen = new Set<string>();
- return links.filter((link) => {
- if (seen.has(link.href)) return false;
- seen.add(link.href);
- return true;
- });
+ return dedupeResourceSurfaceLinks(links);
};
const resolveStorageRouteSource = (resource: Resource): string => {
@@ -378,13 +433,28 @@ export const buildStorageHrefForResource = (resource: Resource): string | null =
const source = resolveStorageRouteSource(resource);
if (!source || source === 'all') return null;
- if (resource.type === 'storage' || resource.type === 'datastore') {
+ if (
+ resource.type === 'storage' ||
+ resource.type === 'datastore' ||
+ resource.type === 'pool' ||
+ resource.type === 'dataset' ||
+ resource.type === 'ceph'
+ ) {
return buildStoragePath({
source,
resource: resource.id,
});
}
+ if (resource.type === 'physical_disk') {
+ return buildStoragePath({
+ tab: 'disks',
+ source,
+ node: firstNonEmpty([resource.parentId, resource.platformId]),
+ resource: resource.id,
+ });
+ }
+
if (resource.type === 'truenas' || resource.type === 'pbs') {
return buildStoragePath({
source,
@@ -402,6 +472,33 @@ export const buildStorageHrefForResource = (resource: Resource): string | null =
return null;
};
+export const buildResolvedResourceSurfaceLinks = ({
+ resourceId,
+ displayName,
+ resource,
+ allowInfrastructureFallback = false,
+}: ResolvedResourceSurfaceLinkOptions): ResourceSurfaceLink[] => {
+ const links: ResourceSurfaceLink[] = [];
+
+ if (resource) {
+ const infrastructure = buildInfrastructureResourceLink(resource.id, displayName);
+ if (infrastructure) {
+ links.push(infrastructure);
+ }
+ links.push(...buildResourceSurfaceLinksForResource(resource, displayName));
+ return dedupeResourceSurfaceLinks(links);
+ }
+
+ if (allowInfrastructureFallback) {
+ const infrastructure = buildInfrastructureResourceLink(resourceId, displayName);
+ if (infrastructure) {
+ links.push(infrastructure);
+ }
+ }
+
+ return dedupeResourceSurfaceLinks(links);
+};
+
export const buildRecoveryHrefForResource = (resource: Resource): string | null => {
const mergedPlatform = Array.isArray(resource.platformData?.sources)
? resolvePlatformTypeFromSources(resource.platformData.sources)
diff --git a/tests/integration/tests/29-truenas-patrol-finding-links.spec.ts b/tests/integration/tests/29-truenas-patrol-finding-links.spec.ts
new file mode 100644
index 0000000000..a00c34249d
--- /dev/null
+++ b/tests/integration/tests/29-truenas-patrol-finding-links.spec.ts
@@ -0,0 +1,363 @@
+import fs from 'node:fs';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { test as base, expect } from '@playwright/test';
+
+import { createAuthenticatedStorageState } from './helpers';
+
+const __dirname = path.dirname(fileURLToPath(import.meta.url));
+
+type WorkerFixtures = {
+ authStorageStatePath: string;
+};
+
+const SCREENSHOT_PATH = '/tmp/truenas-patrol-finding-links.png';
+
+const test = base.extend<{}, WorkerFixtures>({
+ storageState: async ({ authStorageStatePath }, use) => {
+ await use(authStorageStatePath);
+ },
+ authStorageStatePath: [async ({ browser }, use, workerInfo) => {
+ const storageStatePath = path.resolve(
+ __dirname,
+ '..',
+ '..',
+ 'tmp',
+ 'playwright-auth',
+ `truenas-patrol-finding-links-${workerInfo.project.name}.json`,
+ );
+ fs.mkdirSync(path.dirname(storageStatePath), { recursive: true });
+ await createAuthenticatedStorageState(browser, storageStatePath);
+ try {
+ await use(storageStatePath);
+ } finally {
+ fs.rmSync(storageStatePath, { force: true });
+ }
+ }, { scope: 'worker' }],
+});
+
+test.describe('TrueNAS patrol finding links', () => {
+ test.setTimeout(180_000);
+
+ test('keeps TrueNAS Patrol findings on canonical surface handoff routes', async ({ page }) => {
+ await page.route('**/api/resources**', async (route) => {
+ const requestUrl = new URL(route.request().url());
+ if (requestUrl.pathname !== '/api/resources') {
+ await route.continue();
+ return;
+ }
+
+ await route.fulfill({
+ status: 200,
+ contentType: 'application/json',
+ body: JSON.stringify({
+ data: [
+ {
+ id: 'truenas-main',
+ type: 'truenas',
+ name: 'truenas-main',
+ displayName: 'TrueNAS Main',
+ platformId: 'truenas-main',
+ platformType: 'truenas',
+ sourceType: 'hybrid',
+ sources: ['agent', 'truenas'],
+ status: 'online',
+ lastSeen: '2026-03-30T10:00:00Z',
+ canonicalIdentity: {
+ displayName: 'TrueNAS Main',
+ hostname: 'truenas-main',
+ platformId: 'truenas-main',
+ },
+ platformData: {
+ sources: ['agent', 'truenas'],
+ },
+ },
+ {
+ id: 'app-container:truenas-main:nextcloud',
+ type: 'app-container',
+ name: 'nextcloud',
+ displayName: 'Nextcloud',
+ parentId: 'truenas-main',
+ parentName: 'TrueNAS Main',
+ platformId: 'truenas-main',
+ platformType: 'truenas',
+ sourceType: 'api',
+ sources: ['truenas'],
+ status: 'running',
+ lastSeen: '2026-03-30T10:00:00Z',
+ platformData: {
+ sources: ['truenas'],
+ },
+ },
+ ],
+ meta: {
+ page: 1,
+ limit: 200,
+ total: 2,
+ totalPages: 1,
+ },
+ }),
+ });
+ });
+
+ await page.route('**/api/ai/patrol/status', async (route) => {
+ await route.fulfill({
+ status: 200,
+ contentType: 'application/json',
+ body: JSON.stringify({
+ runtime_state: 'active',
+ running: false,
+ enabled: true,
+ last_patrol_at: '2026-03-30T09:00:00Z',
+ last_activity_at: '2026-03-30T10:05:00Z',
+ next_patrol_at: '2026-03-30T15:00:00Z',
+ last_duration_ms: 180000,
+ resources_checked: 42,
+ findings_count: 2,
+ error_count: 0,
+ healthy: false,
+ interval_ms: 21600000,
+ fixed_count: 0,
+ blocked_reason: '',
+ blocked_at: '',
+ license_required: false,
+ license_status: 'active',
+ summary: {
+ critical: 1,
+ warning: 1,
+ watch: 0,
+ info: 0,
+ },
+ using_quickstart: false,
+ quickstart_credits_total: 0,
+ quickstart_credits_remaining: 0,
+ }),
+ });
+ });
+
+ await page.route('**/api/ai/patrol/runs*', async (route) => {
+ await route.fulfill({
+ status: 200,
+ contentType: 'application/json',
+ body: JSON.stringify([
+ {
+ id: 'run-truenas-links',
+ started_at: '2026-03-30T09:00:00Z',
+ completed_at: '2026-03-30T09:03:00Z',
+ duration_ms: 180000,
+ type: 'full',
+ trigger_reason: 'scheduled',
+ resources_checked: 42,
+ findings_summary: '2 findings',
+ finding_ids: ['finding-truenas-system', 'finding-truenas-app'],
+ error_count: 0,
+ status: 'warning',
+ triage_flags: 0,
+ tool_call_count: 0,
+ },
+ ]),
+ });
+ });
+
+ await page.route('**/api/ai/patrol/autonomy', async (route) => {
+ await route.fulfill({
+ status: 200,
+ contentType: 'application/json',
+ body: JSON.stringify({
+ autonomy_level: 'monitor',
+ full_mode_unlocked: false,
+ investigation_budget: 15,
+ investigation_timeout_sec: 300,
+ }),
+ });
+ });
+
+ await page.route('**/api/ai/models', async (route) => {
+ await route.fulfill({
+ status: 200,
+ contentType: 'application/json',
+ body: JSON.stringify({ models: [] }),
+ });
+ });
+
+ await page.route('**/api/settings/ai', async (route) => {
+ await route.fulfill({
+ status: 200,
+ contentType: 'application/json',
+ body: JSON.stringify({
+ patrol_enabled: true,
+ patrol_interval_minutes: 360,
+ patrol_model: '',
+ model: '',
+ alert_triggered_analysis: true,
+ patrol_alert_triggers_enabled: true,
+ patrol_anomaly_triggers_enabled: true,
+ patrol_event_triggers_enabled: true,
+ patrol_auto_fix: false,
+ auto_fix_model: '',
+ }),
+ });
+ });
+
+ await page.route('**/api/ai/unified/findings*', async (route) => {
+ await route.fulfill({
+ status: 200,
+ contentType: 'application/json',
+ body: JSON.stringify({
+ findings: [
+ {
+ id: 'finding-truenas-system',
+ severity: 'critical',
+ category: 'availability',
+ resource_id: 'truenas-main',
+ resource_name: 'TrueNAS Main',
+ resource_type: 'truenas',
+ title: 'TrueNAS system offline',
+ description: 'Pulse Patrol detected that the TrueNAS appliance stopped reporting.',
+ detected_at: '2026-03-30T09:10:00Z',
+ last_seen_at: '2026-03-30T10:05:00Z',
+ auto_resolved: false,
+ times_raised: 1,
+ suppressed: false,
+ investigation_attempts: 0,
+ },
+ {
+ id: 'finding-truenas-app',
+ severity: 'warning',
+ category: 'reliability',
+ resource_id: 'app-container:truenas-main:nextcloud',
+ resource_name: 'Nextcloud',
+ resource_type: 'app-container',
+ title: 'Nextcloud failed readiness checks',
+ description: 'Pulse Patrol detected repeated readiness probe failures.',
+ detected_at: '2026-03-30T09:20:00Z',
+ last_seen_at: '2026-03-30T10:05:00Z',
+ auto_resolved: false,
+ times_raised: 1,
+ suppressed: false,
+ investigation_attempts: 0,
+ },
+ ],
+ count: 2,
+ active_count: 2,
+ }),
+ });
+ });
+
+ await page.route('**/api/ai/intelligence/correlations*', async (route) => {
+ await route.fulfill({
+ status: 200,
+ contentType: 'application/json',
+ body: JSON.stringify({ correlations: [], count: 0 }),
+ });
+ });
+
+ await page.route('**/api/ai/intelligence', async (route) => {
+ await route.fulfill({
+ status: 200,
+ contentType: 'application/json',
+ body: JSON.stringify({
+ timestamp: '2026-03-30T10:05:00Z',
+ overall_health: {
+ score: 71,
+ grade: 'C',
+ trend: 'stable',
+ factors: [],
+ prediction: 'TrueNAS resources need attention.',
+ },
+ findings_count: {
+ critical: 1,
+ warning: 1,
+ watch: 0,
+ info: 0,
+ total: 2,
+ },
+ predictions_count: 0,
+ recent_changes_count: 0,
+ recent_changes: [],
+ learning: {
+ resources_with_knowledge: 0,
+ total_notes: 0,
+ resources_with_baselines: 0,
+ patterns_detected: 0,
+ correlations_learned: 0,
+ incidents_tracked: 0,
+ },
+ }),
+ });
+ });
+
+ await page.route('**/api/ai/circuit/status', async (route) => {
+ await route.fulfill({
+ status: 200,
+ contentType: 'application/json',
+ body: JSON.stringify({
+ state: 'closed',
+ can_patrol: true,
+ consecutive_failures: 0,
+ total_successes: 42,
+ total_failures: 0,
+ }),
+ });
+ });
+
+ await page.route('**/api/ai/approvals', async (route) => {
+ await route.fulfill({
+ status: 200,
+ contentType: 'application/json',
+ body: JSON.stringify({ approvals: [] }),
+ });
+ });
+
+ await page.route('**/api/ai/remediation/plans', async (route) => {
+ await route.fulfill({
+ status: 200,
+ contentType: 'application/json',
+ body: JSON.stringify({ plans: [] }),
+ });
+ });
+
+ await page.goto('/ai', { waitUntil: 'domcontentloaded' });
+
+ await expect(page.getByRole('button', { name: 'Findings' })).toBeVisible();
+
+ await page.getByText('TrueNAS system offline').click();
+ const systemFinding = page.locator('#finding-finding-truenas-system');
+ await expect(
+ systemFinding.getByRole('link', {
+ name: 'Open related infrastructure for TrueNAS Main',
+ }),
+ ).toHaveAttribute('href', '/infrastructure?resource=truenas-main');
+ await expect(
+ systemFinding.getByRole('link', { name: 'Open related workloads for TrueNAS Main' }),
+ ).toHaveAttribute(
+ 'href',
+ '/workloads?type=app-container&platform=truenas&agent=truenas-main',
+ );
+ await expect(
+ systemFinding.getByRole('link', { name: 'Open related storage for TrueNAS Main' }),
+ ).toHaveAttribute('href', '/storage?source=truenas&node=truenas-main');
+ await expect(
+ systemFinding.getByRole('link', { name: 'Open related recovery for TrueNAS Main' }),
+ ).toHaveAttribute('href', '/recovery?platform=truenas&node=truenas-main');
+
+ await page.getByText('Nextcloud failed readiness checks').click();
+ const appFinding = page.locator('#finding-finding-truenas-app');
+ await expect(
+ appFinding.getByRole('link', {
+ name: 'Open related infrastructure for Nextcloud',
+ }),
+ ).toHaveAttribute(
+ 'href',
+ '/infrastructure?resource=app-container%3Atruenas-main%3Anextcloud',
+ );
+ await expect(
+ appFinding.getByRole('link', { name: 'Open related workloads for Nextcloud' }),
+ ).toHaveAttribute(
+ 'href',
+ '/workloads?type=app-container&platform=truenas&agent=truenas-main&resource=app-container%3Atruenas-main%3Anextcloud',
+ );
+
+ await page.screenshot({ path: SCREENSHOT_PATH, fullPage: true });
+ });
+});