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
Split relay settings runtime owners
rcourtman38aebe666a3c
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.mdindex d98a77d86a..5a6253dd16 100644--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md@@ -54,10 +54,12 @@ agreement, and cloud-specific enforcement rules.32. `frontend-modern/src/components/Settings/CommercialBillingSections.tsx`33. `frontend-modern/src/components/Settings/SelfHostedCommercialActivationSection.tsx`34. `frontend-modern/src/components/Settings/RelaySettingsPanel.tsx`-35. `frontend-modern/src/components/Settings/useOrganizationBillingPanelState.ts`-36. `frontend-modern/src/pages/CloudPricing.tsx`-37. `frontend-modern/src/utils/apiClient.ts`-38. `frontend-modern/src/utils/commercialBillingModel.ts`+35. `frontend-modern/src/components/Settings/RelayPairingSection.tsx`+36. `frontend-modern/src/components/Settings/useOrganizationBillingPanelState.ts`+37. `frontend-modern/src/components/Settings/useRelaySettingsPanelState.ts`+38. `frontend-modern/src/pages/CloudPricing.tsx`+39. `frontend-modern/src/utils/apiClient.ts`+40. `frontend-modern/src/utils/commercialBillingModel.ts`## Shared Boundaries@@ -82,7 +84,7 @@ agreement, and cloud-specific enforcement rules.12. Add or change shared commercial plan/usage presentation through `frontend-modern/src/components/Settings/CommercialBillingSections.tsx` and `frontend-modern/src/utils/commercialBillingModel.ts`13. Add or change organization billing and usage presentation through `frontend-modern/src/components/Settings/OrganizationBillingPanel.tsx`, `frontend-modern/src/components/Settings/OrganizationBillingLoadingState.tsx`, and `frontend-modern/src/components/Settings/useOrganizationBillingPanelState.ts`14. Add or change self-hosted Pro activation, trial, and entitlement actions through `frontend-modern/src/components/Settings/ProLicensePanel.tsx` and `frontend-modern/src/components/Settings/SelfHostedCommercialActivationSection.tsx`-15. Add or change paid relay settings and onboarding presentation through `frontend-modern/src/components/Settings/RelaySettingsPanel.tsx` and `frontend-modern/src/components/Dashboard/RelayOnboardingCard.tsx`+15. Add or change paid relay settings and onboarding presentation through `frontend-modern/src/components/Settings/RelaySettingsPanel.tsx`, `frontend-modern/src/components/Settings/RelayPairingSection.tsx`, `frontend-modern/src/components/Settings/useRelaySettingsPanelState.ts`, and `frontend-modern/src/components/Dashboard/RelayOnboardingCard.tsx`16. Add or change cloud plan presentation through `frontend-modern/src/pages/CloudPricing.tsx`17. Add contract tests where runtime and pricing need to stay aligned18. Add or change hosted browser org-context bootstrap through `frontend-modern/src/App.tsx`, `frontend-modern/src/AppLayout.tsx`, `frontend-modern/src/useAppRuntimeState.ts`, and `frontend-modern/src/utils/apiClient.ts`@@ -290,6 +292,13 @@ ownership model. Changes to`frontend-modern/src/components/Dashboard/RelayOnboardingCard.tsx` must carrythis contract and the dedicated relay frontend proof files instead ofremaining unowned consumers of relay licensing and onboarding state.+That relay settings owner is now intentionally split by role as well:+`frontend-modern/src/components/Settings/RelaySettingsPanel.tsx` is the+settings shell, `frontend-modern/src/components/Settings/useRelaySettingsPanelState.ts`+owns relay config/status polling, trial, and pairing runtime, and+`frontend-modern/src/components/Settings/RelayPairingSection.tsx` owns the QR+pairing surface. Future relay settings work must extend that split instead of+pulling polling and QR-generation lifecycle back into the shell component.That relay pairing boundary now also includes ephemeral device-token lifecycle:when the settings surface generates a mobile pairing QR, it must mint a freshscoped API token for that pairing attempt, fetch the onboarding payload throughdiff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.jsonindex 31506260fc..167cfc966b 100644--- a/docs/release-control/v6/internal/subsystems/registry.json+++ b/docs/release-control/v6/internal/subsystems/registry.json@@ -1097,8 +1097,10 @@"frontend-modern/src/components/Settings/OrganizationBillingLoadingState.tsx","frontend-modern/src/components/Settings/OrganizationBillingPanel.tsx","frontend-modern/src/components/Settings/ProLicensePanel.tsx",+ "frontend-modern/src/components/Settings/RelayPairingSection.tsx","frontend-modern/src/components/Settings/RelaySettingsPanel.tsx","frontend-modern/src/components/Settings/useOrganizationBillingPanelState.ts",+ "frontend-modern/src/components/Settings/useRelaySettingsPanelState.ts","frontend-modern/src/pages/CloudPricing.tsx","frontend-modern/src/pages/HostedSignup.tsx","frontend-modern/src/useAppRuntimeState.ts",@@ -1530,7 +1532,9 @@"match_prefixes": [],"match_files": ["frontend-modern/src/components/Dashboard/RelayOnboardingCard.tsx",- "frontend-modern/src/components/Settings/RelaySettingsPanel.tsx"+ "frontend-modern/src/components/Settings/RelayPairingSection.tsx",+ "frontend-modern/src/components/Settings/RelaySettingsPanel.tsx",+ "frontend-modern/src/components/Settings/useRelaySettingsPanelState.ts"],"allow_same_subsystem_tests": false,"test_prefixes": [],diff --git a/frontend-modern/src/components/Settings/RelayPairingSection.tsx b/frontend-modern/src/components/Settings/RelayPairingSection.tsxnew file mode 100644index 0000000000..ed6320a8f0--- /dev/null+++ b/frontend-modern/src/components/Settings/RelayPairingSection.tsx@@ -0,0 +1,99 @@+import { Component, For, Show } from 'solid-js';+import type { OnboardingQRResponse } from '@/api/onboarding';+import { Card } from '@/components/shared/Card';+import { formField, formHelpText, labelClass } from '@/components/shared/Form';+import {+ getRelayDiagnosticClass,+ RELAY_CODE_BLOCK_CLASS,+ RELAY_DIAGNOSTICS_TITLE_CLASS,+ RELAY_DIAGNOSTICS_WRAP_CLASS,+ RELAY_PRIMARY_BUTTON_CLASS,+ RELAY_QR_IMAGE_CLASS,+ RELAY_SECONDARY_BUTTON_CLASS,+} from '@/utils/relayPresentation';++interface RelayPairingSectionProps {+ canManage: boolean;+ pairingLoading: boolean;+ pairingPayload: OnboardingQRResponse | null;+ pairingQRCode: string | null;+ saving: boolean;+ showPairing: boolean;+ onCopyPairingPayload: () => void;+ onPairNewDevice: () => void;+}++export const RelayPairingSection: Component<RelayPairingSectionProps> = (props) => (+ <div class={formField}>+ <label class={labelClass()}>Pair Mobile Device</label>+ <Card tone="muted" padding="md">+ <div class="space-y-3">+ <div class="flex flex-wrap items-center gap-2">+ <button+ class={RELAY_PRIMARY_BUTTON_CLASS}+ onClick={props.onPairNewDevice}+ disabled={!props.canManage || props.saving || props.pairingLoading}+ >+ {props.pairingLoading+ ? 'Generating QR code...'+ : props.showPairing+ ? 'Refresh QR Code'+ : 'Pair New Device'}+ </button>+ <Show when={props.showPairing && props.pairingPayload}>+ <button+ class={RELAY_SECONDARY_BUTTON_CLASS}+ onClick={props.onCopyPairingPayload}+ disabled={!props.canManage || props.pairingLoading}+ >+ Copy Payload+ </button>+ </Show>+ </div>++ <p class={formHelpText}>+ Generate a QR code for pairing during staged mobile beta rollout.+ </p>++ <Show when={props.showPairing}>+ <div class="space-y-3">+ <Show when={props.pairingLoading}>+ <p class="text-sm text-muted">Preparing pairing payload...</p>+ </Show>++ <Show when={!props.pairingLoading && props.pairingQRCode}>+ <img+ src={props.pairingQRCode!}+ alt="Pulse mobile pairing QR code"+ width="256"+ height="256"+ class={RELAY_QR_IMAGE_CLASS}+ />+ </Show>++ <Show when={props.pairingPayload?.deep_link}>+ <code class={RELAY_CODE_BLOCK_CLASS}>{props.pairingPayload!.deep_link}</code>+ </Show>++ <Show when={(props.pairingPayload?.diagnostics?.length ?? 0) > 0}>+ <div class={RELAY_DIAGNOSTICS_WRAP_CLASS}>+ <p class={RELAY_DIAGNOSTICS_TITLE_CLASS}>Diagnostics</p>+ <For each={props.pairingPayload?.diagnostics ?? []}>+ {(diagnostic) => (+ <div class={getRelayDiagnosticClass(diagnostic.severity)}>+ <p class="font-medium">{diagnostic.message}</p>+ <p class="mt-0.5 font-mono">+ {diagnostic.code}+ <Show when={diagnostic.field}> | field: {diagnostic.field}</Show>+ </p>+ </div>+ )}+ </For>+ </div>+ </Show>+ </div>+ </Show>+ </div>+ </Card>+ </div>+);diff --git a/frontend-modern/src/components/Settings/RelaySettingsPanel.tsx b/frontend-modern/src/components/Settings/RelaySettingsPanel.tsxindex d416e413c5..b6cee12427 100644--- a/frontend-modern/src/components/Settings/RelaySettingsPanel.tsx+++ b/frontend-modern/src/components/Settings/RelaySettingsPanel.tsx@@ -1,273 +1,39 @@-import { Component, createSignal, createEffect, onMount, onCleanup, Show } from 'solid-js';+import { Component, Show } from 'solid-js';import RadioTower from 'lucide-solid/icons/radio-tower';import SettingsPanel from '@/components/shared/SettingsPanel';import { StatusDot } from '@/components/shared/StatusDot';import { Toggle } from '@/components/shared/Toggle';import { Card } from '@/components/shared/Card';import { formField, labelClass, controlClass, formHelpText } from '@/components/shared/Form';-import {- hasFeature,- licenseLoaded,- loadLicenseStatus,- getUpgradeActionUrlOrFallback,- startProTrial,- entitlements,-} from '@/stores/license';-import { trackPaywallViewed, trackUpgradeClicked } from '@/utils/upgradeMetrics';-import { showSuccess, showError } from '@/utils/toast';-import { RelayAPI, type RelayConfig, type RelayStatus } from '@/api/relay';-import { OnboardingAPI, type OnboardingQRResponse } from '@/api/onboarding';-import { SecurityAPI } from '@/api/security';-import { logger } from '@/utils/logger';+import { trackUpgradeClicked } from '@/utils/upgradeMetrics';import { getSettingsConfigurationLoadingState } from '@/utils/settingsShellPresentation';import {- getRelayConnectionPresentation,- getRelayDiagnosticClass,RELAY_BETA_MESSAGE_CLASS,RELAY_BETA_TITLE_CLASS,- RELAY_CODE_BLOCK_CLASS,- RELAY_DIAGNOSTICS_TITLE_CLASS,- RELAY_DIAGNOSTICS_WRAP_CLASS,RELAY_INLINE_ACTION_CLASS,RELAY_LAST_ERROR_CLASS,RELAY_PRIMARY_BUTTON_CLASS,RELAY_PRIMARY_LINK_CLASS,- RELAY_QR_IMAGE_CLASS,RELAY_READONLY_NOTICE_CLASS,- RELAY_SECONDARY_BUTTON_CLASS,} from '@/utils/relayPresentation';-import QRCode from 'qrcode';--interface RelaySettingsPanelProps {- canManage?: boolean;-}--function buildRelayPairingTokenName(now: Date): string {- return `Relay mobile device ${now.toISOString()}`;-}+import { RelayPairingSection } from './RelayPairingSection';+import {+ useRelaySettingsPanelState,+ type RelaySettingsPanelProps,+} from './useRelaySettingsPanelState';export const RelaySettingsPanel: Component<RelaySettingsPanelProps> = (props) => {- const [config, setConfig] = createSignal<RelayConfig | null>(null);- const [status, setStatus] = createSignal<RelayStatus | null>(null);- const [loading, setLoading] = createSignal(true);- const [saving, setSaving] = createSignal(false);- const [serverUrl, setServerUrl] = createSignal('');- const [showPairing, setShowPairing] = createSignal(false);- const [pairingLoading, setPairingLoading] = createSignal(false);- const [pairingPayload, setPairingPayload] = createSignal<OnboardingQRResponse | null>(null);- const [pairingQRCode, setPairingQRCode] = createSignal<string | null>(null);- const [pairingTokenId, setPairingTokenId] = createSignal<string | null>(null);- const [startingTrial, setStartingTrial] = createSignal(false);- const canManage = () => props.canManage !== false;-- const canStartTrial = () => entitlements()?.trial_eligible !== false;-- const handleStartTrial = async () => {- if (startingTrial()) return;- setStartingTrial(true);- try {- const result = await startProTrial();- if (result?.outcome === 'redirect') {- window.location.href = result.actionUrl;- return;- }- showSuccess('Remote access trial started');- } catch (err) {- const statusCode = (err as { status?: number } | null)?.status;- if (statusCode === 409) {- showError('Trial already used');- } else {- showError(err instanceof Error ? err.message : 'Failed to start trial');- }- } finally {- setStartingTrial(false);- }- };-- createEffect((wasPaywallVisible: boolean) => {- const isPaywallVisible = licenseLoaded() && !hasFeature('relay');- if (isPaywallVisible && !wasPaywallVisible) {- trackPaywallViewed('relay', 'settings_relay_panel');- }- return isPaywallVisible;- }, false);-- let statusInterval: ReturnType<typeof setInterval> | undefined;-- const resetPairingState = () => {- setShowPairing(false);- setPairingLoading(false);- setPairingPayload(null);- setPairingQRCode(null);- setPairingTokenId(null);- };-- const deletePairingToken = async (tokenID: string | null) => {- if (!tokenID) return;- try {- await SecurityAPI.deleteToken(tokenID);- } catch (err) {- logger.warn('[RelaySettings] Failed to clean up relay pairing token', err);- }- };-- const loadConfig = async () => {- try {- const cfg = await RelayAPI.getConfig();- setConfig(cfg);- setServerUrl(cfg.server_url);- if (!cfg.enabled) {- resetPairingState();- }- } catch (err) {- logger.error('[RelaySettings] Failed to load config', err);- }- };-- const loadStatus = async () => {- try {- const st = await RelayAPI.getStatus();- setStatus(st);- } catch (err) {- logger.error('[RelaySettings] Failed to load status', err);- }- };-- const startStatusPolling = () => {- stopStatusPolling();- void loadStatus();- statusInterval = setInterval(() => void loadStatus(), 5000);- };-- const stopStatusPolling = () => {- if (statusInterval !== undefined) {- clearInterval(statusInterval);- statusInterval = undefined;- }- };-- onMount(async () => {- await loadLicenseStatus();- if (!hasFeature('relay')) {- setLoading(false);- return;- }- await loadConfig();- if (config()?.enabled) {- startStatusPolling();- }- setLoading(false);- });-- onCleanup(() => {- stopStatusPolling();- });-- const handleToggleEnabled = async (enabled: boolean) => {- if (!canManage()) return;- setSaving(true);- try {- await RelayAPI.updateConfig({ enabled });- await loadConfig();- if (enabled) {- startStatusPolling();- showSuccess('Remote access enabled');- } else {- stopStatusPolling();- setStatus(null);- resetPairingState();- showSuccess('Remote access disabled');- }- } catch (err) {- showError('Failed to update relay configuration');- logger.error('[RelaySettings] Failed to toggle', err);- } finally {- setSaving(false);- }- };-- const handleSaveServerUrl = async () => {- if (!canManage()) return;- const url = serverUrl().trim();- if (!url) return;- setSaving(true);- try {- await RelayAPI.updateConfig({ server_url: url });- await loadConfig();- showSuccess('Server URL updated');- } catch (err) {- showError('Failed to update server URL');- logger.error('[RelaySettings] Failed to save server URL', err);- } finally {- setSaving(false);- }- };-- const handlePairNewDevice = async () => {- if (!canManage()) return;- const previousPayload = pairingPayload();- const previousQRCode = pairingQRCode();- const previousTokenId = pairingTokenId();- setShowPairing(true);- setPairingLoading(true);- let createdTokenId: string | null = null;- try {- const createdToken = await SecurityAPI.createToken(buildRelayPairingTokenName(new Date()));- if (!createdToken.token) {- throw new Error('Failed to generate relay device token');- }- createdTokenId = createdToken.record.id;-- const payload = await OnboardingAPI.getQRPayload(createdToken.token);- if (!payload.auth_token) {- throw new Error('Relay pairing payload is missing auth_token');- }- const qrCodeDataUrl = await QRCode.toDataURL(payload.deep_link, {- width: 256,- margin: 2,- });- setPairingPayload(payload);- setPairingQRCode(qrCodeDataUrl);- setPairingTokenId(createdTokenId);- if (previousTokenId && previousTokenId != createdTokenId) {- await deletePairingToken(previousTokenId);- }- } catch (err) {- await deletePairingToken(createdTokenId);- setPairingPayload(previousPayload);- setPairingQRCode(previousQRCode);- setPairingTokenId(previousTokenId);- showError('Failed to generate pairing QR code');- logger.error('[RelaySettings] Failed to generate onboarding QR', err);- } finally {- setPairingLoading(false);- }- };-- const handleCopyPairingPayload = async () => {- const payload = pairingPayload();- if (!payload) return;-- try {- await navigator.clipboard.writeText(JSON.stringify(payload, null, 2));- showSuccess('Pairing payload copied');- } catch (err) {- showError('Failed to copy pairing payload');- logger.error('[RelaySettings] Failed to copy pairing payload', err);- }- };-- const connectionPresentation = () => getRelayConnectionPresentation(config(), status());+ const state = useRelaySettingsPanelState(props);// Pro feature gate- if (!hasFeature('relay')) {+ if (!state.relayEnabled()) {return (<SettingsPaneltitle="Remote Access"description="Configure Pulse relay connectivity for secure remote access (mobile rollout coming soon)."icon={<RadioTower size={20} strokeWidth={2} />}>- <Show when={!loading()} fallback={<div class="text-sm ">Loading...</div>}>+ <Show when={!state.loading()} fallback={<div class="text-sm ">Loading...</div>}><Card tone="info" padding="md"><div class="flex flex-col sm:flex-row items-center gap-4"><div class="flex items-start gap-3 flex-1">@@ -282,7 +48,7 @@ export const RelaySettingsPanel: Component<RelaySettingsPanelProps> = (props) =></div><div class="flex flex-col sm:flex-row items-center gap-2"><a- href={getUpgradeActionUrlOrFallback('relay')}+ href={state.upgradeActionUrl()}target="_blank"rel="noopener noreferrer"class={RELAY_PRIMARY_LINK_CLASS}@@ -290,11 +56,11 @@ export const RelaySettingsPanel: Component<RelaySettingsPanelProps> = (props) =>>Upgrade</a>- <Show when={canStartTrial()}>+ <Show when={state.canStartTrial()}><buttontype="button"- onClick={handleStartTrial}- disabled={startingTrial()}+ onClick={state.handleStartTrial}+ disabled={state.startingTrial()}class={RELAY_INLINE_ACTION_CLASS}>Start free trial@@ -315,10 +81,10 @@ export const RelaySettingsPanel: Component<RelaySettingsPanelProps> = (props) =>icon={<RadioTower size={20} strokeWidth={2} />}><Show- when={!loading()}+ when={!state.loading()}fallback={<div class="text-sm ">{getSettingsConfigurationLoadingState().text}</div>}>- <Show when={!canManage()}>+ <Show when={!state.canManage()}><Cardtone="info"padding="md"@@ -340,26 +106,26 @@ export const RelaySettingsPanel: Component<RelaySettingsPanelProps> = (props) =><Card padding="md"><div class="flex items-center gap-3"><StatusDot- variant={connectionPresentation().variant}+ variant={state.connectionPresentation().variant}size="md"- pulse={connectionPresentation().pulse}+ pulse={state.connectionPresentation().pulse}/><div class="flex-1">- <p class="text-sm font-medium text-base-content">{connectionPresentation().label}</p>- <Show when={status()?.instance_id}>- <p class="text-xs text-muted mt-0.5">Instance: {status()!.instance_id}</p>+ <p class="text-sm font-medium text-base-content">{state.connectionPresentation().label}</p>+ <Show when={state.status()?.instance_id}>+ <p class="text-xs text-muted mt-0.5">Instance: {state.status()!.instance_id}</p></Show>- <Show when={status()?.connected && status()!.active_channels > 0}>+ <Show when={state.status()?.connected && state.status()!.active_channels > 0}><p class="text-xs text-muted">- {status()!.active_channels} active{' '}- {status()!.active_channels === 1 ? 'channel' : 'channels'}+ {state.status()!.active_channels} active{' '}+ {state.status()!.active_channels === 1 ? 'channel' : 'channels'}</p></Show></div></div>- <Show when={status()?.last_error}>+ <Show when={state.status()?.last_error}><div class={RELAY_LAST_ERROR_CLASS}>- {status()!.last_error}+ {state.status()!.last_error}</div></Show></Card>@@ -375,9 +141,9 @@ export const RelaySettingsPanel: Component<RelaySettingsPanelProps> = (props) =></p></div><Toggle- checked={config()?.enabled ?? false}- onChange={(e) => void handleToggleEnabled(e.currentTarget.checked)}- disabled={!canManage() || saving()}+ checked={state.config()?.enabled ?? false}+ onChange={(e) => void state.handleToggleEnabled(e.currentTarget.checked)}+ disabled={!state.canManage() || state.saving()}containerClass="self-end sm:self-auto"/></div>@@ -390,16 +156,16 @@ export const RelaySettingsPanel: Component<RelaySettingsPanelProps> = (props) =><inputtype="text"class={controlClass()}- value={serverUrl()}- onInput={(e) => setServerUrl(e.currentTarget.value)}+ value={state.serverUrl()}+ onInput={(e) => state.setServerUrl(e.currentTarget.value)}placeholder="wss://relay.example.com/ws/instance"- disabled={!canManage() || saving()}+ disabled={!state.canManage() || state.saving()}/>- <Show when={canManage() && serverUrl() !== config()?.server_url}>+ <Show when={state.canManage() && state.serverUrl() !== state.config()?.server_url}><buttonclass={`${RELAY_PRIMARY_BUTTON_CLASS} sm:self-auto self-end`}- onClick={() => void handleSaveServerUrl()}- disabled={saving()}+ onClick={() => void state.handleSaveServerUrl()}+ disabled={state.saving()}>Save</button>@@ -411,11 +177,11 @@ export const RelaySettingsPanel: Component<RelaySettingsPanelProps> = (props) =></div>{/* Identity Fingerprint */}- <Show when={config()?.identity_fingerprint}>+ <Show when={state.config()?.identity_fingerprint}><div class={formField}><label class={labelClass()}>Instance Fingerprint</label><code class="block text-xs font-mono text-base-content bg-surface-alt rounded px-3 py-2 select-all break-all">- {config()!.identity_fingerprint}+ {state.config()!.identity_fingerprint}</code><p class={formHelpText}>This fingerprint uniquely identifies your Pulse instance. Mobile clients verify this@@ -424,79 +190,17 @@ export const RelaySettingsPanel: Component<RelaySettingsPanelProps> = (props) =></div></Show>- <Show when={config()?.enabled && status()?.connected}>- <div class={formField}>- <label class={labelClass()}>Pair Mobile Device</label>- <Card tone="muted" padding="md">- <div class="space-y-3">- <div class="flex flex-wrap items-center gap-2">- <button- class={RELAY_PRIMARY_BUTTON_CLASS}- onClick={() => void handlePairNewDevice()}- disabled={!canManage() || saving() || pairingLoading()}- >- {pairingLoading()- ? 'Generating QR code...'- : showPairing()- ? 'Refresh QR Code'- : 'Pair New Device'}- </button>- <Show when={showPairing() && pairingPayload()}>- <button- class={RELAY_SECONDARY_BUTTON_CLASS}- onClick={() => void handleCopyPairingPayload()}- disabled={!canManage() || pairingLoading()}- >- Copy Payload- </button>- </Show>- </div>-- <p class={formHelpText}>- Generate a QR code for pairing during staged mobile beta rollout.- </p>-- <Show when={showPairing()}>- <div class="space-y-3">- <Show when={pairingLoading()}>- <p class="text-sm text-muted">Preparing pairing payload...</p>- </Show>-- <Show when={!pairingLoading() && pairingQRCode()}>- <img- src={pairingQRCode()!}- alt="Pulse mobile pairing QR code"- width="256"- height="256"- class={RELAY_QR_IMAGE_CLASS}- />- </Show>-- <Show when={pairingPayload()?.deep_link}>- <code class={RELAY_CODE_BLOCK_CLASS}>- {pairingPayload()!.deep_link}- </code>- </Show>-- <Show when={(pairingPayload()?.diagnostics?.length ?? 0) > 0}>- <div class={RELAY_DIAGNOSTICS_WRAP_CLASS}>- <p class={RELAY_DIAGNOSTICS_TITLE_CLASS}>Diagnostics</p>- {(pairingPayload()?.diagnostics ?? []).map((diagnostic) => (- <div class={getRelayDiagnosticClass(diagnostic.severity)}>- <p class="font-medium">{diagnostic.message}</p>- <p class="mt-0.5 font-mono">- {diagnostic.code}- <Show when={diagnostic.field}> | field: {diagnostic.field}</Show>- </p>- </div>- ))}- </div>- </Show>- </div>- </Show>- </div>- </Card>- </div>+ <Show when={state.canShowPairing()}>+ <RelayPairingSection+ canManage={state.canManage()}+ pairingLoading={state.pairingLoading()}+ pairingPayload={state.pairingPayload()}+ pairingQRCode={state.pairingQRCode()}+ saving={state.saving()}+ showPairing={state.showPairing()}+ onCopyPairingPayload={() => void state.handleCopyPairingPayload()}+ onPairNewDevice={() => void state.handlePairNewDevice()}+ /></Show></Show></SettingsPanel>diff --git a/frontend-modern/src/components/Settings/__tests__/RelaySettingsPanel.runtime.test.tsx b/frontend-modern/src/components/Settings/__tests__/RelaySettingsPanel.runtime.test.tsxindex b0d23d03c2..12f628724a 100644--- a/frontend-modern/src/components/Settings/__tests__/RelaySettingsPanel.runtime.test.tsx+++ b/frontend-modern/src/components/Settings/__tests__/RelaySettingsPanel.runtime.test.tsx@@ -1,5 +1,8 @@import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import { cleanup, fireEvent, render, screen, waitFor } from '@solidjs/testing-library';+import relayPairingSectionSource from '../RelayPairingSection.tsx?raw';+import relaySettingsPanelSource from '../RelaySettingsPanel.tsx?raw';+import relaySettingsPanelStateSource from '../useRelaySettingsPanelState.ts?raw';const loadLicenseStatusMock = vi.fn();const hasFeatureMock = vi.fn();@@ -325,4 +328,14 @@ describe('RelaySettingsPanel runtime', () => {expect(screen.getByText('pulse://connect?instance_id=instance-local&auth_token=token-123')).toBeInTheDocument();expect(showErrorMock).toHaveBeenCalledWith('Failed to generate pairing QR code');});++ it('keeps relay settings split into shell, runtime, and pairing owners', () => {+ expect(relaySettingsPanelSource).toContain('./useRelaySettingsPanelState');+ expect(relaySettingsPanelSource).toContain('./RelayPairingSection');+ expect(relaySettingsPanelSource).not.toContain('createSignal(');+ expect(relaySettingsPanelSource).not.toContain('QRCode.toDataURL(');+ expect(relaySettingsPanelStateSource).toContain('QRCode.toDataURL(payload.deep_link');+ expect(relaySettingsPanelStateSource).toContain('setInterval(() => void loadStatus(), 5000)');+ expect(relayPairingSectionSource).toContain('getRelayDiagnosticClass');+ });});diff --git a/frontend-modern/src/components/Settings/__tests__/RelaySettingsPanel.test.ts b/frontend-modern/src/components/Settings/__tests__/RelaySettingsPanel.test.tsindex 4cdb10d9ee..88b94c94a2 100644--- a/frontend-modern/src/components/Settings/__tests__/RelaySettingsPanel.test.ts+++ b/frontend-modern/src/components/Settings/__tests__/RelaySettingsPanel.test.ts@@ -1,4 +1,6 @@import { describe, expect, it } from 'vitest';+import relayPairingSectionSource from '../RelayPairingSection.tsx?raw';+import relaySettingsPanelStateSource from '../useRelaySettingsPanelState.ts?raw';const onboardingSource = Object.values(import.meta.glob('../../../api/onboarding.ts', {@@ -41,7 +43,13 @@ describe('Onboarding QR payload contract', () => {expect(onboardingSource).toContain('diagnostics?: OnboardingDiagnostic[];');});- it('uses deep_link as QR code content', () => {- expect(relaySettingsPanelSource).toContain('QRCode.toDataURL(payload.deep_link');+ it('keeps relay settings split into shell, runtime, and pairing owners', () => {+ expect(relaySettingsPanelSource).toContain('./useRelaySettingsPanelState');+ expect(relaySettingsPanelSource).toContain('./RelayPairingSection');+ expect(relaySettingsPanelSource).not.toContain('createSignal(');+ expect(relaySettingsPanelSource).not.toContain('QRCode.toDataURL(');+ expect(relaySettingsPanelStateSource).toContain('QRCode.toDataURL(payload.deep_link');+ expect(relaySettingsPanelStateSource).toContain('setInterval(() => void loadStatus(), 5000)');+ expect(relayPairingSectionSource).toContain('getRelayDiagnosticClass');});});diff --git a/frontend-modern/src/components/Settings/__tests__/monitoredSystemModelGuardrails.test.ts b/frontend-modern/src/components/Settings/__tests__/monitoredSystemModelGuardrails.test.tsindex e8504cee30..b158783338 100644--- a/frontend-modern/src/components/Settings/__tests__/monitoredSystemModelGuardrails.test.ts+++ b/frontend-modern/src/components/Settings/__tests__/monitoredSystemModelGuardrails.test.ts@@ -137,7 +137,9 @@ import statusUtilsSource from '@/utils/status.ts?raw';import unifiedAgentStatusPresentationSource from '@/utils/unifiedAgentStatusPresentation.ts?raw';import unifiedAgentInventoryPresentationSource from '@/utils/unifiedAgentInventoryPresentation.ts?raw';import relayPresentationSource from '@/utils/relayPresentation.ts?raw';+import relayPairingSectionSource from '../RelayPairingSection.tsx?raw';import relaySettingsPanelSource from '../RelaySettingsPanel.tsx?raw';+import relaySettingsPanelStateSource from '../useRelaySettingsPanelState.ts?raw';import proxmoxDeleteNodeDialogSource from '../ProxmoxDeleteNodeDialog.tsx?raw';import proxmoxConfiguredNodesTableSource from '../ProxmoxConfiguredNodesTable.tsx?raw';import proxmoxDirectConnectionsCardSource from '../ProxmoxDirectConnectionsCard.tsx?raw';@@ -332,12 +334,14 @@ describe('monitored-system model guardrails', () => {expect(infrastructureOperationsSource).not.toContain("notificationStore.error('Failed to copy')",);- expect(relaySettingsPanelSource).toContain('getRelayConnectionPresentation');- expect(relaySettingsPanelSource).toContain('getRelayDiagnosticClass');+ expect(relaySettingsPanelSource).toContain('./useRelaySettingsPanelState');+ expect(relaySettingsPanelSource).toContain('./RelayPairingSection');expect(relaySettingsPanelSource).toContain('getSettingsConfigurationLoadingState');- expect(relaySettingsPanelSource).not.toContain('const connectionStatusVariant =');- expect(relaySettingsPanelSource).not.toContain('const connectionStatusText =');+ expect(relaySettingsPanelSource).not.toContain('createSignal(');expect(relaySettingsPanelSource).not.toContain('Loading configuration...');+ expect(relaySettingsPanelStateSource).toContain('getRelayConnectionPresentation');+ expect(relaySettingsPanelStateSource).toContain('trackPaywallViewed');+ expect(relayPairingSectionSource).toContain('getRelayDiagnosticClass');expect(proxmoxSettingsPanelSource).toContain('CalloutCard');expect(proxmoxSettingsPanelSource).not.toContain('Loading configuration...');expect(proxmoxSettingsPanelSource).toContain('./useProxmoxSettingsPanelState');diff --git a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.tsindex db163aa60d..f3055575c2 100644--- a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts+++ b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts@@ -42,10 +42,12 @@ import updatesSettingsModelSource from '../updatesSettingsModel.ts?raw';import updatesSettingsPanelSource from '../UpdatesSettingsPanel.tsx?raw';import recoverySettingsPanelSource from '../RecoverySettingsPanel.tsx?raw';import relaySettingsPanelSource from '../RelaySettingsPanel.tsx?raw';+import relayPairingSectionSource from '../RelayPairingSection.tsx?raw';import proLicensePanelSource from '../ProLicensePanel.tsx?raw';import commercialBillingSectionsSource from '../CommercialBillingSections.tsx?raw';import selfHostedCommercialActivationSectionSource from '../SelfHostedCommercialActivationSection.tsx?raw';import commercialBillingModelSource from '@/utils/commercialBillingModel.ts?raw';+import relaySettingsPanelStateSource from '../useRelaySettingsPanelState.ts?raw';import organizationOverviewPanelSource from '../OrganizationOverviewPanel.tsx?raw';import organizationOverviewLoadingStateSource from '../OrganizationOverviewLoadingState.tsx?raw';import organizationOverviewDetailsSectionSource from '../OrganizationOverviewDetailsSection.tsx?raw';@@ -129,6 +131,7 @@ const extractedModules = ['../UpdateInstallGuide.tsx','../ReportingPanel.tsx','../reportingPanelModel.ts',+ '../RelayPairingSection.tsx','../OrganizationOverviewLoadingState.tsx','../OrganizationOverviewDetailsSection.tsx','../OrganizationOverviewMembersSection.tsx',@@ -151,6 +154,7 @@ const extractedModules = ['../UserAssignmentsDialog.tsx','../useUserAssignmentsPanelState.ts','../updatesSettingsModel.ts',+ '../useRelaySettingsPanelState.ts','../useDiagnosticsPanelState.ts','../useReportingPanelState.ts','../useSSOProvidersState.ts',@@ -364,6 +368,18 @@ describe('Settings architecture guardrails', () => {expect(settingsSource).not.toContain('organizationAgentUsage');});+ it('keeps relay settings split into shell, runtime, and pairing owners', () => {+ expect(relaySettingsPanelSource).toContain('./useRelaySettingsPanelState');+ expect(relaySettingsPanelSource).toContain('./RelayPairingSection');+ expect(relaySettingsPanelSource).not.toContain('createSignal(');+ expect(relaySettingsPanelSource).not.toContain('QRCode.toDataURL(');+ expect(relaySettingsPanelStateSource).toContain("trackPaywallViewed('relay', 'settings_relay_panel')");+ expect(relaySettingsPanelStateSource).toContain('setInterval(() => void loadStatus(), 5000)');+ expect(relaySettingsPanelStateSource).toContain('QRCode.toDataURL(payload.deep_link');+ expect(relayPairingSectionSource).toContain('getRelayDiagnosticClass');+ expect(relayPairingSectionSource).toContain('Pair New Device');+ });+it('does not re-inline extracted tab and header metadata definitions', () => {expect(settingsSource).not.toMatch(/\b(?:const|let|var)\s+baseTabGroups\s*=/);expect(settingsSource).not.toMatch(/\b(?:const|let|var)\s+SETTINGS_HEADER_META\s*=/);diff --git a/frontend-modern/src/components/Settings/useRelaySettingsPanelState.ts b/frontend-modern/src/components/Settings/useRelaySettingsPanelState.tsnew file mode 100644index 0000000000..7fc8a871fe--- /dev/null+++ b/frontend-modern/src/components/Settings/useRelaySettingsPanelState.ts@@ -0,0 +1,271 @@+import { createEffect, createMemo, createSignal, onCleanup, onMount } from 'solid-js';+import {+ entitlements,+ getUpgradeActionUrlOrFallback,+ hasFeature,+ licenseLoaded,+ loadLicenseStatus,+ startProTrial,+} from '@/stores/license';+import { trackPaywallViewed } from '@/utils/upgradeMetrics';+import { showError, showSuccess } from '@/utils/toast';+import { RelayAPI, type RelayConfig, type RelayStatus } from '@/api/relay';+import { OnboardingAPI, type OnboardingQRResponse } from '@/api/onboarding';+import { SecurityAPI } from '@/api/security';+import { logger } from '@/utils/logger';+import { getRelayConnectionPresentation } from '@/utils/relayPresentation';+import QRCode from 'qrcode';++export interface RelaySettingsPanelProps {+ canManage?: boolean;+}++function buildRelayPairingTokenName(now: Date): string {+ return `Relay mobile device ${now.toISOString()}`;+}++export function useRelaySettingsPanelState(props: RelaySettingsPanelProps) {+ const [config, setConfig] = createSignal<RelayConfig | null>(null);+ const [status, setStatus] = createSignal<RelayStatus | null>(null);+ const [loading, setLoading] = createSignal(true);+ const [saving, setSaving] = createSignal(false);+ const [serverUrl, setServerUrl] = createSignal('');+ const [showPairing, setShowPairing] = createSignal(false);+ const [pairingLoading, setPairingLoading] = createSignal(false);+ const [pairingPayload, setPairingPayload] = createSignal<OnboardingQRResponse | null>(null);+ const [pairingQRCode, setPairingQRCode] = createSignal<string | null>(null);+ const [pairingTokenId, setPairingTokenId] = createSignal<string | null>(null);+ const [startingTrial, setStartingTrial] = createSignal(false);++ const canManage = () => props.canManage !== false;+ const canStartTrial = () => entitlements()?.trial_eligible !== false;+ const relayEnabled = () => hasFeature('relay');+ const upgradeActionUrl = () => getUpgradeActionUrlOrFallback('relay');+ const connectionPresentation = createMemo(() =>+ getRelayConnectionPresentation(config(), status()),+ );+ const canShowPairing = createMemo(() => Boolean(config()?.enabled && status()?.connected));++ createEffect((wasPaywallVisible: boolean) => {+ const isPaywallVisible = licenseLoaded() && !relayEnabled();+ if (isPaywallVisible && !wasPaywallVisible) {+ trackPaywallViewed('relay', 'settings_relay_panel');+ }+ return isPaywallVisible;+ }, false);++ let statusInterval: ReturnType<typeof setInterval> | undefined;++ const resetPairingState = () => {+ setShowPairing(false);+ setPairingLoading(false);+ setPairingPayload(null);+ setPairingQRCode(null);+ setPairingTokenId(null);+ };++ const deletePairingToken = async (tokenID: string | null) => {+ if (!tokenID) return;+ try {+ await SecurityAPI.deleteToken(tokenID);+ } catch (error) {+ logger.warn('[RelaySettings] Failed to clean up relay pairing token', error);+ }+ };++ const loadConfig = async () => {+ try {+ const nextConfig = await RelayAPI.getConfig();+ setConfig(nextConfig);+ setServerUrl(nextConfig.server_url);+ if (!nextConfig.enabled) {+ resetPairingState();+ }+ } catch (error) {+ logger.error('[RelaySettings] Failed to load config', error);+ }+ };++ const loadStatus = async () => {+ try {+ const nextStatus = await RelayAPI.getStatus();+ setStatus(nextStatus);+ } catch (error) {+ logger.error('[RelaySettings] Failed to load status', error);+ }+ };++ const stopStatusPolling = () => {+ if (statusInterval !== undefined) {+ clearInterval(statusInterval);+ statusInterval = undefined;+ }+ };++ const startStatusPolling = () => {+ stopStatusPolling();+ void loadStatus();+ statusInterval = setInterval(() => void loadStatus(), 5000);+ };++ onMount(async () => {+ await loadLicenseStatus();+ if (!relayEnabled()) {+ setLoading(false);+ return;+ }++ await loadConfig();+ if (config()?.enabled) {+ startStatusPolling();+ }+ setLoading(false);+ });++ onCleanup(() => {+ stopStatusPolling();+ });++ const handleStartTrial = async () => {+ if (startingTrial()) return;+ setStartingTrial(true);+ try {+ const result = await startProTrial();+ if (result?.outcome === 'redirect') {+ window.location.href = result.actionUrl;+ return;+ }+ showSuccess('Remote access trial started');+ } catch (error) {+ const statusCode = (error as { status?: number } | null)?.status;+ if (statusCode === 409) {+ showError('Trial already used');+ } else {+ showError(error instanceof Error ? error.message : 'Failed to start trial');+ }+ } finally {+ setStartingTrial(false);+ }+ };++ const handleToggleEnabled = async (enabled: boolean) => {+ if (!canManage()) return;+ setSaving(true);+ try {+ await RelayAPI.updateConfig({ enabled });+ await loadConfig();+ if (enabled) {+ startStatusPolling();+ showSuccess('Remote access enabled');+ } else {+ stopStatusPolling();+ setStatus(null);+ resetPairingState();+ showSuccess('Remote access disabled');+ }+ } catch (error) {+ showError('Failed to update relay configuration');+ logger.error('[RelaySettings] Failed to toggle', error);+ } finally {+ setSaving(false);+ }+ };++ const handleSaveServerUrl = async () => {+ if (!canManage()) return;+ const url = serverUrl().trim();+ if (!url) return;+ setSaving(true);+ try {+ await RelayAPI.updateConfig({ server_url: url });+ await loadConfig();+ showSuccess('Server URL updated');+ } catch (error) {+ showError('Failed to update server URL');+ logger.error('[RelaySettings] Failed to save server URL', error);+ } finally {+ setSaving(false);+ }+ };++ const handlePairNewDevice = async () => {+ if (!canManage()) return;+ const previousPayload = pairingPayload();+ const previousQRCode = pairingQRCode();+ const previousTokenId = pairingTokenId();+ setShowPairing(true);+ setPairingLoading(true);++ let createdTokenId: string | null = null;+ try {+ const createdToken = await SecurityAPI.createToken(buildRelayPairingTokenName(new Date()));+ if (!createdToken.token) {+ throw new Error('Failed to generate relay device token');+ }+ createdTokenId = createdToken.record.id;++ const payload = await OnboardingAPI.getQRPayload(createdToken.token);+ if (!payload.auth_token) {+ throw new Error('Relay pairing payload is missing auth_token');+ }++ const qrCodeDataUrl = await QRCode.toDataURL(payload.deep_link, {+ width: 256,+ margin: 2,+ });+ setPairingPayload(payload);+ setPairingQRCode(qrCodeDataUrl);+ setPairingTokenId(createdTokenId);+ if (previousTokenId && previousTokenId !== createdTokenId) {+ await deletePairingToken(previousTokenId);+ }+ } catch (error) {+ await deletePairingToken(createdTokenId);+ setPairingPayload(previousPayload);+ setPairingQRCode(previousQRCode);+ setPairingTokenId(previousTokenId);+ showError('Failed to generate pairing QR code');+ logger.error('[RelaySettings] Failed to generate onboarding QR', error);+ } finally {+ setPairingLoading(false);+ }+ };++ const handleCopyPairingPayload = async () => {+ const payload = pairingPayload();+ if (!payload) return;++ try {+ await navigator.clipboard.writeText(JSON.stringify(payload, null, 2));+ showSuccess('Pairing payload copied');+ } catch (error) {+ showError('Failed to copy pairing payload');+ logger.error('[RelaySettings] Failed to copy pairing payload', error);+ }+ };++ return {+ canManage,+ canShowPairing,+ canStartTrial,+ config,+ connectionPresentation,+ handleCopyPairingPayload,+ handlePairNewDevice,+ handleSaveServerUrl,+ handleStartTrial,+ handleToggleEnabled,+ loading,+ pairingLoading,+ pairingPayload,+ pairingQRCode,+ relayEnabled,+ saving,+ serverUrl,+ setServerUrl,+ showPairing,+ startingTrial,+ status,+ upgradeActionUrl,+ };+}diff --git a/scripts/release_control/subsystem_lookup_test.py b/scripts/release_control/subsystem_lookup_test.pyindex c2a14881f0..bf98821963 100644--- a/scripts/release_control/subsystem_lookup_test.py+++ b/scripts/release_control/subsystem_lookup_test.py@@ -115,6 +115,27 @@ class SubsystemLookupTest(unittest.TestCase):["frontend-modern/src/components/Settings/__tests__/ProLicensePanel.test.tsx"],)+ def test_lookup_paths_assigns_relay_settings_state_owner_to_cloud_paid(self) -> None:+ result = lookup_paths(["frontend-modern/src/components/Settings/useRelaySettingsPanelState.ts"])+ self.assertEqual(result["unowned_runtime_files"], [])+ self.assertEqual(+ {item["subsystem"] for item in result["impacted_subsystems"]},+ {"cloud-paid"},+ )+ file_entry = result["files"][0]+ self.assertEqual(file_entry["classification"], "runtime")+ self.assertEqual(+ {match["subsystem"] for match in file_entry["matches"]},+ {"cloud-paid"},+ )+ match = file_entry["matches"][0]+ self.assertEqual(match["contract"], "docs/release-control/v6/internal/subsystems/cloud-paid.md")+ self.assertEqual(match["lane_context"]["lane_id"], "L3")+ self.assertEqual(+ match["verification_requirement"]["id"],+ "relay-frontend-surfaces",+ )+def test_lookup_paths_assigns_recovery_route_to_storage_recovery(self) -> None:result = lookup_paths(["frontend-modern/src/pages/RecoveryRoute.tsx"])self.assertEqual(result["unowned_runtime_files"], [])