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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Centralize org scope normalization
rcourtmane1056e8d732f
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.mdindex 9a7e336d22..6973294d18 100644--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md@@ -194,6 +194,10 @@ to `frontend-modern/src/components/Settings/OrganizationBillingPanel.tsx` mustcarry this contract and the dedicated organization-billing proof file insteadof remaining an unowned consumer of plan tier, entitlement limits, andusage-versus-cap presentation.+That same billing surface now also normalizes org scope through+`frontend-modern/src/utils/orgScope.ts` before it builds per-tenant state, so+cache keys and tenant lookups do not keep a local `getOrgID() || 'default'`+fallback in the hosted billing UI.The self-hosted and hosted billing surfaces now also share a canonicalcommercial page shell and plan/usage model. `ProLicensePanel.tsx` and`OrganizationBillingPanel.tsx` may still differ in deployment-specific actionsdiff --git a/docs/release-control/v6/internal/subsystems/organization-settings.md b/docs/release-control/v6/internal/subsystems/organization-settings.mdindex c8d8f2887c..fe0d35e5b1 100644--- a/docs/release-control/v6/internal/subsystems/organization-settings.md+++ b/docs/release-control/v6/internal/subsystems/organization-settings.md@@ -98,4 +98,7 @@ hosted subscription state rather than requiring the self-hosted`multi_tenant` feature flag. Provisioned hosted workspaces must therefore keep`org.OwnerUserID` aligned with the authenticated creator when that actor isknown, so organization-owner checks stay consistent across runtime auth and the-settings surfaces.+settings surfaces. The organization settings panels now also normalize org+scope through `frontend-modern/src/utils/orgScope.ts` instead of carrying+their own `getOrgID() || 'default'` fallbacks, so access, overview, and+sharing views stay aligned with the shared multi-tenant org context contract.diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.mdindex 7253caa8b0..70fa2e3478 100644--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md@@ -121,6 +121,13 @@ shared `frontend-modern/src/utils/sourcePlatforms.ts` helper directly, so theselector boundary keeps using the canonical source-platform contract instead ofmaintaining a local source-normalization alias.+Dashboard, workload-summary, infrastructure-summary, and org-scoped cache-key+paths now normalize org scope through the shared+`frontend-modern/src/utils/orgScope.ts` helper instead of each file carrying+its own `getOrgID() || 'default'` fallback. That keeps cache isolation and+multi-tenant row-scoping aligned across the dashboard and resource-summary hot+paths.+GitHub-hosted runner proof for the API performance surface now intentionallyuses a looser budget envelope than local/staging benchmark runs for themixed-endpoint load test and the infrastructure/workload chart p95 checks.diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex 68037499db..2b487e9be8 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -169,6 +169,11 @@ The shared unified-resource consumer hook now also preserves `capabilities`,fields when storage and recovery surfaces read unified resources, so thosepages see the same control-plane facets as the dedicated resource drawerinstead of flattening them away locally.+The same storage-facing runtime paths now also normalize org scope through+`frontend-modern/src/utils/orgScope.ts` before building cache keys or+multi-tenant fetch state, so Dashboard, StorageSummary, and other storage+adjacent consumers do not each keep a local `getOrgID() || 'default'`+fallback.The frontend storage and recovery surfaces are also first-class runtime entrypoints. `frontend-modern/src/components/Storage/` plusdiff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.mdindex b07fe4ca7d..124aa75101 100644--- a/docs/release-control/v6/internal/subsystems/unified-resources.md+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md@@ -464,6 +464,11 @@ options: `frontend-modern/src/pages/Infrastructure.tsx` may render friendlystring keys, but membership checks against available sources must normalizethrough the shared `frontend-modern/src/utils/sourcePlatforms.ts` helperbefore consulting `KnownSourcePlatform` sets.+Shared unified-resource consumers now also normalize org scope through+`frontend-modern/src/utils/orgScope.ts` before building cache keys or+multi-tenant resource fetch state, so the canonical resource hooks do not+keep their own `getOrgID() || 'default'` fallback logic in each runtime+surface.Canonical monitored-system counting now also depends on this subsystem. Thecounted commercial unit is a deduped top-level monitored system assembled fromcanonical unified-resource roots, so read-state helpers that derivediff --git a/frontend-modern/src/components/Dashboard/Dashboard.tsx b/frontend-modern/src/components/Dashboard/Dashboard.tsxindex 0665f19e9f..9d796352ea 100644--- a/frontend-modern/src/components/Dashboard/Dashboard.tsx+++ b/frontend-modern/src/components/Dashboard/Dashboard.tsx@@ -43,6 +43,7 @@ import { blurFocusedTypeToSearch } from '@/hooks/useTypeToSearch';import { useWorkloads } from '@/hooks/useWorkloads';import { STORAGE_KEYS } from '@/utils/localStorage';import { getOrgID } from '@/utils/apiClient';+import { normalizeOrgScope } from '@/utils/orgScope';import { aiChatStore } from '@/stores/aiChat';import { eventBus } from '@/stores/events';import { useKioskMode } from '@/hooks/useKioskMode';@@ -106,12 +107,6 @@ let pendingPersistMetadata: GuestMetadataRecord | null = null;let pendingPersistStorageKey: string | null = null;let persistHandle: number | null = null;let persistHandleType: 'idle' | 'timeout' | null = null;-const DEFAULT_ORG_SCOPE = 'default';--const normalizeOrgScope = (orgID?: string | null): string => {- const normalized = (orgID || '').trim();- return normalized || DEFAULT_ORG_SCOPE;-};const guestMetadataStorageKeyForOrg = (orgScope: string): string =>`${STORAGE_KEYS.GUEST_METADATA}.${encodeURIComponent(orgScope)}`;diff --git a/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx b/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsxindex 61ef8d2d1d..8e3699cf57 100644--- a/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx+++ b/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx@@ -2,6 +2,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';import { render, waitFor } from '@solidjs/testing-library';import { createSignal, onCleanup, onMount } from 'solid-js';import { Dashboard } from '../Dashboard';+import dashboardSource from '../Dashboard.tsx?raw';import {filterWorkloads,createWorkloadSortComparator,@@ -404,6 +405,12 @@ describe('Dashboard performance contract', () => {expect(canonicalId).toBe('shared:node-x:42');});+ it('routes org scope normalization through the shared helper', () => {+ expect(dashboardSource).toContain('normalizeOrgScope(getOrgID())');+ expect(dashboardSource).not.toContain("const DEFAULT_ORG_SCOPE = 'default'");+ expect(dashboardSource).not.toContain('const normalizeOrgScope =');+ });+it('filterWorkloads returns all guests when no filters active', () => {const guests = makeGuests(PROFILES.S);const result = filterWorkloads({diff --git a/frontend-modern/src/components/Infrastructure/InfrastructureSummary.tsx b/frontend-modern/src/components/Infrastructure/InfrastructureSummary.tsxindex dd01e628b8..08eea63853 100644--- a/frontend-modern/src/components/Infrastructure/InfrastructureSummary.tsx+++ b/frontend-modern/src/components/Infrastructure/InfrastructureSummary.tsx@@ -25,6 +25,7 @@ import {getResourceIdentityAliases,} from '@/utils/resourceIdentity';import { getOrgID } from '@/utils/apiClient';+import { normalizeOrgScope } from '@/utils/orgScope';import { eventBus } from '@/stores/events';import { getChartSeriesColor } from '@/utils/chartSeriesPresentation';@@ -105,7 +106,7 @@ const MAX_IN_MEMORY_INFRA_ENTRIES = 20;const inMemoryChartCache = new Map<string, Map<string, ChartData>>();function inMemoryCacheKey(range: TimeRange): string {- return `${getOrgID() || 'default'}::${range}`;+ return `${normalizeOrgScope(getOrgID())}::${range}`;}/** @internal Test-only reset for in-memory chart cache. */diff --git a/frontend-modern/src/components/Settings/OrganizationAccessPanel.tsx b/frontend-modern/src/components/Settings/OrganizationAccessPanel.tsxindex b8531cebdd..c63ee8a8b7 100644--- a/frontend-modern/src/components/Settings/OrganizationAccessPanel.tsx+++ b/frontend-modern/src/components/Settings/OrganizationAccessPanel.tsx@@ -7,6 +7,7 @@ import {type OrganizationRole,} from '@/api/orgs';import { getOrgID } from '@/utils/apiClient';+import { normalizeOrgScope } from '@/utils/orgScope';import { canManageOrg, normalizeRole, roleBadgeClass } from '@/utils/orgUtils';import { ORGANIZATION_MEMBER_ROLE_OPTIONS } from '@/utils/organizationRolePresentation';import {@@ -39,7 +40,7 @@ export const OrganizationAccessPanel: Component<OrganizationAccessPanelProps> =const [inviteUserID, setInviteUserID] = createSignal('');const [inviteRole, setInviteRole] = createSignal<OrganizationRole>('viewer');- const activeOrgId = () => getOrgID() || 'default';+ const activeOrgId = () => normalizeOrgScope(getOrgID());const loadOrganizationAccess = async () => {setLoading(true);diff --git a/frontend-modern/src/components/Settings/OrganizationBillingPanel.tsx b/frontend-modern/src/components/Settings/OrganizationBillingPanel.tsxindex 3c94271917..aa960fc3a7 100644--- a/frontend-modern/src/components/Settings/OrganizationBillingPanel.tsx+++ b/frontend-modern/src/components/Settings/OrganizationBillingPanel.tsx@@ -2,6 +2,7 @@ import { Component, For, Show, createSignal, onCleanup, onMount } from 'solid-jsimport { LicenseAPI, type LicenseStatus } from '@/api/license';import { OrgsAPI } from '@/api/orgs';import { getOrgID } from '@/utils/apiClient';+import { normalizeOrgScope } from '@/utils/orgScope';import { isMultiTenantEnabled } from '@/stores/license';import { eventBus } from '@/stores/events';import { notificationStore } from '@/stores/notifications';@@ -74,7 +75,7 @@ export const OrganizationBillingPanel: Component<OrganizationBillingPanelProps>const loadBillingData = async () => {setLoading(true);try {- const activeOrgID = getOrgID() || 'default';+ const activeOrgID = normalizeOrgScope(getOrgID());const [licenseStatus, orgs, members] = await Promise.all([LicenseAPI.getStatus(),OrgsAPI.list(),diff --git a/frontend-modern/src/components/Settings/OrganizationOverviewPanel.tsx b/frontend-modern/src/components/Settings/OrganizationOverviewPanel.tsxindex 5d403297dc..ca4a06ff84 100644--- a/frontend-modern/src/components/Settings/OrganizationOverviewPanel.tsx+++ b/frontend-modern/src/components/Settings/OrganizationOverviewPanel.tsx@@ -2,6 +2,7 @@ import { Component, Show, createSignal, onCleanup, onMount } from 'solid-js';import SettingsPanel from '@/components/shared/SettingsPanel';import { OrgsAPI, type Organization, type OrganizationMember } from '@/api/orgs';import { getOrgID } from '@/utils/apiClient';+import { normalizeOrgScope } from '@/utils/orgScope';import { canManageOrg, formatOrgDate, normalizeRole, roleBadgeClass } from '@/utils/orgUtils';import {getOrganizationDisplayNameRequiredMessage,@@ -29,7 +30,7 @@ export const OrganizationOverviewPanel: Component<OrganizationOverviewPanelPropsconst [members, setMembers] = createSignal<OrganizationMember[]>([]);const [displayNameDraft, setDisplayNameDraft] = createSignal('');- const activeOrgId = () => getOrgID() || 'default';+ const activeOrgId = () => normalizeOrgScope(getOrgID());const loadOrganization = async () => {setLoading(true);diff --git a/frontend-modern/src/components/Settings/OrganizationSharingPanel.tsx b/frontend-modern/src/components/Settings/OrganizationSharingPanel.tsxindex 36105a616c..f3829e9aa1 100644--- a/frontend-modern/src/components/Settings/OrganizationSharingPanel.tsx+++ b/frontend-modern/src/components/Settings/OrganizationSharingPanel.tsx@@ -16,6 +16,7 @@ import {type OrganizationShare,} from '@/api/orgs';import { getOrgID } from '@/utils/apiClient';+import { normalizeOrgScope } from '@/utils/orgScope';import { canManageOrg, formatOrgDate, roleBadgeClass } from '@/utils/orgUtils';import { isMultiTenantEnabled } from '@/stores/license';import { eventBus } from '@/stores/events';@@ -82,7 +83,7 @@ export const OrganizationSharingPanel: Component<OrganizationSharingPanelProps>const [resourceTypeError, setResourceTypeError] = createSignal('');const [resourceIdError, setResourceIdError] = createSignal('');- const activeOrgId = () => getOrgID() || 'default';+ const activeOrgId = () => normalizeOrgScope(getOrgID());const { resources } = useResources();const targetOrgOptions = createMemo(() =>diff --git a/frontend-modern/src/components/Settings/__tests__/OrganizationBillingPanel.test.tsx b/frontend-modern/src/components/Settings/__tests__/OrganizationBillingPanel.test.tsxindex 8c53c555b1..5842fa6dc2 100644--- a/frontend-modern/src/components/Settings/__tests__/OrganizationBillingPanel.test.tsx+++ b/frontend-modern/src/components/Settings/__tests__/OrganizationBillingPanel.test.tsx@@ -2,6 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import { cleanup, render, screen, waitFor } from '@solidjs/testing-library';import { OrganizationBillingPanel } from '../OrganizationBillingPanel';+import organizationBillingPanelSource from '../OrganizationBillingPanel.tsx?raw';const getStatusMock = vi.hoisted(() => vi.fn());const listOrgsMock = vi.hoisted(() => vi.fn());@@ -92,4 +93,9 @@ describe('OrganizationBillingPanel', () => {expect(screen.getByText('2 / 5')).toBeInTheDocument();expect(errorMock).not.toHaveBeenCalled();});++ it('normalizes org scope through the shared helper', () => {+ expect(organizationBillingPanelSource).toContain('normalizeOrgScope(getOrgID())');+ expect(organizationBillingPanelSource).not.toContain("getOrgID() || 'default'");+ });});diff --git a/frontend-modern/src/components/Settings/__tests__/OrganizationSharingPanel.test.tsx b/frontend-modern/src/components/Settings/__tests__/OrganizationSharingPanel.test.tsxindex b4afa511b0..6f8e700a77 100644--- a/frontend-modern/src/components/Settings/__tests__/OrganizationSharingPanel.test.tsx+++ b/frontend-modern/src/components/Settings/__tests__/OrganizationSharingPanel.test.tsx@@ -2,6 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import { cleanup, fireEvent, render, screen, waitFor } from '@solidjs/testing-library';import type { Resource } from '@/types/resource';import { OrganizationSharingPanel } from '../OrganizationSharingPanel';+import organizationSharingPanelSource from '../OrganizationSharingPanel.tsx?raw';let mockResources: Resource[] = [];@@ -267,4 +268,9 @@ describe('OrganizationSharingPanel', () => {});});});++ it('normalizes org scope through the shared helper', () => {+ expect(organizationSharingPanelSource).toContain('normalizeOrgScope(getOrgID())');+ expect(organizationSharingPanelSource).not.toContain("getOrgID() || 'default'");+ });});diff --git a/frontend-modern/src/components/Storage/StorageSummary.tsx b/frontend-modern/src/components/Storage/StorageSummary.tsxindex 79adf030c0..b17fb7d98d 100644--- a/frontend-modern/src/components/Storage/StorageSummary.tsx+++ b/frontend-modern/src/components/Storage/StorageSummary.tsx@@ -15,6 +15,7 @@ import {} from '@/components/shared/summaryTimeRange';import { formatBytes } from '@/utils/format';import { getOrgID } from '@/utils/apiClient';+import { normalizeOrgScope } from '@/utils/orgScope';import { eventBus } from '@/stores/events';import { getChartSeriesColor } from '@/utils/chartSeriesPresentation';@@ -26,7 +27,7 @@ const POLL_INTERVAL_MS = 30_000;const inMemoryCache = new Map<string, StorageSummaryChartsResponse>();function inMemoryCacheKey(range: TimeRange, nodeId?: string): string {- return `${getOrgID() || 'default'}::${range}::${nodeId || '__all__'}`;+ return `${normalizeOrgScope(getOrgID())}::${range}::${nodeId || '__all__'}`;}// Clear in-memory cache on org switch to prevent cross-org data leakage.diff --git a/frontend-modern/src/components/Workloads/WorkloadsSummary.tsx b/frontend-modern/src/components/Workloads/WorkloadsSummary.tsxindex a35a044fa6..d23d0ff49a 100644--- a/frontend-modern/src/components/Workloads/WorkloadsSummary.tsx+++ b/frontend-modern/src/components/Workloads/WorkloadsSummary.tsx@@ -14,6 +14,7 @@ import {type WorkloadChartsResponse,} from '@/api/charts';import { getOrgID } from '@/utils/apiClient';+import { normalizeOrgScope } from '@/utils/orgScope';import { eventBus } from '@/stores/events';interface WorkloadsSummaryProps {@@ -91,7 +92,6 @@ const WORKLOAD_COLORS = [];const WORKLOADS_SUMMARY_CACHE_PREFIX = 'pulse.workloadsSummaryCharts.';-const DEFAULT_ORG_SCOPE = 'default';const WORKLOADS_SUMMARY_CACHE_VERSION = 3;const WORKLOADS_SUMMARY_CACHE_MAX_AGE_MS = 5 * 60_000;const WORKLOADS_SUMMARY_CACHE_MAX_POINTS_PER_SERIES = 360;@@ -137,11 +137,6 @@ interface CachedWorkloadsSummary {dockerData: Record<string, CachedChartData>;}-const normalizeOrgScope = (orgID?: string | null): string => {- const normalized = (orgID || '').trim();- return normalized || DEFAULT_ORG_SCOPE;-};-const cacheKeyFor = (range: TimeRange, nodeScope: string, orgScope: string) =>`${WORKLOADS_SUMMARY_CACHE_PREFIX}${encodeURIComponent(orgScope)}::${range}::${encodeURIComponent(nodeScope || '__all__')}`;diff --git a/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts b/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.tsindex 1a3e7ae492..38a1b2c657 100644--- a/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts+++ b/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts@@ -2,6 +2,7 @@ import { batch, createEffect, createRoot, createSignal } from 'solid-js';import { createStore, reconcile, type SetStoreFunction } from 'solid-js/store';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import type { State } from '@/types/api';+import useUnifiedResourcesSource from '../useUnifiedResources.ts?raw';type UseUnifiedResourcesModule = typeof import('@/hooks/useUnifiedResources');@@ -902,4 +903,10 @@ describe('useUnifiedResources', () => {dispose();});++ it('uses the shared org scope helper for cache and fetch state', () => {+ expect(useUnifiedResourcesSource).toContain('normalizeOrgScope(getOrgID())');+ expect(useUnifiedResourcesSource).not.toContain('const DEFAULT_ORG_SCOPE = \'default\'');+ expect(useUnifiedResourcesSource).not.toContain('const normalizeOrgScope =');+ });});diff --git a/frontend-modern/src/hooks/__tests__/useWorkloads.test.ts b/frontend-modern/src/hooks/__tests__/useWorkloads.test.tsindex e862df2022..b86f5e7db7 100644--- a/frontend-modern/src/hooks/__tests__/useWorkloads.test.ts+++ b/frontend-modern/src/hooks/__tests__/useWorkloads.test.ts@@ -1,5 +1,6 @@import { createEffect, createRoot, createSignal } from 'solid-js';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';+import useWorkloadsSource from '../useWorkloads.ts?raw';type UseWorkloadsModule = typeof import('@/hooks/useWorkloads');@@ -264,4 +265,10 @@ describe('useWorkloads', () => {dispose();});++ it('normalizes org scope through the shared helper', () => {+ expect(useWorkloadsSource).toContain('normalizeOrgScope(getOrgID())');+ expect(useWorkloadsSource).not.toContain("const DEFAULT_ORG_SCOPE = 'default'");+ expect(useWorkloadsSource).not.toContain('const normalizeOrgScope =');+ });});diff --git a/frontend-modern/src/hooks/useUnifiedResources.ts b/frontend-modern/src/hooks/useUnifiedResources.tsindex 566d30a8d6..2ed78e0747 100644--- a/frontend-modern/src/hooks/useUnifiedResources.ts+++ b/frontend-modern/src/hooks/useUnifiedResources.ts@@ -3,6 +3,7 @@ import { createStore, reconcile } from 'solid-js/store';import { canonicalizeMetricsHistoryTargetType } from '@/api/charts';import { readAPIErrorMessage } from '@/api/responseUtils';import { apiFetch, getOrgID } from '@/utils/apiClient';+import { normalizeOrgScope } from '@/utils/orgScope';import { getGlobalWebSocketStore } from '@/stores/websocket-global';import type {Resource,@@ -36,7 +37,6 @@ const UNIFIED_RESOURCES_MAX_PAGES = 20;const UNIFIED_RESOURCES_CACHE_MAX_AGE_MS = 15_000;const UNIFIED_RESOURCES_WS_DEBOUNCE_MS = 800;const UNIFIED_RESOURCES_WS_MIN_REFETCH_INTERVAL_MS = 2_500;-const DEFAULT_ORG_SCOPE = 'default';type APIMetricValue = {value?: number;@@ -410,11 +410,6 @@ type UnifiedResourcesCacheEntry = {const unifiedResourcesCaches = new Map<string, UnifiedResourcesCacheEntry>();-const normalizeOrgScope = (orgID?: string | null): string => {- const normalized = (orgID || '').trim();- return normalized || DEFAULT_ORG_SCOPE;-};-const buildScopedUnifiedResourcesCacheKey = (cacheKey: string, orgScope: string): string =>`${encodeURIComponent(orgScope)}::${cacheKey}`;diff --git a/frontend-modern/src/hooks/useWorkloads.ts b/frontend-modern/src/hooks/useWorkloads.tsindex a6115c881d..85fe78888a 100644--- a/frontend-modern/src/hooks/useWorkloads.ts+++ b/frontend-modern/src/hooks/useWorkloads.ts@@ -7,6 +7,7 @@ import {type Accessor,} from 'solid-js';import { apiFetchJSON, getOrgID } from '@/utils/apiClient';+import { normalizeOrgScope } from '@/utils/orgScope';import { eventBus } from '@/stores/events';import { resolvePlatformTypeFromSources } from '@/utils/sourcePlatforms';import { normalizeDiskArray } from '@/utils/format';@@ -17,7 +18,6 @@ const WORKLOADS_URL = '/api/resources?type=vm,system-container,app-container,podconst WORKLOADS_PAGE_LIMIT = 200;const WORKLOADS_MAX_PAGES = 20;const WORKLOADS_CACHE_MAX_AGE_MS = 15_000;-const DEFAULT_ORG_SCOPE = 'default';type APIMetricValue = {value?: number;@@ -140,11 +140,6 @@ type WorkloadsCacheEntry = {const workloadsCaches = new Map<string, WorkloadsCacheEntry>();-const normalizeOrgScope = (orgID?: string | null): string => {- const normalized = (orgID || '').trim();- return normalized || DEFAULT_ORG_SCOPE;-};-const getWorkloadsCacheEntry = (orgScope: string): WorkloadsCacheEntry => {const existing = workloadsCaches.get(orgScope);if (existing) {diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.tsindex 40afb9054e..0f979f26e5 100644--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts@@ -42,6 +42,7 @@ import recoveryTablePresentationSource from '@/utils/recoveryTablePresentation.timport recoveryTimelineChartPresentationSource from '@/utils/recoveryTimelineChartPresentation.ts?raw';import recoveryTimelinePresentationSource from '@/utils/recoveryTimelinePresentation.ts?raw';import dashboardSource from '@/components/Dashboard/Dashboard.tsx?raw';+import workloadsSummarySource from '@/components/Workloads/WorkloadsSummary.tsx?raw';import dashboardRouteSource from '@/pages/Dashboard.tsx?raw';import dashboardHelpersSource from '@/pages/DashboardPanels/dashboardHelpers.ts?raw';import dashboardMetricPresentationSource from '@/utils/dashboardMetricPresentation.ts?raw';@@ -60,7 +61,9 @@ import guestRowSource from '@/components/Dashboard/GuestRow.tsx?raw';import dashboardDiskListSource from '@/components/Dashboard/DiskList.tsx?raw';import guestDrawerSource from '@/components/Dashboard/GuestDrawer.tsx?raw';import dashboardGuestPresentationSource from '@/utils/dashboardGuestPresentation.ts?raw';+import orgScopeSource from '@/utils/orgScope.ts?raw';import workloadsSource from '@/utils/workloads.ts?raw';+import infrastructureSummaryCacheSource from '@/utils/infrastructureSummaryCache.ts?raw';import dashboardAlertPresentationSource from '@/utils/dashboardAlertPresentation.ts?raw';import dashboardStoragePresentationSource from '@/utils/dashboardStoragePresentation.ts?raw';import dashboardRecoveryPresentationSource from '@/utils/dashboardRecoveryPresentation.ts?raw';@@ -97,6 +100,7 @@ import storagePageBannerSource from '@/components/Storage/StoragePageBanner.tsx?import useStoragePageBannerModelSource from '@/components/Storage/useStoragePageBannerModel.ts?raw';import storagePageBannersSource from '@/components/Storage/StoragePageBanners.tsx?raw';import useStoragePageBannersModelSource from '@/components/Storage/useStoragePageBannersModel.ts?raw';+import storageSummarySource from '@/components/Storage/StorageSummary.tsx?raw';import storagePageSummarySource from '@/components/Storage/StoragePageSummary.tsx?raw';import storageCephSummaryCardSource from '@/components/Storage/StorageCephSummaryCard.tsx?raw';import useStorageCephSummaryCardModelSource from '@/components/Storage/useStorageCephSummaryCardModel.ts?raw';@@ -148,9 +152,11 @@ import licensePresentationSource from '@/utils/licensePresentation.ts?raw';import securityScorePresentationSource from '@/utils/securityScorePresentation.ts?raw';import securityAuthPresentationSource from '@/utils/securityAuthPresentation.ts?raw';import resourceDetailDrawerSource from '@/components/Infrastructure/ResourceDetailDrawer.tsx?raw';+import infrastructureSummarySource from '@/components/Infrastructure/InfrastructureSummary.tsx?raw';import resourceDetailMappersSource from '@/components/Infrastructure/resourceDetailMappers.ts?raw';import unifiedResourceTableSource from '@/components/Infrastructure/UnifiedResourceTable.tsx?raw';import useUnifiedResourcesSource from '@/hooks/useUnifiedResources.ts?raw';+import useWorkloadsSource from '@/hooks/useWorkloads.ts?raw';import findingsPanelSource from '@/components/AI/FindingsPanel.tsx?raw';import exploreStatusBlockSource from '@/components/AI/Chat/ExploreStatusBlock.tsx?raw';import aiExplorePresentationSource from '@/utils/aiExplorePresentation.ts?raw';@@ -331,11 +337,29 @@ describe('frontend resource type boundaries', () => {expect(storageSourcesSource).toContain('titleCaseDelimitedLabel');expect(storageSourcesSource).not.toContain('const titleCaseLabel =');expect(workloadsSource).toContain('export const normalizeWorkloadViewModeParam');+ expect(orgScopeSource).toContain("export const DEFAULT_ORG_SCOPE = 'default'");+ expect(orgScopeSource).toContain('export const normalizeOrgScope');expect(dashboardSource).toContain('normalizeWorkloadViewModeParam');expect(dashboardSource).not.toContain('function normalizeViewModeParam');expect(dashboardSource).not.toContain('workloadSummaryGuestId');expect(dashboardSource).toContain('createMemo(() => getCanonicalWorkloadId(guest()))');+ expect(dashboardSource).toContain('normalizeOrgScope(getOrgID())');+ expect(dashboardSource).not.toContain("const DEFAULT_ORG_SCOPE = 'default'");+ expect(dashboardSource).not.toContain('const normalizeOrgScope =');expect(dashboardSource).not.toContain('const guestId = () => {');+ expect(workloadsSummarySource).toContain('normalizeOrgScope(getOrgID())');+ expect(workloadsSummarySource).not.toContain("const DEFAULT_ORG_SCOPE = 'default'");+ expect(workloadsSummarySource).not.toContain('const normalizeOrgScope =');+ expect(infrastructureSummaryCacheSource).toContain('normalizeOrgScope(getOrgID())');+ expect(infrastructureSummaryCacheSource).not.toContain('const normalizeOrgScope =');+ expect(useWorkloadsSource).toContain('normalizeOrgScope(getOrgID())');+ expect(useWorkloadsSource).not.toContain('const normalizeOrgScope =');+ expect(useUnifiedResourcesSource).toContain('normalizeOrgScope(getOrgID())');+ expect(useUnifiedResourcesSource).not.toContain('const normalizeOrgScope =');+ expect(infrastructureSummarySource).toContain('normalizeOrgScope(getOrgID())');+ expect(infrastructureSummarySource).not.toContain("getOrgID() || 'default'");+ expect(storageSummarySource).toContain('normalizeOrgScope(getOrgID())');+ expect(storageSummarySource).not.toContain("getOrgID() || 'default'");expect(guestRowSource).toContain('getCanonicalWorkloadId');expect(guestRowSource).not.toContain('buildGuestId');expect(guestDrawerSource).toContain('getCanonicalWorkloadId');@@ -713,6 +737,10 @@ describe('frontend resource type boundaries', () => {expect(organizationRolePresentationSource).toContain('export function normalizeOrganizationShareRole',);+ expect(organizationAccessPanelSource).toContain('normalizeOrgScope(getOrgID())');+ expect(organizationOverviewPanelSource).toContain('normalizeOrgScope(getOrgID())');+ expect(organizationSharingPanelSource).toContain('normalizeOrgScope(getOrgID())');+ expect(organizationBillingPanelSource).toContain('normalizeOrgScope(getOrgID())');expect(organizationAccessPanelSource).toContain('@/utils/organizationSettingsPresentation');expect(billingAdminPanelSource).toContain('@/utils/organizationSettingsPresentation');expect(billingAdminPanelSource).toContain('@/utils/licensePresentation');diff --git a/frontend-modern/src/utils/__tests__/infrastructureSummaryCache.test.ts b/frontend-modern/src/utils/__tests__/infrastructureSummaryCache.test.tsindex 691135812d..08dcc13481 100644--- a/frontend-modern/src/utils/__tests__/infrastructureSummaryCache.test.ts+++ b/frontend-modern/src/utils/__tests__/infrastructureSummaryCache.test.ts@@ -1,6 +1,7 @@import { beforeEach, describe, expect, it, vi } from 'vitest';import type { ChartData, TimeRange } from '@/api/charts';import { setOrgID } from '@/utils/apiClient';+import infrastructureSummaryCacheSource from '../infrastructureSummaryCache.ts?raw';import {__resetInfrastructureSummaryFetchesForTests,extractInfrastructureSummaryChartMapFromInfrastructureResponse,@@ -307,4 +308,10 @@ describe('infrastructureSummaryCache persistence', () => {expect(localStorage.getItem(cacheKeyForRange('1h', 'org-a'))).not.toBeNull();expect(localStorage.getItem(cacheKeyForRange('1h', 'org-b'))).not.toBeNull();});++ it('normalizes org scope through the shared helper', () => {+ expect(infrastructureSummaryCacheSource).toContain('normalizeOrgScope(getOrgID())');+ expect(infrastructureSummaryCacheSource).not.toContain("const DEFAULT_ORG_SCOPE = 'default'");+ expect(infrastructureSummaryCacheSource).not.toContain('const normalizeOrgScope =');+ });});diff --git a/frontend-modern/src/utils/__tests__/orgScope.test.ts b/frontend-modern/src/utils/__tests__/orgScope.test.tsnew file mode 100644index 0000000000..145ccca208--- /dev/null+++ b/frontend-modern/src/utils/__tests__/orgScope.test.ts@@ -0,0 +1,16 @@+import { describe, expect, it } from 'vitest';+import { DEFAULT_ORG_SCOPE, normalizeOrgScope } from '@/utils/orgScope';++describe('orgScope', () => {+ it('normalizes empty org ids to the default scope', () => {+ expect(normalizeOrgScope(undefined)).toBe(DEFAULT_ORG_SCOPE);+ expect(normalizeOrgScope(null)).toBe(DEFAULT_ORG_SCOPE);+ expect(normalizeOrgScope('')).toBe(DEFAULT_ORG_SCOPE);+ expect(normalizeOrgScope(' ')).toBe(DEFAULT_ORG_SCOPE);+ });++ it('trims explicit org ids without changing their meaning', () => {+ expect(normalizeOrgScope(' acme ')).toBe('acme');+ expect(normalizeOrgScope('tenant-1')).toBe('tenant-1');+ });+});diff --git a/frontend-modern/src/utils/infrastructureSummaryCache.ts b/frontend-modern/src/utils/infrastructureSummaryCache.tsindex 1657ad938c..0a1f42cae8 100644--- a/frontend-modern/src/utils/infrastructureSummaryCache.ts+++ b/frontend-modern/src/utils/infrastructureSummaryCache.ts@@ -6,6 +6,7 @@ import {type TimeRange,} from '@/api/charts';import { getOrgID } from '@/utils/apiClient';+import { normalizeOrgScope } from '@/utils/orgScope';import { eventBus } from '@/stores/events';export const INFRA_SUMMARY_CACHE_PREFIX = 'pulse.infrastructureSummaryCharts.';@@ -13,7 +14,6 @@ export const INFRA_SUMMARY_CACHE_MAX_AGE_MS = 5 * 60_000;const INFRA_SUMMARY_CACHE_VERSION = 1;const INFRA_SUMMARY_CACHE_MAX_CHARS = 900_000;const INFRA_SUMMARY_CACHE_MAX_POINTS_PER_SERIES = 360;-const DEFAULT_ORG_SCOPE = 'default';const INFRA_SUMMARY_PERF_LOG_PREFIX = '[InfraSummaryPerf]';@@ -111,14 +111,6 @@ const toCachedChartData = (data: ChartData): CachedChartData => ({netout: trimPoints(data.netout ?? [], INFRA_SUMMARY_CACHE_MAX_POINTS_PER_SERIES),});-const normalizeOrgScope = (orgID: string | null | undefined): string => {- const normalized = orgID?.trim();- if (!normalized) {- return DEFAULT_ORG_SCOPE;- }- return normalized;-};-const inFlightKeyFor = (range: TimeRange, orgScope: string) =>`${encodeURIComponent(orgScope)}::${range}`;diff --git a/frontend-modern/src/utils/orgScope.ts b/frontend-modern/src/utils/orgScope.tsnew file mode 100644index 0000000000..3eb1b6e970--- /dev/null+++ b/frontend-modern/src/utils/orgScope.ts@@ -0,0 +1,6 @@+export const DEFAULT_ORG_SCOPE = 'default';++export const normalizeOrgScope = (orgID?: string | null): string => {+ const normalized = (orgID || '').trim();+ return normalized || DEFAULT_ORG_SCOPE;+};