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.

Gate commercial posture bootstrap on upgrade policy

rcourtmanff6016daab09
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.md
index 36df791426..634dd63640 100644
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@ -500,7 +500,10 @@ Community limit enforcement.
and suppress Relay/Pro plan comparison, Pro trial CTAs, monitored-system
limit pressure, paid-only settings navigation, and feature upsells unless
hosted mode, direct intent, activation/recovery state, or active entitlement
- makes them relevant.
+ makes them relevant. The authenticated app shell must also skip background
+ `/api/license/commercial-posture` bootstrap while `presentationPolicy.hideUpgrade`
+ is true; explicit Plans/Activation and hosted or prompt-allowed flows may
+ still refresh the shared posture store.
17. Keep hosted and trial billing construction separate from retired hosted-AI
quickstart inventory: `pkg/licensing/trial_start.go` and hosted
entitlement refresh paths may preserve historical billing fields for old
@@ -630,12 +633,15 @@ staging, never an ordinary live refresh.
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
+owner for the first `/api/license/commercial-posture` read when upgrade prompts
+are allowed, 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
+must not each trigger their own mount-time posture fetch. Ordinary self-hosted
+sessions where `presentationPolicy.hideUpgrade` is true must not perform that
+background posture read from the app shell at all. Billing-owned
surfaces such as `frontend-modern/src/components/Settings/useProLicensePanelState.ts`
may still force refresh through the same shared store when plan, activation, or
recovery actions mutate commercial truth.
diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
index 1d3efa202e..05b3accdcc 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -296,7 +296,9 @@ regression protection.
non-hot-path UI. Retired self-hosted trial or managed-model acquisition
surfaces must not be reintroduced into `frontend-modern/src/App.tsx` as
always-mounted chrome that preloads commercial posture or adds route-global
- render work to ordinary monitoring sessions.
+ render work to ordinary monitoring sessions. The authenticated app shell
+ must also avoid background commercial-posture bootstrap while
+ `presentationPolicy.hideUpgrade` suppresses upgrade prompts.
Invitation accept/revoke and other org-membership changes follow that same
hot-path contract: `frontend-modern/src/useAppRuntimeState.ts` may reload
the org list from the shared `organizations_changed` event, but that refresh
diff --git a/frontend-modern/src/__tests__/App.architecture.test.ts b/frontend-modern/src/__tests__/App.architecture.test.ts
index 3ef4046dfa..8630208168 100644
--- a/frontend-modern/src/__tests__/App.architecture.test.ts
+++ b/frontend-modern/src/__tests__/App.architecture.test.ts
@@ -216,9 +216,11 @@ describe('App architecture', () => {
"import { loadCommercialPosture } from '@/stores/licenseCommercial';",
);
expect(appRuntimeStateSource).toContain('presentationPolicyHidesOrganizationSurfaces');
+ expect(appRuntimeStateSource).toContain('presentationPolicyHidesUpgradePrompts');
expect(appRuntimeStateSource).toContain('const [activeOrgID, setActiveOrgID] = createSignal(');
expect(appRuntimeStateSource).toContain('onMount(() => {');
expect(appRuntimeStateSource).toContain('onMount(async () => {');
+ expect(appRuntimeStateSource).toContain('if (!presentationPolicyHidesUpgradePrompts()) {');
expect(appRuntimeStateSource).toContain('void loadCommercialPosture();');
expect(appRuntimeStateSource).toContain('const hasLocalAuthBootstrapHint = (): boolean => {');
expect(appRuntimeStateSource).toContain(
diff --git a/frontend-modern/src/__tests__/useAppRuntimeState.test.ts b/frontend-modern/src/__tests__/useAppRuntimeState.test.ts
index be3bfd0449..f6ec119427 100644
--- a/frontend-modern/src/__tests__/useAppRuntimeState.test.ts
+++ b/frontend-modern/src/__tests__/useAppRuntimeState.test.ts
@@ -14,6 +14,7 @@ describe('useAppRuntimeState', () => {
let apiFetchMock: ReturnType<typeof vi.fn>;
let orgsListMock: ReturnType<typeof vi.fn>;
let loadLicenseStatusMock: ReturnType<typeof vi.fn>;
+ let loadCommercialPostureMock: ReturnType<typeof vi.fn>;
let isMultiTenantEnabledMock: ReturnType<typeof vi.fn>;
let isHostedModeEnabledMock: ReturnType<typeof vi.fn>;
let getOrgIDMock: ReturnType<typeof vi.fn>;
@@ -66,6 +67,7 @@ describe('useAppRuntimeState', () => {
});
orgsListMock = vi.fn().mockResolvedValue([{ id: 'acme', displayName: 'Acme' }]);
loadLicenseStatusMock = vi.fn().mockResolvedValue(undefined);
+ loadCommercialPostureMock = vi.fn().mockResolvedValue(undefined);
isMultiTenantEnabledMock = vi.fn().mockReturnValue(false);
isHostedModeEnabledMock = vi.fn().mockReturnValue(false);
getOrgIDMock = vi.fn().mockReturnValue('default');
@@ -216,6 +218,10 @@ describe('useAppRuntimeState', () => {
},
}));
+ vi.doMock('@/stores/licenseCommercial', () => ({
+ loadCommercialPosture: loadCommercialPostureMock,
+ }));
+
vi.doMock('@/utils/layout', () => ({
layoutStore: {
loadFromServer: vi.fn(),
@@ -322,6 +328,76 @@ describe('useAppRuntimeState', () => {
dispose();
});
+ it('skips commercial posture bootstrap when upgrade prompts are hidden', async () => {
+ apiFetchMock.mockImplementation(async (url: string) => {
+ if (url === '/api/security/status') {
+ return new Response(
+ JSON.stringify({
+ hasAuthentication: true,
+ presentationPolicy: {
+ demoMode: false,
+ readOnly: false,
+ hideCommercial: false,
+ hideUpgrade: true,
+ },
+ }),
+ { status: 200 },
+ );
+ }
+ if (url === '/api/state') {
+ return new Response('{}', { status: 200 });
+ }
+ if (url === '/api/health') {
+ return new Response('{}', { status: 200 });
+ }
+ throw new Error(`Unhandled apiFetch URL: ${url}`);
+ });
+
+ const { dispose } = mountHook();
+
+ await flushAsync();
+ await flushAsync();
+
+ expect(loadCommercialPostureMock).not.toHaveBeenCalled();
+
+ dispose();
+ });
+
+ it('loads commercial posture during bootstrap when upgrade prompts are allowed', async () => {
+ apiFetchMock.mockImplementation(async (url: string) => {
+ if (url === '/api/security/status') {
+ return new Response(
+ JSON.stringify({
+ hasAuthentication: true,
+ presentationPolicy: {
+ demoMode: false,
+ readOnly: false,
+ hideCommercial: false,
+ hideUpgrade: false,
+ },
+ }),
+ { status: 200 },
+ );
+ }
+ if (url === '/api/state') {
+ return new Response('{}', { status: 200 });
+ }
+ if (url === '/api/health') {
+ return new Response('{}', { status: 200 });
+ }
+ throw new Error(`Unhandled apiFetch URL: ${url}`);
+ });
+
+ const { dispose } = mountHook();
+
+ await flushAsync();
+ await flushAsync();
+
+ expect(loadCommercialPostureMock).toHaveBeenCalledOnce();
+
+ dispose();
+ });
+
it('skips the protected state bootstrap probe on the login route until a local auth hint exists', async () => {
window.history.replaceState({}, '', '/login');
hasStoredAuthSessionMock.mockReturnValue(false);
diff --git a/frontend-modern/src/useAppRuntimeState.ts b/frontend-modern/src/useAppRuntimeState.ts
index c10d9a5f89..bdc75ca21c 100644
--- a/frontend-modern/src/useAppRuntimeState.ts
+++ b/frontend-modern/src/useAppRuntimeState.ts
@@ -56,6 +56,7 @@ import { aiChatStore } from '@/stores/aiChat';
import { loadCommercialPosture } from '@/stores/licenseCommercial';
import {
presentationPolicyHidesOrganizationSurfaces,
+ presentationPolicyHidesUpgradePrompts,
syncSessionPresentationPolicy,
} from '@/stores/sessionPresentationPolicy';
import { layoutStore } from '@/utils/layout';
@@ -320,8 +321,10 @@ export const useAppRuntimeState = () => {
setWsStore(acquireWsStore());
setBackendHealthy(true);
await loadSystemSettingsAndLayout();
- // Shared commercial posture bootstraps once per authenticated app shell.
- void loadCommercialPosture();
+ // Shared commercial posture stays off ordinary self-hosted app shells.
+ if (!presentationPolicyHidesUpgradePrompts()) {
+ void loadCommercialPosture();
+ }
};
const checkBackendHealth = async () => {