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.

frontend(platforms): resolve resource platform family via sources fallback

rcourtmancfc3fd160626
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 625194ad39..cb51e81525 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -706,6 +706,16 @@ AI runtime.
must derive primary issue labels and summaries from explicit incidents,
storage risk summaries, or storage-risk reasons so healthy rows do not
render impact text as a warning.
+ The shared `resolveResourcePlatformType(resource)` helper in
+ `frontend-modern/src/utils/sourcePlatforms.ts` is the canonical reader for
+ "what platform family does this unified resource belong to" and must be
+ used by every frontend consumer that buckets unified resources by family
+ (platform pages, filter resolvers, presentation pickers). The helper
+ prefers `resource.platformType` when present and falls back to the
+ resource's `sources` array via the existing source-platform normalization,
+ so client-side family grouping behaves identically against mock fixtures
+ and live backends that leave `platformType` empty on a subset of
+ canonical resource types.
8. Keep shared source/platform vocabulary on the governed manifest boundary. `frontend-modern/src/utils/platformSupportManifest.generated.ts` must be the tracked frontend projection of `docs/release-control/v6/internal/PLATFORM_SUPPORT_MANIFEST.json`, `frontend-modern/src/utils/platformSupportManifest.ts`, `frontend-modern/src/utils/sourcePlatforms.ts`, and `frontend-modern/src/utils/sourcePlatformOptions.ts` must consume that generated projection instead of embedding divergent future-label lists, setup/onboarding path allowlists, host-profile labels, or presentation-only guesses, and `frontend-modern/scripts/canonical-platform-audit.mjs` must fail when the generated projection drifts from the governed manifest. The generic `docker` source-platform label is "Docker / Podman" in shared selectors, badges, and filter options so v5 Docker users can find the runtime surface while Podman-backed rows are not mislabeled as Docker-only; "Container runtime" remains the governed platform family, not the primary customer-facing label. Agent host-profile entries, including Unraid, stay in the generated `agentHostProfiles` projection and shared wrapper helpers; frontend primitives may render those labels for Pulse Agent install/identity copy but must not add them to the first-class platform union.
The generated host-profile projection also carries runtime platform fallback
metadata for shared explanation and parity with backend normalization, but
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index ef023fe9fe..170c0a272a 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -137,6 +137,15 @@ cross-source deduplication.
selectors, badges, and filter options render it as "Docker / Podman" so
v5 Docker users can still find the runtime surface while Podman-backed
rows are not mislabeled as Docker-only.
+ That same boundary also owns `resolveResourcePlatformType(resource)`,
+ the canonical reader for "what platform family does a unified resource
+ belong to". Consumers that bucket unified resources by family (platform
+ pages, filter resolvers, presentation pickers) must call it instead of
+ inspecting `resource.platformType` directly: the legacy backend resource
+ projection leaves `platformType` empty on several canonical resource
+ types, and the helper falls back through the existing source-platform
+ normalization so client-side grouping behaves identically against mock
+ fixtures and live backends.
17. `internal/api/resources.go` shared with `api-contracts`: the unified resource endpoint is both a backend payload contract surface and a unified-resource runtime boundary.
## Extension Points
@@ -2269,6 +2278,14 @@ sources, `frontend-modern/src/utils/sourcePlatforms.ts` must still resolve the
platform as `truenas` and the source mode as `hybrid`, so workload and
infrastructure consumers do not collapse API-backed TrueNAS systems or apps
back onto the generic agent path just because host telemetry is also present.
+The shared `resolveResourcePlatformType(resource)` helper in that same module
+is the canonical "what platform does this unified resource belong to" reader.
+Platform-first top-level pages and any consumer that buckets unified resources
+by family must call it instead of inspecting `resource.platformType` directly,
+because the legacy backend resource projection leaves `platformType` empty on
+several canonical resource types; the helper falls back to the resource's
+`sources` array via the existing source-platform normalization so mock
+fixtures and live backends produce the same client-side platform grouping.
That same boundary also owns the infrastructure table's operator-facing system
identity vocabulary. `frontend-modern/src/utils/resourceBadgePresentation.ts`,
`frontend-modern/src/components/Infrastructure/resourceBadges.ts`, and the
diff --git a/frontend-modern/src/features/docker/dockerPageModel.ts b/frontend-modern/src/features/docker/dockerPageModel.ts
index 6a5d6a5451..dff79ecc4b 100644
--- a/frontend-modern/src/features/docker/dockerPageModel.ts
+++ b/frontend-modern/src/features/docker/dockerPageModel.ts
@@ -1,4 +1,4 @@
-import { normalizeSourcePlatformQueryValue } from '@/utils/sourcePlatforms';
+import { resolveResourcePlatformType } from '@/utils/sourcePlatforms';
import type { Resource, ResourceType } from '@/types/resource';
export type DockerPageTabId = 'overview' | 'containers' | 'services';
@@ -20,7 +20,7 @@ const DOCKER_CONTAINER_TYPES = new Set<ResourceType>(['app-container']);
const DOCKER_SERVICE_TYPES = new Set<ResourceType>(['docker-service']);
const isDockerPlatform = (resource: Resource): boolean =>
- normalizeSourcePlatformQueryValue(resource.platformType || '') === 'docker';
+ resolveResourcePlatformType(resource) === 'docker';
export type DockerPageModel = {
resources: Resource[];
diff --git a/frontend-modern/src/features/kubernetes/kubernetesPageModel.ts b/frontend-modern/src/features/kubernetes/kubernetesPageModel.ts
index a92287ac47..74fb0d79c1 100644
--- a/frontend-modern/src/features/kubernetes/kubernetesPageModel.ts
+++ b/frontend-modern/src/features/kubernetes/kubernetesPageModel.ts
@@ -1,4 +1,4 @@
-import { normalizeSourcePlatformQueryValue } from '@/utils/sourcePlatforms';
+import { resolveResourcePlatformType } from '@/utils/sourcePlatforms';
import type { Resource, ResourceType } from '@/types/resource';
export type KubernetesPageTabId =
@@ -31,7 +31,7 @@ const KUBERNETES_RESOURCE_TYPES = new Set<ResourceType>([
]);
const isKubernetesPlatform = (resource: Resource): boolean => {
- if (normalizeSourcePlatformQueryValue(resource.platformType || '') === 'kubernetes') return true;
+ if (resolveResourcePlatformType(resource) === 'kubernetes') return true;
return KUBERNETES_RESOURCE_TYPES.has(resource.type);
};
diff --git a/frontend-modern/src/features/truenas/truenasPageModel.ts b/frontend-modern/src/features/truenas/truenasPageModel.ts
index e865c57203..eb13ddcf2f 100644
--- a/frontend-modern/src/features/truenas/truenasPageModel.ts
+++ b/frontend-modern/src/features/truenas/truenasPageModel.ts
@@ -1,4 +1,4 @@
-import { normalizeSourcePlatformQueryValue } from '@/utils/sourcePlatforms';
+import { resolveResourcePlatformType } from '@/utils/sourcePlatforms';
import type { Resource, ResourceType } from '@/types/resource';
export type TrueNASPageTabId = 'overview' | 'storage' | 'apps';
@@ -25,7 +25,7 @@ const TRUENAS_RESOURCE_TYPES = new Set<ResourceType>([
]);
const isTrueNASPlatform = (resource: Resource): boolean =>
- normalizeSourcePlatformQueryValue(resource.platformType || '') === 'truenas';
+ resolveResourcePlatformType(resource) === 'truenas';
export type TrueNASPageModel = {
resources: Resource[];
diff --git a/frontend-modern/src/features/vmware/vmwarePageModel.ts b/frontend-modern/src/features/vmware/vmwarePageModel.ts
index ce5b5f3a7c..8ed1a0d404 100644
--- a/frontend-modern/src/features/vmware/vmwarePageModel.ts
+++ b/frontend-modern/src/features/vmware/vmwarePageModel.ts
@@ -1,4 +1,4 @@
-import { normalizeSourcePlatformQueryValue } from '@/utils/sourcePlatforms';
+import { resolveResourcePlatformType } from '@/utils/sourcePlatforms';
import type { Resource, ResourceType } from '@/types/resource';
export type VmwarePageTabId = 'overview' | 'vms' | 'storage';
@@ -23,7 +23,7 @@ const VMWARE_RESOURCE_TYPES = new Set<ResourceType>([
]);
const isVmwarePlatform = (resource: Resource): boolean =>
- normalizeSourcePlatformQueryValue(resource.platformType || '') === 'vmware-vsphere';
+ resolveResourcePlatformType(resource) === 'vmware-vsphere';
export type VmwarePageModel = {
resources: Resource[];
diff --git a/frontend-modern/src/utils/__tests__/sourcePlatforms.test.ts b/frontend-modern/src/utils/__tests__/sourcePlatforms.test.ts
index 1914855613..e35a3cad69 100644
--- a/frontend-modern/src/utils/__tests__/sourcePlatforms.test.ts
+++ b/frontend-modern/src/utils/__tests__/sourcePlatforms.test.ts
@@ -6,6 +6,7 @@ import {
normalizeSourcePlatformQueryValue,
normalizeSourcePlatformKey,
resolvePlatformTypeFromSources,
+ resolveResourcePlatformType,
resolveSourceTypeFromSources,
} from '@/utils/sourcePlatforms';
import {
@@ -183,6 +184,32 @@ describe('sourcePlatforms', () => {
});
});
+ describe('resolveResourcePlatformType', () => {
+ it('prefers the resource platformType field when present', () => {
+ expect(
+ resolveResourcePlatformType({ platformType: 'proxmox-pve', sources: ['agent'] }),
+ ).toBe('proxmox-pve');
+ expect(resolveResourcePlatformType({ platformType: 'docker', sources: [] })).toBe('docker');
+ });
+
+ it('falls back to the source-derived platform when platformType is empty', () => {
+ expect(resolveResourcePlatformType({ platformType: null, sources: ['docker'] })).toBe(
+ 'docker',
+ );
+ expect(resolveResourcePlatformType({ sources: ['kubernetes'] })).toBe('kubernetes');
+ expect(resolveResourcePlatformType({ platformType: '', sources: ['truenas', 'agent'] })).toBe(
+ 'truenas',
+ );
+ expect(resolveResourcePlatformType({ sources: ['vmware'] })).toBe('vmware-vsphere');
+ expect(resolveResourcePlatformType({ sources: ['pbs'] })).toBe('proxmox-pbs');
+ });
+
+ it('returns undefined when neither field nor sources resolve a known platform', () => {
+ expect(resolveResourcePlatformType({})).toBeUndefined();
+ expect(resolveResourcePlatformType({ sources: ['mystery-source'] })).toBeUndefined();
+ });
+ });
+
describe('resolveSourceTypeFromSources', () => {
it('derives agent, api, and hybrid source modes from source arrays', () => {
expect(resolveSourceTypeFromSources(['agent'])).toBe('agent');
diff --git a/frontend-modern/src/utils/sourcePlatforms.ts b/frontend-modern/src/utils/sourcePlatforms.ts
index f2fa848f60..40176e4821 100644
--- a/frontend-modern/src/utils/sourcePlatforms.ts
+++ b/frontend-modern/src/utils/sourcePlatforms.ts
@@ -155,6 +155,21 @@ export const resolvePlatformTypeFromSources = (sources?: string[]): PlatformType
return undefined;
};
+// Canonical resolver: prefer the backend-emitted `platformType` when present,
+// otherwise derive it from the resource's `sources` array. Platform pages and
+// other consumers that filter unified resources by family should use this so
+// they work uniformly against mock fixtures and live data — the legacy backend
+// path leaves `platformType` empty on certain resource types and the
+// derivation by source remains the canonical fallback.
+export const resolveResourcePlatformType = (resource: {
+ platformType?: string | null;
+ sources?: string[];
+}): PlatformType | undefined => {
+ const fromField = normalizeSourcePlatformQueryValue(resource.platformType || '');
+ if (fromField) return fromField as PlatformType;
+ return resolvePlatformTypeFromSources(resource.sources);
+};
+
export const resolveSourceTypeFromSources = (sources?: string[]): SourceType => {
const flags = readSourcePlatformFlags(sources);
const hasOther =
diff --git a/tests/integration/tests/68-platform-pages-shell.spec.ts b/tests/integration/tests/68-platform-pages-shell.spec.ts
index 95622383fb..7bc6c40fcd 100644
--- a/tests/integration/tests/68-platform-pages-shell.spec.ts
+++ b/tests/integration/tests/68-platform-pages-shell.spec.ts
@@ -42,6 +42,12 @@ type PlatformPageCase = {
testId: string;
ariaLabel: string;
tabPaths: readonly string[];
+ // Sub-tab routes that should render at least one canonical row under the
+ // mock backend. We assert presence of a `<table>` to confirm the embedded
+ // canonical surface mounted and reached a non-empty state. Empty arrays
+ // are allowed for platform pages whose subtab is service-only or stays
+ // empty under the default mock fixtures.
+ populatedTabPaths?: readonly string[];
};
const PLATFORM_PAGES: readonly PlatformPageCase[] = [
@@ -51,6 +57,7 @@ const PLATFORM_PAGES: readonly PlatformPageCase[] = [
testId: 'docker-page',
ariaLabel: 'Docker sections',
tabPaths: ['/docker/overview', '/docker/containers', '/docker/services'],
+ populatedTabPaths: ['/docker/overview', '/docker/containers'],
},
{
id: 'kubernetes',
@@ -64,6 +71,7 @@ const PLATFORM_PAGES: readonly PlatformPageCase[] = [
'/kubernetes/deployments',
'/kubernetes/services',
],
+ populatedTabPaths: ['/kubernetes/pods', '/kubernetes/deployments'],
},
{
id: 'truenas',
@@ -71,6 +79,7 @@ const PLATFORM_PAGES: readonly PlatformPageCase[] = [
testId: 'truenas-page',
ariaLabel: 'TrueNAS sections',
tabPaths: ['/truenas/overview', '/truenas/storage', '/truenas/apps'],
+ populatedTabPaths: ['/truenas/storage'],
},
{
id: 'vmware',
@@ -78,6 +87,7 @@ const PLATFORM_PAGES: readonly PlatformPageCase[] = [
testId: 'vmware-page',
ariaLabel: 'VMware sections',
tabPaths: ['/vmware/overview', '/vmware/vms', '/vmware/storage'],
+ populatedTabPaths: ['/vmware/vms', '/vmware/storage'],
},
];
@@ -100,7 +110,7 @@ test.describe('Platform pages shell', () => {
test.setTimeout(180_000);
for (const platform of PLATFORM_PAGES) {
- test(`${platform.id} platform page renders with table-first sub-tab chrome`, async ({
+ test(`${platform.id} no-data state renders sub-tab chrome with empty resources`, async ({
page,
}, testInfo) => {
test.skip(testInfo.project.name.startsWith('mobile-'), 'Desktop shell smoke');
@@ -118,5 +128,31 @@ test.describe('Platform pages shell', () => {
await expect(sectionNav.locator(`a[href="${tabPath}"]`)).toBeVisible();
}
});
+
+ test(`${platform.id} populated state renders canonical rows under mock mode`, async ({
+ page,
+ }, testInfo) => {
+ test.skip(testInfo.project.name.startsWith('mobile-'), 'Desktop shell smoke');
+
+ const populated = platform.populatedTabPaths ?? [];
+ if (populated.length === 0) {
+ test.skip(
+ true,
+ `No mock-populated sub-tabs declared for ${platform.id}; default mock fixtures do not exercise this platform's tables yet.`,
+ );
+ }
+
+ for (const tabPath of populated) {
+ await page.goto(tabPath, { waitUntil: 'domcontentloaded' });
+
+ const pageRoot = page.getByTestId(platform.testId);
+ await expect(pageRoot).toBeVisible({ timeout: 30_000 });
+
+ // Each populated sub-tab must render at least one canonical table.
+ await expect(pageRoot.locator('table tbody tr').first()).toBeVisible({
+ timeout: 30_000,
+ });
+ }
+ });
}
});