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
Promote demo bootstrap and suppress public commercial surfaces
rcourtmanc712a69691a0
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex 25ef3b61fd..3f41d36356 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -308,7 +308,10 @@ transport, but `DEMO_MODE` must continue to 404 commercial read surfacesinstead of teaching lifecycle or mock-mode paths to bypass licensing. Publicdemo readiness therefore comes from hiding commercial presentation on theshared API boundary, not from introducing a second fake-entitlement path into-lifecycle-owned install or reporting flows.+lifecycle-owned install or reporting flows. Browser-facing lifecycle surfaces+must also treat `/api/security/status.sessionCapabilities.demoMode` as the+canonical public-demo bootstrap signal instead of inferring demo posture from+headers, `/api/health`, or hostname heuristics.Lifecycle-adjacent storage and fleet surfaces now also depend on one governedphysical-disk history transport. When agent-backed disk telemetry is renderedthrough shared drawers or lifecycle-adjacent resource context, those reads@@ -1840,4 +1843,7 @@ transport, but `DEMO_MODE` must continue to 404 commercial read surfacesinstead of teaching lifecycle or mock-mode paths to bypass licensing. Publicdemo readiness therefore comes from hiding commercial presentation on theshared API boundary, not from introducing a second fake-entitlement path into-lifecycle-owned install or reporting flows.+lifecycle-owned install or reporting flows. Browser-facing lifecycle surfaces+must also treat `/api/security/status.sessionCapabilities.demoMode` as the+canonical public-demo bootstrap signal instead of inferring demo posture from+headers, `/api/health`, or hostname heuristics.diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 4c71647668..b3f7e754c5 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -75,6 +75,7 @@ Own canonical runtime payload shapes between backend and frontend.51. `internal/api/recovery_handlers.go`52. `internal/api/config_setup_handlers.go`53. `internal/api/demo_mode_commercial.go`+54. `internal/api/security_status_capabilities.go`## Shared Boundaries@@ -204,6 +205,14 @@ Own canonical runtime payload shapes between backend and frontend.target before refresh, persistence, and evaluator rewiring, so tenant-scoped hosted routes cannot refresh against an empty non-default org whilethe machine's real hosted lease still lives on `default`.+32. Keep public demo bootstrap posture on the shared security-status contract.+ `internal/api/router_routes_auth_security.go`,+ `internal/api/security_status_capabilities.go`, frontend security-status+ consumers, and shared demo-mode stores must treat+ `/api/security/status.sessionCapabilities.demoMode` as the canonical+ browser bootstrap signal for public demo posture instead of asking+ frontend callers to infer demo state from response headers, `/api/health`+ probes, or hostname heuristics.## Forbidden Pathsdiff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.mdindex 0f50060427..186545363f 100644--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md@@ -152,12 +152,18 @@ That same cloud-paid/browser boundary now also governs public demo posture.`DEMO_MODE` may run against a real internal entitlement, but public demosurfaces must not reveal self-hosted license metadata, hosted billing state,monitored-system ledgers, upgrade nudges, or activation controls just because-the underlying runtime is commercially enabled. `frontend-modern/src/utils/apiClient.ts`-must treat `X-Demo-Mode` as the canonical browser signal, and shared billing-or upgrade surfaces must hide or suppress themselves from that signal rather-than teaching mock mode or frontend-only feature flags to bypass the real-licensing model. Demo readiness therefore means presentation isolation, not a-license exemption.+the underlying runtime is commercially enabled.+`internal/api/router_routes_auth_security.go`,+`internal/api/security_status_capabilities.go`,+`frontend-modern/src/useAppRuntimeState.ts`, and the shared session-capability+stores must treat `/api/security/status.sessionCapabilities.demoMode` as the+canonical browser bootstrap signal, and shared billing or upgrade surfaces+must hide or suppress themselves from that contract rather than teaching mock+mode, response-header inference, or frontend-only feature flags to bypass the+real licensing model. That includes settings billing tabs, public-demo banner+and monitored-system/trial nudges, dashboard relay paywalls, Patrol upgrade+CTAs, and history-lock upsells. Demo readiness therefore means presentation+isolation, not a license exemption.Legacy Cloud plan aliases are now expected to canonicalize to the `cloud_*`contract not only when Stripe metadata is parsed, but also when persisted planversions are consumed at hosted entitlement and workspace-limit enforcement@@ -1102,9 +1108,15 @@ That same cloud-paid/browser boundary now also governs public demo posture.`DEMO_MODE` may run against a real internal entitlement, but public demosurfaces must not reveal self-hosted license metadata, hosted billing state,monitored-system ledgers, upgrade nudges, or activation controls just because-the underlying runtime is commercially enabled. `frontend-modern/src/utils/apiClient.ts`-must treat `X-Demo-Mode` as the canonical browser signal, and shared billing-or upgrade surfaces must hide or suppress themselves from that signal rather-than teaching mock mode or frontend-only feature flags to bypass the real-licensing model. Demo readiness therefore means presentation isolation, not a-license exemption.+the underlying runtime is commercially enabled.+`internal/api/router_routes_auth_security.go`,+`internal/api/security_status_capabilities.go`,+`frontend-modern/src/useAppRuntimeState.ts`, and the shared session-capability+stores must treat `/api/security/status.sessionCapabilities.demoMode` as the+canonical browser bootstrap signal, and shared billing or upgrade surfaces+must hide or suppress themselves from that contract rather than teaching mock+mode, response-header inference, or frontend-only feature flags to bypass the+real licensing model. That includes settings billing tabs, public-demo banner+and monitored-system/trial nudges, dashboard relay paywalls, Patrol upgrade+CTAs, and history-lock upsells. Demo readiness therefore means presentation+isolation, not a license exemption.diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex f983ee7de5..97b8f2cdb1 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -136,6 +136,11 @@ work extends shared components instead of creating new local variants.114. `frontend-modern/src/components/shared/UpgradeLink.tsx`115. `frontend-modern/src/components/shared/useUpgradeNavigation.ts`116. `frontend-modern/src/utils/upgradeNavigation.ts`+117. `frontend-modern/src/components/DemoBanner.tsx`+118. `frontend-modern/src/components/Login.tsx`+119. `frontend-modern/src/stores/demoMode.ts`+120. `frontend-modern/src/stores/sessionCapabilities.ts`+121. `frontend-modern/src/useAppRuntimeState.ts`## Shared Boundaries@@ -399,14 +404,25 @@ badges, or panel copy just because the underlying signal came from vSphere.That same shared settings-shell and banner boundary now also owns demo-modecommercial suppression. `frontend-modern/src/components/Settings/settingsNavCatalog.ts`,`frontend-modern/src/components/Settings/settingsNavVisibility.ts`,+`frontend-modern/src/stores/sessionCapabilities.ts`,+`frontend-modern/src/stores/demoMode.ts`,+`frontend-modern/src/useAppRuntimeState.ts`,`frontend-modern/src/components/shared/useTrialBannerState.ts`, and-`frontend-modern/src/components/shared/useMonitoredSystemLimitWarningBannerState.ts`-must consume one shared demo-mode truth and hide billing tabs, trial nudges,-and monitored-system warning banners when the browser is rendering a public-demo runtime. Shared primitives must not perform their own ad hoc `/api/health`-polling or rebuild per-banner demo heuristics; the settings shell and shared-banner hooks stay on the canonical shared demo-mode owner so suppression stays-coherent across customer-facing surfaces.+`frontend-modern/src/components/shared/useMonitoredSystemLimitWarningBannerState.ts`,+`frontend-modern/src/components/Dashboard/RelayOnboardingCard.tsx`,+`frontend-modern/src/components/shared/HistoryChartOverlay.tsx`,+`frontend-modern/src/features/patrol/PatrolIntelligenceBanners.tsx`, and+`frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx`+must consume one shared bootstrap truth from+`/api/security/status.sessionCapabilities.demoMode` and hide billing tabs,+trial nudges, monitored-system warning banners, dashboard upsells, Patrol+upgrade CTAs, history-lock paywalls, and other public-demo commercial+affordances when the browser is rendering a public demo runtime.+Shared primitives must not perform their own ad hoc `/api/health` polling,+response-header inference, hostname heuristics, or per-banner demo branching;+the runtime bootstrap, shared session-capability store, and shared banner+hooks stay on one canonical owner so suppression stays coherent across+customer-facing surfaces.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@@ -1833,11 +1849,22 @@ own reusable consumption only.That same shared settings-shell and banner boundary now also owns demo-modecommercial suppression. `frontend-modern/src/components/Settings/settingsNavCatalog.ts`,`frontend-modern/src/components/Settings/settingsNavVisibility.ts`,+`frontend-modern/src/stores/sessionCapabilities.ts`,+`frontend-modern/src/stores/demoMode.ts`,+`frontend-modern/src/useAppRuntimeState.ts`,`frontend-modern/src/components/shared/useTrialBannerState.ts`, and-`frontend-modern/src/components/shared/useMonitoredSystemLimitWarningBannerState.ts`-must consume one shared demo-mode truth and hide billing tabs, trial nudges,-and monitored-system warning banners when the browser is rendering a public-demo runtime. Shared primitives must not perform their own ad hoc `/api/health`-polling or rebuild per-banner demo heuristics; the settings shell and shared-banner hooks stay on the canonical shared demo-mode owner so suppression stays-coherent across customer-facing surfaces.+`frontend-modern/src/components/shared/useMonitoredSystemLimitWarningBannerState.ts`,+`frontend-modern/src/components/Dashboard/RelayOnboardingCard.tsx`,+`frontend-modern/src/components/shared/HistoryChartOverlay.tsx`,+`frontend-modern/src/features/patrol/PatrolIntelligenceBanners.tsx`, and+`frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx`+must consume one shared bootstrap truth from+`/api/security/status.sessionCapabilities.demoMode` and hide billing tabs,+trial nudges, monitored-system warning banners, dashboard upsells, Patrol+upgrade CTAs, history-lock paywalls, and other public-demo commercial+affordances when the browser is rendering a public demo runtime.+Shared primitives must not perform their own ad hoc `/api/health` polling,+response-header inference, hostname heuristics, or per-banner demo branching;+the runtime bootstrap, shared session-capability store, and shared banner+hooks stay on one canonical owner so suppression stays coherent across+customer-facing surfaces.diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.mdindex 14a96092dd..00794fe4f3 100644--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md@@ -135,6 +135,12 @@ Patrol paywall actions now follow the same shared commercial navigation split.commercial destinations from the shared license boundary, but they must leaveinternal-versus-external navigation semantics to `frontend-primitives` once aPatrol feature can resolve to either product-owned routes or public pricing.+That same Patrol-owned commercial boundary must also fail closed in public+demo runtimes. Patrol header and banner upgrade/trial affordances may render+for real customer workspaces, but when+`/api/security/status.sessionCapabilities.demoMode` is true they must suppress+upgrade CTAs, trial nudges, and Pro-only helper copy instead of leaking+commercial posture into the public demo presentation.That degraded empty-state copy must also interpret the finding state ratherthan simply replaying the primary assessment sentence verbatim: when coverageis incomplete, the findings panel should tell the operator that Patrol has notdiff --git a/docs/release-control/v6/internal/subsystems/security-privacy.md b/docs/release-control/v6/internal/subsystems/security-privacy.mdindex 1f47efa62a..0787685971 100644--- a/docs/release-control/v6/internal/subsystems/security-privacy.md+++ b/docs/release-control/v6/internal/subsystems/security-privacy.md@@ -379,6 +379,12 @@ reads, expose the backend-owned Pulse Mobile relay access token creator, andthe relay pairing UI may revoke a displayed token only when that metadata stillshows no `lastUsedAt`. Refreshing or hiding a QR payload must not delete atoken that an already paired device is actively depending on.+That same auth/security boundary also owns browser session-capability posture:+`internal/api/router_routes_auth_security.go` together with+`internal/api/security_status_capabilities.go` must expose+`/api/security/status.sessionCapabilities.demoMode` as the backend-owned+public-demo posture signal, and security/privacy consumers must not infer demo+state from response headers, `/api/health`, or hostname heuristics.That same token-management boundary now also depends on one neutralapp-runtime context owner. `frontend-modern/src/components/Settings/useAPITokenManagerState.ts`may consume websocket-backed revocation fan-out throughdiff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex 666452fe4a..1fc3c0038a 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -322,6 +322,10 @@ system-ledger reads so adjacent recovery or storage pages do not leakcommercial identity or upgrade posture into a public demo. Storage/recoverymust consume that redacted boundary as presentation truth rather thanreintroducing mock-only license bypasses or page-local commercial fallbacks.+Browser-facing storage/recovery surfaces must also treat+`/api/security/status.sessionCapabilities.demoMode` as the canonical+public-demo bootstrap signal instead of inferring demo posture from headers,+`/api/health`, or hostname heuristics.Physical-disk live I/O drawers now also sit on the canonical storage surface.Storage disk drawers may show read, write, busy, and SMART history, but everychart must route through the shared `HistoryChart` API contract using the disk@@ -2004,3 +2008,7 @@ system-ledger reads so adjacent recovery or storage pages do not leakcommercial identity or upgrade posture into a public demo. Storage/recoverymust consume that redacted boundary as presentation truth rather thanreintroducing mock-only license bypasses or page-local commercial fallbacks.+Browser-facing storage/recovery surfaces must also treat+`/api/security/status.sessionCapabilities.demoMode` as the canonical+public-demo bootstrap signal instead of inferring demo posture from headers,+`/api/health`, or hostname heuristics.diff --git a/frontend-modern/src/AppLayout.tsx b/frontend-modern/src/AppLayout.tsxindex 52e949aa72..77304b8be4 100644--- a/frontend-modern/src/AppLayout.tsx+++ b/frontend-modern/src/AppLayout.tsx@@ -38,6 +38,7 @@ import { buildStorageRecoveryTabSpecs } from '@/routing/platformTabs';import { getKioskModePreference, setKioskMode } from '@/utils/url';import { updateStore } from '@/stores/updates';import { aiChatStore } from '@/stores/aiChat';+import { demoModeEnabled } from '@/stores/demoMode';import { isMultiTenantEnabled, isPro } from '@/stores/license';import type { AppConnectionStatus } from '@/useAppRuntimeState';@@ -724,7 +725,7 @@ export function AppLayout(props: AppLayoutProps) {/></span></Show>- <Show when={tab.badge === 'pro'}>+ <Show when={tab.badge === 'pro' && !demoModeEnabled()}><span class="ml-1.5 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-blue-700 dark:text-blue-300 bg-blue-100 dark:bg-blue-900 rounded">Pro</span>diff --git a/frontend-modern/src/__tests__/useAppRuntimeState.test.ts b/frontend-modern/src/__tests__/useAppRuntimeState.test.tsindex 6842d702b1..e5841deb74 100644--- a/frontend-modern/src/__tests__/useAppRuntimeState.test.ts+++ b/frontend-modern/src/__tests__/useAppRuntimeState.test.ts@@ -270,4 +270,33 @@ describe('useAppRuntimeState', () => {dispose();});++ it('syncs demo mode from security status session capabilities during bootstrap', async () => {+ apiFetchMock.mockImplementation(async (url: string) => {+ if (url === '/api/security/status') {+ return new Response(+ JSON.stringify({+ hasAuthentication: true,+ sessionCapabilities: { demoMode: true },+ }),+ { status: 200 },+ );+ }+ if (url === '/api/state') {+ return new Response('{}', { status: 200 });+ }+ throw new Error(`Unhandled apiFetch URL: ${url}`);+ });++ const demoModeModule = await import('@/stores/demoMode');+ const { dispose } = mountHook();++ await flushAsync();+ await flushAsync();++ expect(demoModeModule.demoModeResolved()).toBe(true);+ expect(demoModeModule.demoModeEnabled()).toBe(true);++ dispose();+ });});diff --git a/frontend-modern/src/components/Dashboard/RelayOnboardingCard.tsx b/frontend-modern/src/components/Dashboard/RelayOnboardingCard.tsxindex 5430fc1a03..44c169f556 100644--- a/frontend-modern/src/components/Dashboard/RelayOnboardingCard.tsx+++ b/frontend-modern/src/components/Dashboard/RelayOnboardingCard.tsx@@ -3,6 +3,7 @@ import Smartphone from 'lucide-solid/icons/smartphone';import X from 'lucide-solid/icons/x';import { Card } from '@/components/shared/Card';import { UpgradeLink } from '@/components/shared/UpgradeLink';+import { demoModeEnabled } from '@/stores/demoMode';import { getUpgradeActionDestination } from '@/stores/license';import {RELAY_ONBOARDING_DESCRIPTION,@@ -19,7 +20,7 @@ export const RelayOnboardingCard: Component = () => {const state = useRelayOnboardingCardState();return (- <Show when={state.shouldShow()}>+ <Show when={state.shouldShow() && (!demoModeEnabled() || state.hasRelay())}><Card padding="lg" class="relative overflow-hidden"><div class="absolute -right-10 -top-10 h-32 w-32 rounded-full bg-blue-100 dark:bg-blue-900" /><div class="absolute -right-16 -bottom-16 h-40 w-40 rounded-full bg-surface-alt" />diff --git a/frontend-modern/src/components/Dashboard/__tests__/RelayOnboardingCard.test.tsx b/frontend-modern/src/components/Dashboard/__tests__/RelayOnboardingCard.test.tsxindex c00787be23..bdd95db1f4 100644--- a/frontend-modern/src/components/Dashboard/__tests__/RelayOnboardingCard.test.tsx+++ b/frontend-modern/src/components/Dashboard/__tests__/RelayOnboardingCard.test.tsx@@ -20,6 +20,7 @@ const {hasFeatureMock,licenseLoadedMock,getUpgradeActionUrlOrFallbackMock,+ demoModeEnabledMock,} = vi.hoisted(() => ({getUpgradeActionDestinationMock: vi.fn(),mockNavigate: vi.fn(),@@ -35,6 +36,7 @@ const {hasFeatureMock: vi.fn(),licenseLoadedMock: vi.fn(),getUpgradeActionUrlOrFallbackMock: vi.fn(),+ demoModeEnabledMock: vi.fn(),}));vi.mock('@solidjs/router', () => ({@@ -50,6 +52,10 @@ vi.mock('@/stores/license', () => ({getUpgradeActionUrlOrFallback: (...args: unknown[]) => getUpgradeActionUrlOrFallbackMock(...args),}));+vi.mock('@/stores/demoMode', () => ({+ demoModeEnabled: () => demoModeEnabledMock(),+}));+vi.mock('@/api/relay', () => ({RelayAPI: {getStatus: (...args: unknown[]) => getRelayStatusMock(...args),@@ -101,6 +107,8 @@ function resetAllMocks() {licenseLoadedMock.mockReset();getUpgradeActionDestinationMock.mockReset();getUpgradeActionUrlOrFallbackMock.mockReset();+ demoModeEnabledMock.mockReset();+ demoModeEnabledMock.mockReturnValue(false);}/**@@ -205,6 +213,20 @@ describe('RelayOnboardingCard', () => {expect(screen.queryByText('Set Up Relay')).not.toBeInTheDocument();});++ it('hides the relay paywall entirely in demo mode', async () => {+ setupWithoutRelayFeature();+ demoModeEnabledMock.mockReturnValue(true);+ render(() => <RelayOnboardingCard />);++ await waitFor(() => {+ expect(loadLicenseStatusMock).toHaveBeenCalled();+ });++ expect(screen.queryByTestId('card')).not.toBeInTheDocument();+ expect(screen.queryByText(/Get Relay/)).not.toBeInTheDocument();+ expect(screen.queryByText(/or start a Pro trial/)).not.toBeInTheDocument();+ });});// ── Setup scenario (has relay feature, not connected) ──────────────diff --git a/frontend-modern/src/components/DemoBanner.tsx b/frontend-modern/src/components/DemoBanner.tsxindex 46410d8c08..facf95eaf6 100644--- a/frontend-modern/src/components/DemoBanner.tsx+++ b/frontend-modern/src/components/DemoBanner.tsx@@ -1,13 +1,9 @@import { createSignal, onMount, Show } from 'solid-js';-import { demoModeEnabled, ensureDemoModeResolved } from '@/stores/demoMode';+import { demoModeEnabled } from '@/stores/demoMode';export function DemoBanner() {const [dismissed, setDismissed] = createSignal(false);- onMount(async () => {- void ensureDemoModeResolved();- });-onMount(() => {if (sessionStorage.getItem('demoBannerDismissed') === 'true') {setDismissed(true);diff --git a/frontend-modern/src/components/Login.tsx b/frontend-modern/src/components/Login.tsxindex f91d81bfa4..c63b3d1f2b 100644--- a/frontend-modern/src/components/Login.tsx+++ b/frontend-modern/src/components/Login.tsx@@ -271,6 +271,7 @@ export const Login: Component<LoginProps> = (props) => {oidcLoading,oidcError,oidcMessage,+ demoModeEnabled: authStatus()?.sessionCapabilities?.demoMode === true,showLocalLogin: shouldShowLocalLogin(),ssoProviders: ssoProviders(),}}@@ -313,6 +314,7 @@ const LoginForm: Component<{oidcLoading: () => boolean;oidcError: () => string;oidcMessage: () => string;+ demoModeEnabled: boolean;showLocalLogin: boolean;ssoProviders: SSOProviderInfo[];}> = (props) => {@@ -329,22 +331,16 @@ const LoginForm: Component<{oidcLoading,oidcError,oidcMessage,+ demoModeEnabled,showLocalLogin,ssoProviders,} = props;- // Check if we're on the demo server- const isDemoServer = () => {- const hostname = window.location.hostname;- const normalized = hostname.toLowerCase();- return normalized === 'demo' || normalized.startsWith('demo.') || normalized.includes('.demo.');- };-return (<div class="min-h-screen flex items-center justify-center bg-base py-12 px-4 sm:px-6 lg:px-8"><div class="max-w-md w-full space-y-8">{/* Demo Credentials Banner */}- <Show when={isDemoServer()}>+ <Show when={demoModeEnabled}><div class="bg-surface rounded-md p-4 shadow-sm border border-blue-200 dark:border-blue-800 animate-fade-in"><div class="flex items-center gap-3"><div class="flex-shrink-0 w-10 h-10 rounded-full bg-blue-600 flex items-center justify-center">diff --git a/frontend-modern/src/components/Settings/Settings.tsx b/frontend-modern/src/components/Settings/Settings.tsxindex 4d2f2f0578..51733ba967 100644--- a/frontend-modern/src/components/Settings/Settings.tsx+++ b/frontend-modern/src/components/Settings/Settings.tsx@@ -142,6 +142,9 @@ const Settings: Component<SettingsProps> = (props) => {});const activeSettingsPanelEntry = createMemo(() => {const currentTab = activeTab();+ if (!flatTabs().some((tab) => tab.id === currentTab)) {+ return null;+ }return settingsPanelRegistry()[currentTab];});@@ -169,7 +172,16 @@ const Settings: Component<SettingsProps> = (props) => {setActiveTab={setActiveTab}isPro={isPro}>- <Show when={activeSettingsPanelEntry()}>+ <Show+ when={activeSettingsPanelEntry()}+ fallback={+ securityStatusLoading() ? (+ <div class="flex items-center justify-center rounded-md border border-dashed border-border bg-surface-alt py-12 text-sm text-muted">+ {getSettingsLoadingState().text}+ </div>+ ) : null+ }+ >{(entry) => (<Suspensefallback={diff --git a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.tsindex 99b24a6bb1..de8cf15bc7 100644--- a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts+++ b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts@@ -1442,7 +1442,9 @@ describe('Settings architecture guardrails', () => {it('keeps demo-mode billing visibility on the shared settings shell owner', () => {expect(settingsNavigationModelSource).toContain('hideInDemoMode?: boolean;');- expect(settingsNavVisibilitySource).toContain('item.hideInDemoMode && context.demoModeEnabled');+ expect(settingsNavVisibilitySource).toContain('if (item.hideInDemoMode)');+ expect(settingsNavVisibilitySource).toContain('context.demoModeResolved === false');+ expect(settingsNavVisibilitySource).toContain('if (context.demoModeEnabled)');expect(getSettingsNavItem('system-billing')?.hideInDemoMode).toBe(true);expect(getSettingsNavItem('organization-billing')?.hideInDemoMode).toBe(true);expect(getSettingsNavItem('organization-billing-admin')?.hideInDemoMode).toBe(true);diff --git a/frontend-modern/src/components/Settings/__tests__/settingsNavigation.integration.test.tsx b/frontend-modern/src/components/Settings/__tests__/settingsNavigation.integration.test.tsxindex 00d50ad1a7..62574fe411 100644--- a/frontend-modern/src/components/Settings/__tests__/settingsNavigation.integration.test.tsx+++ b/frontend-modern/src/components/Settings/__tests__/settingsNavigation.integration.test.tsx@@ -116,6 +116,26 @@ describe('settingsNavigation integration scaffold', () => {).toBe(true);});+ it('fails closed for demo-hidden tabs until demo mode is resolved', () => {+ expect(+ shouldHideSettingsNavItem('system-billing', {+ hasFeature: hasFeatures([]),+ licenseLoaded: () => true,+ demoModeResolved: false,+ hostedModeEnabled: false,+ }),+ ).toBe(true);++ expect(+ shouldHideSettingsNavItem('organization-billing', {+ hasFeature: hasFeatures(['multi_tenant']),+ licenseLoaded: () => true,+ demoModeResolved: false,+ hostedModeEnabled: true,+ }),+ ).toBe(true);+ });+it('hides tabs when the backend denies the required capability', () => {expect(shouldHideSettingsNavItem('api', {diff --git a/frontend-modern/src/components/Settings/settingsNavVisibility.ts b/frontend-modern/src/components/Settings/settingsNavVisibility.tsindex f4aea2da1a..cd65508784 100644--- a/frontend-modern/src/components/Settings/settingsNavVisibility.ts+++ b/frontend-modern/src/components/Settings/settingsNavVisibility.ts@@ -32,8 +32,14 @@ export function shouldHideSettingsNavItem(return true;}- if (item.hideInDemoMode && context.demoModeEnabled) {- return true;+ if (item.hideInDemoMode) {+ if (context.demoModeResolved === false) {+ return true;+ }++ if (context.demoModeEnabled) {+ return true;+ }}if (diff --git a/frontend-modern/src/components/Settings/useSettingsAccess.ts b/frontend-modern/src/components/Settings/useSettingsAccess.tsindex 223c88d0f1..45035a777b 100644--- a/frontend-modern/src/components/Settings/useSettingsAccess.ts+++ b/frontend-modern/src/components/Settings/useSettingsAccess.ts@@ -1,5 +1,6 @@import { Accessor, createEffect, createMemo, createSignal } from 'solid-js';-import { demoModeEnabled, demoModeResolved } from '@/stores/demoMode';+import { syncDemoModeFromSecurityStatus } from '@/stores/demoMode';+import { sessionCapabilities, sessionCapabilitiesResolved } from '@/stores/sessionCapabilities';import type { SecurityStatus } from '@/types/config';import { logger } from '@/utils/logger';import { hasFeature, isHostedModeEnabled, licenseLoaded } from '@/stores/license';@@ -22,6 +23,16 @@ export function useSettingsAccess({}: UseSettingsAccessParams) {const [securityStatus, setSecurityStatus] = createSignal<SecurityStatus | null>(null);const [securityStatusLoading, setSecurityStatusLoading] = createSignal(true);+ const demoModeEnabled = createMemo(() => {+ const resolvedSecurityStatus = securityStatus();+ if (resolvedSecurityStatus) {+ return resolvedSecurityStatus.sessionCapabilities?.demoMode === true;+ }+ return sessionCapabilities().demoMode;+ });+ const demoModeResolved = createMemo(+ () => securityStatus() !== null || sessionCapabilitiesResolved(),+ );const visibleTabGroups = createMemo(() => {const hostedModeEnabled = isHostedModeEnabled();@@ -93,8 +104,9 @@ export function useSettingsAccess({const { apiFetch } = await import('@/utils/apiClient');const response = await apiFetch('/api/security/status');if (response.ok) {- const status = await response.json();+ const status = (await response.json()) as SecurityStatus;logger.debug('Security status loaded', status);+ syncDemoModeFromSecurityStatus(status);setSecurityStatus(status);} else {logger.error('Failed to fetch security status', { status: response.status });diff --git a/frontend-modern/src/components/__tests__/DemoBanner.test.tsx b/frontend-modern/src/components/__tests__/DemoBanner.test.tsxindex 206756fd07..84257b1494 100644--- a/frontend-modern/src/components/__tests__/DemoBanner.test.tsx+++ b/frontend-modern/src/components/__tests__/DemoBanner.test.tsx@@ -6,11 +6,9 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';/* ------------------------------------------------------------------ */const demoModeEnabledMock = vi.hoisted(() => vi.fn());-const ensureDemoModeResolvedMock = vi.hoisted(() => vi.fn());vi.mock('@/stores/demoMode', () => ({demoModeEnabled: () => demoModeEnabledMock(),- ensureDemoModeResolved: (...args: unknown[]) => ensureDemoModeResolvedMock(...args),}));vi.mock('@/utils/logger', () => ({@@ -24,9 +22,7 @@ vi.mock('@/utils/logger', () => ({describe('DemoBanner', () => {beforeEach(() => {demoModeEnabledMock.mockReset();- ensureDemoModeResolvedMock.mockReset();demoModeEnabledMock.mockReturnValue(false);- ensureDemoModeResolvedMock.mockResolvedValue(false);sessionStorage.clear();});@@ -92,16 +88,4 @@ describe('DemoBanner', () => {expect(screen.queryByText('Demo instance with mock data (read-only)')).not.toBeInTheDocument();});-- /* ---------- Demo-mode resolve ---------- */-- it('resolves demo mode exactly once on mount', async () => {- ensureDemoModeResolvedMock.mockResolvedValue(false);-- await renderBanner();-- await waitFor(() => {- expect(ensureDemoModeResolvedMock).toHaveBeenCalledTimes(1);- });- });});diff --git a/frontend-modern/src/components/__tests__/Login.test.tsx b/frontend-modern/src/components/__tests__/Login.test.tsxindex d2fc940db7..1249346a4f 100644--- a/frontend-modern/src/components/__tests__/Login.test.tsx+++ b/frontend-modern/src/components/__tests__/Login.test.tsx@@ -155,4 +155,20 @@ describe('Login', () => {// because we passed securityStatus directlyexpect(mockFetch).not.toHaveBeenCalledWith('/api/security/status');});++ it('shows demo credentials when session capabilities mark the runtime as demo mode', async () => {+ const mockOnLogin = vi.fn();+ const securityStatus = {+ hasAuthentication: true,+ hideLocalLogin: false,+ sessionCapabilities: { demoMode: true },+ };++ render(() => (+ <Login onLogin={mockOnLogin} hasAuth={true} securityStatus={securityStatus as any} />+ ));++ expect(await screen.findByText('Demo Mode')).toBeInTheDocument();+ expect(screen.getAllByText('demo')).toHaveLength(2);+ });});diff --git a/frontend-modern/src/components/shared/HistoryChartOverlay.tsx b/frontend-modern/src/components/shared/HistoryChartOverlay.tsxindex 1566ca9cdd..478eed12b4 100644--- a/frontend-modern/src/components/shared/HistoryChartOverlay.tsx+++ b/frontend-modern/src/components/shared/HistoryChartOverlay.tsx@@ -1,4 +1,5 @@import { Component, Show } from 'solid-js';+import { demoModeEnabled } from '@/stores/demoMode';import { UpgradeLink } from './UpgradeLink';import type { HistoryChartState } from './useHistoryChartState';@@ -69,29 +70,38 @@ export const HistoryChartOverlay: Component<HistoryChartOverlayProps> = (props)</svg></div><h3 class="text-lg font-bold text-base-content mb-1">{props.chart.lockDays()}-Day History</h3>- <p class="text-sm text-muted text-center max-w-[200px] mb-4">- Upgrade to {props.chart.lockTierLabel()} to unlock {props.chart.lockDays()} days of- historical data retention.- </p>- <div class="flex flex-col items-center gap-2">- <UpgradeLink- destination={props.chart.getUpgradeActionDestination('long_term_metrics')}- onClick={() => props.chart.trackUpgradeClicked('history_chart', 'long_term_metrics')}- class="px-4 py-2 bg-indigo-600 hover:bg-indigo-700 text-white text-sm font-medium rounded-md shadow-sm transition-colors"- >- Unlock {props.chart.lockTierLabel()} Features- </UpgradeLink>- <Show when={props.chart.canStartTrial()}>- <button- type="button"- class="text-xs font-semibold text-indigo-700 dark:text-indigo-300 hover:underline disabled:opacity-60"- disabled={props.chart.startingTrial()}- onClick={props.chart.handleStartTrial}+ <Show+ when={!demoModeEnabled()}+ fallback={+ <p class="text-sm text-muted text-center max-w-[220px] mb-4">+ Historical data beyond {props.chart.lockDays()} days is hidden in this demo.+ </p>+ }+ >+ <p class="text-sm text-muted text-center max-w-[200px] mb-4">+ Upgrade to {props.chart.lockTierLabel()} to unlock {props.chart.lockDays()} days of+ historical data retention.+ </p>+ <div class="flex flex-col items-center gap-2">+ <UpgradeLink+ destination={props.chart.getUpgradeActionDestination('long_term_metrics')}+ onClick={() => props.chart.trackUpgradeClicked('history_chart', 'long_term_metrics')}+ class="px-4 py-2 bg-indigo-600 hover:bg-indigo-700 text-white text-sm font-medium rounded-md shadow-sm transition-colors">- Or start a free 14-day trial- </button>- </Show>- </div>+ Unlock {props.chart.lockTierLabel()} Features+ </UpgradeLink>+ <Show when={props.chart.canStartTrial()}>+ <button+ type="button"+ class="text-xs font-semibold text-indigo-700 dark:text-indigo-300 hover:underline disabled:opacity-60"+ disabled={props.chart.startingTrial()}+ onClick={props.chart.handleStartTrial}+ >+ Or start a free 14-day trial+ </button>+ </Show>+ </div>+ </Show></div></Show></>diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.tsindex 0f0f2d2c0d..5fa762fe91 100644--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts@@ -470,7 +470,6 @@ describe('shared primitive guardrails', () => {expect(trialBannerStateSource).toContain('loadLicenseStatus');expect(trialBannerStateSource).toContain('licenseStatus');expect(trialBannerStateSource).toContain('demoModeEnabled');- expect(trialBannerStateSource).toContain('ensureDemoModeResolved');expect(trialBannerStateSource).toContain('getUpgradeActionDestination');expect(trialBannerStateSource).toContain('snoozeUpsell');expect(trialBannerStateSource).not.toContain("fetch('/api/health'");@@ -665,7 +664,6 @@ describe('shared primitive guardrails', () => {expect(monitoredSystemLimitWarningBannerStateSource).toContain('createMemo');expect(monitoredSystemLimitWarningBannerStateSource).toContain('loadLicenseStatus');expect(monitoredSystemLimitWarningBannerStateSource).toContain('demoModeEnabled');- expect(monitoredSystemLimitWarningBannerStateSource).toContain('ensureDemoModeResolved');expect(monitoredSystemLimitWarningBannerStateSource).toContain('trackUpgradeMetricEvent');expect(monitoredSystemLimitWarningBannerStateSource).toContain('legacyConnections');expect(monitoredSystemLimitWarningBannerStateSource).toContain(diff --git a/frontend-modern/src/components/shared/__tests__/HistoryChart.test.tsx b/frontend-modern/src/components/shared/__tests__/HistoryChart.test.tsxindex 6770ef99c0..736237518f 100644--- a/frontend-modern/src/components/shared/__tests__/HistoryChart.test.tsx+++ b/frontend-modern/src/components/shared/__tests__/HistoryChart.test.tsx@@ -45,6 +45,10 @@ vi.mock('@/stores/license', () => ({startProTrial: vi.fn(),}));+vi.mock('@/stores/demoMode', () => ({+ demoModeEnabled: () => false,+}));+vi.mock('@/api/charts', () => ({ChartsAPI: {getMetricsHistory: vi.fn().mockResolvedValue({ points: [], source: 'store' }),@@ -87,6 +91,8 @@ describe('HistoryChart', () => {expect(historyChartOverlaySource).toContain('Collecting data... History will appear here.');expect(historyChartOverlaySource).toContain('Unlock {props.chart.lockTierLabel()} Features');+ expect(historyChartOverlaySource).toContain('demoModeEnabled');+ expect(historyChartOverlaySource).toContain('Historical data beyond {props.chart.lockDays()} days is hidden in this demo.');expect(historyChartOverlaySource).not.toContain('ChartsAPI.getMetricsHistory');expect(historyChartOverlaySource).not.toContain('setupCanvasDPR');diff --git a/frontend-modern/src/components/shared/__tests__/MonitoredSystemLimitWarningBanner.test.tsx b/frontend-modern/src/components/shared/__tests__/MonitoredSystemLimitWarningBanner.test.tsxindex 3f81449fff..37f65cc826 100644--- a/frontend-modern/src/components/shared/__tests__/MonitoredSystemLimitWarningBanner.test.tsx+++ b/frontend-modern/src/components/shared/__tests__/MonitoredSystemLimitWarningBanner.test.tsx@@ -32,7 +32,6 @@ const mockTrackUpgradeMetricEvent = vi.hoisted(() => vi.fn());const mockTrackUpgradeClicked = vi.hoisted(() => vi.fn());const mockLoadLicenseStatus = vi.hoisted(() => vi.fn());const mockDemoModeEnabled = vi.hoisted(() => vi.fn(() => false));-const mockEnsureDemoModeResolved = vi.hoisted(() => vi.fn());const mockGetUpgradeActionDestination = vi.hoisted(() => vi.fn());const mockGetUpgradeActionUrlOrFallback = vi.hoisted(() => vi.fn());@@ -48,7 +47,6 @@ vi.mock('@/stores/license', () => ({vi.mock('@/stores/demoMode', () => ({demoModeEnabled: () => mockDemoModeEnabled(),- ensureDemoModeResolved: (...args: unknown[]) => mockEnsureDemoModeResolved(...args),}));vi.mock('@/utils/upgradeMetrics', () => ({@@ -72,8 +70,6 @@ describe('MonitoredSystemLimitWarningBanner', () => {});mockDemoModeEnabled.mockReset();mockDemoModeEnabled.mockReturnValue(false);- mockEnsureDemoModeResolved.mockReset();- mockEnsureDemoModeResolved.mockResolvedValue(false);mockLoadLicenseStatus.mockReset();mockLoadLicenseStatus.mockResolvedValue(undefined);mockGetUpgradeActionDestination.mockReset();@@ -109,7 +105,7 @@ describe('MonitoredSystemLimitWarningBanner', () => {expect(monitoredSystemLimitWarningBannerStateSource).toContain('createEffect');expect(monitoredSystemLimitWarningBannerStateSource).toContain('createMemo');expect(monitoredSystemLimitWarningBannerStateSource).toContain('loadLicenseStatus');- expect(monitoredSystemLimitWarningBannerStateSource).toContain('ensureDemoModeResolved');+ expect(monitoredSystemLimitWarningBannerStateSource).toContain('demoModeEnabled');expect(monitoredSystemLimitWarningBannerStateSource).toContain('trackUpgradeMetricEvent');expect(monitoredSystemLimitWarningBannerStateSource).toContain('legacyConnections');expect(monitoredSystemLimitWarningBannerStateSource).toContain('handleUpgradeClick');@@ -142,7 +138,6 @@ describe('MonitoredSystemLimitWarningBanner', () => {));expect(mockLoadLicenseStatus).toHaveBeenCalled();- expect(mockEnsureDemoModeResolved).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.tsxindex 242d73c4a4..36d41ec276 100644--- a/frontend-modern/src/components/shared/__tests__/TrialBanner.test.tsx+++ b/frontend-modern/src/components/shared/__tests__/TrialBanner.test.tsx@@ -9,7 +9,6 @@ import { getPublicPricingUrl } from '@/utils/pricingHandoff';const {demoModeEnabledMock,- ensureDemoModeResolvedMock,getUpgradeActionDestinationMock,getUpgradeActionUrlOrFallbackMock,licenseStatusMock,@@ -19,7 +18,6 @@ const {} =vi.hoisted(() => ({demoModeEnabledMock: vi.fn(),- ensureDemoModeResolvedMock: vi.fn(),getUpgradeActionDestinationMock: vi.fn(),getUpgradeActionUrlOrFallbackMock: vi.fn(),licenseStatusMock: vi.fn(),@@ -37,7 +35,6 @@ vi.mock('@/stores/license', () => ({vi.mock('@/stores/demoMode', () => ({demoModeEnabled: () => demoModeEnabledMock(),- ensureDemoModeResolved: (...args: unknown[]) => ensureDemoModeResolvedMock(...args),}));vi.mock('@/utils/snooze', () => ({@@ -49,7 +46,6 @@ describe('TrialBanner', () => {beforeEach(() => {cleanup();demoModeEnabledMock.mockReset();- ensureDemoModeResolvedMock.mockReset();getUpgradeActionDestinationMock.mockReset();getUpgradeActionUrlOrFallbackMock.mockReset();licenseStatusMock.mockReset();@@ -61,7 +57,6 @@ describe('TrialBanner', () => {external: true,});demoModeEnabledMock.mockReturnValue(false);- ensureDemoModeResolvedMock.mockResolvedValue(false);getUpgradeActionUrlOrFallbackMock.mockReturnValue(getPublicPricingUrl('trial_banner'));loadLicenseStatusMock.mockResolvedValue(undefined);isUpsellSnoozedMock.mockReturnValue(false);@@ -84,7 +79,7 @@ describe('TrialBanner', () => {expect(trialBannerStateSource).toContain('createSignal');expect(trialBannerStateSource).toContain('createMemo');expect(trialBannerStateSource).toContain('loadLicenseStatus');- expect(trialBannerStateSource).toContain('ensureDemoModeResolved');+ expect(trialBannerStateSource).toContain('demoModeEnabled');expect(trialBannerStateSource).toContain('licenseStatus');expect(trialBannerStateSource).toContain('getUpgradeActionDestination');expect(trialBannerStateSource).toContain('snoozeUpsell');@@ -106,7 +101,6 @@ describe('TrialBanner', () => {await waitFor(() => {expect(loadLicenseStatusMock).toHaveBeenCalled();- expect(ensureDemoModeResolvedMock).toHaveBeenCalled();});expect(screen.getByRole('status')).toBeInTheDocument();expect(screen.getByText('Pro Trial:')).toBeInTheDocument();diff --git a/frontend-modern/src/components/shared/useMonitoredSystemLimitWarningBannerState.ts b/frontend-modern/src/components/shared/useMonitoredSystemLimitWarningBannerState.tsindex a013f7b141..7fcd5b8dd5 100644--- a/frontend-modern/src/components/shared/useMonitoredSystemLimitWarningBannerState.ts+++ b/frontend-modern/src/components/shared/useMonitoredSystemLimitWarningBannerState.ts@@ -1,5 +1,5 @@import { createEffect, createMemo, onMount } from 'solid-js';-import { demoModeEnabled, ensureDemoModeResolved } from '@/stores/demoMode';+import { demoModeEnabled } from '@/stores/demoMode';import {entitlements,getLimit,@@ -34,7 +34,6 @@ import {export function useMonitoredSystemLimitWarningBannerState() {onMount(() => {void loadLicenseStatus();- void ensureDemoModeResolved();});const monitoredSystemLimit = createMemo(() => getLimit(MONITORED_SYSTEM_LIMIT_KEY));diff --git a/frontend-modern/src/components/shared/useTrialBannerState.ts b/frontend-modern/src/components/shared/useTrialBannerState.tsindex 117488b33d..8600b06043 100644--- a/frontend-modern/src/components/shared/useTrialBannerState.ts+++ b/frontend-modern/src/components/shared/useTrialBannerState.ts@@ -1,5 +1,5 @@import { createMemo, createSignal, onMount } from 'solid-js';-import { demoModeEnabled, ensureDemoModeResolved } from '@/stores/demoMode';+import { demoModeEnabled } from '@/stores/demoMode';import { getUpgradeActionDestination, licenseStatus, loadLicenseStatus } from '@/stores/license';import { isUpsellSnoozed, snoozeUpsell } from '@/utils/snooze';import {@@ -14,7 +14,6 @@ export function useTrialBannerState() {onMount(() => {void loadLicenseStatus();- void ensureDemoModeResolved();});const isTrial = createMemo(diff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceBanners.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceBanners.tsxindex c9cf30f0d2..fd457895da 100644--- a/frontend-modern/src/features/patrol/PatrolIntelligenceBanners.tsx+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceBanners.tsx@@ -3,6 +3,7 @@ import ShieldAlertIcon from 'lucide-solid/icons/shield-alert';import SettingsIcon from 'lucide-solid/icons/settings';import SparklesIcon from 'lucide-solid/icons/sparkles';import { UpgradeLink } from '@/components/shared/UpgradeLink';+import { demoModeEnabled } from '@/stores/demoMode';import { formatRelativeTime } from '@/utils/format';import { trackUpgradeClicked } from '@/utils/upgradeMetrics';import type { PatrolIntelligenceState } from './usePatrolIntelligenceState';@@ -36,7 +37,7 @@ export function PatrolIntelligenceBanners(props: { state: PatrolIntelligenceStat</div></Show>- <Show when={state.licenseRequired() && !state.showBlockedBanner()}>+ <Show when={!demoModeEnabled() && state.licenseRequired() && !state.showBlockedBanner()}><div class="flex-shrink-0 bg-blue-50 dark:bg-blue-900 border-b border-blue-200 dark:border-blue-800 px-3 py-2"><div class="flex flex-wrap items-center justify-between gap-2"><p class="text-xs text-blue-700 dark:text-blue-300">@@ -82,7 +83,7 @@ export function PatrolIntelligenceBanners(props: { state: PatrolIntelligenceStat<SettingsIcon class="w-3.5 h-3.5" />Open AI Settings</a>- <Show when={state.licenseRequired()}>+ <Show when={!demoModeEnabled() && state.licenseRequired()}><UpgradeLinkdestination={state.upgradeDestination()}class="inline-flex items-center justify-center gap-2 px-3 py-1.5 text-xs font-semibold text-white bg-amber-600 hover:bg-amber-700 rounded-md transition-colors"diff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsxindex 1c4b54603d..d2ca14c909 100644--- a/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx@@ -9,6 +9,7 @@ import { PageHeader } from '@/components/shared/PageHeader';import { UpgradeLink } from '@/components/shared/UpgradeLink';import { Toggle, TogglePrimitive } from '@/components/shared/Toggle';import { CountdownTimer } from '@/components/patrol';+import { demoModeEnabled } from '@/stores/demoMode';import { formatRelativeTime } from '@/utils/format';import { groupModelsByProvider } from '@/utils/patrolFormat';import {@@ -268,7 +269,7 @@ export function PatrolIntelligenceHeader(props: { state: PatrolIntelligenceStateonClick={() => state.handleAutonomyChange(level)}disabled={isDisabled()}title={- isProLocked()+ !demoModeEnabled() && isProLocked()? level === 'approval'? 'Upgrade to Pro to investigate findings': 'Upgrade to Pro for automatic fixes'@@ -286,7 +287,7 @@ export function PatrolIntelligenceHeader(props: { state: PatrolIntelligenceState}}</For></div>- <Show when={state.autoFixLocked()}>+ <Show when={!demoModeEnabled() && state.autoFixLocked()}><div class="pl-1 text-[11px] text-slate-500"><UpgradeLinkdestination={state.upgradeDestination()}@@ -329,7 +330,7 @@ export function PatrolIntelligenceHeader(props: { state: PatrolIntelligenceState/></div>- <Show when={state.alertAnalysisLocked()}>+ <Show when={!demoModeEnabled() && state.alertAnalysisLocked()}><div class="-my-1 pl-1 text-[11px]"><UpgradeLinkdestination={state.alertAnalysisUpgradeDestination()}diff --git a/frontend-modern/src/features/patrol/__tests__/patrolCommercialBoundary.test.ts b/frontend-modern/src/features/patrol/__tests__/patrolCommercialBoundary.test.tsnew file mode 100644index 0000000000..75c2ac6c09--- /dev/null+++ b/frontend-modern/src/features/patrol/__tests__/patrolCommercialBoundary.test.ts@@ -0,0 +1,20 @@+import { describe, expect, it } from 'vitest';+import patrolIntelligenceBannersSource from '../PatrolIntelligenceBanners.tsx?raw';+import patrolIntelligenceHeaderSource from '../PatrolIntelligenceHeader.tsx?raw';++describe('patrol commercial boundary', () => {+ it('suppresses patrol upgrade surfaces in demo mode', () => {+ expect(patrolIntelligenceBannersSource).toContain('demoModeEnabled');+ expect(patrolIntelligenceBannersSource).toContain(+ '!demoModeEnabled() && state.licenseRequired()',+ );+ expect(patrolIntelligenceHeaderSource).toContain('demoModeEnabled');+ expect(patrolIntelligenceHeaderSource).toContain(+ '!demoModeEnabled() && state.autoFixLocked()',+ );+ expect(patrolIntelligenceHeaderSource).toContain(+ '!demoModeEnabled() && state.alertAnalysisLocked()',+ );+ expect(patrolIntelligenceHeaderSource).toContain('!demoModeEnabled() && isProLocked()');+ });+});diff --git a/frontend-modern/src/stores/demoMode.ts b/frontend-modern/src/stores/demoMode.tsindex fdec782b79..56bfc504f1 100644--- a/frontend-modern/src/stores/demoMode.ts+++ b/frontend-modern/src/stores/demoMode.ts@@ -1,52 +1,18 @@-import { createSignal } from 'solid-js';-import { logger } from '@/utils/logger';--const [demoModeEnabled, setDemoModeEnabled] = createSignal(false);-const [demoModeResolved, setDemoModeResolved] = createSignal(false);--let pendingDemoModeCheck: Promise<boolean> | null = null;--function applyDemoModeHeaderValue(value: string | null): boolean {- const enabled = value === 'true';- setDemoModeEnabled(enabled);- setDemoModeResolved(true);- return enabled;+import type { SecurityStatus } from '@/types/config';+import {+ sessionCapabilities,+ sessionCapabilitiesResolved as demoModeResolved,+ syncSessionCapabilities,+} from '@/stores/sessionCapabilities';++export function syncDemoModeFromSecurityStatus(+ status?: Pick<SecurityStatus, 'sessionCapabilities'> | null,+): boolean {+ return syncSessionCapabilities(status).demoMode;}-export function syncDemoModeFromResponse(response: Response): boolean {- return applyDemoModeHeaderValue(response.headers.get('X-Demo-Mode'));-}--export async function ensureDemoModeResolved(force = false): Promise<boolean> {- if (demoModeResolved() && !force) {- return demoModeEnabled();- }- if (pendingDemoModeCheck && !force) {- return pendingDemoModeCheck;- }-- pendingDemoModeCheck = fetch('/api/health', {- method: 'GET',- cache: 'no-store',- credentials: 'include',- headers: {- Accept: 'application/json',- 'X-Requested-With': 'XMLHttpRequest',- },- })- .then((response) => syncDemoModeFromResponse(response))- .catch((error) => {- logger.debug('[demoModeStore] Failed to resolve demo mode from /api/health', error);- if (!demoModeResolved()) {- setDemoModeResolved(true);- }- return demoModeEnabled();- })- .finally(() => {- pendingDemoModeCheck = null;- });-- return pendingDemoModeCheck;+export function demoModeEnabled(): boolean {+ return sessionCapabilities().demoMode;}-export { demoModeEnabled, demoModeResolved };+export { demoModeResolved };diff --git a/frontend-modern/src/stores/sessionCapabilities.ts b/frontend-modern/src/stores/sessionCapabilities.tsnew file mode 100644index 0000000000..9e8acbb16a--- /dev/null+++ b/frontend-modern/src/stores/sessionCapabilities.ts@@ -0,0 +1,31 @@+import { createSignal } from 'solid-js';+import type { SecurityStatus, SecurityStatusSessionCapabilities } from '@/types/config';++const DEFAULT_SESSION_CAPABILITIES: SecurityStatusSessionCapabilities = {+ demoMode: false,+};++const [sessionCapabilities, setSessionCapabilities] = createSignal<SecurityStatusSessionCapabilities>(+ { ...DEFAULT_SESSION_CAPABILITIES },+);+const [sessionCapabilitiesResolved, setSessionCapabilitiesResolved] = createSignal(false);++function normalizeSessionCapabilities(+ capabilities?: Partial<SecurityStatusSessionCapabilities> | null,+): SecurityStatusSessionCapabilities {+ return {+ ...DEFAULT_SESSION_CAPABILITIES,+ demoMode: capabilities?.demoMode === true,+ };+}++export function syncSessionCapabilities(+ status?: Pick<SecurityStatus, 'sessionCapabilities'> | null,+): SecurityStatusSessionCapabilities {+ const next = normalizeSessionCapabilities(status?.sessionCapabilities);+ setSessionCapabilities(next);+ setSessionCapabilitiesResolved(true);+ return next;+}++export { sessionCapabilities, sessionCapabilitiesResolved };diff --git a/frontend-modern/src/types/config.ts b/frontend-modern/src/types/config.tsindex e39bfd2204..c538a9f5c7 100644--- a/frontend-modern/src/types/config.ts+++ b/frontend-modern/src/types/config.ts@@ -117,6 +117,10 @@ export interface SecurityStatusSettingsCapabilities {billingAdmin: boolean;}+export interface SecurityStatusSessionCapabilities {+ demoMode: boolean;+}+export interface SecurityStatus {hasAuthentication: boolean;apiTokenConfigured: boolean;@@ -153,6 +157,7 @@ export interface SecurityStatus {ssoProviders?: SSOProviderInfo[];// Token auth scopes (for kiosk/limited-access mode)tokenScopes?: string[];+ sessionCapabilities?: SecurityStatusSessionCapabilities;settingsCapabilities?: SecurityStatusSettingsCapabilities;}diff --git a/frontend-modern/src/useAppRuntimeState.ts b/frontend-modern/src/useAppRuntimeState.tsindex 84640f0932..754e82321c 100644--- a/frontend-modern/src/useAppRuntimeState.ts+++ b/frontend-modern/src/useAppRuntimeState.ts@@ -52,6 +52,7 @@ import {licenseLoaded,loadLicenseStatus,} from '@/stores/license';+import { syncDemoModeFromSecurityStatus } from '@/stores/demoMode';import { layoutStore } from '@/utils/layout';import {markSystemSettingsLoadedWithDefaults,@@ -578,7 +579,9 @@ export const useAppRuntimeState = () => {localStorage.removeItem('just_logged_out');logger.debug('[App] User logged out, showing login page');if (securityResponse.ok) {- setSecurityStatus((await securityResponse.json()) as SecurityStatus);+ const securityData = (await securityResponse.json()) as SecurityStatus;+ syncDemoModeFromSecurityStatus(securityData);+ setSecurityStatus(securityData);}setHasAuth(true);setNeedsAuth(true);@@ -600,6 +603,7 @@ export const useAppRuntimeState = () => {ssoLogoutURL?: string;};logger.debug('[App] Security status fetched', securityData);+ syncDemoModeFromSecurityStatus(securityData);setSecurityStatus(securityData);const authConfigured = securityData.hasAuthentication || false;diff --git a/frontend-modern/src/utils/__tests__/apiClient.org.test.ts b/frontend-modern/src/utils/__tests__/apiClient.org.test.tsindex df6c94ebb7..d1dccc4f58 100644--- a/frontend-modern/src/utils/__tests__/apiClient.org.test.ts+++ b/frontend-modern/src/utils/__tests__/apiClient.org.test.ts@@ -67,25 +67,6 @@ describe('apiClient org context', () => {expect(headers['X-Pulse-Org-ID']).toBe('tenant-ledger');});- it('tracks demo mode from shared API response headers', async () => {- vi.resetModules();- mockFetch.mockResolvedValue(- new Response('{}', {- status: 200,- headers: { 'X-Demo-Mode': 'true' },- }),- );- global.fetch = mockFetch as unknown as typeof fetch;-- const apiClientModule = await import('@/utils/apiClient');- const demoModeModule = await import('@/stores/demoMode');-- await apiClientModule.apiFetch('/api/state');-- expect(demoModeModule.demoModeResolved()).toBe(true);- expect(demoModeModule.demoModeEnabled()).toBe(true);- });-it('uses default org context when skipOrgContext is enabled', async () => {mockFetch.mockResolvedValue(new Response('[]', { status: 200 }));diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.tsindex ce8c961bae..71b5c8b4b8 100644--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts@@ -1557,6 +1557,8 @@ describe('frontend resource type boundaries', () => {expect(billingAdminPanelSource).toContain('./useBillingAdminPanelState');expect(billingAdminPanelSource).toContain('./BillingAdminOrganizationsTable');expect(relayOnboardingCardSource).toContain('./useRelayOnboardingCardState');+ expect(relayOnboardingCardSource).toContain('demoModeEnabled');+ expect(relayOnboardingCardSource).toContain('!demoModeEnabled() || state.hasRelay()');expect(relayOnboardingCardSource).not.toContain('createSignal(');expect(relayOnboardingCardSource).not.toContain('RelayAPI.getStatus()');expect(relayOnboardingCardStateSource).toContain('RelayAPI.getStatus()');@@ -3179,7 +3181,11 @@ describe('frontend resource type boundaries', () => {expect(historyChartModelSource).toContain('getHistoryChartScale');expect(historyChartHeaderSource).toContain('formatHistoryChartTooltipValue');expect(historyChartOverlaySource).toContain('Collecting data... History will appear here.');+ expect(historyChartOverlaySource).toContain('demoModeEnabled');expect(historyChartOverlaySource).toContain('Unlock {props.chart.lockTierLabel()} Features');+ expect(historyChartOverlaySource).toContain(+ 'Historical data beyond {props.chart.lockDays()} days is hidden in this demo.',+ );expect(historyChartTooltipSource).toContain('formatHistoryChartTooltipValue');expect(containerUpdateBadgeSource).toContain('useContainerUpdateButtonState');expect(containerUpdateBadgeSource).toContain('getUpdateButtonClass');@@ -4396,6 +4402,17 @@ describe('frontend resource type boundaries', () => {expect(patrolIntelligenceSurfaceSource).toContain('./PatrolIntelligenceBanners');expect(patrolIntelligenceSurfaceSource).toContain('./PatrolIntelligenceSummary');expect(patrolIntelligenceSurfaceSource).toContain('./PatrolIntelligenceWorkspace');+ expect(patrolIntelligenceBannersSource).toContain('demoModeEnabled');+ expect(patrolIntelligenceBannersSource).toContain(+ '!demoModeEnabled() && state.licenseRequired()',+ );+ expect(patrolIntelligenceHeaderSource).toContain('demoModeEnabled');+ expect(patrolIntelligenceHeaderSource).toContain(+ '!demoModeEnabled() && state.autoFixLocked()',+ );+ expect(patrolIntelligenceHeaderSource).toContain(+ '!demoModeEnabled() && state.alertAnalysisLocked()',+ );expect(operationsPageRouteSource).toContain("import { OperationsPageSurface } from '@/features/operations/OperationsPageSurface';",);diff --git a/frontend-modern/src/utils/apiClient.ts b/frontend-modern/src/utils/apiClient.tsindex 2aee5dc24d..d345c42547 100644--- a/frontend-modern/src/utils/apiClient.ts+++ b/frontend-modern/src/utils/apiClient.ts@@ -2,7 +2,6 @@// This replaces the three separate auth utilities (api.ts, auth.ts, authInterceptor.ts)import { logger } from '@/utils/logger';-import { syncDemoModeFromResponse } from '@/stores/demoMode';import { STORAGE_KEYS } from '@/utils/localStorage';const AUTH_STORAGE_KEY = STORAGE_KEYS.AUTH;@@ -627,12 +626,7 @@ class ApiClient {credentials: 'include', // Important for session cookies};- const observeDemoMode = (response: Response): Response => {- syncDemoModeFromResponse(response);- return response;- };-- const response = observeDemoMode(await fetch(url, finalOptions));+ const response = await fetch(url, finalOptions);// Handle stale/invalid org context by clearing it and retrying once against default org.if (@@ -655,13 +649,11 @@ class ApiClient {this.setOrgID(null);const retryHeaders: Record<string, string> = { ...finalHeaders };delete retryHeaders[ORG_HEADER_NAME];- return observeDemoMode(- await fetch(url, {+ return await fetch(url, {...fetchOptions,headers: retryHeaders,credentials: 'include',- }),- );+ });}}@@ -702,11 +694,11 @@ class ApiClient {this.csrfToken = refreshedToken;logger.debug(`[apiClient] Retrying ${method} ${url} with refreshed CSRF token`);finalHeaders['X-CSRF-Token'] = refreshedToken;- const retryResponse = observeDemoMode(await fetch(url, {+ const retryResponse = await fetch(url, {...fetchOptions,headers: finalHeaders,credentials: 'include',- }));+ });return retryResponse;}}@@ -748,11 +740,11 @@ class ApiClient {throw err;}- return observeDemoMode(await fetch(url, {+ return await fetch(url, {...fetchOptions,headers: finalHeaders,credentials: 'include',- }));+ });}return response;diff --git a/internal/api/contract_test.go b/internal/api/contract_test.goindex 91e0e96e8a..4838e5021d 100644--- a/internal/api/contract_test.go+++ b/internal/api/contract_test.go@@ -5963,6 +5963,33 @@ func TestContract_SetupScriptURLResponseJSONSnapshot(t *testing.T) {assertJSONSnapshot(t, got, want)}+func TestContract_SecurityStatusIncludesSessionCapabilitiesDemoMode(t *testing.T) {+ cfg := newTestConfigWithTokens(t)+ cfg.DemoMode = true++ router := NewRouter(cfg, nil, nil, nil, nil, "1.0.0")++ req := httptest.NewRequest(http.MethodGet, "/api/security/status", nil)+ rec := httptest.NewRecorder()+ router.Handler().ServeHTTP(rec, req)+ if rec.Code != http.StatusOK {+ t.Fatalf("security status = %d, want 200 (%s)", rec.Code, rec.Body.String())+ }++ var payload map[string]any+ if err := json.Unmarshal(rec.Body.Bytes(), &payload); err != nil {+ t.Fatalf("decode security status payload: %v", err)+ }++ sessionCapabilities, ok := payload["sessionCapabilities"].(map[string]any)+ if !ok {+ t.Fatalf("sessionCapabilities = %#v, want object", payload["sessionCapabilities"])+ }+ if got, _ := sessionCapabilities["demoMode"].(bool); !got {+ t.Fatalf("sessionCapabilities.demoMode = %v, want true", sessionCapabilities["demoMode"])+ }+}+func TestContract_SetupScriptURLRejectsNonCanonicalRequestJSON(t *testing.T) {handler := newTestConfigHandlers(t, &config.Config{DataPath: t.TempDir()})diff --git a/internal/api/router_routes_auth_security.go b/internal/api/router_routes_auth_security.goindex 171bab150b..79ec551d09 100644--- a/internal/api/router_routes_auth_security.go+++ b/internal/api/router_routes_auth_security.go@@ -288,6 +288,7 @@ func (r *Router) registerAuthSecurityInstallRoutes() {"ssoSessionUsername": ssoSessionUsername,"hideLocalLogin": r.config.HideLocalLogin,"agentUrl": agentURL,+ "sessionCapabilities": r.securityStatusSessionCapabilities(),"settingsCapabilities": r.securityStatusSettingsCapabilitiesFromSnapshot(authSnapshot),}diff --git a/internal/api/security_status_additional_test.go b/internal/api/security_status_additional_test.goindex dc05427d9e..d6414f5218 100644--- a/internal/api/security_status_additional_test.go+++ b/internal/api/security_status_additional_test.go@@ -385,3 +385,28 @@ func TestSecurityStatusRestrictsSessionCapabilitiesToConfiguredAdmin(t *testing.t.Fatalf("did not expect audit capability for non-admin session user")}}++func TestSecurityStatusIncludesDemoModeSessionCapabilities(t *testing.T) {+ t.Setenv("PULSE_DATA_DIR", t.TempDir())+ cfg := &config.Config{DemoMode: true}+ router := NewRouter(cfg, nil, nil, nil, nil, "1.0.0")++ req := httptest.NewRequest(http.MethodGet, "/api/security/status", nil)+ rec := httptest.NewRecorder()+ router.Handler().ServeHTTP(rec, req)++ if rec.Code != http.StatusOK {+ t.Fatalf("expected 200 for security status, got %d", rec.Code)+ }++ var payload struct {+ SessionCapabilities securityStatusSessionCapabilities `json:"sessionCapabilities"`+ }+ if err := json.Unmarshal(rec.Body.Bytes(), &payload); err != nil {+ t.Fatalf("decode response: %v", err)+ }++ if !payload.SessionCapabilities.DemoMode {+ t.Fatalf("expected sessionCapabilities.demoMode to be true, got %#v", payload.SessionCapabilities)+ }+}diff --git a/internal/api/security_status_capabilities.go b/internal/api/security_status_capabilities.goindex 845ee62971..2c1c8e921c 100644--- a/internal/api/security_status_capabilities.go+++ b/internal/api/security_status_capabilities.go@@ -25,6 +25,10 @@ type securityStatusSettingsCapabilities struct {BillingAdmin bool `json:"billingAdmin"`}+type securityStatusSessionCapabilities struct {+ DemoMode bool `json:"demoMode"`+}+type securityStatusAuthSnapshot struct {request *http.Requestauthenticated bool@@ -226,3 +230,9 @@ func (r *Router) securityStatusSettingsCapabilitiesFromSnapshot(snapshot securitfunc (r *Router) securityStatusSettingsCapabilities(req *http.Request) securityStatusSettingsCapabilities {return r.securityStatusSettingsCapabilitiesFromSnapshot(r.buildSecurityStatusAuthSnapshot(req))}++func (r *Router) securityStatusSessionCapabilities() securityStatusSessionCapabilities {+ return securityStatusSessionCapabilities{+ DemoMode: r != nil && r.config != nil && r.config.DemoMode,+ }+}diff --git a/scripts/release_control/subsystem_lookup_test.py b/scripts/release_control/subsystem_lookup_test.pyindex ef23fbfa2d..424be7b15f 100644--- a/scripts/release_control/subsystem_lookup_test.py+++ b/scripts/release_control/subsystem_lookup_test.py@@ -3709,8 +3709,8 @@ class SubsystemLookupTest(unittest.TestCase):{"heading": "## Shared Boundaries","path": "internal/api/access_control_handlers.go",- "line": 111,- "heading_line": 79,+ "line": 112,+ "heading_line": 80,}],)diff --git a/tests/integration/tests/53-demo-mode-commercial-boundary.spec.ts b/tests/integration/tests/53-demo-mode-commercial-boundary.spec.tsnew file mode 100644index 0000000000..c564ed5713--- /dev/null+++ b/tests/integration/tests/53-demo-mode-commercial-boundary.spec.ts@@ -0,0 +1,221 @@+import fs from 'node:fs';+import path from 'node:path';+import { fileURLToPath } from 'node:url';+import { expect, test as base } from '@playwright/test';+import { createAuthenticatedStorageState } from './helpers';++const __dirname = path.dirname(fileURLToPath(import.meta.url));++type WorkerFixtures = {+ authStorageStatePath: string;+};++const SECURITY_STATUS_DEMO_PAYLOAD = {+ hasAuthentication: true,+ hideLocalLogin: false,+ ssoProviders: [],+ sessionCapabilities: {+ demoMode: true,+ },+};++const DEMO_COMMERCIAL_ENTITLEMENTS = {+ capabilities: ['ai_patrol', 'relay'],+ limits: [+ {+ key: 'max_monitored_systems',+ limit: 5,+ current: 16,+ state: 'enforced',+ },+ ],+ subscription_state: 'trial',+ upgrade_reasons: [+ {+ key: 'max_monitored_systems',+ reason: 'Upgrade to monitor more systems.',+ action_url: '/settings/system/billing#plan',+ },+ {+ key: 'trial_banner',+ reason: 'Upgrade to keep Pro features active.',+ action_url: '/settings/system/billing#plan',+ },+ ],+ tier: 'pro',+ hosted_mode: false,+ trial_days_remaining: 7,+ trial_eligible: false,+ legacy_connections: {+ proxmox_nodes: 0,+ docker_hosts: 0,+ kubernetes_clusters: 0,+ },+ has_migration_gap: false,+};++const authenticatedTest = base.extend<{}, WorkerFixtures>({+ storageState: async ({ authStorageStatePath }, use) => {+ await use(authStorageStatePath);+ },+ authStorageStatePath: [async ({ browser }, use, workerInfo) => {+ const storageStatePath = path.resolve(+ __dirname,+ '..',+ '..',+ 'tmp',+ 'playwright-auth',+ `demo-mode-commercial-boundary-${workerInfo.project.name}.json`,+ );+ fs.mkdirSync(path.dirname(storageStatePath), { recursive: true });+ await createAuthenticatedStorageState(browser, storageStatePath);+ try {+ await use(storageStatePath);+ } finally {+ fs.rmSync(storageStatePath, { force: true });+ }+ }, { scope: 'worker' }],+});++base.describe('Demo mode commercial boundary', () => {+ base.setTimeout(180_000);++ base('shows demo credentials on the login page from session capabilities', async ({+ page,+ }, testInfo) => {+ await page.route('**/api/state', async (route) => {+ await route.fulfill({+ status: 401,+ contentType: 'application/json',+ body: JSON.stringify({ error: 'authentication required' }),+ });+ });++ await page.route('**/api/security/status', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify(SECURITY_STATUS_DEMO_PAYLOAD),+ });+ });++ await page.goto('/', { waitUntil: 'domcontentloaded' });++ await expect(page.locator('input[name="username"]')).toBeVisible();+ await expect(page.getByText('Demo Mode', { exact: true })).toBeVisible();+ await expect(page.getByText('Login with', { exact: false })).toBeVisible();+ await expect(page.getByText('demo', { exact: true }).first()).toBeVisible();++ const screenshotPath = path.resolve(+ __dirname,+ '..',+ '..',+ 'tmp',+ `demo-mode-login-${testInfo.project.name}.png`,+ );+ fs.mkdirSync(path.dirname(screenshotPath), { recursive: true });+ await page.screenshot({ path: screenshotPath, fullPage: true });+ });++ authenticatedTest(+ 'hides billing surfaces and commercial prompts in the authenticated demo shell',+ async ({+ page,+ }, testInfo) => {+ let entitlementsRequests = 0;+ let licenseStatusRequests = 0;+ let monitoredSystemLedgerRequests = 0;+ let billingStateRequests = 0;++ await page.addInitScript(() => {+ localStorage.setItem('pulse_whats_new_v2_shown', 'true');+ });++ await page.route('**/api/security/status', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify(SECURITY_STATUS_DEMO_PAYLOAD),+ });+ });++ await page.route('**/api/license/entitlements', async (route) => {+ entitlementsRequests += 1;+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify(DEMO_COMMERCIAL_ENTITLEMENTS),+ });+ });++ await page.route('**/api/license/status', async (route) => {+ licenseStatusRequests += 1;+ await route.fulfill({+ status: 404,+ contentType: 'application/json',+ body: JSON.stringify({ error: 'not found' }),+ });+ });++ await page.route('**/api/license/monitored-system-ledger', async (route) => {+ monitoredSystemLedgerRequests += 1;+ await route.fulfill({+ status: 404,+ contentType: 'application/json',+ body: JSON.stringify({ error: 'not found' }),+ });+ });++ await page.route('**/api/admin/orgs/**/billing-state', async (route) => {+ billingStateRequests += 1;+ await route.fulfill({+ status: 404,+ contentType: 'application/json',+ body: JSON.stringify({ error: 'not found' }),+ });+ });++ await page.goto('/settings/system/billing', { waitUntil: 'domcontentloaded' });+ await page.waitForURL('**/settings/infrastructure/install', { timeout: 15_000 });++ await expect+ .poll(() => entitlementsRequests, { message: 'expected demo shell to load entitlements' })+ .toBeGreaterThan(0);++ await expect(+ page.getByText('Demo instance with mock data (read-only)', { exact: true }),+ ).toBeVisible();+ await expect(page.getByRole('heading', { level: 1, name: 'Infrastructure Operations' })).toBeVisible();+ const settingsNavigation = page.locator('[aria-label="Settings navigation"]');+ await expect(settingsNavigation).toBeVisible();+ await expect(+ settingsNavigation.getByText('Pulse Pro', { exact: true }),+ ).toHaveCount(0);+ await expect(page.getByText('Pro Trial:', { exact: false })).toHaveCount(0);+ await expect(page.getByText('Monitored systems: 16/5', { exact: true })).toHaveCount(0);+ await expect(+ page+ .locator('[role="tab"]')+ .filter({ hasText: 'Settings' })+ .getByText('Pro', { exact: true }),+ ).toHaveCount(0);++ expect(licenseStatusRequests, 'demo settings route should not read license status').toBe(0);+ expect(+ monitoredSystemLedgerRequests,+ 'demo settings route should not read the monitored-system ledger',+ ).toBe(0);+ expect(billingStateRequests, 'demo settings route should not read hosted billing state').toBe(0);++ const screenshotPath = path.resolve(+ __dirname,+ '..',+ '..',+ 'tmp',+ `demo-mode-settings-${testInfo.project.name}.png`,+ );+ fs.mkdirSync(path.dirname(screenshotPath), { recursive: true });+ await page.screenshot({ path: screenshotPath, fullPage: true });+ },+ );+});