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.

Restore resource drawer identity model owner

rcourtmanfb79bd3c43a8
diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.json
index 77d4046bd0..cb9e57834a 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -3220,6 +3220,7 @@
"frontend-modern/src/components/Infrastructure/resourceDetailDiscoveryModel.ts",
"frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx",
"frontend-modern/src/components/Infrastructure/ResourceDetailDrawerDebugTab.tsx",
+ "frontend-modern/src/components/Infrastructure/resourceDetailDrawerIdentityModel.ts",
"frontend-modern/src/components/Infrastructure/resourceDetailDrawerOperationalModel.ts",
"frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx",
"frontend-modern/src/components/Infrastructure/resourceDetailDrawerServiceModel.ts",
@@ -3317,6 +3318,7 @@
"frontend-modern/src/components/Infrastructure/resourceDetailDiscoveryModel.ts",
"frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx",
"frontend-modern/src/components/Infrastructure/ResourceDetailDrawerDebugTab.tsx",
+ "frontend-modern/src/components/Infrastructure/resourceDetailDrawerIdentityModel.ts",
"frontend-modern/src/components/Infrastructure/resourceDetailDrawerOperationalModel.ts",
"frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx",
"frontend-modern/src/components/Infrastructure/resourceDetailDrawerServiceModel.ts",
@@ -3354,6 +3356,7 @@
"frontend-modern/src/components/Infrastructure/__tests__/infrastructureSelectors.test.ts",
"frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.discovery.test.ts",
"frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx",
+ "frontend-modern/src/components/Infrastructure/__tests__/resourceDetailDrawerIdentityModel.test.ts",
"frontend-modern/src/components/Infrastructure/__tests__/resourceDetailDrawerOperationalModel.test.ts",
"frontend-modern/src/components/Infrastructure/__tests__/resourceDetailMappers.test.ts",
"frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx",
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 9af2601e10..d17008bef5 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -72,6 +72,7 @@ cross-source deduplication.
50. `frontend-modern/src/components/Infrastructure/useInfrastructureSummaryState.ts`
51. `frontend-modern/src/components/Infrastructure/infrastructureSummaryModel.ts`
52. `frontend-modern/src/utils/resourceIdentity.ts`
+53. `frontend-modern/src/components/Infrastructure/resourceDetailDrawerIdentityModel.ts`
## Shared Boundaries
@@ -187,6 +188,9 @@ that canonical identifier now lives in the `Identity` card as `Primary ID`,
`resourceDetailDrawerServiceModel.ts` owns the pure Docker/PBS/PMG service
summary and breakdown derivations that feed the overview service-details
surface,
+`resourceDetailDrawerIdentityModel.ts` owns the pure identity-card,
+discovery-summary, source-debug, and debug-bundle derivations that feed the
+overview and debug drawer surfaces,
`useResourceDetailDrawerDockerActionsState.ts` owns Docker action runtime, and
the overview/debug render-heavy surfaces live in dedicated drawer-local owners
instead of staying inline in the shell.
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/resourceDetailDrawerIdentityModel.test.ts b/frontend-modern/src/components/Infrastructure/__tests__/resourceDetailDrawerIdentityModel.test.ts
new file mode 100644
index 0000000000..c9e505df54
--- /dev/null
+++ b/frontend-modern/src/components/Infrastructure/__tests__/resourceDetailDrawerIdentityModel.test.ts
@@ -0,0 +1,138 @@
+import { describe, expect, it } from 'vitest';
+
+import {
+ buildDiscoveryContextSummary,
+ buildIdentityMatchInfo,
+ buildResourceDebugBundle,
+ buildResourceIdentityView,
+ buildSourceSections,
+} from '@/components/Infrastructure/resourceDetailDrawerIdentityModel';
+import type { Resource } from '@/types/resource';
+
+const baseResource = (overrides: Partial<Resource> = {}): Resource => ({
+ id: 'resource-1',
+ type: 'vm',
+ name: 'vm-101',
+ displayName: 'VM 101',
+ platformId: 'vm-101',
+ platformType: 'proxmox-vm',
+ sourceType: 'hybrid',
+ status: 'online',
+ lastSeen: Date.now(),
+ platformData: { sources: ['proxmox'] },
+ ...overrides,
+});
+
+describe('resourceDetailDrawerIdentityModel', () => {
+ it('builds canonical identity card state including alias collapse policy', () => {
+ const identityView = buildResourceIdentityView(
+ baseResource({
+ canonicalIdentity: {
+ primaryId: 'vm:101',
+ aliases: ['alpha', 'beta', 'gamma', 'delta', 'epsilon'],
+ },
+ identity: {
+ ips: ['192.0.2.10'],
+ },
+ }),
+ );
+
+ expect(identityView.primaryIdentityRows).toContainEqual({
+ label: 'Primary ID',
+ value: 'vm:101',
+ });
+ expect(identityView.identityIpValues).toEqual(['192.0.2.10']);
+ expect(identityView.aliasPreviewValues).toEqual(
+ identityView.identityAliasValues.slice(0, 4),
+ );
+ expect(identityView.hasAliasOverflow).toBe(true);
+ expect(identityView.identityCardHasRichData).toBe(true);
+ });
+
+ it('keeps discovery context wording in the canonical identity model', () => {
+ expect(
+ buildDiscoveryContextSummary({
+ resourceType: 'vm',
+ agentId: 'pve-1',
+ resourceId: '101',
+ hostname: 'pve-1.local',
+ metadataKind: 'guest',
+ metadataId: 'resource-1',
+ targetLabel: 'guest',
+ }),
+ ).toBe('vm analysis via pve-1.local');
+
+ expect(
+ buildDiscoveryContextSummary({
+ resourceType: 'agent',
+ agentId: 'host-1',
+ resourceId: 'host-1',
+ hostname: 'host-1.local',
+ metadataKind: 'agent',
+ metadataId: 'host-1',
+ targetLabel: 'agent',
+ }),
+ ).toBeNull();
+ });
+
+ it('builds canonical source sections and identity-match precedence', () => {
+ const platformData = {
+ agent: { hostname: 'host-1' },
+ pbs: { instanceId: 'pbs-1' },
+ metrics: { cpu: 42 },
+ matchResults: { source: 'match-results' },
+ matches: { source: 'matches' },
+ };
+
+ expect(buildSourceSections(platformData).map((section) => section.id)).toEqual([
+ 'agent',
+ 'pbs',
+ 'metrics',
+ ]);
+ expect(buildIdentityMatchInfo(platformData)).toEqual({ source: 'match-results' });
+ expect(
+ buildIdentityMatchInfo({
+ matchCandidates: { source: 'match-candidates' },
+ matches: { source: 'matches' },
+ }),
+ ).toEqual({ source: 'match-candidates' });
+ });
+
+ it('assembles the canonical debug bundle from model-owned identity and source state', () => {
+ const resource = baseResource({
+ identity: { hostname: 'vm-101.local' },
+ });
+
+ expect(
+ buildResourceDebugBundle({
+ resource,
+ platformData: {
+ proxmox: { nodeName: 'pve-1' },
+ docker: { runtime: 'docker' },
+ },
+ sourceStatus: {
+ proxmox: { status: 'online' },
+ },
+ identityMatchInfo: { matchedBy: 'hostname' },
+ }),
+ ).toEqual({
+ resource,
+ identity: {
+ resourceIdentity: { hostname: 'vm-101.local' },
+ matchInfo: { matchedBy: 'hostname' },
+ },
+ sources: {
+ sourceStatus: {
+ proxmox: { status: 'online' },
+ },
+ proxmox: { nodeName: 'pve-1' },
+ agent: undefined,
+ docker: { runtime: 'docker' },
+ pbs: undefined,
+ pmg: undefined,
+ kubernetes: undefined,
+ metrics: undefined,
+ },
+ });
+ });
+});
diff --git a/frontend-modern/src/components/Infrastructure/resourceDetailDrawerIdentityModel.ts b/frontend-modern/src/components/Infrastructure/resourceDetailDrawerIdentityModel.ts
new file mode 100644
index 0000000000..6b16c6412c
--- /dev/null
+++ b/frontend-modern/src/components/Infrastructure/resourceDetailDrawerIdentityModel.ts
@@ -0,0 +1,106 @@
+import type { Resource } from '@/types/resource';
+import {
+ getPrimaryResourceIdentityRows,
+ getResourceIdentityAliases,
+ type ResourceIdentityRow,
+} from '@/utils/resourceIdentity';
+import { formatIdentifierLabel } from '@/utils/textPresentation';
+import type { DiscoveryConfig } from './resourceDetailDiscoveryModel';
+import type { PlatformData } from './resourceDetailMappers';
+
+export type ResourceDetailDrawerSourceSection = {
+ id: string;
+ label: string;
+ payload: unknown;
+};
+
+export type ResourceDetailDrawerIdentityView = {
+ identityAliasValues: string[];
+ identityIpValues: string[];
+ primaryIdentityRows: ResourceIdentityRow[];
+ identityCardHasRichData: boolean;
+ aliasPreviewValues: string[];
+ hasAliasOverflow: boolean;
+};
+
+const ALIAS_COLLAPSE_THRESHOLD = 4;
+
+export const buildResourceIdentityView = (resource: Resource): ResourceDetailDrawerIdentityView => {
+ const identityAliasValues = getResourceIdentityAliases(resource);
+ const identityIpValues = resource.identity?.ips ?? [];
+ const primaryIdentityRows = getPrimaryResourceIdentityRows(resource);
+
+ return {
+ identityAliasValues,
+ identityIpValues,
+ primaryIdentityRows,
+ identityCardHasRichData:
+ primaryIdentityRows.length > 0 ||
+ identityIpValues.length > 0 ||
+ (resource.tags?.length || 0) > 0 ||
+ identityAliasValues.length > 0,
+ aliasPreviewValues: identityAliasValues.slice(0, ALIAS_COLLAPSE_THRESHOLD),
+ hasAliasOverflow: identityAliasValues.length > ALIAS_COLLAPSE_THRESHOLD,
+ };
+};
+
+export const buildDiscoveryContextSummary = (
+ discoveryConfig: DiscoveryConfig | null,
+): string | null => {
+ if (!discoveryConfig || discoveryConfig.resourceType === 'agent') {
+ return null;
+ }
+
+ const discoveryMode = `${formatIdentifierLabel(discoveryConfig.resourceType)} analysis`;
+ return discoveryConfig.hostname
+ ? `${discoveryMode} via ${discoveryConfig.hostname}`
+ : discoveryMode;
+};
+
+export const buildSourceSections = (
+ platformData?: PlatformData,
+): ResourceDetailDrawerSourceSection[] => {
+ if (!platformData) {
+ return [];
+ }
+
+ return [
+ { id: 'proxmox', label: 'Proxmox', payload: platformData.proxmox },
+ { id: 'agent', label: 'Agent', payload: platformData.agent },
+ { id: 'docker', label: 'Containers', payload: platformData.docker },
+ { id: 'pbs', label: 'PBS', payload: platformData.pbs },
+ { id: 'pmg', label: 'PMG', payload: platformData.pmg },
+ { id: 'kubernetes', label: 'Kubernetes', payload: platformData.kubernetes },
+ { id: 'metrics', label: 'Metrics', payload: platformData.metrics },
+ ].filter((section) => section.payload !== undefined);
+};
+
+export const buildIdentityMatchInfo = (platformData?: PlatformData): unknown =>
+ platformData?.identityMatch ??
+ platformData?.matchResults ??
+ platformData?.matchCandidates ??
+ platformData?.matches ??
+ undefined;
+
+export const buildResourceDebugBundle = (options: {
+ resource: Resource;
+ platformData?: PlatformData;
+ sourceStatus: NonNullable<PlatformData['sourceStatus']>;
+ identityMatchInfo: unknown;
+}) => ({
+ resource: options.resource,
+ identity: {
+ resourceIdentity: options.resource.identity,
+ matchInfo: options.identityMatchInfo,
+ },
+ sources: {
+ sourceStatus: options.sourceStatus,
+ proxmox: options.platformData?.proxmox,
+ agent: options.platformData?.agent,
+ docker: options.platformData?.docker,
+ pbs: options.platformData?.pbs,
+ pmg: options.platformData?.pmg,
+ kubernetes: options.platformData?.kubernetes,
+ metrics: options.platformData?.metrics,
+ },
+});
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index 87423ca726..c7f707b868 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -341,6 +341,7 @@ import resourceDetailDrawerDiscoveryModelSource from '@/components/Infrastructur
import resourceDetailMappersSource from '@/components/Infrastructure/resourceDetailMappers.ts?raw';
import resourceDetailDrawerHistoryStateSource from '@/components/Infrastructure/useResourceDetailDrawerHistoryState.ts?raw';
import resourceDetailDrawerDerivedStateSource from '@/components/Infrastructure/useResourceDetailDrawerDerivedState.ts?raw';
+import resourceDetailDrawerIdentityModelSource from '@/components/Infrastructure/resourceDetailDrawerIdentityModel.ts?raw';
import resourceDetailDrawerOperationalModelSource from '@/components/Infrastructure/resourceDetailDrawerOperationalModel.ts?raw';
import resourceDetailDrawerServiceModelSource from '@/components/Infrastructure/resourceDetailDrawerServiceModel.ts?raw';
import resourceDetailDrawerDockerActionsStateSource from '@/components/Infrastructure/useResourceDetailDrawerDockerActionsState.ts?raw';
@@ -1000,13 +1001,21 @@ describe('frontend resource type boundaries', () => {
expect(resourceDetailDrawerDerivedStateSource).toContain(
"from './resourceDetailDrawerServiceModel'",
);
+ expect(resourceDetailDrawerDerivedStateSource).toContain(
+ "from './resourceDetailDrawerIdentityModel'",
+ );
expect(resourceDetailDrawerDiscoveryModelSource).toContain('export const toDiscoveryConfig');
+ expect(resourceDetailDrawerIdentityModelSource).toContain('buildResourceIdentityView');
+ expect(resourceDetailDrawerIdentityModelSource).toContain('buildDiscoveryContextSummary');
+ expect(resourceDetailDrawerIdentityModelSource).toContain('buildResourceDebugBundle');
expect(resourceDetailDrawerDerivedStateSource).not.toContain('buildWorkloadsHref');
expect(resourceDetailDrawerDerivedStateSource).not.toContain('buildServiceDetailLinks');
expect(resourceDetailDrawerDerivedStateSource).not.toContain('const supportedBadge =');
expect(resourceDetailDrawerDerivedStateSource).not.toContain(
'const links: Array<{ href: string;',
);
+ expect(resourceDetailDrawerDerivedStateSource).not.toContain('ALIAS_COLLAPSE_THRESHOLD');
+ expect(resourceDetailDrawerDerivedStateSource).not.toContain('formatIdentifierLabel');
expect(resourceDetailDrawerOperationalModelSource).toContain('buildKubernetesCapabilityBadges');
expect(resourceDetailDrawerOperationalModelSource).toContain('buildHostDetailCards');
expect(resourceDetailDrawerOperationalModelSource).toContain('buildHostDetailSummary');
@@ -2655,7 +2664,7 @@ describe('frontend resource type boundaries', () => {
expect(approvalPresentationSource).toContain('getResourceApprovalLevelLabel');
expect(throughputPresentationSource).toContain('formatThroughputRate');
expect(resourceDetailDrawerSource).toContain('formatIdentifierLabel');
- expect(resourceDetailDrawerDerivedStateSource).toContain('formatIdentifierLabel');
+ expect(resourceDetailDrawerIdentityModelSource).toContain('formatIdentifierLabel');
expect(resourceDetailDrawerServiceModelSource).toContain('buildPbsVisibleJobBreakdown');
expect(resourceDetailDrawerServiceModelSource).toContain('buildPmgVisibleQueueBreakdown');
expect(resourceDetailDrawerServiceModelSource).toContain('buildPmgVisibleMailBreakdown');
diff --git a/scripts/release_control/canonical_completion_guard_test.py b/scripts/release_control/canonical_completion_guard_test.py
index 8f533ac467..e773feaec7 100644
--- a/scripts/release_control/canonical_completion_guard_test.py
+++ b/scripts/release_control/canonical_completion_guard_test.py
@@ -504,6 +504,7 @@ class CanonicalCompletionGuardTest(unittest.TestCase):
"frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx",
"frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.workloads-link.test.tsx",
"frontend-modern/src/components/Infrastructure/__tests__/infrastructureSelectors.test.ts",
+ "frontend-modern/src/components/Infrastructure/__tests__/resourceDetailDrawerIdentityModel.test.ts",
"frontend-modern/src/components/Infrastructure/__tests__/resourceDetailDrawerOperationalModel.test.ts",
"frontend-modern/src/components/Infrastructure/__tests__/resourceDetailMappers.test.ts",
"frontend-modern/src/components/Infrastructure/__tests__/unifiedResourceTableStateModel.test.ts",
diff --git a/scripts/release_control/subsystem_lookup_test.py b/scripts/release_control/subsystem_lookup_test.py
index ebf5fd536e..6564b9bc1f 100644
--- a/scripts/release_control/subsystem_lookup_test.py
+++ b/scripts/release_control/subsystem_lookup_test.py
@@ -156,6 +156,36 @@ class SubsystemLookupTest(unittest.TestCase):
match["verification_requirement"]["exact_files"],
)
+ def test_lookup_paths_assigns_resource_detail_drawer_identity_model_to_unified_resources(self) -> None:
+ result = lookup_paths(
+ ["frontend-modern/src/components/Infrastructure/resourceDetailDrawerIdentityModel.ts"]
+ )
+ self.assertEqual(result["unowned_runtime_files"], [])
+ self.assertEqual(
+ {item["subsystem"] for item in result["impacted_subsystems"]},
+ {"unified-resources"},
+ )
+ file_entry = result["files"][0]
+ self.assertEqual(file_entry["classification"], "runtime")
+ self.assertEqual(
+ {match["subsystem"] for match in file_entry["matches"]},
+ {"unified-resources"},
+ )
+ match = file_entry["matches"][0]
+ self.assertEqual(
+ match["contract"],
+ "docs/release-control/v6/internal/subsystems/unified-resources.md",
+ )
+ self.assertEqual(match["lane_context"]["lane_id"], "L13")
+ self.assertEqual(
+ match["verification_requirement"]["id"],
+ "resource-consumers",
+ )
+ self.assertIn(
+ "frontend-modern/src/components/Infrastructure/__tests__/resourceDetailDrawerIdentityModel.test.ts",
+ match["verification_requirement"]["exact_files"],
+ )
+
def test_lookup_paths_assigns_unified_resource_table_state_model_to_shared_infrastructure_hot_path(
self,
) -> None:
@@ -4081,6 +4111,7 @@ class SubsystemLookupTest(unittest.TestCase):
"frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx",
"frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.workloads-link.test.tsx",
"frontend-modern/src/components/Infrastructure/__tests__/infrastructureSelectors.test.ts",
+ "frontend-modern/src/components/Infrastructure/__tests__/resourceDetailDrawerIdentityModel.test.ts",
"frontend-modern/src/components/Infrastructure/__tests__/resourceDetailDrawerOperationalModel.test.ts",
"frontend-modern/src/components/Infrastructure/__tests__/resourceDetailMappers.test.ts",
"frontend-modern/src/components/Infrastructure/__tests__/unifiedResourceTableStateModel.test.ts",