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.

Centralize normalized identity lookup variants

rcourtmane087b6aac261
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 3b7ddecde3..5218167424 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -91,6 +91,11 @@ The subsystem registry now also requires explicit proof-policy coverage for all
shared runtime files, and shared-component guardrails fail if raw table
composition is reintroduced in new shared components outside the canonical
allowlist.
+Infrastructure summary and detail surfaces now also use the shared normalized
+identity lookup helper from `frontend-modern/src/utils/resourceIdentity.ts`
+so dotted hostnames and alias variants stay consistent between the shared
+table, drawer, and detail views instead of each component carrying its own
+identifier-variant logic.
General settings segmented selectors for theme preference and temperature unit
must now also route through the shared `FilterButtonGroup` primitive instead of
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 124aa75101..edfdd4e7ee 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -425,6 +425,11 @@ ReadState resource-resolution lookups must also normalize surrounding
whitespace on the incoming name before matching canonical resources. A valid
resource must not look missing just because a consumer asked for `" myserver "`
instead of `"myserver"`.
+The infrastructure summary surfaces now use the shared normalized identity
+lookup helper for these matches, so dotted hostnames such as
+`tower.example.local` collapse to the same canonical lookup variants as the
+resource table and resource graph surfaces instead of each view inventing its
+own comparison rule.
The same governed lookup boundary now also owns policy-aware resolved context:
downstream consumers that need routing plus canonical policy metadata must use
the unified-resource resolution context instead of rescanning typed views or
diff --git a/frontend-modern/src/components/Infrastructure/InfrastructureSummary.tsx b/frontend-modern/src/components/Infrastructure/InfrastructureSummary.tsx
index 08eea63853..5d4391e735 100644
--- a/frontend-modern/src/components/Infrastructure/InfrastructureSummary.tsx
+++ b/frontend-modern/src/components/Infrastructure/InfrastructureSummary.tsx
@@ -23,31 +23,22 @@ import {
getPreferredResourceDisplayName,
getPreferredResourceHostname,
getResourceIdentityAliases,
+ getNormalizedIdentityLookupVariants,
} from '@/utils/resourceIdentity';
import { getOrgID } from '@/utils/apiClient';
import { normalizeOrgScope } from '@/utils/orgScope';
import { eventBus } from '@/stores/events';
import { getChartSeriesColor } from '@/utils/chartSeriesPresentation';
-const normalizeResourceIdentifier = (value?: string | null): string[] => {
- if (!value) return [];
- const normalized = value.trim().toLowerCase();
- if (!normalized) return [];
- const variants = new Set<string>([normalized]);
- const dotIndex = normalized.indexOf('.');
- if (dotIndex > 0) {
- variants.add(normalized.slice(0, dotIndex));
- }
- return Array.from(variants);
-};
-
const getNormalizedResourceIdentifiers = (resource: Resource): Set<string> =>
new Set<string>([
- ...normalizeResourceIdentifier(resource.id),
- ...normalizeResourceIdentifier(resource.platformId),
- ...normalizeResourceIdentifier(getPreferredResourceDisplayName(resource)),
- ...normalizeResourceIdentifier(getPreferredResourceHostname(resource)),
- ...getResourceIdentityAliases(resource).flatMap((value) => normalizeResourceIdentifier(value)),
+ ...getNormalizedIdentityLookupVariants(resource.id),
+ ...getNormalizedIdentityLookupVariants(resource.platformId),
+ ...getNormalizedIdentityLookupVariants(getPreferredResourceDisplayName(resource)),
+ ...getNormalizedIdentityLookupVariants(getPreferredResourceHostname(resource)),
+ ...getResourceIdentityAliases(resource).flatMap((value) =>
+ getNormalizedIdentityLookupVariants(value),
+ ),
]);
const asTrimmedString = (value: unknown): string | null => {
diff --git a/frontend-modern/src/components/shared/InfrastructureSummaryTable.tsx b/frontend-modern/src/components/shared/InfrastructureSummaryTable.tsx
index ce85136d84..4371cc129b 100644
--- a/frontend-modern/src/components/shared/InfrastructureSummaryTable.tsx
+++ b/frontend-modern/src/components/shared/InfrastructureSummaryTable.tsx
@@ -24,7 +24,10 @@ import { StackedDiskBar } from '@/components/Dashboard/StackedDiskBar';
import { EnhancedCPUBar } from '@/components/Dashboard/EnhancedCPUBar';
import { TemperatureGauge } from '@/components/shared/TemperatureGauge';
import { useBreakpoint } from '@/hooks/useBreakpoint';
-import { getAgentLikeIdentityAliases } from '@/utils/resourceIdentity';
+import {
+ getAgentLikeIdentityAliases,
+ getNormalizedIdentityLookupVariants,
+} from '@/utils/resourceIdentity';
// Lazy load InfrastructureDetailsDrawer to avoid circular dependencies and reduce bundle size
const InfrastructureDetailsDrawer = lazy(() =>
@@ -52,17 +55,6 @@ const getAgentLinkedNodeId = (agent: Agent): string | undefined => {
);
};
-const normalizeIdentifier = (value: string): string[] => {
- const normalized = value.trim().toLowerCase();
- if (!normalized) return [];
- const variants = new Set<string>([normalized]);
- const dotIndex = normalized.indexOf('.');
- if (dotIndex > 0) {
- variants.add(normalized.slice(0, dotIndex));
- }
- return Array.from(variants);
-};
-
interface InfrastructureSummaryTableProps {
nodes: Node[];
pbsInstances?: PBSInstance[];
@@ -544,7 +536,7 @@ export const InfrastructureSummaryTable: Component<InfrastructureSummaryTablePro
return false;
}
const aliases = getAgentLikeIdentityAliases(agent).flatMap((value) =>
- normalizeIdentifier(value),
+ getNormalizedIdentityLookupVariants(value),
);
return aliases.includes(nodeName.toLowerCase());
});
diff --git a/frontend-modern/src/components/shared/__tests__/InfrastructureSummaryTable.test.tsx b/frontend-modern/src/components/shared/__tests__/InfrastructureSummaryTable.test.tsx
index 3d047475ae..bb32050839 100644
--- a/frontend-modern/src/components/shared/__tests__/InfrastructureSummaryTable.test.tsx
+++ b/frontend-modern/src/components/shared/__tests__/InfrastructureSummaryTable.test.tsx
@@ -2,6 +2,7 @@ import { describe, expect, it, vi } from 'vitest';
import { fireEvent, render, waitFor } from '@solidjs/testing-library';
import { InfrastructureSummaryTable } from '@/components/shared/InfrastructureSummaryTable';
import type { Agent, Node } from '@/types/api';
+import resourceIdentitySource from '@/utils/resourceIdentity.ts?raw';
const enhancedCpuBarMock = vi.fn();
const infrastructureDetailsDrawerMock = vi.fn();
@@ -95,6 +96,11 @@ const makeAgent = (overrides: Partial<Agent> = {}): Agent => ({
});
describe('InfrastructureSummaryTable', () => {
+ it('uses the shared normalized identity lookup helper', () => {
+ expect(resourceIdentitySource).toContain('getNormalizedIdentityLookupVariants');
+ expect(resourceIdentitySource).not.toContain('const dedupeTrimmedValues = (values: Array<string | undefined>): string[] => {');
+ });
+
it('uses linked agent ids for agent-backed node metric keys', () => {
enhancedCpuBarMock.mockClear();
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index 0c1e5cd132..a105e10f7e 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -8,6 +8,7 @@ import chartsApiSource from '@/api/charts.ts?raw';
import investigateAlertButtonSource from '@/components/Alerts/InvestigateAlertButton.tsx?raw';
import alertTargetTypesSource from '@/utils/alertTargetTypes.ts?raw';
import resourceBadgesSource from '@/components/Infrastructure/resourceBadges.ts?raw';
+import infrastructureSummaryTableSource from '@/components/shared/InfrastructureSummaryTable.tsx?raw';
import resourceBadgePresentationSource from '@/utils/resourceBadgePresentation.ts?raw';
import workloadTypeBadgesSource from '@/components/shared/workloadTypeBadges.ts?raw';
import emptyStateSource from '@/components/shared/EmptyState.tsx?raw';
@@ -83,6 +84,7 @@ import patrolStatusBarSource from '@/components/patrol/PatrolStatusBar.tsx?raw';
import patrolFormatSource from '@/utils/patrolFormat.ts?raw';
import aiFindingPresentationSource from '@/utils/aiFindingPresentation.ts?raw';
import chatIdentifiersSource from '@/utils/chatIdentifiers.ts?raw';
+import resourceIdentitySource from '@/utils/resourceIdentity.ts?raw';
import diskListSource from '@/components/Storage/DiskList.tsx?raw';
import useDiskListModelSource from '@/components/Storage/useDiskListModel.ts?raw';
import diskDetailSource from '@/components/Storage/DiskDetail.tsx?raw';
@@ -1940,6 +1942,9 @@ describe('frontend resource type boundaries', () => {
expect(aiChatSource).not.toContain("const normalizeMentionKeyPart =");
expect(chatIdentifiersSource).toContain('normalizeChatMentionKeyPart');
expect(chatIdentifiersSource).toContain('normalizeChatToolName');
+ expect(infrastructureSummarySource).toContain('getNormalizedIdentityLookupVariants');
+ expect(infrastructureSummaryTableSource).toContain('getNormalizedIdentityLookupVariants');
+ expect(resourceIdentitySource).toContain('getNormalizedIdentityLookupVariants');
expect(useUnifiedResourcesSource).not.toContain('normalizeResourcePolicyAISafeSummary(');
expect(useUnifiedResourcesSource).not.toContain('normalizeResourcePolicy(');
expect(useUnifiedResourcesSource).not.toContain('const resolvePolicySensitivity =');
diff --git a/frontend-modern/src/utils/__tests__/resourceIdentity.test.ts b/frontend-modern/src/utils/__tests__/resourceIdentity.test.ts
index 8055f92554..7659a95636 100644
--- a/frontend-modern/src/utils/__tests__/resourceIdentity.test.ts
+++ b/frontend-modern/src/utils/__tests__/resourceIdentity.test.ts
@@ -7,6 +7,7 @@ import {
getPreferredConfiguredNodeLabel,
getPreferredNamedEntityLabel,
getPreferredNormalizedPlatformId,
+ getNormalizedIdentityLookupVariants,
getInfrastructureDiscoveryHostname,
getInfrastructureMetadataId,
getPreferredResourceDisplayName,
@@ -228,6 +229,14 @@ describe('resourceIdentity', () => {
]);
});
+ it('builds normalized identity lookup variants for host-like values', () => {
+ expect(getNormalizedIdentityLookupVariants('tower.local')).toEqual(['tower.local', 'tower']);
+ expect(getNormalizedIdentityLookupVariants('Tower.Local')).toEqual(['tower.local', 'tower']);
+ expect(getNormalizedIdentityLookupVariants('tower')).toEqual(['tower']);
+ expect(getNormalizedIdentityLookupVariants('')).toEqual([]);
+ expect(getNormalizedIdentityLookupVariants(undefined)).toEqual([]);
+ });
+
it('resolves infrastructure metadata ids and discovery hostnames', () => {
const node = {
id: 'node-1',
diff --git a/frontend-modern/src/utils/resourceIdentity.ts b/frontend-modern/src/utils/resourceIdentity.ts
index 02bab38142..80b97fea3d 100644
--- a/frontend-modern/src/utils/resourceIdentity.ts
+++ b/frontend-modern/src/utils/resourceIdentity.ts
@@ -57,6 +57,18 @@ const dedupeTrimmedValues = (values: Array<string | undefined>): string[] => {
return deduped;
};
+export const getNormalizedIdentityLookupVariants = (value?: string | null): string[] => {
+ if (!value) return [];
+ const normalized = value.trim().toLowerCase();
+ if (!normalized) return [];
+ const variants = new Set<string>([normalized]);
+ const dotIndex = normalized.indexOf('.');
+ if (dotIndex > 0) {
+ variants.add(normalized.slice(0, dotIndex));
+ }
+ return Array.from(variants);
+};
+
const formatIdentityTarget = (resourceType?: string, resourceId?: string): string | null => {
const type = asTrimmedString(resourceType);
const id = asTrimmedString(resourceId);