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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
feat(alerts): add canonical resource incident handoffs
rcourtman744aab33106a
diff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.mdindex 2a608a9fc8..38f9f372af 100644--- a/docs/release-control/v6/internal/subsystems/alerts.md+++ b/docs/release-control/v6/internal/subsystems/alerts.md@@ -388,6 +388,14 @@ Future alert-history control-flow work should extend the feature hook, newgrouping or trend semantics should extend the history model, and render-heavyhistory surfaces should extend those section owners instead of putting fetch,resource-incident state, or table rendering back into the shell.+That same history surface now also owns the canonical resource-incident+handoff. `frontend-modern/src/features/alerts/AlertResourceIncidentsPanel.tsx`+must treat the selected incident resource as a unified-resource consumer,+linking back into canonical infrastructure/resource detail first and then into+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.Alert configuration load/save state, notification config reloads, and thresholdoverride normalization now route throughdiff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex 82effa1409..ec5e25e4cf 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -248,6 +248,13 @@ work extends shared components instead of creating new local variants.derive TrueNAS connection counts and availability from the sharedinfrastructure settings state instead of letting the reporting summary andthe provider-specific panel issue separate connection fetches.+18. Keep alert-history feature composition on the current owned state contract.+ `frontend-modern/src/features/alerts/tabs/HistoryTab.tsx` must react to the+ shared `alertData()` history state instead of reviving deleted aliases, and+ it must pass unified-resource resolution through to+ `frontend-modern/src/features/alerts/AlertResourceIncidentsPanel.tsx` so+ the panel can render shared route chips without creating another page-local+ resource lookup or provider-specific handoff layer.## Current State@@ -1379,6 +1386,15 @@ now route throughFuture alert-history control flow should extend the hook, pure history analyticsshould extend the model, and section rendering should extend those ownersrather than rebuilding any of those concerns in the tab shell.+That same feature shell now owns the resource-resolution handoff into the+resource-incident panel. `frontend-modern/src/features/alerts/tabs/HistoryTab.tsx`+must pass the unified-resource resolver through to+`frontend-modern/src/features/alerts/AlertResourceIncidentsPanel.tsx`, and the+tab shell itself should only react to the current `alertData()` contract rather+than reviving deleted history-state aliases such as `filteredAlerts()`. The+panel may render compact route chips, but it must stay on shared route helpers+and feature-owned composition instead of growing provider-local routing logic+or another page-local resource lookup path.Top-level settings surfaces must route through `Settings.tsx`,`SettingsPageShell.tsx`, and`frontend-modern/src/components/shared/SettingsPanel.tsx` instead ofdiff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex 578f37c964..ef76b64b3f 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -86,6 +86,7 @@ querying, and the operator-facing storage health presentation layer.24. Keep backend-native platform configuration reads on the adjacent AI/runtime and platform contracts. When `internal/api/` wires native TrueNAS app config for Assistant, storage and recovery may use that runtime shape during investigation, but they must not grow a parallel recovery-local config transport or provider-shaped configuration payload.25. Keep provider-backed poll cadence and settings-runtime health on the adjacent platform-connections contract. When shared `internal/api/` and poller wiring expose TrueNAS last-sync status, failure summaries, discovered contribution counts, or platform handoff links in settings, storage and recovery may consume the resulting datasets, apps, disks, and recovery artifacts but must not redefine those settings-runtime health semantics or connection-level handoffs in storage/recovery-local transport or page flows.26. Keep cross-surface recovery handoffs on the shared route-helper contract. When infrastructure or other unified-resource consumers expose TrueNAS recovery links, they must reuse the canonical `frontend-modern/src/routing/resourceLinks.ts` recovery builder with owned `platform` and `node` queries instead of inventing drawer-local recovery URLs or treating PBS services as the only infrastructure-to-recovery path.+27. Keep alert-side recovery drill-ins on that same shared route-helper contract. When alert investigation surfaces such as resource-incident panels expose recovery follow-up links for TrueNAS or future API-backed platforms, they must route through the canonical `frontend-modern/src/routing/resourceLinks.ts` recovery builder instead of freezing alert-local recovery URLs or introducing another provider-shaped recovery handoff vocabulary.## Forbidden Pathsdiff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.mdindex 8607c3fa3c..d8f05d1555 100644--- a/docs/release-control/v6/internal/subsystems/unified-resources.md+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md@@ -524,6 +524,13 @@ TrueNAS-backed top-level systems through canonical `/recovery` route statethere, using owned `platform` and `node` queries instead of rebuildingdrawer-local recovery links or assuming only PBS services can expose recoveryhandoffs from infrastructure.+That same shared routing boundary now also owns alert-investigation handoffs.+Resource-incident panels and other alert-side resource drill-down consumers+must route operators back through canonical infrastructure resource detail and+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 drawer shell now routes its canonical timeline filter, facet-bundle, andresource-intelligence state through`frontend-modern/src/components/Infrastructure/useResourceDetailDrawerHistoryState.ts`,diff --git a/frontend-modern/src/components/Infrastructure/resourceDetailDrawerOperationalModel.ts b/frontend-modern/src/components/Infrastructure/resourceDetailDrawerOperationalModel.tsindex 8a3a15638e..bc3ba5f90e 100644--- a/frontend-modern/src/components/Infrastructure/resourceDetailDrawerOperationalModel.ts+++ b/frontend-modern/src/components/Infrastructure/resourceDetailDrawerOperationalModel.ts@@ -1,8 +1,7 @@import type { Resource } from '@/types/resource';import type { KubernetesMetricCapabilities, PlatformData } from './resourceDetailMappers';import { buildServiceDetailLinks, type ServiceDetailLink } from './serviceDetailLinks';-import { buildWorkloadsHref } from './workloadsLink';-import { buildRecoveryHrefForResource, buildStorageHrefForResource } from '@/routing/resourceLinks';+import { buildResourceSurfaceLinksForResource } from '@/routing/resourceLinks';export type ResourceDetailDrawerOperationalBadge = {label: string;@@ -198,36 +197,9 @@ export const buildRelatedLinks = (resource: Resource,displayName: string,): ResourceDetailDrawerOperationalLink[] => {- const links: ResourceDetailDrawerOperationalLink[] = [];- const workloads = buildWorkloadsHref(resource);- const workloadSearch = workloads ? new URLSearchParams(workloads.split('?')[1] ?? '') : null;- const scopedWorkloadType = workloadSearch?.get('type')?.trim() ?? '';- if (workloads && scopedWorkloadType) {- links.push({- href: workloads,- label: 'Open in Workloads',- compactLabel: 'Workloads',- ariaLabel: `Open related workloads for ${displayName}`,- });- }- const storage = buildStorageHrefForResource(resource);- if (storage) {- links.push({- href: storage,- label: 'Open in Storage',- compactLabel: 'Storage',- ariaLabel: `Open related storage for ${displayName}`,- });- }- const recovery = buildRecoveryHrefForResource(resource);- if (recovery) {- links.push({- href: recovery,- label: 'Open in Recovery',- compactLabel: 'Recovery',- ariaLabel: `Open related recovery for ${displayName}`,- });- }+ const links: ResourceDetailDrawerOperationalLink[] = [+ ...buildResourceSurfaceLinksForResource(resource, displayName),+ ];links.push(...buildServiceDetailLinks(resource));const seen = new Set<string>();diff --git a/frontend-modern/src/components/Infrastructure/workloadsLink.ts b/frontend-modern/src/components/Infrastructure/workloadsLink.tsindex 11475c7dc0..291e31c6b0 100644--- a/frontend-modern/src/components/Infrastructure/workloadsLink.ts+++ b/frontend-modern/src/components/Infrastructure/workloadsLink.ts@@ -1,87 +1,5 @@import type { Resource } from '@/types/resource';-import { buildWorkloadsPath } from '@/routing/resourceLinks';-import {- getActionableDockerRuntimeIdFromResource,- getPlatformDataRecord,- hasDockerWorkloadsScope,-} from '@/utils/agentResources';-import {- getPreferredInfrastructureDisplayName,- getPreferredWorkloadsAgentHint,- getPreferredResourceKubernetesContext,-} from '@/utils/resourceIdentity';-import { requiresGovernedResourceDisplay } from '@/types/resource';-import { normalizeSourcePlatformKey } from '@/utils/sourcePlatforms';+import { buildWorkloadsHrefForResource } from '@/routing/resourceLinks';-const firstNonEmpty = (values: Array<string | undefined | null>): string | undefined => {- for (const value of values) {- if (typeof value !== 'string') continue;- const trimmed = value.trim();- if (trimmed.length > 0) return trimmed;- }- return undefined;-};--const resolveKubernetesContext = (resource: Resource): string | undefined => {- const kubernetesContext = getPreferredResourceKubernetesContext(resource);- if (resource.type === 'k8s-cluster') {- const displayLabel = requiresGovernedResourceDisplay(resource.policy)- ? getPreferredInfrastructureDisplayName(resource)- : resource.displayName?.trim() || resource.name?.trim() || undefined;- return firstNonEmpty([- kubernetesContext,- displayLabel,- ]);- }- if (resource.type === 'k8s-node') {- return kubernetesContext;- }- return undefined;-};--const resolveHostHint = (resource: Resource): string | undefined => {- return getPreferredWorkloadsAgentHint(resource);-};--const resolveDockerWorkloadsHint = (resource: Resource): string | undefined =>- getActionableDockerRuntimeIdFromResource(resource) || resolveHostHint(resource);--const hasMergedSource = (resource: Resource, source: string): boolean => {- const platformData = getPlatformDataRecord(resource);- const mergedSources = Array.isArray(platformData?.sources) ? platformData.sources : [];- return mergedSources.some((value) => normalizeSourcePlatformKey(value) === source);-};--export const buildWorkloadsHref = (resource: Resource): string | null => {- if (resource.type === 'k8s-cluster' || resource.type === 'k8s-node') {- const context = resolveKubernetesContext(resource);- return buildWorkloadsPath({ type: 'pod', platform: 'kubernetes', context });- }-- if (resource.type === 'docker-host') {- const agent = resolveDockerWorkloadsHint(resource);- return buildWorkloadsPath({ type: 'app-container', platform: 'docker', agent });- }-- if (resource.type === 'truenas') {- const agent = resolveHostHint(resource);- return buildWorkloadsPath({ type: 'app-container', platform: 'truenas', agent });- }-- if (resource.type === 'agent') {- const agent = resolveHostHint(resource);- if (resource.platformType === 'truenas' || hasMergedSource(resource, 'truenas')) {- return buildWorkloadsPath({ type: 'app-container', platform: 'truenas', agent });- }- if (hasDockerWorkloadsScope(resource)) {- return buildWorkloadsPath({- type: 'app-container',- platform: 'docker',- agent: resolveDockerWorkloadsHint(resource),- });- }- return buildWorkloadsPath({ agent });- }-- return null;-};+export const buildWorkloadsHref = (resource: Resource): string | null =>+ buildWorkloadsHrefForResource(resource);diff --git a/frontend-modern/src/features/alerts/AlertResourceIncidentsPanel.tsx b/frontend-modern/src/features/alerts/AlertResourceIncidentsPanel.tsxindex b17a218092..ed1a93f712 100644--- a/frontend-modern/src/features/alerts/AlertResourceIncidentsPanel.tsx+++ b/frontend-modern/src/features/alerts/AlertResourceIncidentsPanel.tsx@@ -1,8 +1,16 @@+import { A } from '@solidjs/router';import { For, Show } from 'solid-js';import { IncidentEventFilters } from '@/components/Alerts/IncidentEventFilters';import { IncidentTimelineEventCard } from '@/components/Alerts/IncidentTimelineEventCard';import { Card } from '@/components/shared/Card';+import {+ buildInfrastructureResourceLink,+ buildResourceSurfaceLinksForResource,+ type ResourceSurfaceLink,+} from '@/routing/resourceLinks';+import type { Resource } from '@/types/resource';+import { getPreferredResourceDisplayName } from '@/utils/resourceIdentity';import {getAlertIncidentLevelBadgeClass,getAlertIncidentStatusPresentation,@@ -30,6 +38,7 @@ import type { AlertHistoryState } from './useAlertHistoryState';interface AlertResourceIncidentsPanelProps {state: AlertHistoryState;+ getResource: (resourceId: string) => Resource | undefined;}export function AlertResourceIncidentsPanel(props: AlertResourceIncidentsPanelProps) {@@ -39,6 +48,33 @@ export function AlertResourceIncidentsPanel(props: AlertResourceIncidentsPanelPrconst resourceId = selection().resourceId;const incidents = () => props.state.resourceIncidents()[resourceId] || [];const isLoading = () => props.state.resourceIncidentLoading()[resourceId];+ const resource = () => props.getResource(resourceId);+ const resourceDisplayName = () => {+ const current = resource();+ if (current) {+ return getPreferredResourceDisplayName(current);+ }+ 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 (<Card padding="md">@@ -48,11 +84,26 @@ export function AlertResourceIncidentsPanel(props: AlertResourceIncidentsPanelPr{getAlertResourceIncidentPanelTitle()}</h3><p class="text-xs text-muted">- {selection().resourceName}+ {resourceDisplayName()}<Show when={incidents().length > 0}><span> · {getAlertResourceIncidentCountLabel(incidents().length)}</span></Show></p>+ <Show when={links().length > 0}>+ <div class="mt-2 flex flex-wrap gap-2">+ <For each={links()}>+ {(link) => (+ <A+ href={link.href}+ aria-label={link.ariaLabel}+ 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"+ >+ {link.compactLabel}+ </A>+ )}+ </For>+ </div>+ </Show></div><div class="flex items-center gap-2"><buttondiff --git a/frontend-modern/src/features/alerts/__tests__/AlertResourceIncidentsPanel.test.tsx b/frontend-modern/src/features/alerts/__tests__/AlertResourceIncidentsPanel.test.tsxnew file mode 100644index 0000000000..7fa65d76f7--- /dev/null+++ b/frontend-modern/src/features/alerts/__tests__/AlertResourceIncidentsPanel.test.tsx@@ -0,0 +1,80 @@+import { render, screen } from '@solidjs/testing-library';+import { describe, expect, it, vi } from 'vitest';++import { AlertResourceIncidentsPanel } from '../AlertResourceIncidentsPanel';++vi.mock('@solidjs/router', () => ({+ A: (props: { href: string; children: unknown; [key: string]: unknown }) => (+ <a href={props.href} aria-label={props['aria-label'] as string}>+ {props.children}+ </a>+ ),+}));++describe('AlertResourceIncidentsPanel', () => {+ it('surfaces canonical investigation handoff links for TrueNAS resources', () => {+ render(() => (+ <AlertResourceIncidentsPanel+ state={{+ resourceIncidentPanel: () => ({+ resourceId: 'truenas-main',+ resourceName: 'TrueNAS Main',+ }),+ resourceIncidents: () => ({+ 'truenas-main': [+ {+ id: 'incident-1',+ alertType: 'Storage Health',+ level: 'critical',+ status: 'open',+ acknowledged: false,+ openedAt: '2026-03-30T09:00:00Z',+ message: 'Pool tank is DEGRADED',+ events: [],+ },+ ],+ }),+ resourceIncidentLoading: () => ({ 'truenas-main': false }),+ expandedResourceIncidentIds: () => new Set<string>(),+ resourceIncidentEventFilters: () => new Set<string>(['opened']),+ setResourceIncidentEventFilters: vi.fn(),+ refreshResourceIncidentPanel: vi.fn(),+ setResourceIncidentPanel: vi.fn(),+ toggleResourceIncidentDetails: vi.fn(),+ } as any}+ getResource={(resourceId) =>+ resourceId === 'truenas-main'+ ? ({+ id: 'truenas-main',+ type: 'truenas',+ name: 'truenas-main',+ displayName: 'TrueNAS Main',+ platformId: 'truenas-main',+ platformType: 'truenas',+ sourceType: 'hybrid',+ status: 'online',+ lastSeen: Date.now(),+ platformData: { sources: ['truenas'] },+ } as any)+ : undefined+ }+ />+ ));++ expect(+ screen.getByRole('link', { name: 'Open related infrastructure for TrueNAS Main' }),+ ).toHaveAttribute('href', '/infrastructure?resource=truenas-main');+ expect(+ screen.getByRole('link', { name: 'Open related workloads for TrueNAS Main' }),+ ).toHaveAttribute(+ 'href',+ '/workloads?type=app-container&platform=truenas&agent=truenas-main',+ );+ expect(+ screen.getByRole('link', { name: 'Open related storage for TrueNAS Main' }),+ ).toHaveAttribute('href', '/storage?source=truenas&node=truenas-main');+ expect(+ screen.getByRole('link', { name: 'Open related recovery for TrueNAS Main' }),+ ).toHaveAttribute('href', '/recovery?platform=truenas&node=truenas-main');+ });+});diff --git a/frontend-modern/src/features/alerts/__tests__/HistoryTab.test.tsx b/frontend-modern/src/features/alerts/__tests__/HistoryTab.test.tsxnew file mode 100644index 0000000000..74d693830e--- /dev/null+++ b/frontend-modern/src/features/alerts/__tests__/HistoryTab.test.tsx@@ -0,0 +1,67 @@+import { render, screen } from '@solidjs/testing-library';+import { describe, expect, it, vi } from 'vitest';++import { HistoryTab } from '../tabs/HistoryTab';++vi.mock('@solidjs/router', () => ({+ useLocation: () => ({+ hash: '',+ }),+}));++vi.mock('@/App', () => ({+ useWebSocket: () => ({+ activeAlerts: {},+ }),+}));++vi.mock('@/hooks/useBreakpoint', () => ({+ useBreakpoint: () => ({+ isMobile: () => false,+ }),+}));++vi.mock('../useAlertHistoryState', () => ({+ useAlertHistoryState: () => ({+ alertData: () => [],+ }),+}));++vi.mock('../AlertHistoryFrequencyCard', () => ({+ AlertHistoryFrequencyCard: () => <div>frequency-card</div>,+}));++vi.mock('../AlertHistoryFiltersCard', () => ({+ AlertHistoryFiltersCard: () => <div>filters-card</div>,+}));++vi.mock('../AlertResourceIncidentsPanel', () => ({+ AlertResourceIncidentsPanel: () => <div>resource-incidents-panel</div>,+}));++vi.mock('../AlertHistoryTableSection', () => ({+ AlertHistoryTableSection: () => <div>history-table</div>,+}));++vi.mock('../AlertHistoryAdministrationCard', () => ({+ AlertHistoryAdministrationCard: () => <div>administration-card</div>,+}));++describe('HistoryTab', () => {+ it('renders against the current history-state contract without depending on legacy filteredAlerts', () => {+ render(() => (+ <HistoryTab+ hasAIAlertsFeature={() => true}+ licenseLoading={() => false}+ getResource={() => undefined}+ allResources={() => []}+ />+ ));++ expect(screen.getByText('frequency-card')).toBeInTheDocument();+ expect(screen.getByText('filters-card')).toBeInTheDocument();+ expect(screen.getByText('resource-incidents-panel')).toBeInTheDocument();+ expect(screen.getByText('history-table')).toBeInTheDocument();+ expect(screen.getByText('administration-card')).toBeInTheDocument();+ });+});diff --git a/frontend-modern/src/features/alerts/tabs/HistoryTab.tsx b/frontend-modern/src/features/alerts/tabs/HistoryTab.tsxindex 8e7d8fdeb4..ba83b79919 100644--- a/frontend-modern/src/features/alerts/tabs/HistoryTab.tsx+++ b/frontend-modern/src/features/alerts/tabs/HistoryTab.tsx@@ -51,7 +51,7 @@ export function HistoryTab(props: HistoryTabProps) {createEffect(() => {location.hash;- historyState.filteredAlerts().length;+ historyState.alertData().length;if (hashScrollRafId !== undefined) {cancelAnimationFrame(hashScrollRafId);}@@ -72,7 +72,7 @@ export function HistoryTab(props: HistoryTabProps) {<div class="space-y-4"><AlertHistoryFrequencyCard state={historyState} /><AlertHistoryFiltersCard state={historyState} isMobile={isMobile()} />- <AlertResourceIncidentsPanel state={historyState} />+ <AlertResourceIncidentsPanel state={historyState} getResource={props.getResource} /><AlertHistoryTableSectionstate={historyState}hasAIAlertsFeature={props.hasAIAlertsFeature}diff --git a/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts b/frontend-modern/src/pages/__tests__/Alerts.helpers.test.tsindex d615f38012..3dc760c5f1 100644--- a/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts+++ b/frontend-modern/src/pages/__tests__/Alerts.helpers.test.ts@@ -326,6 +326,11 @@ describe('tab path helpers', () => {expect(alertHistoryTabSource).toContain('AlertResourceIncidentsPanel');expect(alertHistoryTabSource).toContain('AlertHistoryTableSection');expect(alertHistoryTabSource).toContain('AlertHistoryAdministrationCard');+ expect(alertHistoryTabSource).toContain('historyState.alertData().length');+ expect(alertHistoryTabSource).not.toContain('historyState.filteredAlerts().length');+ expect(alertHistoryTabSource).toContain(+ '<AlertResourceIncidentsPanel state={historyState} getResource={props.getResource} />',+ );expect(alertDestinationsTabSource).toContain('useAlertDestinationsTabState');expect(alertDestinationsTabSource).toContain('AlertDestinationsLoadingState');expect(alertDestinationsTabSource).toContain('AlertDestinationsLoadErrorCard');@@ -356,6 +361,12 @@ 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('{link.compactLabel}');expect(alertHistoryTableSectionSource).toContain('export function AlertHistoryTableSection');expect(alertHistoryTableSectionSource).toContain('AlertHistoryTableGroupRow');expect(alertHistoryTableSectionSource).toContain('AlertHistoryTableAlertRow');diff --git a/frontend-modern/src/routing/__tests__/resourceLinks.test.ts b/frontend-modern/src/routing/__tests__/resourceLinks.test.tsindex a2d85f885e..7bd050f648 100644--- a/frontend-modern/src/routing/__tests__/resourceLinks.test.ts+++ b/frontend-modern/src/routing/__tests__/resourceLinks.test.ts@@ -3,13 +3,16 @@ import type { WorkloadGuest } from '@/types/workloads';import {PMG_THRESHOLDS_PATH,RECOVERY_QUERY_PARAMS,+ buildInfrastructureResourceLink,buildInfrastructureHrefForWorkload,buildRecoveryPath,buildRecoveryHrefForResource,buildInfrastructurePath,buildInfrastructureResourceHref,+ buildResourceSurfaceLinksForResource,buildStorageHrefForResource,buildStoragePath,+ buildWorkloadsHrefForResource,buildWorkloadsPath,parseRecoveryLinkSearch,INFRASTRUCTURE_QUERY_PARAMS,@@ -125,6 +128,15 @@ describe('resource link routing contract', () => {expect(buildInfrastructureResourceHref('')).toBeNull();});+ it('builds canonical infrastructure resource link metadata', () => {+ expect(buildInfrastructureResourceLink(' truenas-main ', 'TrueNAS Main')).toEqual({+ href: '/infrastructure?resource=truenas-main',+ label: 'Open in Infrastructure',+ compactLabel: 'Infrastructure',+ ariaLabel: 'Open related infrastructure for TrueNAS Main',+ });+ });+it('maps vm workloads to proxmox infrastructure source with node query', () => {const href = buildInfrastructureHrefForWorkload(baseGuest({@@ -161,6 +173,22 @@ describe('resource link routing contract', () => {expect(href).toBe('/infrastructure?source=truenas&q=truenas-main');});+ it('builds TrueNAS workloads links from canonical unified resources', () => {+ expect(+ buildWorkloadsHrefForResource({+ id: 'truenas-main',+ type: 'truenas',+ name: 'truenas-main',+ displayName: 'TrueNAS Main',+ platformId: 'truenas-main',+ platformType: 'truenas',+ sourceType: 'hybrid',+ status: 'online',+ lastSeen: Date.now(),+ } as any),+ ).toBe('/workloads?type=app-container&platform=truenas&agent=truenas-main');+ });+it('maps pod workloads to kubernetes infrastructure source with cluster query', () => {const href = buildInfrastructureHrefForWorkload(baseGuest({@@ -306,6 +334,45 @@ describe('resource link routing contract', () => {expect(href).toBe('/recovery?platform=truenas&node=truenas-main');});+ it('builds canonical shared surface links for top-level truenas systems', () => {+ expect(+ buildResourceSurfaceLinksForResource(+ {+ id: 'truenas-main',+ type: 'truenas',+ name: 'truenas-main',+ displayName: 'TrueNAS Main',+ platformId: 'truenas-main',+ platformType: 'truenas',+ sourceType: 'hybrid',+ status: 'online',+ lastSeen: Date.now(),+ platformData: { sources: ['truenas'] },+ } as any,+ 'TrueNAS Main',+ ),+ ).toEqual([+ {+ href: '/workloads?type=app-container&platform=truenas&agent=truenas-main',+ label: 'Open in Workloads',+ compactLabel: 'Workloads',+ ariaLabel: 'Open related workloads for TrueNAS Main',+ },+ {+ href: '/storage?source=truenas&node=truenas-main',+ label: 'Open in Storage',+ compactLabel: 'Storage',+ ariaLabel: 'Open related storage for TrueNAS Main',+ },+ {+ href: '/recovery?platform=truenas&node=truenas-main',+ label: 'Open in Recovery',+ compactLabel: 'Recovery',+ ariaLabel: 'Open related recovery for TrueNAS Main',+ },+ ]);+ });+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.tsindex 978ad6f503..a96731f8cd 100644--- a/frontend-modern/src/routing/resourceLinks.ts+++ b/frontend-modern/src/routing/resourceLinks.ts@@ -1,4 +1,5 @@import {+ normalizeSourcePlatformKey,normalizeSourcePlatformQueryValue,resolvePlatformTypeFromSources,} from '@/utils/sourcePlatforms';@@ -10,6 +11,17 @@ import {} from '@/utils/workloads';import type { WorkloadGuest } from '@/types/workloads';import type { Resource } from '@/types/resource';+import {+ getActionableDockerRuntimeIdFromResource,+ getPlatformDataRecord,+ hasDockerWorkloadsScope,+} from '@/utils/agentResources';+import {+ getPreferredInfrastructureDisplayName,+ getPreferredResourceKubernetesContext,+ getPreferredWorkloadsAgentHint,+} from '@/utils/resourceIdentity';+import { requiresGovernedResourceDisplay } from '@/types/resource';export const WORKLOADS_QUERY_PARAMS = {type: 'type',@@ -134,6 +146,13 @@ type RecoveryLinkOptions = {query?: string | null;};+export type ResourceSurfaceLink = {+ href: string;+ label: string;+ compactLabel: string;+ ariaLabel: string;+};+const RECOVERY_LEGACY_PLATFORM_QUERY_PARAM = 'provider';export const parseWorkloadsLinkSearch = (search: string) => {@@ -195,6 +214,20 @@ export const buildInfrastructureResourceHref = (resourceId: string): string | nureturn trimmed ? buildInfrastructurePath({ resource: trimmed }) : null;};+export const buildInfrastructureResourceLink = (+ resourceId: string,+ displayName: string,+): ResourceSurfaceLink | null => {+ const href = buildInfrastructureResourceHref(resourceId);+ if (!href) return null;+ return {+ href,+ label: 'Open in Infrastructure',+ compactLabel: 'Infrastructure',+ ariaLabel: `Open related infrastructure for ${displayName}`,+ };+};+export const buildInfrastructureHrefForWorkload = (guest: WorkloadGuest): string => {const type = resolveWorkloadType(guest);@@ -225,6 +258,112 @@ export const buildInfrastructureHrefForWorkload = (guest: WorkloadGuest): stringreturn buildInfrastructurePath();};+const resolveKubernetesContextForResource = (resource: Resource): string | undefined => {+ const kubernetesContext = getPreferredResourceKubernetesContext(resource);+ if (resource.type === 'k8s-cluster') {+ const displayLabel = requiresGovernedResourceDisplay(resource.policy)+ ? getPreferredInfrastructureDisplayName(resource)+ : resource.displayName?.trim() || resource.name?.trim() || undefined;+ return firstNonEmpty([kubernetesContext, displayLabel]);+ }+ if (resource.type === 'k8s-node') {+ return kubernetesContext;+ }+ return undefined;+};++const resolveHostHintForResource = (resource: Resource): string | undefined =>+ getPreferredWorkloadsAgentHint(resource);++const resolveDockerWorkloadsHintForResource = (resource: Resource): string | undefined =>+ getActionableDockerRuntimeIdFromResource(resource) || resolveHostHintForResource(resource);++const hasMergedSource = (resource: Resource, source: string): boolean => {+ const platformData = getPlatformDataRecord(resource);+ const mergedSources = Array.isArray(platformData?.sources) ? platformData.sources : [];+ return mergedSources.some((value) => normalizeSourcePlatformKey(value) === source);+};++export const buildWorkloadsHrefForResource = (resource: Resource): string | null => {+ if (resource.type === 'k8s-cluster' || resource.type === 'k8s-node') {+ const context = resolveKubernetesContextForResource(resource);+ return buildWorkloadsPath({ type: 'pod', platform: 'kubernetes', context });+ }++ if (resource.type === 'docker-host') {+ const agent = resolveDockerWorkloadsHintForResource(resource);+ return buildWorkloadsPath({ type: 'app-container', platform: 'docker', agent });+ }++ if (resource.type === 'truenas') {+ const agent = resolveHostHintForResource(resource);+ return buildWorkloadsPath({ type: 'app-container', platform: 'truenas', agent });+ }++ if (resource.type === 'agent') {+ const agent = resolveHostHintForResource(resource);+ if (resource.platformType === 'truenas' || hasMergedSource(resource, 'truenas')) {+ return buildWorkloadsPath({ type: 'app-container', platform: 'truenas', agent });+ }+ if (hasDockerWorkloadsScope(resource)) {+ return buildWorkloadsPath({+ type: 'app-container',+ platform: 'docker',+ agent: resolveDockerWorkloadsHintForResource(resource),+ });+ }+ return buildWorkloadsPath({ agent });+ }++ return null;+};++export const buildResourceSurfaceLinksForResource = (+ resource: Resource,+ displayName: string,+): ResourceSurfaceLink[] => {+ const links: ResourceSurfaceLink[] = [];+ const workloads = buildWorkloadsHrefForResource(resource);+ const workloadSearch = workloads ? new URLSearchParams(workloads.split('?')[1] ?? '') : null;+ const scopedWorkloadType = workloadSearch?.get('type')?.trim() ?? '';++ if (workloads && scopedWorkloadType) {+ links.push({+ href: workloads,+ label: 'Open in Workloads',+ compactLabel: 'Workloads',+ ariaLabel: `Open related workloads for ${displayName}`,+ });+ }++ const storage = buildStorageHrefForResource(resource);+ if (storage) {+ links.push({+ href: storage,+ label: 'Open in Storage',+ compactLabel: 'Storage',+ ariaLabel: `Open related storage for ${displayName}`,+ });+ }++ const recovery = buildRecoveryHrefForResource(resource);+ if (recovery) {+ links.push({+ href: recovery,+ label: 'Open in Recovery',+ compactLabel: 'Recovery',+ ariaLabel: `Open related recovery for ${displayName}`,+ });+ }++ const seen = new Set<string>();+ return links.filter((link) => {+ if (seen.has(link.href)) return false;+ seen.add(link.href);+ return true;+ });+};+const resolveStorageRouteSource = (resource: Resource): string => {const mergedPlatform = Array.isArray(resource.platformData?.sources)? resolvePlatformTypeFromSources(resource.platformData.sources)diff --git a/tests/integration/tests/28-truenas-alert-resource-links.spec.ts b/tests/integration/tests/28-truenas-alert-resource-links.spec.tsnew file mode 100644index 0000000000..40a39c22d6--- /dev/null+++ b/tests/integration/tests/28-truenas-alert-resource-links.spec.ts@@ -0,0 +1,225 @@+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-alert-resource-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-alert-resource-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 alert resource links', () => {+ test.setTimeout(180_000);++ test('keeps TrueNAS alert investigation on canonical resource 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'],+ },+ },+ ],+ meta: {+ page: 1,+ limit: 200,+ total: 1,+ totalPages: 1,+ },+ }),+ });+ });++ await page.route('**/api/alerts/config', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({+ enabled: true,+ activationState: 'active',+ overrides: {},+ }),+ });+ });++ await page.route('**/api/alerts/active', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify([]),+ });+ });++ await page.route('**/api/alerts/history**', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify([+ {+ id: 'truenas-alert-1',+ type: 'host-offline',+ level: 'critical',+ startTime: '2026-03-30T09:00:00Z',+ lastSeen: '2026-03-30T09:15:00Z',+ resourceId: 'truenas-main',+ resourceName: 'TrueNAS Main',+ message: 'TrueNAS Main is offline',+ acknowledged: false,+ node: 'truenas-main',+ nodeDisplayName: 'TrueNAS Main',+ metadata: {+ resourceType: 'truenas',+ },+ },+ ]),+ });+ });++ await page.route('**/api/alerts/incidents**', async (route) => {+ const requestUrl = new URL(route.request().url());+ if (requestUrl.searchParams.get('resource_id') !== 'truenas-main') {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify(null),+ });+ return;+ }++ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify([+ {+ id: 'incident-truenas-1',+ alertType: 'Host Offline',+ level: 'critical',+ status: 'open',+ acknowledged: false,+ openedAt: '2026-03-30T09:00:00Z',+ message: 'TrueNAS Main is offline',+ events: [+ {+ id: 'incident-event-1',+ type: 'opened',+ timestamp: '2026-03-30T09:00:00Z',+ summary: 'Alert opened',+ },+ ],+ },+ ]),+ });+ });++ await page.route('**/api/notifications/email', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({+ enabled: false,+ provider: '',+ server: '',+ port: 587,+ username: '',+ password: '',+ from: '',+ to: [],+ tls: false,+ startTLS: false,+ }),+ });+ });++ await page.route('**/api/notifications/apprise', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({+ enabled: false,+ }),+ });+ });++ await page.goto('/alerts/history', {+ waitUntil: 'domcontentloaded',+ });++ await expect(page.getByRole('heading', { name: 'Alert History' })).toBeVisible();+ await expect(page.getByRole('button', { name: 'Resource' })).toBeVisible();++ await page.getByRole('button', { name: 'Resource' }).click();++ await expect(page.getByRole('heading', { name: 'Resource incidents' })).toBeVisible();+ await expect(+ page.getByRole('link', { name: 'Open related infrastructure for TrueNAS Main' }),+ ).toHaveAttribute('href', '/infrastructure?resource=truenas-main');+ await expect(+ page.getByRole('link', { name: 'Open related workloads for TrueNAS Main' }),+ ).toHaveAttribute(+ 'href',+ '/workloads?type=app-container&platform=truenas&agent=truenas-main',+ );+ await expect(+ page.getByRole('link', { name: 'Open related storage for TrueNAS Main' }),+ ).toHaveAttribute('href', '/storage?source=truenas&node=truenas-main');+ await expect(+ page.getByRole('link', { name: 'Open related recovery for TrueNAS Main' }),+ ).toHaveAttribute('href', '/recovery?platform=truenas&node=truenas-main');++ await page.screenshot({ path: SCREENSHOT_PATH, fullPage: true });+ });+});