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 policy-aware display names

rcourtmancdd282d74406
diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
index 671088f0b3..ed9a5ccd43 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -118,11 +118,12 @@ the table, but it must remain on the same bounded row-windowing and mounted-row
budget proved by `UnifiedResourceTable.performance.contract.test.tsx` rather
than creating a separate unbounded rendering path for policy-rich fleets.
The shared table and detail drawer now also render governed resource labels
-through `getResourcePolicyDisplayLabel` and suppress the raw alternate name
-when policy requires governed handling. That keeps the policy-aware label path
-inside the same hot-row rendering budget instead of adding a second display
-branch for redacted fleets, and the proof for that behavior lives in
-`UnifiedResourceTable.performance.contract.test.tsx`.
+through the shared identity/display contract, which routes policy-aware
+resources through the canonical policy-aware helper and suppresses the raw
+alternate name when policy requires governed handling. That keeps the
+policy-aware label path inside the same hot-row rendering budget instead of
+adding a second display branch for redacted fleets, and the proof for that
+behavior lives in `UnifiedResourceTable.performance.contract.test.tsx`.
The aggregate `/api/charts/workloads-summary` endpoint now also has its own
explicit API p95 budget constant, aligned with the per-workload charts budget,
and `internal/api/slo_bench_test.go` must fail if that aggregate budget or its
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index b90fd81996..0dd8795dd3 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -277,6 +277,10 @@ governed display label through the same policy-aware helper, and they suppress
the raw alternate name when policy requires governed handling, so the visible
label stays aligned with the backend redaction boundary instead of
reconstructing a local name fallback.
+The shared frontend resource identity helper now inherits the same policy-aware
+display contract, so other infrastructure surfaces that ask for the preferred
+resource label no longer need to re-encode the governed summary boundary by
+hand.
That same contract also owns the canonical resource display-name fallback, so
name-or-ID presentation stays consistent between the unified AI adapter, the
AI resource context, and the connected-infrastructure / monitored-system
diff --git a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx
index f9c4e18991..a424aa2e7d 100644
--- a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx
+++ b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx
@@ -30,6 +30,7 @@ import {
getPrimaryResourceIdentity,
getPrimaryResourceIdentityRows,
getResourceIdentityAliases,
+ getPreferredResourceDisplayName,
} from '@/utils/resourceIdentity';
import { SystemInfoCard } from '@/components/shared/cards/SystemInfoCard';
import { HardwareCard } from '@/components/shared/cards/HardwareCard';
@@ -54,7 +55,6 @@ import { getServiceHealthPresentation } from '@/utils/serviceHealthPresentation'
import { ResourceAPI } from '@/api/resources';
import {
getResourcePolicyBadges,
- getResourcePolicyDisplayLabel,
getResourcePolicyRedactionLabels,
getResourceRoutingScopeLabel,
getResourceSensitivityLabel,
@@ -139,7 +139,7 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {
const [copied, setCopied] = createSignal(false);
const [showReportModal, setShowReportModal] = createSignal(false);
- const displayName = createMemo(() => getResourcePolicyDisplayLabel(props.resource));
+ const displayName = createMemo(() => getPreferredResourceDisplayName(props.resource));
const statusIndicator = createMemo(() =>
getAgentStatusIndicator({ status: props.resource.status }),
);
diff --git a/frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx b/frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx
index 0f6388b7ea..823e8f99f0 100644
--- a/frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx
+++ b/frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx
@@ -25,9 +25,9 @@ import {
import { useBreakpoint } from '@/hooks/useBreakpoint';
import { getAgentStatusIndicator } from '@/utils/status';
import { getServiceHealthSummaryPresentation } from '@/utils/serviceHealthPresentation';
+import { getPreferredResourceDisplayName } from '@/utils/resourceIdentity';
import {
getResourcePolicyBadges,
- getResourcePolicyDisplayLabel,
shouldShowResourceAlternateName,
} from '@/utils/resourcePolicyPresentation';
import type { Disk } from '@/types/api';
@@ -537,7 +537,7 @@ export const UnifiedResourceTable: Component<UnifiedResourceTableProps> = (props
const isHighlighted = createMemo(
() => props.highlightedResourceId === resource.id,
);
- const displayName = createMemo(() => getResourcePolicyDisplayLabel(resource));
+ const displayName = createMemo(() => getPreferredResourceDisplayName(resource));
const statusIndicator = createMemo(() =>
getAgentStatusIndicator({ status: resource.status }),
);
@@ -1036,7 +1036,7 @@ export const UnifiedResourceTable: Component<UnifiedResourceTableProps> = (props
const isHighlighted = createMemo(
() => props.highlightedResourceId === resource.id,
);
- const displayName = createMemo(() => getResourcePolicyDisplayLabel(resource));
+ const displayName = createMemo(() => getPreferredResourceDisplayName(resource));
const serviceLink = createMemo(
() => buildServiceDetailLinks(resource)[0] ?? null,
);
@@ -1338,7 +1338,7 @@ export const UnifiedResourceTable: Component<UnifiedResourceTableProps> = (props
const isHighlighted = createMemo(
() => props.highlightedResourceId === resource.id,
);
- const displayName = createMemo(() => getResourcePolicyDisplayLabel(resource));
+ const displayName = createMemo(() => getPreferredResourceDisplayName(resource));
const serviceLink = createMemo(
() => buildServiceDetailLinks(resource)[0] ?? null,
);
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx b/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx
index c81a93e354..96d08f0ca8 100644
--- a/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx
+++ b/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx
@@ -4,6 +4,7 @@ import type { Resource } from '@/types/resource';
import { UnifiedResourceTable } from '@/components/Infrastructure/UnifiedResourceTable';
import { ResourceFacetSummary } from '@/components/Infrastructure/ResourceFacetSummary';
import { formatSensorName } from '@/components/Infrastructure/resourceDetailMappers';
+import { getPreferredResourceDisplayName } from '@/utils/resourceIdentity';
import {
buildStatusOptions,
filterResources,
@@ -378,6 +379,9 @@ describe('UnifiedResourceTable performance contract', () => {
await waitFor(() => {
expect(getAllByText('Restricted').length).toBeGreaterThan(0);
});
+ expect(getPreferredResourceDisplayName(resources[0]!)).toBe(
+ 'restricted host summary safe for remote AI consumption',
+ );
expect(getByTitle('restricted host summary safe for remote AI consumption')).toBeInTheDocument();
expect(queryByText('Sensitive Host')).toBeNull();
expect(queryByText('sensitive-host')).toBeNull();
diff --git a/frontend-modern/src/utils/__tests__/resourceIdentity.test.ts b/frontend-modern/src/utils/__tests__/resourceIdentity.test.ts
index 7659a95636..bb7ba3d2f0 100644
--- a/frontend-modern/src/utils/__tests__/resourceIdentity.test.ts
+++ b/frontend-modern/src/utils/__tests__/resourceIdentity.test.ts
@@ -364,6 +364,23 @@ describe('resourceIdentity', () => {
expect(getPreferredResourceHostname(resource)).toBe('platform-host.local');
expect(getPreferredResourceDisplayName(resource)).toBe('platform-host.local');
+ expect(
+ getPreferredResourceDisplayName(
+ makeResource({
+ name: 'sensitive-host',
+ displayName: 'Sensitive Host',
+ policy: {
+ sensitivity: 'restricted',
+ routing: {
+ scope: 'local-only',
+ redact: ['hostname', 'alias'],
+ },
+ },
+ aiSafeSummary: 'restricted host summary safe for remote AI consumption',
+ }),
+ ),
+ ).toBe('restricted host summary safe for remote AI consumption');
+
expect(
getPreferredResourceDisplayName(
makeResource({
diff --git a/frontend-modern/src/utils/resourceIdentity.ts b/frontend-modern/src/utils/resourceIdentity.ts
index 6ecb18ecac..412d381d53 100644
--- a/frontend-modern/src/utils/resourceIdentity.ts
+++ b/frontend-modern/src/utils/resourceIdentity.ts
@@ -1,6 +1,10 @@
import type { Agent, Node } from '@/types/api';
import type { Resource, ResourceCanonicalIdentity } from '@/types/resource';
import type { NodeConfig } from '@/types/nodes';
+import {
+ getResourcePolicyDisplayLabel,
+ requiresGovernedResourceDisplay,
+} from '@/utils/resourcePolicyPresentation';
import {
getActionableAgentIdFromResource,
getActionableDockerRuntimeIdFromResource,
@@ -297,10 +301,12 @@ export const getPreferredResourceHostname = (resource: Resource): string | undef
};
export const getPreferredResourceDisplayName = (resource: Resource): string =>
- resource.displayName ||
- asTrimmedString(getCanonicalIdentityRecord(resource)?.displayName) ||
- getPreferredResourceHostname(resource) ||
- getPrimaryResourceIdentity(resource);
+ requiresGovernedResourceDisplay(resource.policy)
+ ? getResourcePolicyDisplayLabel(resource)
+ : asTrimmedString(resource.displayName) ||
+ asTrimmedString(getCanonicalIdentityRecord(resource)?.displayName) ||
+ getPreferredResourceHostname(resource) ||
+ getPrimaryResourceIdentity(resource);
export const getPreferredWorkloadsAgentHint = (resource: Resource): string | undefined => {
const platformData = getPlatformDataRecord(resource);
diff --git a/frontend-modern/src/utils/resourcePolicyPresentation.ts b/frontend-modern/src/utils/resourcePolicyPresentation.ts
index 1d4c9874f3..12df5f45ef 100644
--- a/frontend-modern/src/utils/resourcePolicyPresentation.ts
+++ b/frontend-modern/src/utils/resourcePolicyPresentation.ts
@@ -119,6 +119,11 @@ export const getResourceRedactionHintLabel = (hint?: ResourceRedactionHint): str
export const getResourcePolicyRedactionLabels = (policy?: ResourcePolicy): string[] =>
(policy?.routing.redact ?? []).map((hint) => getResourceRedactionHintLabel(hint));
+export const requiresGovernedResourceDisplay = (policy?: ResourcePolicy | null): boolean => {
+ if (!policy) return false;
+ return policy.routing.scope === 'local-only' || (policy.routing.redact?.length ?? 0) > 0;
+};
+
const buildCountSummaries = <T extends string>(
counts: Partial<Record<T, number>> | undefined,
order: readonly T[],
@@ -181,10 +186,7 @@ export const getResourcePolicyDisplayLabel = (
if (!policy) {
return resource.displayName?.trim() || resource.name?.trim() || '';
}
- const requiresGovernedDisplay =
- (policy.routing.scope === 'local-only' || (policy.routing.redact?.length ?? 0) > 0);
-
- if (requiresGovernedDisplay) {
+ if (requiresGovernedResourceDisplay(policy)) {
return summary || 'redacted by policy';
}
@@ -196,10 +198,7 @@ export const shouldShowResourceAlternateName = (
): boolean => {
if (!resource?.displayName || !resource.name) return false;
- if (
- resource.policy &&
- (resource.policy.routing.scope === 'local-only' || (resource.policy.routing.redact?.length ?? 0) > 0)
- ) {
+ if (requiresGovernedResourceDisplay(resource.policy)) {
return false;
}