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 commercial posture bootstrap and ban non-billing entitlement reads

rcourtman4eedaf72da26
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index af66f317ae..5fe50ee386 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -337,6 +337,17 @@ Lifecycle-owned browser shells must also defer any commercial helper reads
until that presentation policy resolves so demo suppression stays fail-closed
during first render instead of racing hidden commercial endpoints from shared
setup or install surfaces.
+The governed exception is
+`frontend-modern/src/components/SetupWizard/SetupCompletionPanel.tsx`: because
+that first-run completion surface renders before the authenticated shell has
+mounted `frontend-modern/src/useAppRuntimeState.ts`, it may issue the local
+commercial posture bootstrap needed for trial and upgrade posture, and it may
+force-refresh that posture after a successful trial start. Other
+lifecycle-adjacent authenticated-shell surfaces such as
+`frontend-modern/src/components/Settings/useNodeModalState.ts` and
+`frontend-modern/src/components/Settings/useAgentProfilesPanelState.ts` must
+consume the shared posture owner instead of reintroducing their own mount-time
+commercial reads.
That same shared boundary now also owns the one-time checkout-return lookup:
lifecycle-adjacent surfaces may initiate billing or account handoff through
shared public routes, but they must never persist, derive, or replay the
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index cf07234bde..3cea74d674 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -477,6 +477,15 @@ contract for real customer workspaces, and `/api/license/entitlements`
remains billing-only. New callers must extend one of those owned shapes
instead of reviving a combined entitlement payload for mixed runtime,
commercial, and billing concerns.
+That same shared API contract now also owns browser-proofed read separation.
+Non-billing browser journeys such as
+`tests/integration/tests/11-first-session.spec.ts`,
+`tests/integration/tests/journeys/01-smoke-bootstrap-login-dashboard.spec.ts`,
+and `tests/integration/tests/journeys/03-relay-pairing.spec.ts` may call
+`/api/license/runtime-capabilities` for feature truth, but they must assert
+zero browser requests to `/api/license/entitlements`. Billing activation,
+upgrade, and owned billing panels remain the only browser surfaces allowed to
+read the billing-only entitlements contract.
`/portal` is now one bootstrap-driven shell for both anonymous and
authenticated users, so new account frontend work must extend that shared
contract rather than inventing a second local payload shape, reviving separate
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.md
index 0907787d3c..9b8af08502 100644
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@ -193,6 +193,27 @@ The governed browser proof for that posture lives in
`tests/integration/tests/53-demo-mode-commercial-boundary.spec.ts` and is
expected to stay runnable through
`tests/integration/scripts/run-tests.sh demo-contract`.
+That same licensing/browser boundary now also owns authenticated commercial
+posture bootstrap and the prohibition on non-billing entitlement reads.
+`frontend-modern/src/useAppRuntimeState.ts` is the canonical authenticated
+owner for the first `/api/license/commercial-posture` read, while
+`frontend-modern/src/AppLayout.tsx`,
+`frontend-modern/src/components/Settings/Settings.tsx`,
+`frontend-modern/src/components/Settings/useRelaySettingsPanelState.ts`, and
+other non-billing feature hooks may consume the resolved posture store but
+must not each trigger their own mount-time posture fetch. Billing-owned
+surfaces such as `frontend-modern/src/components/Settings/useProLicensePanelState.ts`
+may still force refresh through the same shared store when plan, trial, or
+recovery actions mutate commercial truth.
+Non-billing browser journeys must also stay off
+`/api/license/entitlements` entirely. Dashboard, infrastructure, alerts,
+first-session gated routes, and relay settings must take feature truth from
+`/api/license/runtime-capabilities` or already loaded commercial posture, and
+the governed browser proof in
+`tests/integration/tests/11-first-session.spec.ts`,
+`tests/integration/tests/journeys/01-smoke-bootstrap-login-dashboard.spec.ts`,
+and `tests/integration/tests/journeys/03-relay-pairing.spec.ts` must continue
+to assert zero browser-shell entitlement requests outside owned billing flows.
Legacy Cloud plan aliases are now expected to canonicalize to the `cloud_*`
contract not only when Stripe metadata is parsed, but also when persisted plan
versions are consumed at hosted entitlement and workspace-limit enforcement
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index 8e55f01050..f8eb3c0699 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -265,6 +265,15 @@ restarts, or startup build.
Otherwise unrelated parallel test edits or hot-dev's own binary output can
tear down `7655`, produce transient `5173` proxy failures, and undermine the
canonical browser-runtime proof path.
+That same shared helper boundary now also owns browser-versus-API request
+truth inside Playwright helpers. `tests/integration/tests/helpers.ts` may
+offer request trackers for browser-shell contract proofs, but those helpers
+must observe page-originated traffic only and must not blur browser runtime
+requests together with `page.request` or other direct API helper calls.
+Managed runtime recovery and browser bootstrap proofs therefore need to keep
+helper coverage that demonstrates browser-shell request tracking remains
+trustworthy when the same test also performs direct health or security-status
+API probes.
`scripts/hot-dev-bg.sh` must also supervise `scripts/hot-dev.sh` in an isolated
child session so an unexpected owner-process death cannot leave orphaned
watchers or health monitors behind. When the supervisor replaces the managed
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 850a37527f..cb15f62b72 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -435,6 +435,16 @@ commercial identity, upgrade routing, and trial state must stay in
`frontend-modern/src/stores/licenseCommercial.ts`, which suppresses public-demo
loads locally and defers its first fetch until the presentation policy has
resolved instead of depending on route-local guards.
+That same shared primitive boundary now also centralizes authenticated-shell
+commercial posture bootstrap. `frontend-modern/src/useAppRuntimeState.ts`
+owns the first shared `loadCommercialPosture()` read after authenticated app
+runtime has mounted, while `frontend-modern/src/AppLayout.tsx`,
+`frontend-modern/src/components/Settings/Settings.tsx`, shared warning-banner
+hooks, Patrol state hooks, and settings-panel state hooks must consume the
+resolved store state instead of reissuing mount-time posture fetches from each
+surface. Shared commercial posture loading may still dedupe or force-refresh
+through the store for governed billing or first-run flows, but route-local or
+panel-local bootstrap ownership is forbidden.
Storage disk drawers now also sit on that same shared-primitives floor.
`frontend-modern/src/components/Storage/DiskDetail.tsx` must render physical-
disk read, write, and busy charts through `HistoryChart` plus
diff --git a/docs/release-control/v6/internal/subsystems/organization-settings.md b/docs/release-control/v6/internal/subsystems/organization-settings.md
index 9fa6efb922..50213053ac 100644
--- a/docs/release-control/v6/internal/subsystems/organization-settings.md
+++ b/docs/release-control/v6/internal/subsystems/organization-settings.md
@@ -195,3 +195,10 @@ store, while free-trial eligibility and upgrade routing stay on the canonical
commercial-posture store backed by `/api/license/commercial-posture`.
Organization settings must not collapse those two concerns back into one
payload just because the same paywall shell renders both.
+That same posture split now also fixes RBAC bootstrap ownership.
+`frontend-modern/src/components/Settings/useRBACFeatureGateState.ts` may
+consume the resolved commercial-posture store for trial and upgrade copy, but
+it must not issue its own mount-time `loadCommercialPosture()` read.
+Authenticated-shell bootstrap belongs to
+`frontend-modern/src/useAppRuntimeState.ts`, with only the governed first-run
+setup completion surface allowed to bootstrap posture outside that shell.
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index ae7001f516..270f9e21b2 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -144,6 +144,14 @@ suppression is now the shared resolved `presentationPolicy` from
upgrade CTAs, trial nudges, and Pro-only helper copy only from that shared
policy instead of reviving local demo heuristics or issuing early commercial
reads before the policy resolves.
+That same posture split now also centralizes Patrol commercial bootstrap.
+`frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts` and
+`frontend-modern/src/components/patrol/ApprovalSection.tsx` may consume the
+resolved commercial-posture store when Patrol needs upgrade or trial context,
+but they must not trigger their own mount-time `loadCommercialPosture()`
+reads. Authenticated Patrol shells inherit that bootstrap from
+`frontend-modern/src/useAppRuntimeState.ts`, so Patrol-specific hooks do not
+quietly retake ownership of commercial fetch timing.
That degraded empty-state copy must also interpret the finding state rather
than simply replaying the primary assessment sentence verbatim: when coverage
is incomplete, the findings panel should tell the operator that Patrol has not
diff --git a/frontend-modern/src/AppLayout.tsx b/frontend-modern/src/AppLayout.tsx
index 0b97a49f26..3c381ceb1d 100644
--- a/frontend-modern/src/AppLayout.tsx
+++ b/frontend-modern/src/AppLayout.tsx
@@ -39,15 +39,8 @@ import { getKioskModePreference, setKioskMode } from '@/utils/url';
import { updateStore } from '@/stores/updates';
import { aiChatStore } from '@/stores/aiChat';
import { isMultiTenantEnabled } from '@/stores/license';
-import {
- isPro,
- loadCommercialPosture,
-} from '@/stores/licenseCommercial';
-import {
- presentationPolicyHidesCommercialSurfaces,
- presentationPolicyHidesUpgradePrompts,
- sessionPresentationPolicyResolved,
-} from '@/stores/sessionPresentationPolicy';
+import { isPro } from '@/stores/licenseCommercial';
+import { presentationPolicyHidesUpgradePrompts } from '@/stores/sessionPresentationPolicy';
import type { AppConnectionStatus } from '@/useAppRuntimeState';
const ROOT_INFRASTRUCTURE_PATH = buildInfrastructurePath();
@@ -181,16 +174,6 @@ export function AppLayout(props: AppLayoutProps) {
}
};
- createEffect(() => {
- if (!sessionPresentationPolicyResolved()) {
- return;
- }
- if (presentationPolicyHidesCommercialSurfaces()) {
- return;
- }
- void loadCommercialPosture();
- });
-
const showHeader = () => {
clearHeaderHideTimeout();
setHeaderVisible(true);
diff --git a/frontend-modern/src/__tests__/App.architecture.test.ts b/frontend-modern/src/__tests__/App.architecture.test.ts
index 0b2c0adabf..c3732e503c 100644
--- a/frontend-modern/src/__tests__/App.architecture.test.ts
+++ b/frontend-modern/src/__tests__/App.architecture.test.ts
@@ -55,10 +55,9 @@ describe('App architecture', () => {
expect(appLayoutSource).not.toContain('props.connected()');
expect(appLayoutSource).toContain('const utilityTabs = createMemo(() =>');
expect(appLayoutSource).toContain("import { isMultiTenantEnabled } from '@/stores/license';");
- expect(appLayoutSource).toContain("loadCommercialPosture");
- expect(appLayoutSource).toContain('sessionPresentationPolicyResolved');
- expect(appLayoutSource).toContain('if (presentationPolicyHidesCommercialSurfaces()) {');
- expect(appLayoutSource).toContain('void loadCommercialPosture();');
+ expect(appLayoutSource).not.toContain('loadCommercialPosture');
+ expect(appLayoutSource).not.toContain('sessionPresentationPolicyResolved');
+ expect(appLayoutSource).not.toContain('presentationPolicyHidesCommercialSurfaces');
expect(appSource).not.toContain("eventBus.on('theme_changed'");
expect(appSource).not.toContain("eventBus.on('websocket_reconnected'");
expect(appSource).not.toContain("apiFetch('/api/security/status')");
@@ -74,11 +73,15 @@ describe('App architecture', () => {
expect(appRuntimeStateSource).toContain(
"import {\n isHostedModeEnabled,\n isMultiTenantEnabled,\n runtimeCapabilitiesLoaded,\n loadRuntimeCapabilities,\n} from '@/stores/license';",
);
+ expect(appRuntimeStateSource).toContain(
+ "import { loadCommercialPosture } from '@/stores/licenseCommercial';",
+ );
expect(appRuntimeStateSource).toContain(
'const [activeOrgID, setActiveOrgID] = createSignal(',
);
expect(appRuntimeStateSource).toContain('onMount(() => {');
expect(appRuntimeStateSource).toContain('onMount(async () => {');
+ expect(appRuntimeStateSource).toContain('void loadCommercialPosture();');
expect(appRuntimeStateSource).toContain("eventBus.on('theme_changed', handleRemoteThemeChange);");
expect(appRuntimeStateSource).toContain(
"eventBus.on('websocket_reconnected', handleWebSocketReconnected);",
diff --git a/frontend-modern/src/components/Settings/Settings.tsx b/frontend-modern/src/components/Settings/Settings.tsx
index 4e1c693e35..7dd7e51100 100644
--- a/frontend-modern/src/components/Settings/Settings.tsx
+++ b/frontend-modern/src/components/Settings/Settings.tsx
@@ -1,4 +1,4 @@
-import { Component, createSignal, onMount, Show, Suspense, createMemo, createEffect } from 'solid-js';
+import { Component, createSignal, onMount, Show, Suspense, createMemo } from 'solid-js';
import { Dynamic } from 'solid-js/web';
import { useNavigate, useLocation } from '@solidjs/router';
import { useWebSocket } from '@/contexts/appRuntime';
@@ -22,11 +22,7 @@ import {
getRuntimeLimit,
loadRuntimeCapabilities,
} from '@/stores/license';
-import { isPro, loadCommercialPosture } from '@/stores/licenseCommercial';
-import {
- presentationPolicyHidesCommercialSurfaces,
- sessionPresentationPolicyResolved,
-} from '@/stores/sessionPresentationPolicy';
+import { isPro } from '@/stores/licenseCommercial';
interface SettingsProps {
darkMode: () => boolean;
@@ -160,16 +156,6 @@ const Settings: Component<SettingsProps> = (props) => {
void loadRuntimeCapabilities();
});
- createEffect(() => {
- if (!sessionPresentationPolicyResolved()) {
- return;
- }
- if (presentationPolicyHidesCommercialSurfaces()) {
- return;
- }
- void loadCommercialPosture();
- });
-
return (
<>
<SettingsPageShell
diff --git a/frontend-modern/src/components/Settings/__tests__/AgentProfilesPanel.test.tsx b/frontend-modern/src/components/Settings/__tests__/AgentProfilesPanel.test.tsx
index 6dd99173d4..4a5633e3c5 100644
--- a/frontend-modern/src/components/Settings/__tests__/AgentProfilesPanel.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/AgentProfilesPanel.test.tsx
@@ -1,5 +1,6 @@
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { render, screen, waitFor, fireEvent, cleanup, within } from '@solidjs/testing-library';
+import agentProfilesPanelStateSource from '../useAgentProfilesPanelState.ts?raw';
import { AgentProfilesPanel } from '../AgentProfilesPanel';
import { notificationStore } from '@/stores/notifications';
import type { ConnectedInfrastructureItem, State } from '@/types/api';
@@ -262,6 +263,10 @@ afterEach(() => {
});
describe('AgentProfilesPanel V6 agent ID handling', () => {
+ it('relies on shared commercial posture bootstrap instead of local posture loads', () => {
+ expect(agentProfilesPanelStateSource).not.toContain('loadCommercialPosture(');
+ });
+
it('maps assignments using actionable V6 agent ID instead of resource hash ID', async () => {
listAssignmentsMock.mockResolvedValue([
{ agent_id: 'agent-123', profile_id: 'profile-a', updated_at: new Date().toISOString() },
diff --git a/frontend-modern/src/components/Settings/__tests__/NodeModal.guardrails.test.ts b/frontend-modern/src/components/Settings/__tests__/NodeModal.guardrails.test.ts
index 94d079f1f4..31f8d7e4ea 100644
--- a/frontend-modern/src/components/Settings/__tests__/NodeModal.guardrails.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/NodeModal.guardrails.test.ts
@@ -55,7 +55,7 @@ describe('NodeModal guardrails', () => {
expect(nodeModalSource).toContain('useNodeModalState');
expect(nodeModalStateSource).toContain("from '@/stores/licenseCommercial';");
expect(nodeModalStateSource).not.toContain("from '@/stores/license';\n");
- expect(nodeModalStateSource).toContain('void loadCommercialPosture();');
+ expect(nodeModalStateSource).not.toContain('loadCommercialPosture(');
expect(nodeModalStateSource).toContain('const ent = commercialPosture();');
expect(nodeModalStateSource).toContain('const copyProxmoxAgentInstallCommand = async (');
expect(nodeModalStateSource).toContain("const data = await NodesAPI.getAgentInstallCommand({");
diff --git a/frontend-modern/src/components/Settings/__tests__/RBACPaywallPanels.test.tsx b/frontend-modern/src/components/Settings/__tests__/RBACPaywallPanels.test.tsx
index 414cff956b..e1c9d7ef76 100644
--- a/frontend-modern/src/components/Settings/__tests__/RBACPaywallPanels.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/RBACPaywallPanels.test.tsx
@@ -130,7 +130,6 @@ describe('RBAC paywall settings panels', () => {
'href',
'https://example.com/upgrade?feature=rbac',
);
- expect(loadCommercialPostureMock).toHaveBeenCalled();
expect(screen.getByRole('button', { name: 'New Role' })).toBeDisabled();
expect(getRolesMock).not.toHaveBeenCalled();
expect(trackPaywallViewedMock).toHaveBeenCalledWith('rbac', 'settings_roles_panel');
@@ -158,7 +157,6 @@ describe('RBAC paywall settings panels', () => {
expect(screen.getByText('Centralized Access Control (Pro)')).toBeInTheDocument();
});
- expect(loadCommercialPostureMock).toHaveBeenCalled();
expect(screen.getByRole('link', { name: 'Upgrade to Pro' })).toHaveAttribute(
'href',
'https://example.com/upgrade?feature=rbac',
diff --git a/frontend-modern/src/components/Settings/__tests__/RelaySettingsPanel.runtime.test.tsx b/frontend-modern/src/components/Settings/__tests__/RelaySettingsPanel.runtime.test.tsx
index 4b17a0a894..9bd26bfe21 100644
--- a/frontend-modern/src/components/Settings/__tests__/RelaySettingsPanel.runtime.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/RelaySettingsPanel.runtime.test.tsx
@@ -155,6 +155,10 @@ describe('RelaySettingsPanel runtime', () => {
cleanup();
});
+ it('relies on shared commercial posture bootstrap for relay settings', () => {
+ expect(relaySettingsPanelStateSource).not.toContain('loadCommercialPosture(');
+ });
+
it('shows supported Pulse Mobile pairing copy on the relay paywall', async () => {
hasFeatureMock.mockReturnValue(false);
@@ -182,6 +186,7 @@ describe('RelaySettingsPanel runtime', () => {
expect(screen.getByDisplayValue('wss://relay.example.test/ws/instance')).toBeInTheDocument();
});
+ expect(loadCommercialPostureMock).not.toHaveBeenCalled();
expect(screen.getByText('Pair Pulse Mobile through Relay')).toBeInTheDocument();
expect(
screen.getByText(
diff --git a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
index e889113a3e..26799b534f 100644
--- a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
@@ -1507,17 +1507,22 @@ describe('Settings architecture guardrails', () => {
expect(aiSettingsStateSource).toContain("} from '@/stores/license';");
expect(aiSettingsStateSource).toContain("} from '@/stores/licenseCommercial';");
- expect(aiSettingsStateSource).toContain('loadCommercialPosture();');
+ expect(aiSettingsStateSource).not.toContain('loadCommercialPosture();');
expect(reportingPanelStateSource).toContain("} from '@/stores/license';");
expect(reportingPanelStateSource).toContain("} from '@/stores/licenseCommercial';");
- expect(reportingPanelStateSource).toContain('loadCommercialPosture();');
+ expect(reportingPanelStateSource).not.toContain('loadCommercialPosture();');
expect(auditLogStateSource).toContain("} from '@/stores/license';");
expect(auditLogStateSource).toContain("} from '@/stores/licenseCommercial';");
+ expect(auditLogStateSource).not.toContain('loadCommercialPosture();');
expect(auditWebhookStateSource).toContain("} from '@/stores/licenseCommercial';");
+ expect(auditWebhookStateSource).not.toContain('loadCommercialPosture();');
expect(ssoProvidersStateSource).toContain("} from '@/stores/licenseCommercial';");
+ expect(ssoProvidersStateSource).not.toContain('loadCommercialPosture();');
expect(rbacFeatureGateStateSource).toContain("} from '@/stores/licenseCommercial';");
+ expect(rbacFeatureGateStateSource).not.toContain('loadCommercialPosture();');
expect(nodeModalStateSource).toContain("from '@/stores/licenseCommercial';");
+ expect(nodeModalStateSource).not.toContain('loadCommercialPosture();');
});
});
diff --git a/frontend-modern/src/components/Settings/__tests__/useReportingPanelState.test.ts b/frontend-modern/src/components/Settings/__tests__/useReportingPanelState.test.ts
index 71759a3731..4c9c0b5d49 100644
--- a/frontend-modern/src/components/Settings/__tests__/useReportingPanelState.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/useReportingPanelState.test.ts
@@ -157,7 +157,7 @@ describe('useReportingPanelState', () => {
await flushAsync();
expect(loadRuntimeLicenseStatusMock).toHaveBeenCalledOnce();
- expect(loadCommercialLicenseStatusMock).toHaveBeenCalledOnce();
+ expect(loadCommercialLicenseStatusMock).not.toHaveBeenCalled();
expect(apiFetchMock).toHaveBeenCalledWith('/api/admin/reports/catalog');
expect(hookState.reportingCatalog()?.performanceReport.defaultFormat).toBe('csv');
expect(hookState.format()).toBe('csv');
@@ -237,7 +237,7 @@ describe('useReportingPanelState', () => {
await flushAsync();
expect(loadRuntimeLicenseStatusMock).toHaveBeenCalledOnce();
- expect(loadCommercialLicenseStatusMock).toHaveBeenCalledOnce();
+ expect(loadCommercialLicenseStatusMock).not.toHaveBeenCalled();
expect(apiFetchMock).toHaveBeenCalledWith('/api/admin/reports/catalog');
expect(hookState.reportingCatalog()?.title).toBe('Detailed Reporting');
expect(hookState.isLocked()).toBe(false);
diff --git a/frontend-modern/src/components/Settings/useAISettingsState.ts b/frontend-modern/src/components/Settings/useAISettingsState.ts
index 99a1e6256f..d7956ea88c 100644
--- a/frontend-modern/src/components/Settings/useAISettingsState.ts
+++ b/frontend-modern/src/components/Settings/useAISettingsState.ts
@@ -17,7 +17,6 @@ import {
import {
commercialPosture,
getUpgradeActionDestination,
- loadCommercialPosture,
} from '@/stores/licenseCommercial';
import { notificationStore } from '@/stores/notifications';
import type { AISettings as AISettingsType, AIProvider, AuthMethod } from '@/types/ai';
@@ -831,7 +830,6 @@ export const useAISettingsState = () => {
onMount(() => {
loadRuntimeCapabilities();
- loadCommercialPosture();
if (typeof window !== 'undefined') {
const params = new URLSearchParams(window.location.search);
diff --git a/frontend-modern/src/components/Settings/useAgentProfilesPanelState.ts b/frontend-modern/src/components/Settings/useAgentProfilesPanelState.ts
index 40b2d9712e..60caefbc90 100644
--- a/frontend-modern/src/components/Settings/useAgentProfilesPanelState.ts
+++ b/frontend-modern/src/components/Settings/useAgentProfilesPanelState.ts
@@ -18,7 +18,6 @@ import {
import {
commercialPosture,
getUpgradeActionDestination,
- loadCommercialPosture,
} from '@/stores/licenseCommercial';
import { loadRuntimeCapabilities } from '@/stores/license';
import type { ConnectedInfrastructureItem } from '@/types/api';
@@ -238,7 +237,6 @@ export const useAgentProfilesPanelState = () => {
onMount(async () => {
await loadRuntimeCapabilities();
- await loadCommercialPosture();
try {
const aiSettings = await AIAPI.getSettings();
diff --git a/frontend-modern/src/components/Settings/useAuditLogPanelState.ts b/frontend-modern/src/components/Settings/useAuditLogPanelState.ts
index 8d0d86a1fc..c19c81472b 100644
--- a/frontend-modern/src/components/Settings/useAuditLogPanelState.ts
+++ b/frontend-modern/src/components/Settings/useAuditLogPanelState.ts
@@ -14,7 +14,6 @@ import {
import {
commercialPosture,
getUpgradeActionDestination,
- loadCommercialPosture,
} from '@/stores/licenseCommercial';
import { loadRuntimeCapabilities } from '@/stores/license';
import { trackPaywallViewed, trackUpgradeClicked } from '@/utils/upgradeMetrics';
@@ -545,7 +544,6 @@ export const useAuditLogPanelState = () => {
onMount(() => {
setIsMounted(true);
void loadRuntimeCapabilities();
- void loadCommercialPosture();
});
createEffect(() => {
diff --git a/frontend-modern/src/components/Settings/useAuditWebhookPanelState.ts b/frontend-modern/src/components/Settings/useAuditWebhookPanelState.ts
index a8c17d8e5e..1b03f64db3 100644
--- a/frontend-modern/src/components/Settings/useAuditWebhookPanelState.ts
+++ b/frontend-modern/src/components/Settings/useAuditWebhookPanelState.ts
@@ -9,7 +9,6 @@ import {
import {
commercialPosture,
getUpgradeActionDestination,
- loadCommercialPosture,
} from '@/stores/licenseCommercial';
import { loadRuntimeCapabilities } from '@/stores/license';
import { trackPaywallViewed } from '@/utils/upgradeMetrics';
@@ -102,7 +101,6 @@ export const useAuditWebhookPanelState = (canManageOverride?: boolean) => {
onMount(() => {
loadRuntimeCapabilities();
- loadCommercialPosture();
});
createEffect((wasPaywallVisible: boolean) => {
diff --git a/frontend-modern/src/components/Settings/useNodeModalState.ts b/frontend-modern/src/components/Settings/useNodeModalState.ts
index 2275a2e9e1..0d48662b91 100644
--- a/frontend-modern/src/components/Settings/useNodeModalState.ts
+++ b/frontend-modern/src/components/Settings/useNodeModalState.ts
@@ -1,10 +1,10 @@
-import { createEffect, createMemo, createSignal, onMount } from 'solid-js';
+import { createEffect, createMemo, createSignal } from 'solid-js';
import type { NodeConfig } from '@/types/nodes';
import { notificationStore } from '@/stores/notifications';
import { NodesAPI } from '@/api/nodes';
import type { ProxmoxSetupCommandResponse } from '@/api/nodes';
-import { commercialPosture, loadCommercialPosture } from '@/stores/licenseCommercial';
+import { commercialPosture } from '@/stores/licenseCommercial';
import { copyToClipboard } from '@/utils/clipboard';
import { logger } from '@/utils/logger';
import {
@@ -43,10 +43,6 @@ export const useNodeModalState = (props: NodeModalProps) => {
const [loadingAgentCommand, setLoadingAgentCommand] = createSignal(false);
const [agentCommandError, setAgentCommandError] = createSignal<string | null>(null);
- onMount(() => {
- void loadCommercialPosture();
- });
-
const isAdvancedSetupMode = () =>
formData().setupMode === 'auto' || formData().setupMode === 'manual';
const showTemperatureMonitoringSection = () =>
diff --git a/frontend-modern/src/components/Settings/useRBACFeatureGateState.ts b/frontend-modern/src/components/Settings/useRBACFeatureGateState.ts
index 1af886e07a..690f853d81 100644
--- a/frontend-modern/src/components/Settings/useRBACFeatureGateState.ts
+++ b/frontend-modern/src/components/Settings/useRBACFeatureGateState.ts
@@ -5,7 +5,6 @@ import {
} from '@/stores/license';
import {
commercialPosture,
- loadCommercialPosture,
} from '@/stores/licenseCommercial';
import { loadRuntimeCapabilities } from '@/stores/license';
import { notificationStore } from '@/stores/notifications';
@@ -39,7 +38,6 @@ export function useRBACFeatureGateState(options: UseRBACFeatureGateStateOptions)
onMount(() => {
void loadRuntimeCapabilities();
- void loadCommercialPosture();
});
createEffect((wasPaywallVisible) => {
diff --git a/frontend-modern/src/components/Settings/useRelaySettingsPanelState.ts b/frontend-modern/src/components/Settings/useRelaySettingsPanelState.ts
index 2cc7222cb7..c472e70e77 100644
--- a/frontend-modern/src/components/Settings/useRelaySettingsPanelState.ts
+++ b/frontend-modern/src/components/Settings/useRelaySettingsPanelState.ts
@@ -6,7 +6,6 @@ import {
import {
commercialPosture,
getUpgradeActionDestination,
- loadCommercialPosture,
} from '@/stores/licenseCommercial';
import { loadRuntimeCapabilities } from '@/stores/license';
import { trackPaywallViewed } from '@/utils/upgradeMetrics';
@@ -134,7 +133,7 @@ export function useRelaySettingsPanelState(props: RelaySettingsPanelProps) {
};
onMount(async () => {
- await Promise.all([loadRuntimeCapabilities(), loadCommercialPosture()]);
+ await loadRuntimeCapabilities();
if (!relayEnabled()) {
setLoading(false);
return;
diff --git a/frontend-modern/src/components/Settings/useReportingPanelState.ts b/frontend-modern/src/components/Settings/useReportingPanelState.ts
index df0f72c9a1..039a4421b2 100644
--- a/frontend-modern/src/components/Settings/useReportingPanelState.ts
+++ b/frontend-modern/src/components/Settings/useReportingPanelState.ts
@@ -9,7 +9,6 @@ import {
import {
commercialPosture,
getUpgradeActionDestination,
- loadCommercialPosture,
} from '@/stores/licenseCommercial';
import { loadRuntimeCapabilities } from '@/stores/license';
import { trackPaywallViewed } from '@/utils/upgradeMetrics';
@@ -70,7 +69,6 @@ export const useReportingPanelState = () => {
onMount(() => {
loadRuntimeCapabilities();
- loadCommercialPosture();
});
createEffect((wasVisible: boolean) => {
diff --git a/frontend-modern/src/components/Settings/useSSOProvidersState.ts b/frontend-modern/src/components/Settings/useSSOProvidersState.ts
index 0061d45696..231e750b13 100644
--- a/frontend-modern/src/components/Settings/useSSOProvidersState.ts
+++ b/frontend-modern/src/components/Settings/useSSOProvidersState.ts
@@ -9,7 +9,6 @@ import {
import {
commercialPosture,
getUpgradeActionDestination,
- loadCommercialPosture,
} from '@/stores/licenseCommercial';
import { loadRuntimeCapabilities } from '@/stores/license';
import { trackPaywallViewed, trackUpgradeClicked } from '@/utils/upgradeMetrics';
@@ -131,7 +130,6 @@ export const useSSOProvidersState = (props: SSOProvidersPanelProps) => {
onMount(() => {
loadRuntimeCapabilities();
- loadCommercialPosture();
void loadProviders();
});
diff --git a/frontend-modern/src/components/patrol/ApprovalSection.tsx b/frontend-modern/src/components/patrol/ApprovalSection.tsx
index 9eb0749335..01b95cf2ba 100644
--- a/frontend-modern/src/components/patrol/ApprovalSection.tsx
+++ b/frontend-modern/src/components/patrol/ApprovalSection.tsx
@@ -5,11 +5,11 @@
* States: Pending, Expired, Executed, Denied, Failed, Verified, VerificationFailed.
*/
-import { Component, Show, createSignal, createResource, createMemo, onMount } from 'solid-js';
+import { Component, Show, createSignal, createResource, createMemo } from 'solid-js';
import { aiIntelligenceStore } from '@/stores/aiIntelligence';
import { notificationStore } from '@/stores/notifications';
import { aiChatStore } from '@/stores/aiChat';
-import { commercialPosture, loadCommercialPosture } from '@/stores/licenseCommercial';
+import { commercialPosture } from '@/stores/licenseCommercial';
import { hasFeature } from '@/stores/license';
import { AIAPI, type ApprovalRequest, type ApprovalExecutionResult } from '@/api/ai';
import { getApprovalRiskPresentation } from '@/utils/approvalRiskPresentation';
@@ -29,10 +29,6 @@ export const ApprovalSection: Component<ApprovalSectionProps> = (props) => {
const [actionLoading, setActionLoading] = createSignal<string | null>(null);
const [executionResult, setExecutionResult] = createSignal<ApprovalExecutionResult | null>(null);
- onMount(() => {
- void loadCommercialPosture();
- });
-
// Find the pending approval for this finding from the store
const pendingApproval = createMemo(() => {
return (
diff --git a/frontend-modern/src/components/patrol/__tests__/ApprovalSection.test.tsx b/frontend-modern/src/components/patrol/__tests__/ApprovalSection.test.tsx
index 2fa90fca47..69ec9149ae 100644
--- a/frontend-modern/src/components/patrol/__tests__/ApprovalSection.test.tsx
+++ b/frontend-modern/src/components/patrol/__tests__/ApprovalSection.test.tsx
@@ -111,7 +111,6 @@ describe('ApprovalSection', () => {
/>
));
- expect(loadCommercialPostureMock).toHaveBeenCalled();
expect(await screen.findByText('Fix Pending Approval')).toBeInTheDocument();
expect(screen.getAllByText('Fix Pending Approval')).toHaveLength(1);
expect(screen.getByText('details unavailable')).toBeInTheDocument();
@@ -150,7 +149,6 @@ describe('ApprovalSection', () => {
render(() => <ApprovalSection findingId="finding-2" investigationOutcome="fix_queued" />);
- expect(loadCommercialPostureMock).toHaveBeenCalled();
expect(await screen.findAllByRole('button', { name: /re-approve & execute/i })).toHaveLength(1);
fireEvent.click(screen.getByRole('button', { name: /re-approve & execute/i }));
diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
index 35da71e3d1..ed748ac9f9 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -467,7 +467,7 @@ describe('shared primitive guardrails', () => {
expect(trialBannerStateSource).toContain('export function useTrialBannerState');
expect(trialBannerStateSource).toContain('createSignal');
expect(trialBannerStateSource).toContain('createMemo');
- expect(trialBannerStateSource).toContain('loadCommercialPosture');
+ expect(trialBannerStateSource).not.toContain('loadCommercialPosture');
expect(trialBannerStateSource).toContain('commercialPosture');
expect(trialBannerStateSource).toContain('presentationPolicyHidesCommercialSurfaces');
expect(trialBannerStateSource).toContain('getUpgradeActionDestination');
diff --git a/frontend-modern/src/components/shared/__tests__/MonitoredSystemLimitWarningBanner.test.tsx b/frontend-modern/src/components/shared/__tests__/MonitoredSystemLimitWarningBanner.test.tsx
index 8365a06deb..304f5945d5 100644
--- a/frontend-modern/src/components/shared/__tests__/MonitoredSystemLimitWarningBanner.test.tsx
+++ b/frontend-modern/src/components/shared/__tests__/MonitoredSystemLimitWarningBanner.test.tsx
@@ -115,7 +115,7 @@ describe('MonitoredSystemLimitWarningBanner', () => {
expect(monitoredSystemLimitWarningBannerStateSource).toContain('createEffect');
expect(monitoredSystemLimitWarningBannerStateSource).toContain('createMemo');
expect(monitoredSystemLimitWarningBannerStateSource).toContain('loadRuntimeCapabilities');
- expect(monitoredSystemLimitWarningBannerStateSource).toContain('loadCommercialPosture');
+ expect(monitoredSystemLimitWarningBannerStateSource).not.toContain('loadCommercialPosture');
expect(monitoredSystemLimitWarningBannerStateSource).toContain(
'presentationPolicyHidesCommercialSurfaces',
);
@@ -155,7 +155,7 @@ describe('MonitoredSystemLimitWarningBanner', () => {
));
expect(mockLoadRuntimeLicenseStatus).toHaveBeenCalled();
- expect(mockLoadCommercialPosture).toHaveBeenCalled();
+ expect(mockLoadCommercialPosture).not.toHaveBeenCalled();
expect(screen.queryByText(/Monitored systems:/i)).not.toBeInTheDocument();
});
diff --git a/frontend-modern/src/components/shared/__tests__/TrialBanner.test.tsx b/frontend-modern/src/components/shared/__tests__/TrialBanner.test.tsx
index 13c083d603..888d096d61 100644
--- a/frontend-modern/src/components/shared/__tests__/TrialBanner.test.tsx
+++ b/frontend-modern/src/components/shared/__tests__/TrialBanner.test.tsx
@@ -86,7 +86,7 @@ describe('TrialBanner', () => {
expect(trialBannerStateSource).toContain('export function useTrialBannerState');
expect(trialBannerStateSource).toContain('createSignal');
expect(trialBannerStateSource).toContain('createMemo');
- expect(trialBannerStateSource).toContain('loadCommercialPosture');
+ expect(trialBannerStateSource).not.toContain('loadCommercialPosture');
expect(trialBannerStateSource).toContain('presentationPolicyHidesCommercialSurfaces');
expect(trialBannerStateSource).toContain('commercialPosture');
expect(trialBannerStateSource).toContain('getUpgradeActionDestination');
@@ -99,17 +99,13 @@ describe('TrialBanner', () => {
expect(trialBannerModelSource).toContain('TRIAL_BANNER_UPGRADE_LABEL');
});
- it('loads commercial posture on mount and renders trial details when active', async () => {
+ it('renders trial details from shared commercial posture when active', async () => {
commercialPostureMock.mockReturnValue({
subscription_state: 'trial',
trial_days_remaining: 4.8,
});
renderBanner();
-
- await waitFor(() => {
- expect(loadCommercialPostureMock).toHaveBeenCalled();
- });
expect(screen.getByRole('status')).toBeInTheDocument();
expect(screen.getByText('Pro Trial:')).toBeInTheDocument();
expect(screen.getByText('4 days remaining')).toBeInTheDocument();
diff --git a/frontend-modern/src/components/shared/useActiveUseTrialNudgeState.ts b/frontend-modern/src/components/shared/useActiveUseTrialNudgeState.ts
index ea389df38a..14eaa49b4a 100644
--- a/frontend-modern/src/components/shared/useActiveUseTrialNudgeState.ts
+++ b/frontend-modern/src/components/shared/useActiveUseTrialNudgeState.ts
@@ -1,5 +1,5 @@
import { createMemo, createSignal, onCleanup, onMount } from 'solid-js';
-import { commercialPosture, loadCommercialPosture } from '@/stores/licenseCommercial';
+import { commercialPosture } from '@/stores/licenseCommercial';
import { notificationStore } from '@/stores/notifications';
import { isUpsellSnoozed, snoozeUpsell } from '@/utils/snooze';
import { runStartProTrialAction } from '@/utils/trialStartAction';
@@ -38,7 +38,6 @@ export function useActiveUseTrialNudgeState() {
const [startingTrial, setStartingTrial] = createSignal(false);
onMount(() => {
- void loadCommercialPosture();
setFirstSeen(getActiveUseTrialNudgeFirstSeenTimestamp());
const timer = window.setInterval(() => setNow(Date.now()), ACTIVE_USE_TRIAL_NUDGE_REFRESH_MS);
onCleanup(() => window.clearInterval(timer));
diff --git a/frontend-modern/src/components/shared/useHistoryChartState.ts b/frontend-modern/src/components/shared/useHistoryChartState.ts
index 29e9658ffa..89ffe52c95 100644
--- a/frontend-modern/src/components/shared/useHistoryChartState.ts
+++ b/frontend-modern/src/components/shared/useHistoryChartState.ts
@@ -14,7 +14,6 @@ import {
import {
commercialPosture,
getUpgradeActionDestination,
- loadCommercialPosture,
} from '@/stores/licenseCommercial';
import { calculateOptimalPoints } from '@/utils/downsample';
import { setupCanvasDPR } from '@/utils/canvasRenderQueue';
@@ -79,7 +78,6 @@ export function useHistoryChartState(props: HistoryChartProps, refs: HistoryChar
onMount(() => {
loadRuntimeCapabilities();
- loadCommercialPosture();
});
createEffect(() => {
diff --git a/frontend-modern/src/components/shared/useMonitoredSystemLimitWarningBannerState.ts b/frontend-modern/src/components/shared/useMonitoredSystemLimitWarningBannerState.ts
index 0fa61970ed..360c462a85 100644
--- a/frontend-modern/src/components/shared/useMonitoredSystemLimitWarningBannerState.ts
+++ b/frontend-modern/src/components/shared/useMonitoredSystemLimitWarningBannerState.ts
@@ -9,7 +9,6 @@ import {
getUpgradeActionDestination,
hasMigrationGap,
legacyConnections,
- loadCommercialPosture,
} from '@/stores/licenseCommercial';
import { resolveUpgradeDestination } from '@/utils/upgradeNavigation';
import {
@@ -37,7 +36,6 @@ import {
export function useMonitoredSystemLimitWarningBannerState() {
onMount(() => {
void loadRuntimeCapabilities();
- void loadCommercialPosture();
});
const monitoredSystemLimit = createMemo(() => getRuntimeLimit(MONITORED_SYSTEM_LIMIT_KEY));
diff --git a/frontend-modern/src/components/shared/useTrialBannerState.ts b/frontend-modern/src/components/shared/useTrialBannerState.ts
index 6b7ad7c69e..80a0e6d0d2 100644
--- a/frontend-modern/src/components/shared/useTrialBannerState.ts
+++ b/frontend-modern/src/components/shared/useTrialBannerState.ts
@@ -1,9 +1,5 @@
-import { createMemo, createSignal, onMount } from 'solid-js';
-import {
- commercialPosture,
- getUpgradeActionDestination,
- loadCommercialPosture,
-} from '@/stores/licenseCommercial';
+import { createMemo, createSignal } from 'solid-js';
+import { commercialPosture, getUpgradeActionDestination } from '@/stores/licenseCommercial';
import { presentationPolicyHidesCommercialSurfaces } from '@/stores/sessionPresentationPolicy';
import { isUpsellSnoozed, snoozeUpsell } from '@/utils/snooze';
import {
@@ -16,10 +12,6 @@ import {
export function useTrialBannerState() {
const [snoozed, setSnoozed] = createSignal(isUpsellSnoozed(TRIAL_BANNER_SNOOZE_KEY));
- onMount(() => {
- void loadCommercialPosture();
- });
-
const isTrial = createMemo(
() =>
!presentationPolicyHidesCommercialSurfaces() &&
diff --git a/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts b/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts
index 5fc24e89cc..6c4bb94db5 100644
--- a/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts
+++ b/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts
@@ -29,7 +29,6 @@ import {
import {
commercialPosture,
getUpgradeActionDestination,
- loadCommercialPosture,
} from '@/stores/licenseCommercial';
import { getCanonicalScopeResourceIds } from '@/utils/patrolFormat';
import { buildPatrolInvestigationContextSummary } from './patrolInvestigationContextModel';
@@ -673,7 +672,6 @@ export function usePatrolIntelligenceState() {
onMount(async () => {
await Promise.all([
loadRuntimeCapabilities(),
- loadCommercialPosture(),
loadAllData(),
loadAutonomySettings(),
loadModels(),
diff --git a/frontend-modern/src/stores/__tests__/license.test.ts b/frontend-modern/src/stores/__tests__/license.test.ts
index aa14c0a1bd..c4e3ac945f 100644
--- a/frontend-modern/src/stores/__tests__/license.test.ts
+++ b/frontend-modern/src/stores/__tests__/license.test.ts
@@ -296,6 +296,25 @@ describe('license stores', () => {
expect(commercialPosture()).toEqual(mockCommercialPosture);
});
+ it('deduplicates in-flight commercial posture loads', async () => {
+ let resolveLoad: ((value: typeof mockCommercialPosture) => void) | null = null;
+ vi.mocked(LicenseAPI.getCommercialPosture).mockImplementation(
+ () =>
+ new Promise((resolve) => {
+ resolveLoad = resolve;
+ }),
+ );
+
+ const firstLoad = loadCommercialPosture(true);
+ const secondLoad = loadCommercialPosture();
+
+ expect(LicenseAPI.getCommercialPosture).toHaveBeenCalledTimes(1);
+ resolveLoad?.(mockCommercialPosture);
+ await Promise.all([firstLoad, secondLoad]);
+
+ expect(commercialPosture()).toEqual(mockCommercialPosture);
+ });
+
it('sets commercial fallback posture on error', async () => {
vi.mocked(LicenseAPI.getCommercialPosture).mockRejectedValue(new Error('API error'));
diff --git a/frontend-modern/src/stores/licenseCommercial.ts b/frontend-modern/src/stores/licenseCommercial.ts
index 6656d787a0..158c890e6d 100644
--- a/frontend-modern/src/stores/licenseCommercial.ts
+++ b/frontend-modern/src/stores/licenseCommercial.ts
@@ -41,6 +41,7 @@ const [commercialPostureState, setCommercialPostureState] =
const [loading, setLoading] = createSignal(false);
const [loaded, setLoaded] = createSignal(false);
const [loadError, setLoadError] = createSignal<Error | null>(null);
+let inFlightCommercialPostureLoad: Promise<void> | null = null;
type TrialStartErrorPayload = {
error?: string;
@@ -78,6 +79,8 @@ function parseRetryAfterSeconds(value: string | null | undefined): number | unde
/**
* Load the commercial posture payload used by non-billing trial and upgrade UI.
+ * Initial bootstrap belongs to the authenticated app shell or first-run setup,
+ * not to feature-local hooks.
*/
export async function loadCommercialPosture(force = false): Promise<void> {
if (!sessionPresentationPolicyResolved()) {
@@ -96,25 +99,43 @@ export async function loadCommercialPosture(force = false): Promise<void> {
return;
}
+ if (inFlightCommercialPostureLoad) {
+ if (!force) {
+ return inFlightCommercialPostureLoad;
+ }
+ await inFlightCommercialPostureLoad;
+ }
+
if (loaded() && !force) return;
setLoading(true);
+ const request = (async () => {
+ try {
+ const next = await LicenseAPI.getCommercialPosture();
+ setCommercialPostureState(next);
+ setLoadError(null);
+ setLoaded(true);
+ logger.debug('[licenseCommercialStore] Commercial posture loaded', {
+ tier: next.tier,
+ sub_state: next.subscription_state,
+ });
+ } catch (err) {
+ logger.error('[licenseCommercialStore] Failed to load commercial posture', err);
+ setLoadError(err instanceof Error ? err : new Error(String(err)));
+ setCommercialPostureState(FREE_COMMERCIAL_POSTURE_FALLBACK);
+ setLoaded(true);
+ } finally {
+ setLoading(false);
+ }
+ })();
+
+ inFlightCommercialPostureLoad = request;
try {
- const next = await LicenseAPI.getCommercialPosture();
- setCommercialPostureState(next);
- setLoadError(null);
- setLoaded(true);
- logger.debug('[licenseCommercialStore] Commercial posture loaded', {
- tier: next.tier,
- sub_state: next.subscription_state,
- });
- } catch (err) {
- logger.error('[licenseCommercialStore] Failed to load commercial posture', err);
- setLoadError(err instanceof Error ? err : new Error(String(err)));
- setCommercialPostureState(FREE_COMMERCIAL_POSTURE_FALLBACK);
- setLoaded(true);
+ await request;
} finally {
- setLoading(false);
+ if (inFlightCommercialPostureLoad === request) {
+ inFlightCommercialPostureLoad = null;
+ }
}
}
diff --git a/frontend-modern/src/useAppRuntimeState.ts b/frontend-modern/src/useAppRuntimeState.ts
index 8d2ec30fc0..d622b81a10 100644
--- a/frontend-modern/src/useAppRuntimeState.ts
+++ b/frontend-modern/src/useAppRuntimeState.ts
@@ -52,6 +52,7 @@ import {
runtimeCapabilitiesLoaded,
loadRuntimeCapabilities,
} from '@/stores/license';
+import { loadCommercialPosture } from '@/stores/licenseCommercial';
import { syncSessionPresentationPolicy } from '@/stores/sessionPresentationPolicy';
import { layoutStore } from '@/utils/layout';
import {
@@ -281,6 +282,8 @@ export const useAppRuntimeState = () => {
setWsStore(acquireWsStore());
setBackendHealthy(true);
await loadSystemSettingsAndLayout();
+ // Shared commercial posture bootstraps once per authenticated app shell.
+ void loadCommercialPosture();
};
const checkBackendHealth = async () => {
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index 44d1b6944f..70c8e3b957 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -2859,7 +2859,7 @@ describe('frontend resource type boundaries', () => {
expect(trialBannerSource).not.toContain('getUpgradeActionUrlOrFallback');
expect(trialBannerStateSource).toContain('createSignal');
expect(trialBannerStateSource).toContain('createMemo');
- expect(trialBannerStateSource).toContain('loadCommercialPosture');
+ expect(trialBannerStateSource).not.toContain('loadCommercialPosture');
expect(trialBannerStateSource).toContain('commercialPosture');
expect(trialBannerStateSource).toContain('presentationPolicyHidesCommercialSurfaces');
expect(trialBannerStateSource).toContain('getUpgradeActionDestination');
diff --git a/tests/integration/tests/11-first-session.spec.ts b/tests/integration/tests/11-first-session.spec.ts
index 021a068a68..bb06363327 100644
--- a/tests/integration/tests/11-first-session.spec.ts
+++ b/tests/integration/tests/11-first-session.spec.ts
@@ -1,5 +1,11 @@
import { test, expect } from '@playwright/test';
-import { ensureAuthenticated, ensureFirstRunExperience, navigateToSettings, apiRequest } from './helpers';
+import {
+ ensureAuthenticated,
+ ensureFirstRunExperience,
+ navigateToSettings,
+ apiRequest,
+ trackBrowserRequests,
+} from './helpers';
/**
* Dedicated first-session E2E test covering the full journey:
@@ -14,11 +20,7 @@ import { ensureAuthenticated, ensureFirstRunExperience, navigateToSettings, apiR
* setup wizard before the rest of the suite continues through normal auth.
*/
-type EntitlementPayload = {
- subscription_state?: string;
- tier?: string;
- valid?: boolean;
- trial_eligible?: boolean;
+type RuntimeCapabilitiesPayload = {
capabilities?: string[];
};
@@ -162,11 +164,13 @@ test.describe.serial('First-session experience', () => {
await ensureAuthenticated(page);
- // Query entitlements to check feature access per-route (not blanket free/paid).
- const entRes = await apiRequest(page, '/api/license/entitlements');
- expect(entRes.ok()).toBeTruthy();
- const entitlements = (await entRes.json()) as EntitlementPayload;
- const features = new Set(entitlements.capabilities || []);
+ // Query runtime capabilities to check feature access per-route without
+ // depending on billing-only entitlements.
+ const runtimeRes = await apiRequest(page, '/api/license/runtime-capabilities');
+ expect(runtimeRes.ok()).toBeTruthy();
+ const runtimeCapabilities = (await runtimeRes.json()) as RuntimeCapabilitiesPayload;
+ const features = new Set(runtimeCapabilities.capabilities || []);
+ const entitlementsRequests = trackBrowserRequests(page, '/api/license/entitlements');
// Gated routes with their required feature. Gating is feature-based, not
// tier-based — e.g. a "relay" tier has the relay feature but not
@@ -177,80 +181,92 @@ test.describe.serial('First-session experience', () => {
{ route: '/settings/system-relay', feature: 'relay' },
] as const;
- for (const { route, feature } of gatedRoutes) {
- const hasFeature = features.has(feature);
- const routePattern = route.startsWith('/operations/') ? /\/operations/ : /\/settings/;
-
- if (!hasFeature) {
- // Install a MutationObserver via addInitScript BEFORE navigating so it
- // runs before any app code. This catches transient form elements that
- // flash before the paywall renders (flash-of-unlocked-content).
- await page.addInitScript(() => {
- (window as any).__pulseFlashDetected = false;
- const SELECTOR = 'form input:not([type="search"]), form textarea, form select';
-
- const checkForFlash = () => {
- const els = document.querySelectorAll(SELECTOR);
- if (els.length > 0) {
- (window as any).__pulseFlashDetected = true;
- }
- };
-
- const observer = new MutationObserver(checkForFlash);
-
- // Start observing on documentElement immediately (always available
- // in addInitScript context), so we catch body insertion and all
- // subsequent DOM mutations including app boot. This avoids the gap
- // where DOMContentLoaded fires after app scripts.
- observer.observe(document.documentElement, {
- childList: true,
- subtree: true,
+ try {
+ for (const { route, feature } of gatedRoutes) {
+ const hasFeature = features.has(feature);
+ const routePattern = route.startsWith('/operations/') ? /\/operations/ : /\/settings/;
+
+ if (!hasFeature) {
+ // Install a MutationObserver via addInitScript BEFORE navigating so it
+ // runs before any app code. This catches transient form elements that
+ // flash before the paywall renders (flash-of-unlocked-content).
+ await page.addInitScript(() => {
+ (window as any).__pulseFlashDetected = false;
+ const SELECTOR = 'form input:not([type="search"]), form textarea, form select';
+
+ const checkForFlash = () => {
+ const els = document.querySelectorAll(SELECTOR);
+ if (els.length > 0) {
+ (window as any).__pulseFlashDetected = true;
+ }
+ };
+
+ const observer = new MutationObserver(checkForFlash);
+
+ // Start observing on documentElement immediately (always available
+ // in addInitScript context), so we catch body insertion and all
+ // subsequent DOM mutations including app boot. This avoids the gap
+ // where DOMContentLoaded fires after app scripts.
+ observer.observe(document.documentElement, {
+ childList: true,
+ subtree: true,
+ });
+ // Also do an immediate check in case DOM is already populated.
+ checkForFlash();
+
+ // Auto-disconnect after 5 seconds to avoid leaking.
+ setTimeout(() => observer.disconnect(), 5000);
});
- // Also do an immediate check in case DOM is already populated.
- checkForFlash();
-
- // Auto-disconnect after 5 seconds to avoid leaking.
- setTimeout(() => observer.disconnect(), 5000);
- });
-
- await page.goto(route, { waitUntil: 'domcontentloaded' });
- await page.waitForURL(routePattern, { timeout: 10_000 });
- await expect(page.locator('#root')).toBeVisible();
-
- // Wait for the page to settle, then read the observer result.
- await page.waitForTimeout(2_000);
- const flashDetected = await page.evaluate(
- () => (window as any).__pulseFlashDetected === true,
- );
-
- expect(
- flashDetected,
- `Gated route ${route} (feature=${feature}) showed form elements on unlicensed tier (flash-of-unlocked-content)`,
- ).toBe(false);
-
- // Paywall indicator should be visible.
- const paywallIndicator = page.locator(
- 'text=/Upgrade|Pro Feature|Requires Pro|Requires Relay|Start.*Trial/i',
- ).first();
- const isPaywallVisible = await paywallIndicator.isVisible({ timeout: 5_000 }).catch(() => false);
- expect(
- isPaywallVisible,
- `Gated route ${route} (feature=${feature}) should show paywall when feature is not available`,
- ).toBeTruthy();
- } else {
- await page.goto(route, { waitUntil: 'domcontentloaded' });
- await page.waitForURL(routePattern, { timeout: 10_000 });
- await expect(page.locator('#root')).toBeVisible();
-
- // Licensed for this feature — the full panel content should render.
- const panelContent = page.locator('h1, h2, h3, label, form')
- .filter({ hasNotText: 'Settings' })
- .first();
- await expect(
- panelContent,
- `Gated route ${route} should render content when feature=${feature} is available`,
- ).toBeVisible({ timeout: 10_000 });
+
+ await page.goto(route, { waitUntil: 'domcontentloaded' });
+ await page.waitForURL(routePattern, { timeout: 10_000 });
+ await expect(page.locator('#root')).toBeVisible();
+
+ // Wait for the page to settle, then read the observer result.
+ await page.waitForTimeout(2_000);
+ const flashDetected = await page.evaluate(
+ () => (window as any).__pulseFlashDetected === true,
+ );
+
+ expect(
+ flashDetected,
+ `Gated route ${route} (feature=${feature}) showed form elements on unlicensed tier (flash-of-unlocked-content)`,
+ ).toBe(false);
+
+ // Paywall indicator should be visible.
+ const paywallIndicator = page.locator(
+ 'text=/Upgrade|Pro Feature|Requires Pro|Requires Relay|Start.*Trial/i',
+ ).first();
+ const isPaywallVisible = await paywallIndicator
+ .isVisible({ timeout: 5_000 })
+ .catch(() => false);
+ expect(
+ isPaywallVisible,
+ `Gated route ${route} (feature=${feature}) should show paywall when feature is not available`,
+ ).toBeTruthy();
+ } else {
+ await page.goto(route, { waitUntil: 'domcontentloaded' });
+ await page.waitForURL(routePattern, { timeout: 10_000 });
+ await expect(page.locator('#root')).toBeVisible();
+
+ // Licensed for this feature — the full panel content should render.
+ const panelContent = page
+ .locator('h1, h2, h3, label, form')
+ .filter({ hasNotText: 'Settings' })
+ .first();
+ await expect(
+ panelContent,
+ `Gated route ${route} should render content when feature=${feature} is available`,
+ ).toBeVisible({ timeout: 10_000 });
+ }
}
+ } finally {
+ const requestedURLs = entitlementsRequests.urls();
+ entitlementsRequests.stop();
+ expect(
+ requestedURLs,
+ 'Non-billing gated routes must not trigger billing entitlements reads in the browser shell',
+ ).toEqual([]);
}
});
diff --git a/tests/integration/tests/16-dev-runtime-recovery.spec.ts b/tests/integration/tests/16-dev-runtime-recovery.spec.ts
index 383ed832e3..c8dfb7d2ae 100644
--- a/tests/integration/tests/16-dev-runtime-recovery.spec.ts
+++ b/tests/integration/tests/16-dev-runtime-recovery.spec.ts
@@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test';
-import { ensureAuthenticated } from './helpers';
+import { ensureAuthenticated, trackBrowserRequests } from './helpers';
import {
killManagedDevRuntimeOwnerProcess,
restartManagedDevRuntimeBackend,
@@ -10,6 +10,38 @@ const truthy = (value: string | undefined) =>
['1', 'true', 'yes', 'on'].includes(String(value || '').trim().toLowerCase());
test.describe.serial('Managed dev runtime recovery', () => {
+ test('browser request tracking stays browser-only under the managed dev runtime', async ({
+ page,
+ }, testInfo) => {
+ test.setTimeout(120_000);
+ test.skip(testInfo.project.name.startsWith('mobile-'), 'Desktop-only managed dev runtime coverage');
+ test.skip(!truthy(process.env.PULSE_E2E_USE_HOT_DEV), 'Runs only against the managed hot-dev runtime');
+
+ const securityStatusRequests = trackBrowserRequests(page, '/api/security/status');
+
+ try {
+ await ensureAuthenticated(page);
+
+ await expect
+ .poll(() => securityStatusRequests.count(), {
+ timeout: 30_000,
+ message: 'expected browser bootstrap to request security status under the managed runtime',
+ })
+ .toBeGreaterThan(0);
+
+ securityStatusRequests.clear();
+
+ const response = await page.request.get('/api/security/status');
+ expect(response.ok()).toBeTruthy();
+ expect(
+ securityStatusRequests.urls(),
+ 'browser request tracking must ignore direct Playwright API helper calls',
+ ).toEqual([]);
+ } finally {
+ securityStatusRequests.stop();
+ }
+ });
+
test('browser shell distinguishes stream-only reconnect from total backend loss', async ({
page,
}, testInfo) => {
diff --git a/tests/integration/tests/helpers.ts b/tests/integration/tests/helpers.ts
index 887fa60366..817dfa87d4 100644
--- a/tests/integration/tests/helpers.ts
+++ b/tests/integration/tests/helpers.ts
@@ -1,4 +1,4 @@
-import { Browser, Page, expect } from "@playwright/test";
+import { Browser, Page, Request, expect } from "@playwright/test";
import { preferredBrowserBaseURL, readRuntimeState } from "./runtime-defaults";
const runtimePrimaryAPIToken = (): string => {
@@ -62,6 +62,29 @@ export async function waitForPulseReady(page: Page, timeoutMs = 120_000) {
throw lastError ?? new Error("Timed out waiting for Pulse to become ready");
}
+export function trackBrowserRequests(page: Page, matcher: string | RegExp) {
+ const matchedURLs: string[] = [];
+ const matches = (url: string) =>
+ typeof matcher === "string" ? url.includes(matcher) : matcher.test(url);
+ const handleRequest = (request: Request) => {
+ const url = request.url();
+ if (matches(url)) {
+ matchedURLs.push(url);
+ }
+ };
+
+ page.on("request", handleRequest);
+
+ return {
+ clear: () => {
+ matchedURLs.length = 0;
+ },
+ count: () => matchedURLs.length,
+ stop: () => page.off("request", handleRequest),
+ urls: () => [...matchedURLs],
+ };
+}
+
type SecurityStatus = {
hasAuthentication?: boolean;
};
diff --git a/tests/integration/tests/journeys/01-smoke-bootstrap-login-dashboard.spec.ts b/tests/integration/tests/journeys/01-smoke-bootstrap-login-dashboard.spec.ts
index d82a36a743..ea3e409a24 100644
--- a/tests/integration/tests/journeys/01-smoke-bootstrap-login-dashboard.spec.ts
+++ b/tests/integration/tests/journeys/01-smoke-bootstrap-login-dashboard.spec.ts
@@ -9,6 +9,7 @@ import {
navigateToSettings,
setMockMode,
getMockMode,
+ trackBrowserRequests,
} from '../helpers';
/**
@@ -206,6 +207,38 @@ test.describe.serial('Journey: Bootstrap → Login → Dashboard', () => {
}
});
+ test('core non-billing navigation does not read billing entitlements', async ({
+ page,
+ }, testInfo) => {
+ test.skip(testInfo.project.name.startsWith('mobile-'), 'Desktop smoke journey');
+
+ await ensureAuthenticated(page);
+
+ const entitlementsRequests = trackBrowserRequests(page, '/api/license/entitlements');
+ try {
+ await page.goto('/dashboard', { waitUntil: 'domcontentloaded' });
+ await expect(page.locator('#root')).toBeVisible();
+
+ await page.goto('/infrastructure', { waitUntil: 'domcontentloaded' });
+ await expect(page.locator('#root')).toBeVisible();
+
+ await page.goto('/alerts/overview', { waitUntil: 'domcontentloaded' });
+ await expect(page.locator('#root')).toBeVisible();
+
+ await navigateToSettings(page);
+ await expect(page.locator('[aria-label="Settings navigation"]')).toBeVisible({
+ timeout: 10_000,
+ });
+ } finally {
+ const requestedURLs = entitlementsRequests.urls();
+ entitlementsRequests.stop();
+ expect(
+ requestedURLs,
+ 'Core non-billing navigation must not trigger billing entitlements reads in the browser shell',
+ ).toEqual([]);
+ }
+ });
+
test('logout and re-login cycle completes successfully', async ({ page }, testInfo) => {
test.skip(testInfo.project.name.startsWith('mobile-'), 'Desktop smoke journey');
@@ -218,7 +251,7 @@ test.describe.serial('Journey: Bootstrap → Login → Dashboard', () => {
await expect(page).toHaveURL(AUTHENTICATED_URL);
});
- test('API returns valid state after full journey', async ({ page }, testInfo) => {
+ test('API returns runtime capabilities after full journey', async ({ page }, testInfo) => {
test.skip(testInfo.project.name.startsWith('mobile-'), 'Desktop smoke journey');
await ensureAuthenticated(page);
@@ -229,10 +262,13 @@ test.describe.serial('Journey: Bootstrap → Login → Dashboard', () => {
const healthRes = await apiRequest(page, '/api/health');
expect(healthRes.ok(), `GET /api/health failed: ${healthRes.status()}`).toBeTruthy();
- const entRes = await apiRequest(page, '/api/license/entitlements');
- expect(entRes.ok(), `GET /api/license/entitlements failed: ${entRes.status()}`).toBeTruthy();
+ const runtimeRes = await apiRequest(page, '/api/license/runtime-capabilities');
+ expect(
+ runtimeRes.ok(),
+ `GET /api/license/runtime-capabilities failed: ${runtimeRes.status()}`,
+ ).toBeTruthy();
- const entitlements = await entRes.json();
- expect(entitlements).toHaveProperty('valid');
+ const runtimeCapabilities = await runtimeRes.json();
+ expect(Array.isArray(runtimeCapabilities.capabilities)).toBe(true);
});
});
diff --git a/tests/integration/tests/journeys/03-relay-pairing.spec.ts b/tests/integration/tests/journeys/03-relay-pairing.spec.ts
index 3b9bb0fa2b..13c7a90354 100644
--- a/tests/integration/tests/journeys/03-relay-pairing.spec.ts
+++ b/tests/integration/tests/journeys/03-relay-pairing.spec.ts
@@ -2,6 +2,7 @@ import { test, expect } from '@playwright/test';
import {
ensureAuthenticated,
apiRequest,
+ trackBrowserRequests,
} from '../helpers';
/**
@@ -41,9 +42,8 @@ function buildRelayServerURL(): string {
return `${scheme}://${RELAY_HOST}${portSuffix}/ws/instance`;
}
-type EntitlementPayload = {
+type RuntimeCapabilitiesPayload = {
capabilities?: string[];
- valid?: boolean;
};
type CreateRelayMobileTokenResponse = {
@@ -116,21 +116,21 @@ test.describe.serial('Journey: Relay Pairing → Mobile Connection', () => {
test.skip(!RELAY_HOST, 'PULSE_E2E_RELAY_HOST must be set');
});
- test('relay feature is available via entitlements', async ({ page }, testInfo) => {
+ test('relay feature is available via runtime capabilities', async ({ page }, testInfo) => {
test.skip(testInfo.project.name.startsWith('mobile-'), 'Desktop relay journey');
test.skip(!RELAY_HOST, 'Relay host not configured');
await ensureAuthenticated(page);
- const res = await apiRequest(page, '/api/license/entitlements');
+ const res = await apiRequest(page, '/api/license/runtime-capabilities');
expect(res.ok()).toBeTruthy();
- const entitlements = (await res.json()) as EntitlementPayload;
- const capabilities = new Set(entitlements.capabilities || []);
+ const runtimeCapabilities = (await res.json()) as RuntimeCapabilitiesPayload;
+ const capabilities = new Set(runtimeCapabilities.capabilities || []);
expect(
capabilities.has('relay'),
- 'Relay feature must be available in license entitlements. ' +
+ 'Relay feature must be available in runtime capabilities. ' +
'Ensure the test instance has a Pro or higher license.',
).toBeTruthy();
});
@@ -283,18 +283,28 @@ test.describe.serial('Journey: Relay Pairing → Mobile Connection', () => {
test.skip(!RELAY_HOST, 'Relay host not configured');
await ensureAuthenticated(page);
+ const entitlementsRequests = trackBrowserRequests(page, '/api/license/entitlements');
- await page.goto('/settings/system-relay', { waitUntil: 'domcontentloaded' });
- await page.waitForURL(/\/settings/, { timeout: 10_000 });
- await expect(page.locator('#root')).toBeVisible();
-
- const relayContent = page.locator(
- 'text=/Relay|Connected|Enabled|Mobile|Pairing/i',
- ).first();
-
- await expect(
- relayContent,
- 'Relay settings page should show relay-related content',
- ).toBeVisible({ timeout: 15_000 });
+ try {
+ await page.goto('/settings/system-relay', { waitUntil: 'domcontentloaded' });
+ await page.waitForURL(/\/settings/, { timeout: 10_000 });
+ await expect(page.locator('#root')).toBeVisible();
+
+ const relayContent = page.locator(
+ 'text=/Relay|Connected|Enabled|Mobile|Pairing/i',
+ ).first();
+
+ await expect(
+ relayContent,
+ 'Relay settings page should show relay-related content',
+ ).toBeVisible({ timeout: 15_000 });
+ } finally {
+ const requestedURLs = entitlementsRequests.urls();
+ entitlementsRequests.stop();
+ expect(
+ requestedURLs,
+ 'Relay settings browser journey must not trigger billing entitlements reads',
+ ).toEqual([]);
+ }
});
});