Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Keep manual licence recovery feedback beside its controls

pulse-triage[bot]588de0be87dd
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.md
index 3e9478560f..90dc67133c 100644
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@ -15,6 +15,25 @@
## Purpose
+### Manual licence recovery feedback
+
+The existing Plan page keeps the latest deliberate apply/clear-key result in
+the manual recovery disclosure, beside its controls. An error is an assertive
+alert and success is a polite status; neither expires or adds a floating toast.
+Starting another confirmed operation withdraws the previous result, and applying
+another key withdraws the previous activation-success summary. Current saved
+entitlements still come from their existing readers, not the feedback message.
+Cancelling clear keeps the current result and sends no request.
+
+An unavailable or rejected activation preserves the entered key for deliberate
+retry. While either operation is pending, the key and both actions are disabled
+and handlers reject overlapping submissions. Success retains the existing
+entitlement/runtime refresh and submitted-key clearing. Auth, private-runtime
+requirements, activation/refusal policy and unrelated notifications are unchanged.
+The Plan panel tests exercise outage → same-key success → genuine refusal,
+transport failures, cancelled/failed/successful clear and pending duplicate
+suppression through the actual recovery controls.
+
### Dormant transition refund preparation
The expanded transition-refund proposal was withdrawn before activation.
diff --git a/frontend-modern/src/components/Settings/ProLicensePanel.tsx b/frontend-modern/src/components/Settings/ProLicensePanel.tsx
index 4869850d66..170a978181 100644
--- a/frontend-modern/src/components/Settings/ProLicensePanel.tsx
+++ b/frontend-modern/src/components/Settings/ProLicensePanel.tsx
@@ -113,6 +113,7 @@ const ProLicensePanelContent: Component = () => {
loading={state.loading()}
hasLicenseDetails={state.hasLicenseDetails()}
looksLikeLegacyLicenseKey={state.looksLikeLegacyLicenseKey()}
+ feedback={state.recoveryFeedback()}
onLicenseKeyInput={state.setLicenseKey}
onActivate={state.handleActivate}
onClear={state.handleClear}
diff --git a/frontend-modern/src/components/Settings/SelfHostedCommercialRecoverySection.tsx b/frontend-modern/src/components/Settings/SelfHostedCommercialRecoverySection.tsx
index cb99cb8d8c..82754924ef 100644
--- a/frontend-modern/src/components/Settings/SelfHostedCommercialRecoverySection.tsx
+++ b/frontend-modern/src/components/Settings/SelfHostedCommercialRecoverySection.tsx
@@ -3,6 +3,7 @@ import { formField, controlClass } from '@/components/shared/Form';
import { ExternalTextLink } from '@/components/shared/ExternalTextLink';
import { FormTextarea } from '@/components/shared/FormTextarea';
import { Button } from '@/components/shared/Button';
+import { InlineNotice } from '@/components/shared/InlineNotice';
import { SELF_HOSTED_RECOVERY_PRESENTATION } from '@/utils/licensePresentation';
import { TERMS_DOC_URL } from '@/utils/docsLinks';
import { CommercialSection } from './CommercialBillingSections';
@@ -17,6 +18,7 @@ interface SelfHostedCommercialRecoverySectionProps {
loading: boolean;
hasLicenseDetails: boolean;
looksLikeLegacyLicenseKey: boolean;
+ feedback?: { type: 'success' | 'error'; message: string } | null;
onLicenseKeyInput: (value: string) => void;
onActivate: () => void;
onClear: () => void;
@@ -55,6 +57,7 @@ export const SelfHostedCommercialRecoverySection: Component<
textareaBaseClass={controlClass('min-h-[120px] font-mono')}
placeholder={SELF_HOSTED_RECOVERY_PRESENTATION.fieldPlaceholder}
value={props.licenseKey}
+ disabled={props.activating || props.clearing}
onInput={(event) => props.onLicenseKeyInput(event.currentTarget.value)}
help={
<>
@@ -91,12 +94,26 @@ export const SelfHostedCommercialRecoverySection: Component<
</Show>
</div>
+ <Show when={props.feedback}>
+ {(feedback) => (
+ <InlineNotice
+ tone={feedback().type === 'error' ? 'danger' : 'success'}
+ role={feedback().type === 'error' ? 'alert' : 'status'}
+ aria-live={feedback().type === 'error' ? 'assertive' : 'polite'}
+ aria-atomic="true"
+ class="break-words [overflow-wrap:anywhere]"
+ >
+ {feedback().message}
+ </InlineNotice>
+ )}
+ </Show>
+
<div class="flex flex-wrap items-center gap-2">
<Button
variant="primary"
size="settingsAction"
onClick={props.onActivate}
- disabled={props.activating || !props.licenseKey.trim()}
+ disabled={props.activating || props.clearing || !props.licenseKey.trim()}
>
{props.activating
? SELF_HOSTED_RECOVERY_PRESENTATION.activatePendingLabel
@@ -106,7 +123,9 @@ export const SelfHostedCommercialRecoverySection: Component<
variant="outline"
size="settingsAction"
onClick={props.onClear}
- disabled={props.clearing || props.loading || !props.hasLicenseDetails}
+ disabled={
+ props.activating || props.clearing || props.loading || !props.hasLicenseDetails
+ }
>
{props.clearing
? SELF_HOSTED_RECOVERY_PRESENTATION.clearPendingLabel
diff --git a/frontend-modern/src/components/Settings/__tests__/ProLicensePanel.test.tsx b/frontend-modern/src/components/Settings/__tests__/ProLicensePanel.test.tsx
index 7fcba663e6..e3ee655c62 100644
--- a/frontend-modern/src/components/Settings/__tests__/ProLicensePanel.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/ProLicensePanel.test.tsx
@@ -21,6 +21,7 @@ import {
SELF_HOSTED_PRO_BILLING_PURCHASE_FAILED,
SELF_HOSTED_PRO_BILLING_PURCHASE_UNAVAILABLE,
SELF_HOSTED_PRO_BILLING_RECOVERY_DETAIL,
+ SELF_HOSTED_PRO_BILLING_RECOVERY_SECTION_ID,
SELF_HOSTED_PRO_BILLING_PLAN_SECTION_ID,
SELF_HOSTED_PRO_BILLING_USAGE_HREF,
SELF_HOSTED_PRO_BILLING_USAGE_SECTION_ID,
@@ -211,6 +212,130 @@ describe('ProLicensePanel', () => {
cleanup();
});
+ const renderRecovery = () => {
+ useLocationMock.mockReturnValue({
+ search: `?details=${SELF_HOSTED_PRO_BILLING_RECOVERY_DETAIL}`,
+ pathname: '/settings/system/billing/plan',
+ hash: '',
+ });
+ renderPanel();
+ return within(document.getElementById(SELF_HOSTED_PRO_BILLING_RECOVERY_SECTION_ID)!);
+ };
+
+ it('replaces an outage with same-key success and genuine refusal beside the recovery controls', async () => {
+ const outage =
+ 'The license server is temporarily unavailable. Please try again in a few minutes.';
+ activateLicenseMock.mockResolvedValueOnce({ success: false, message: outage });
+ const recovery = renderRecovery();
+ const field = recovery.getByRole('textbox', { name: 'License key' });
+ const apply = recovery.getByRole('button', { name: 'Apply key' });
+ fireEvent.input(field, { target: { value: 'ppk_live_synthetic-original-key' } });
+ fireEvent.click(apply);
+ await waitFor(() => expect(recovery.getByRole('alert')).toHaveTextContent(outage));
+ expect(recovery.getByRole('alert')).toHaveAttribute('aria-live', 'assertive');
+ expect(field).toHaveValue('ppk_live_synthetic-original-key');
+ expect(apply).toBeEnabled();
+ expect(activateLicenseMock).toHaveBeenCalledTimes(1);
+
+ let completeRetry!: (value: { success: boolean; message: string }) => void;
+ activateLicenseMock.mockReturnValueOnce(
+ new Promise((resolve) => {
+ completeRetry = resolve;
+ }),
+ );
+ fireEvent.click(apply);
+ expect(recovery.queryByRole('alert')).not.toBeInTheDocument();
+ expect(recovery.queryByRole('status')).not.toBeInTheDocument();
+ expect(apply).toBeDisabled();
+ expect(field).toBeDisabled();
+ expect(recovery.getByRole('button', { name: 'Clear key' })).toBeDisabled();
+ fireEvent.click(apply);
+ fireEvent.click(recovery.getByRole('button', { name: 'Clear key' }));
+ expect(activateLicenseMock).toHaveBeenCalledTimes(2);
+ expect(clearLicenseMock).not.toHaveBeenCalled();
+
+ completeRetry({ success: true, message: 'License activated successfully' });
+ await waitFor(() =>
+ expect(recovery.getByRole('status')).toHaveTextContent('License activated successfully'),
+ );
+ expect(recovery.getByRole('status')).toHaveAttribute('aria-live', 'polite');
+ expect(field).toHaveValue('');
+ await waitFor(() => expect(field).toBeEnabled());
+ expect(recovery.queryByRole('alert')).not.toBeInTheDocument();
+ expect(screen.queryByText(outage)).not.toBeInTheDocument();
+
+ fireEvent.input(field, { target: { value: 'ppk_live_synthetic-original-key' } });
+ activateLicenseMock.mockResolvedValueOnce({
+ success: false,
+ message: 'Activation key has been revoked',
+ });
+ fireEvent.click(apply);
+ await waitFor(() =>
+ expect(recovery.getByRole('alert')).toHaveTextContent('Activation key has been revoked'),
+ );
+ expect(recovery.queryByRole('status')).not.toBeInTheDocument();
+ expect(screen.queryByText('License activated successfully')).not.toBeInTheDocument();
+ expect(field).toHaveValue('ppk_live_synthetic-original-key');
+ expect(activateLicenseMock.mock.calls).toEqual(
+ Array.from({ length: 3 }, () => ['ppk_live_synthetic-original-key']),
+ );
+ expect(notificationSuccessMock).not.toHaveBeenCalled();
+ expect(notificationErrorMock).not.toHaveBeenCalled();
+ });
+
+ it.each([new Error('Synthetic connection failure'), 'unknown failure'])(
+ 'keeps a failed activation retryable without a floating notification: %s',
+ async (error) => {
+ activateLicenseMock.mockRejectedValueOnce(error);
+ const recovery = renderRecovery();
+ const field = recovery.getByRole('textbox', { name: 'License key' });
+ fireEvent.input(field, { target: { value: 'synthetic-legacy-key' } });
+ fireEvent.click(recovery.getByRole('button', { name: 'Apply key' }));
+ await waitFor(() =>
+ expect(recovery.getByRole('alert')).toHaveTextContent(
+ error instanceof Error ? error.message : 'Failed to activate license',
+ ),
+ );
+ expect(field).toHaveValue('synthetic-legacy-key');
+ expect(recovery.getByRole('button', { name: 'Apply key' })).toBeEnabled();
+ expect(activateLicenseMock).toHaveBeenCalledTimes(1);
+ expect(notificationErrorMock).not.toHaveBeenCalled();
+ },
+ );
+
+ it('keeps clear-key cancellation, failure and success explicit in the same recovery surface', async () => {
+ mockEntitlements = { ...mockEntitlements!, tier: 'pro', subscription_state: 'active' };
+ const confirm = vi.spyOn(window, 'confirm').mockReturnValue(false);
+ try {
+ const recovery = renderRecovery();
+ const clear = recovery.getByRole('button', { name: 'Clear key' });
+ await waitFor(() => expect(clear).toBeEnabled());
+ fireEvent.click(clear);
+ expect(confirm).toHaveBeenCalledOnce();
+ expect(clearLicenseMock).not.toHaveBeenCalled();
+ expect(recovery.queryByRole('alert')).not.toBeInTheDocument();
+ expect(recovery.queryByRole('status')).not.toBeInTheDocument();
+
+ confirm.mockReturnValue(true);
+ clearLicenseMock.mockRejectedValueOnce(new Error('Synthetic clear failure'));
+ fireEvent.click(clear);
+ await waitFor(() =>
+ expect(recovery.getByRole('alert')).toHaveTextContent('Synthetic clear failure'),
+ );
+ clearLicenseMock.mockResolvedValueOnce({ success: true, message: 'License cleared' });
+ fireEvent.click(clear);
+ await waitFor(() =>
+ expect(recovery.getByRole('status')).toHaveTextContent('License cleared'),
+ );
+ expect(recovery.queryByRole('alert')).not.toBeInTheDocument();
+ expect(clearLicenseMock).toHaveBeenCalledTimes(2);
+ expect(notificationSuccessMock).not.toHaveBeenCalled();
+ expect(notificationErrorMock).not.toHaveBeenCalled();
+ } finally {
+ confirm.mockRestore();
+ }
+ });
+
it('fails closed until the session presentation policy is resolved', () => {
sessionPresentationPolicyResolvedMock.mockReturnValue(false);
diff --git a/frontend-modern/src/components/Settings/useProLicensePanelState.ts b/frontend-modern/src/components/Settings/useProLicensePanelState.ts
index 95add420d2..b52412dcb0 100644
--- a/frontend-modern/src/components/Settings/useProLicensePanelState.ts
+++ b/frontend-modern/src/components/Settings/useProLicensePanelState.ts
@@ -1,6 +1,5 @@
import { createEffect, createMemo, createSignal, onMount } from 'solid-js';
import { useLocation, useNavigate } from '@solidjs/router';
-import { notificationStore } from '@/stores/notifications';
import { loadCommercialPosture } from '@/stores/licenseCommercial';
import { loadRuntimeCapabilities } from '@/stores/license';
import {
@@ -82,6 +81,10 @@ export function useProLicensePanelState() {
);
const [activating, setActivating] = createSignal(false);
const [clearing, setClearing] = createSignal(false);
+ const [recoveryFeedback, setRecoveryFeedback] = createSignal<{
+ type: 'success' | 'error';
+ message: string;
+ } | null>(null);
const [purchaseActivationResult, setPurchaseActivationResult] = createSignal('');
const [purchaseActivationIntent, setPurchaseActivationIntent] =
createSignal<SelfHostedBillingPlanIntent | null>(null);
@@ -424,19 +427,28 @@ export function useProLicensePanelState() {
});
const handleActivate = async () => {
+ if (activating() || clearing()) return;
const trimmedKey = licenseKey().trim();
if (!trimmedKey) {
- notificationStore.error('A license key is required');
+ setRecoveryFeedback({ type: 'error', message: 'A license key is required' });
return;
}
+ // Recovery feedback belongs to the current deliberate attempt, beside its
+ // controls. Earlier failures must not outlive a successful retry in a toast
+ // stack, or cover those controls on a phone.
+ setRecoveryFeedback(null);
+ setActivationSuccessSource(null);
setActivating(true);
try {
const result = await LicenseAPI.activateLicense(trimmedKey);
if (!result.success) {
- notificationStore.error(result.message || 'Failed to activate license');
+ setRecoveryFeedback({
+ type: 'error',
+ message: result.message || 'Failed to activate license',
+ });
return;
}
- notificationStore.success(result.message || 'License activated');
+ setRecoveryFeedback({ type: 'success', message: result.message || 'License activated' });
setActivationSuccessSource('manual');
setLicenseKey('');
await Promise.all([
@@ -446,22 +458,25 @@ export function useProLicensePanelState() {
]);
await loadPatrolOperatorStatusIfNeeded();
} catch (error) {
- notificationStore.error(
- error instanceof Error ? error.message : 'Failed to activate license',
- );
+ setRecoveryFeedback({
+ type: 'error',
+ message: error instanceof Error ? error.message : 'Failed to activate license',
+ });
} finally {
setActivating(false);
}
};
const handleClear = async () => {
+ if (activating() || clearing()) return;
if (!confirm('Clear the current Pro license?')) {
return;
}
+ setRecoveryFeedback(null);
setClearing(true);
try {
const result = await LicenseAPI.clearLicense();
- notificationStore.success(result.message || 'License cleared');
+ setRecoveryFeedback({ type: 'success', message: result.message || 'License cleared' });
setActivationSuccessSource(null);
await Promise.all([
loadPanelData(),
@@ -470,7 +485,10 @@ export function useProLicensePanelState() {
]);
await loadPatrolOperatorStatusIfNeeded();
} catch (error) {
- notificationStore.error(error instanceof Error ? error.message : 'Failed to clear license');
+ setRecoveryFeedback({
+ type: 'error',
+ message: error instanceof Error ? error.message : 'Failed to clear license',
+ });
} finally {
setClearing(false);
}
@@ -499,6 +517,7 @@ export function useProLicensePanelState() {
planSelectionPrompt,
purchaseActivationNotice,
purchaseActivationAction,
+ recoveryFeedback,
setActiveSection,
setLicenseKey,
showRecoveryByDefault,