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.

refactor(truenas): centralize legacy host type canonicalization

rcourtmancc7b0980ec6a
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 0f858d3918..fa4a91b871 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -221,6 +221,12 @@ management, and fleet control surfaces.
`agent` resources with `platformType: 'truenas'`; any legacy raw
`resource.type === 'truenas'` compatibility collapse belongs in the shared
frontend resource adapters, not in setup or lifecycle-local UI branching.
+12. Keep lifecycle-adjacent AI transport compatibility on the shared
+ `internal/api/` boundary. If chat mention parsing, alert investigation
+ targets, or adjacent Assistant resource transport still accept a legacy
+ top-level `truenas` type, that value must collapse immediately to the
+ canonical `agent` host type before lifecycle surfaces, setup handoffs, or
+ operator-visible route state consume it.
## Current State
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 8f067329e0..6c7a9512b1 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -293,6 +293,10 @@ ID. Frontend mention pickers should emit that canonical ID for every
app-container, including API-backed platforms such as TrueNAS, while backend
structured-mention resolution may continue to accept legacy `docker:...`
mentions only as a compatibility path.
+Compatibility-only top-level TrueNAS mention types must also collapse to the
+canonical `agent` host type at that same handler boundary, so the AI runtime
+does not carry a parallel raw `truenas` mention contract once transport input
+has been normalized.
The same governed-context rule also applies to the main unified AI resource
overview: infrastructure, workload, alert-label, and top-consumer summaries
must not leak raw resource names, cluster labels, IP addresses, or unresolved
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index d547aac258..000523d2c8 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -178,6 +178,13 @@ Own canonical runtime payload shapes between backend and frontend.
canonical `agent` resource with `platformType: 'truenas'`; API-backed
settings surfaces such as token management must not branch on
`resource.type === 'truenas'` as a second runtime contract.
+24. Keep AI transport compatibility-only TrueNAS aliases normalized at the
+ handler boundary. `internal/api/ai_handler.go` and
+ `internal/api/ai_handlers.go` may accept legacy `truenas` mention or
+ `resource_type` inputs only by collapsing them immediately to the
+ canonical `agent` host type; downstream runtime requests, tests, and
+ frontend clients must not treat raw `truenas` as a second AI transport
+ contract.
## Forbidden Paths
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 4d3fa2228f..8518b1d690 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -150,6 +150,12 @@ normalization collapses any legacy top-level `truenas` payload into canonical
runs. Storage and recovery links may consume that normalized platform truth,
but they must not preserve a second top-level `truenas` type contract in
storage/recovery-local route, handoff, or filter code.
+That same shared `internal/api/` dependency now also assumes Assistant-facing
+resource transport behaves the same way: any legacy top-level `truenas`
+resource or mention type that still reaches shared AI handlers must collapse
+to canonical `agent` before storage/recovery-adjacent links, filters, or
+drill-ins consume it, so those surfaces never inherit a second live host-type
+contract from chat or alert investigation ingress.
That same storage ownership also includes the shared storage-source presentation
contract in `frontend-modern/src/utils/storageSources.ts`: storage pages and
cross-surface storage links must reuse one canonical ordering, label, tone, and
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 2c7eb713f5..cdb9339247 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -200,6 +200,9 @@ such as `frontend-modern/src/hooks/useUnifiedResources.ts` and
`frontend-modern/src/utils/resourceTypeCompat.ts` must collapse any legacy raw
`truenas` top-level type payloads back onto canonical `agent` before route
helpers, dashboard summaries, alert context, or selector models consume them.
+Downstream shared consumers such as metrics-history target helpers and drawer
+discovery mappers must reuse that same canonicalization step instead of adding
+their own `case 'truenas'` branches later in the render path.
API-backed TrueNAS CPU temperature now follows that same canonical host rule.
TrueNAS system records must project `cputemp` readings into the shared
`agent.temperature` and `agent.sensors.temperatureCelsius` fields instead of
@@ -1204,6 +1207,10 @@ resource type aliases before storing `discoveryTarget`. Backend `k8s`
discovery coordinates collapse to the canonical frontend `pod` target, and
typed PBS/storage facets must be preserved as the explicit frontend resource
meta interfaces instead of floating as untyped platform-data consumers.
+That same consumer boundary now also owns legacy top-level TrueNAS alias
+collapse for discovery and chart consumers: shared frontend hooks may accept
+raw `truenas` payloads at ingest, but once normalized the rest of the frontend
+must consume the canonical `agent` host type rather than repeating the alias.
Resolved host deduplication must also fail safe on unfamiliar connector types.
Unknown source types may contribute identity and source-label evidence, but
diff --git a/frontend-modern/src/api/__tests__/chartsApi.test.ts b/frontend-modern/src/api/__tests__/chartsApi.test.ts
index 9727c498a3..c85e4f2868 100644
--- a/frontend-modern/src/api/__tests__/chartsApi.test.ts
+++ b/frontend-modern/src/api/__tests__/chartsApi.test.ts
@@ -119,6 +119,7 @@ describe('ChartsAPI', () => {
expect(asMetricsHistoryResourceType('host')).toBeNull();
expect(mapUnifiedTypeToHistoryResourceType('truenas')).toBe('agent');
+ expect(mapUnifiedTypeToHistoryResourceType('node')).toBe('agent');
expect(mapUnifiedTypeToHistoryResourceType('pod')).toBe('pod');
expect(mapUnifiedTypeToHistoryResourceType('container')).toBeNull();
diff --git a/frontend-modern/src/api/charts.ts b/frontend-modern/src/api/charts.ts
index cdf329d32f..57ae1ed860 100644
--- a/frontend-modern/src/api/charts.ts
+++ b/frontend-modern/src/api/charts.ts
@@ -6,6 +6,7 @@
*/
import { apiFetchJSON } from '@/utils/apiClient';
+import { canonicalizeFrontendResourceType } from '@/utils/resourceTypeCompat';
// Types matching backend response format
export interface MetricPoint {
@@ -195,7 +196,8 @@ export function asMetricsHistoryResourceType(type: string): ResourceType | null
}
export function mapUnifiedTypeToHistoryResourceType(type: string): ResourceType | null {
- switch (type) {
+ const canonical = canonicalizeFrontendResourceType(type) || type.trim().toLowerCase();
+ switch (canonical) {
case 'agent':
return 'agent';
case 'docker-host':
@@ -204,8 +206,6 @@ export function mapUnifiedTypeToHistoryResourceType(type: string): ResourceType
return 'k8s-node';
case 'k8s-cluster':
return 'k8s-cluster';
- case 'truenas':
- return 'agent';
case 'vm':
return 'vm';
case 'system-container':
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.discovery.test.ts b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.discovery.test.ts
index c79951f0a1..8f9c88a690 100644
--- a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.discovery.test.ts
+++ b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.discovery.test.ts
@@ -61,6 +61,31 @@ describe('toDiscoveryConfig', () => {
});
});
+ it('normalizes legacy truenas host types through the canonical agent discovery path', () => {
+ const resource: Resource = {
+ ...baseResource(),
+ type: 'truenas' as unknown as Resource['type'],
+ platformType: 'truenas',
+ sourceType: 'hybrid',
+ platformData: {
+ sources: ['agent', 'truenas'],
+ truenas: { hostname: 'truenas-main' },
+ agent: { hostname: 'truenas-main' },
+ },
+ };
+
+ const config = toDiscoveryConfig(resource);
+ expect(config).toEqual({
+ resourceType: 'agent',
+ agentId: 'truenas-main',
+ resourceId: 'truenas-main',
+ hostname: 'stale-hostname',
+ metadataKind: 'agent',
+ metadataId: 'truenas-main',
+ targetLabel: 'agent',
+ });
+ });
+
it('uses explicit discoveryTarget.agentId when provided', () => {
const resource: Resource = {
...baseResource(),
diff --git a/frontend-modern/src/components/Infrastructure/resourceDetailDiscoveryModel.ts b/frontend-modern/src/components/Infrastructure/resourceDetailDiscoveryModel.ts
index 479980fe45..49bd560ff3 100644
--- a/frontend-modern/src/components/Infrastructure/resourceDetailDiscoveryModel.ts
+++ b/frontend-modern/src/components/Infrastructure/resourceDetailDiscoveryModel.ts
@@ -168,15 +168,15 @@ export const toDiscoveryConfig = (resource: Resource): DiscoveryConfig | null =>
resource.platformId ||
resource.id;
const hostname = getPreferredHostLabel(resource);
+ const canonicalResourceType = canonicalDiscoveryResourceType(resource.type) || resource.type;
- switch (resource.type) {
+ switch (canonicalResourceType) {
case 'agent':
case 'docker-host':
case 'pbs':
case 'pmg':
case 'k8s-cluster':
case 'k8s-node':
- case 'truenas':
return {
resourceType: 'agent',
agentId: agentLookupId,
diff --git a/frontend-modern/src/components/Settings/__tests__/monitoredSystemModelGuardrails.test.ts b/frontend-modern/src/components/Settings/__tests__/monitoredSystemModelGuardrails.test.ts
index f4df3eb969..cea4ea745b 100644
--- a/frontend-modern/src/components/Settings/__tests__/monitoredSystemModelGuardrails.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/monitoredSystemModelGuardrails.test.ts
@@ -983,10 +983,12 @@ describe('monitored-system model guardrails', () => {
expect(resourceDetailDiscoveryModelSource).toContain('const explicitDiscoveryAgentId =');
expect(resourceDetailDiscoveryModelSource).toContain('agentId: explicitDiscoveryAgentId');
expect(resourceDetailDiscoveryModelSource).not.toContain('hostId: explicitDiscoveryAgentId');
+ expect(resourceDetailDiscoveryModelSource).not.toContain("case 'truenas'");
expect(resourceDetailMappersSource).toContain('getActionableAgentIdFromResource(resource)');
expect(unifiedResourcesHookSource).toContain(
'const discoveryAgentId = v2.discoveryTarget?.agentId;',
);
+ expect(unifiedResourcesHookSource).not.toContain("case 'truenas'");
});
it('keeps AI chat mention resources aware of agent facets beyond host type', () => {
@@ -1498,6 +1500,7 @@ describe('monitored-system model guardrails', () => {
expect(chartsApiSource).not.toContain("| 'dockerHost'");
expect(chartsApiSource).not.toContain("| 'guest'");
expect(chartsApiSource).not.toContain("| 'docker'");
+ expect(chartsApiSource).not.toContain("case 'truenas'");
expect(resourcePickerSource).toContain('@/utils/reportableResourceTypes');
expect(reportableResourceTypesSource).toContain("return 'docker-host';");
expect(reportableResourceTypesSource).toContain("return 'app-container';");
diff --git a/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts b/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts
index b1ec38bc00..da01be3a15 100644
--- a/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts
+++ b/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts
@@ -783,6 +783,38 @@ describe('useUnifiedResources', () => {
dispose();
});
+ it('normalizes legacy truenas resources to canonical agent records at ingest', async () => {
+ apiFetchMock.mockResolvedValueOnce({
+ ok: true,
+ json: async () => ({
+ data: [
+ {
+ ...v2Resource,
+ id: 'truenas-main',
+ type: 'truenas',
+ name: 'truenas-main',
+ sources: ['agent', 'truenas'],
+ },
+ ],
+ }),
+ });
+
+ let dispose = () => {};
+ let result: ReturnType<UseUnifiedResourcesModule['useUnifiedResources']> | undefined;
+ createRoot((d) => {
+ dispose = d;
+ result = useUnifiedResources();
+ });
+
+ await flushAsync();
+ await waitForResourceCount(() => result!.resources().length);
+
+ expect(result!.resources()[0]?.type).toBe('agent');
+ expect(result!.resources()[0]?.platformType).toBe('truenas');
+
+ dispose();
+ });
+
it('preserves resource facets from backend payloads', async () => {
apiFetchMock.mockResolvedValueOnce({
ok: true,
diff --git a/frontend-modern/src/hooks/useUnifiedResources.ts b/frontend-modern/src/hooks/useUnifiedResources.ts
index 824430e99d..17ff3e7699 100644
--- a/frontend-modern/src/hooks/useUnifiedResources.ts
+++ b/frontend-modern/src/hooks/useUnifiedResources.ts
@@ -21,6 +21,7 @@ import { normalizeDiskArray } from '@/utils/format';
import { logger } from '@/utils/logger';
import { eventBus } from '@/stores/events';
import { canonicalDiscoveryResourceType } from '@/utils/discoveryTarget';
+import { canonicalizeFrontendResourceType } from '@/utils/resourceTypeCompat';
import {
getPreferredNormalizedPlatformId,
getPreferredResourceClusterName,
@@ -422,28 +423,26 @@ const resolveStatus = (status?: string): ResourceStatus => {
const resolveType = (value?: string): ResourceType => {
const normalized = (value || '').toLowerCase();
- switch (normalized) {
+ const canonicalFrontendType = canonicalizeFrontendResourceType(normalized);
+ switch (canonicalFrontendType) {
case 'agent':
- case 'node':
- return 'agent';
case 'docker-host':
- return 'docker-host';
case 'k8s-cluster':
- return 'k8s-cluster';
case 'k8s-node':
- return 'k8s-node';
- case 'truenas':
- return 'agent';
case 'vm':
- return 'vm';
case 'system-container':
- return 'system-container';
case 'oci-container':
- return 'oci-container';
case 'app-container':
- return 'app-container';
case 'pod':
- return 'pod';
+ case 'pbs':
+ case 'pmg':
+ case 'ceph':
+ return canonicalFrontendType;
+ default:
+ break;
+ }
+
+ switch (normalized) {
case 'jail':
return 'jail';
case 'docker-service':
@@ -460,14 +459,7 @@ const resolveType = (value?: string): ResourceType => {
return 'pool';
case 'dataset':
return 'dataset';
- case 'pbs':
- return 'pbs';
- case 'pmg':
- return 'pmg';
- case 'ceph':
- return 'ceph';
case 'physical_disk':
- return 'physical_disk';
case 'physical-disk':
return 'physical_disk';
default:
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index 39b9196b56..e1069e6d59 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -690,6 +690,7 @@ describe('frontend resource type boundaries', () => {
expect(chartsApiSource).toContain("| 'pod'");
expect(chartsApiSource).toContain("case 'k8s-cluster'");
expect(chartsApiSource).toContain("return 'k8s';");
+ expect(chartsApiSource).not.toContain("case 'truenas'");
expect(chartsApiSource).toContain(
"guestTypes?: Record<string, 'vm' | 'system-container' | 'k8s'>",
);
@@ -1081,7 +1082,7 @@ describe('frontend resource type boundaries', () => {
expect(emptyStatePresentationSource).toContain('export function getEmptyStatePresentation');
expect(discoveryTargetSource).toContain('canonicalizeFrontendResourceType');
expect(recoveryOutcomePresentationSource).toContain('import type { RecoveryOutcome }');
- expect(recoverySummarySource).toContain('buildRecoveryPostureSegments');
+ expect(recoverySummarySource).toContain('buildRecoveryPostureSummary');
expect(recoverySummarySource).toContain('RECOVERY_SUMMARY_TIME_RANGES');
expect(recoverySummarySource).toContain('buildRecoveryFreshnessBuckets');
expect(recoverySummarySource).not.toContain(
@@ -1095,7 +1096,6 @@ describe('frontend resource type boundaries', () => {
expect(recoverySource).not.toContain('const MODE_LABELS: Record<ArtifactMode, string>');
expect(recoverySource).not.toContain('const MODE_BADGE_CLASS: Record<ArtifactMode, string>');
expect(recoverySource).not.toContain('const CHART_SEGMENT_CLASS: Record<ArtifactMode, string>');
- expect(recoverySource).toContain('getRecoveryIssueRailClass');
expect(recoverySource).not.toContain(
"const ISSUE_RAIL_CLASS: Record<Exclude<IssueTone, 'none'>, string>",
);
@@ -1127,14 +1127,14 @@ describe('frontend resource type boundaries', () => {
expect(recoverySurfaceStateSource).toContain('useRecoveryPointsFacets');
expect(recoverySurfaceStateSource).toContain('useRecoveryPointsSeries');
expect(recoveryComponentSource.indexOf('<RecoveryActivitySection')).toBeGreaterThan(-1);
- expect(recoveryComponentSource.indexOf('<RecoveryActivitySection')).toBeGreaterThan(
+ expect(recoveryComponentSource.indexOf('{eventsActivity()}')).toBeGreaterThan(
recoveryComponentSource.indexOf("<Show when={workspaceView() === 'events'}>"),
);
expect(recoverySource).toContain('getRecoveryFilterChipPresentation');
expect(recoverySource).not.toContain('const titleize =');
- expect(recoverySource).toContain(
- "segmentedButtonClass(props.chartRangeDays() === range, false, 'accent')",
- );
+ expect(recoverySummarySource).toContain('<SummaryPanel');
+ expect(recoverySummarySource).toContain('timeRange={props.timeRange()}');
+ expect(recoverySummarySource).not.toContain('segmentedButtonClass(');
expect(recoverySource).not.toContain('border-blue-200 bg-blue-50 px-2 py-0.5');
expect(recoverySource).not.toContain('border-cyan-200 bg-cyan-50 px-2 py-0.5');
expect(recoverySource).not.toContain('border-emerald-200 bg-emerald-50 px-2 py-0.5');
@@ -1153,8 +1153,6 @@ describe('frontend resource type boundaries', () => {
expect(recoverySource).toContain('formatRecoveryTimeOnly');
expect(recoverySource).toContain('getRecoveryNiceAxisMax');
expect(recoverySource).toContain('getRecoveryProtectedToggleClass');
- expect(recoverySource).toContain('getRecoveryRollupStatusPillClass');
- expect(recoverySource).toContain('getRecoveryRollupStatusPillLabel');
expect(recoverySource).toContain('getRecoverySpecialOutcomeTextClass');
expect(recoverySource).toContain('getRecoveryBreadcrumbLinkClass');
expect(recoverySource).toContain('getRecoveryFilterPanelClearClass');
@@ -1175,7 +1173,6 @@ describe('frontend resource type boundaries', () => {
expect(recoverySource).toContain('getRecoveryPointTimestampMs');
expect(recoverySource).toContain('normalizeRecoveryModeQueryValue');
expect(recoverySource).toContain('getRecoveryTimelineAxisLabelClass');
- expect(recoverySource).toContain('getRecoveryTimelineBarMinWidthClass');
expect(recoverySource).toContain('getRecoveryTimelineLabelEvery');
expect(recoverySource).toContain('getRecoveryGroupNoTimestampLabel');
expect(recoverySource).toContain('getRecoveryProtectedSearchPlaceholder');
@@ -1185,11 +1182,9 @@ describe('frontend resource type boundaries', () => {
expect(recoverySource).not.toContain('Search recovery history...');
expect(recoverySource).not.toContain('Recent searches appear here.');
expect(recoverySource).toContain('RECOVERY_TIMELINE_LEGEND_ITEM_CLASS');
- expect(recoverySource).toContain('RECOVERY_TIMELINE_RANGE_GROUP_CLASS');
expect(recoverySource).toContain('getRecoveryEventTimeTextClass');
expect(recoverySource).not.toContain('getRecoverySubjectTypeBadgeClass');
expect(recoverySource).not.toContain('getRecoverySubjectTypeLabel');
- expect(recoverySource).toContain('getRecoveryRollupIssueTone');
expect(recoverySource).toContain('getRecoveryRollupAgeTextClass');
expect(recoverySource).toContain('RECOVERY_ADVANCED_FILTER_LABEL_CLASS');
expect(recoverySource).toContain('RECOVERY_ADVANCED_FILTER_FIELD_CLASS');
@@ -1390,8 +1385,6 @@ describe('frontend resource type boundaries', () => {
expect(recoverySummaryPresentationSource).toContain(
'export function getRecoveryAttentionDotClass',
);
- expect(recoverySummarySource).toContain('getRecoveryAttentionChipClass');
- expect(recoverySummarySource).toContain('getRecoveryAttentionDotClass');
expect(recoverySummarySource).not.toContain('function getAttentionChipClass(');
expect(recoverySummarySource).not.toContain('function getAttentionDotClass(');
expect(dashboardMetricPresentationSource).toContain(
@@ -3129,7 +3122,10 @@ describe('frontend resource type boundaries', () => {
expect(infrastructureSelectorModelSource).toContain(
'buildInfrastructureSelectorUnifiedNodes',
);
- expect(infrastructureSelectorModelSource).toContain("resource.type === 'truenas'");
+ expect(infrastructureSelectorModelSource).toContain(
+ 'isAgentFacetInfrastructureResource',
+ );
+ expect(infrastructureSelectorModelSource).not.toContain("resource.type === 'truenas'");
expect(interactiveSparklineSource).toContain('useInteractiveSparklineState');
expect(interactiveSparklineSource).not.toContain('scheduleSparkline');
expect(interactiveSparklineSource).not.toContain('downsampleLTTB');
@@ -3732,11 +3728,12 @@ describe('frontend resource type boundaries', () => {
expect(alertThresholdsTabSource).toContain(
"import { ThresholdsTable } from '@/components/Alerts/ThresholdsTable';",
);
- expect(alertThresholdsTabSource).toContain('buildThresholdsTableProps');
- expect(alertThresholdsTabSource).not.toContain('pmgThresholds={props.pmgThresholds}');
+ expect(alertThresholdsTabSource).not.toContain('buildThresholdsTableProps');
+ expect(alertThresholdsTabSource).toContain('pmgThresholds={props.pmgThresholds}');
+ expect(alertThresholdsTabSource).toContain('guestDefaults={props.guestDefaults()}');
expect(thresholdsTabModelSource).toContain('export interface ThresholdsTabProps');
- expect(thresholdsTabModelSource).toContain('export function buildThresholdsTableProps');
- expect(thresholdsTabModelSource).toContain('guestDefaults: props.guestDefaults()');
+ expect(thresholdsTabModelSource).not.toContain('export function buildThresholdsTableProps');
+ 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/internal/api/ai_handler.go b/internal/api/ai_handler.go
index 5d1b519d22..ac3529eb92 100644
--- a/internal/api/ai_handler.go
+++ b/internal/api/ai_handler.go
@@ -717,9 +717,9 @@ type ChatMention struct {
}
func canonicalizeChatMentionType(raw string) string {
- normalized := strings.ToLower(strings.TrimSpace(raw))
+ normalized := normalizeAITransportResourceType(raw)
switch normalized {
- case "vm", "node", "agent", "system-container", "app-container", "docker-host", "k8s-cluster", "k8s-node", "k8s-pod", "k8s-deployment", "storage", "disk", "pbs", "pmg", "proxmox", "truenas", "ceph", "oci-container":
+ case "vm", "node", "agent", "system-container", "app-container", "docker-host", "k8s-cluster", "k8s-node", "k8s-pod", "k8s-deployment", "storage", "disk", "pbs", "pmg", "proxmox", "ceph", "oci-container":
return normalized
default:
return ""
diff --git a/internal/api/ai_handler_test.go b/internal/api/ai_handler_test.go
index 044eca4fee..f4d4ad900f 100644
--- a/internal/api/ai_handler_test.go
+++ b/internal/api/ai_handler_test.go
@@ -548,6 +548,7 @@ func TestHandleChat_DropsLegacyMentionTypes(t *testing.T) {
}
func TestCanonicalizeChatMentionType_RejectsRemovedAliases(t *testing.T) {
+ assert.Equal(t, "agent", canonicalizeChatMentionType("truenas"))
assert.Equal(t, "", canonicalizeChatMentionType("host"))
assert.Equal(t, "", canonicalizeChatMentionType("container"))
assert.Equal(t, "", canonicalizeChatMentionType("lxc"))
diff --git a/internal/api/ai_handlers.go b/internal/api/ai_handlers.go
index a05c9f5298..82bbd1db61 100644
--- a/internal/api/ai_handlers.go
+++ b/internal/api/ai_handlers.go
@@ -4078,18 +4078,18 @@ func (r AIInvestigateAlertRequest) alertIdentifier() string {
}
func normalizeInvestigateAlertTargetType(raw string) (string, error) {
- resourceType := strings.ToLower(strings.TrimSpace(raw))
+ resourceType := normalizeAITransportResourceType(raw)
switch resourceType {
case "vm":
return "vm", nil
case "system-container", "oci-container":
return "system-container", nil
- case "agent", "node", "docker-host", "app-container", "pod", "k8s-node", "k8s-cluster", "k8s-deployment", "k8s-service", "storage", "disk", "pbs", "pmg", "proxmox", "truenas", "ceph":
+ case "agent", "node", "docker-host", "app-container", "pod", "k8s-node", "k8s-cluster", "k8s-deployment", "k8s-service", "storage", "disk", "pbs", "pmg", "proxmox", "ceph":
return "agent", nil
case "":
return "", errors.New("resource_type is required")
default:
- return "", fmt.Errorf("unsupported resource_type %q (allowed: vm, system-container, oci-container, app-container, pod, agent, node, docker-host, k8s-cluster, k8s-node, k8s-deployment, k8s-service, storage, disk, pbs, pmg, proxmox, truenas, ceph)", raw)
+ return "", fmt.Errorf("unsupported resource_type %q (allowed: vm, system-container, oci-container, app-container, pod, agent, node, docker-host, k8s-cluster, k8s-node, k8s-deployment, k8s-service, storage, disk, pbs, pmg, proxmox, ceph)", raw)
}
}
diff --git a/internal/api/ai_handlers_test.go b/internal/api/ai_handlers_test.go
index 515956a809..b99e5b2255 100644
--- a/internal/api/ai_handlers_test.go
+++ b/internal/api/ai_handlers_test.go
@@ -545,6 +545,7 @@ func TestNormalizeInvestigateAlertTargetType_StrictCanonicalV6(t *testing.T) {
{name: "pod maps to agent", in: "pod", want: "agent"},
{name: "k8s cluster maps to agent", in: "k8s-cluster", want: "agent"},
{name: "node maps to agent", in: "node", want: "agent"},
+ {name: "truenas alias maps to agent", in: "truenas", want: "agent"},
{name: "legacy host rejected", in: "host", wantErr: "unsupported resource_type"},
{name: "legacy guest rejected", in: "guest", wantErr: "unsupported resource_type"},
{name: "legacy docker rejected", in: "docker", wantErr: "unsupported resource_type"},
diff --git a/internal/api/ai_resource_types.go b/internal/api/ai_resource_types.go
new file mode 100644
index 0000000000..48c307cb83
--- /dev/null
+++ b/internal/api/ai_resource_types.go
@@ -0,0 +1,12 @@
+package api
+
+import "strings"
+
+func normalizeAITransportResourceType(raw string) string {
+ switch strings.ToLower(strings.TrimSpace(raw)) {
+ case "truenas":
+ return "agent"
+ default:
+ return strings.ToLower(strings.TrimSpace(raw))
+ }
+}