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.

Neutralize admission preview quota copy

rcourtman16f9221ab451
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index aca0a92fbe..cbbeca57af 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -667,6 +667,10 @@ route. `buildInfrastructureWorkspacePath()` always returns the base path;
`deriveAddStepFromLegacyPath()` maps legacy sub-paths to in-page panel state.
`SetupCompletionPanel.tsx` uses one `INFRASTRUCTURE_PATH` constant for all
install and platform CTAs.
+The shared monitored-system admission preview now formats save-impact
+summaries through `frontend-modern/src/utils/monitoredSystemPresentation.ts`
+so infrastructure setup screens describe count impact and active-policy
+failures without raw slash-quota rendering.
This subsystem now sits under the dedicated agent lifecycle and fleet
operations lane so install, registration, update continuity, profile
@@ -1524,8 +1528,9 @@ so provider-specific panels must not fork their own monitored-system preview
copy or inline projected-usage rendering.
That shared shell must use neutral count-impact language for ordinary platform
connection previews. Finite policy failures may say the active policy would be
-exceeded, but unchanged or removal previews should not describe "capacity" as
-the operator-facing mental model for self-hosted monitoring.
+exceeded, but unchanged or removal previews should not describe "capacity" or
+raw `current / limit` quota math as the operator-facing mental model for
+self-hosted monitoring.
That same commercial readiness boundary now also assumes settled canonical
usage, not the first non-nil monitor view. Lifecycle-owned setup or first-host
surfaces may not seal migrated-v5 continuity, display counted-system totals as
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.md
index d013a239d8..a620812c11 100644
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@ -448,8 +448,8 @@ Community limit enforcement.
monitored-system volume itself as the primary paid gate.
Monitored-system admission-preview copy must follow the same rule: ordinary
connection previews may describe count impact and active policy checks, but
- they must not use capacity-style titles that imply self-hosted monitoring
- volume is the product being sold.
+ they must not use capacity-style titles or slash-style quota summaries that
+ imply self-hosted monitoring volume is the product being sold.
11. Keep migrated self-hosted Community/free billing state uncapped even when
the persisted file still carries legacy v5 commercial limit keys:
`pkg/licensing/billing_state_normalization.go` and
@@ -1144,6 +1144,8 @@ That same helper also owns preview-impact copy and current/projected
source-label wording for pre-save monitored-system admission UI, so the
TrueNAS and VMware settings panels do not drift into provider-local billing
phrasing when they surface canonical preview results before save.
+Admission preview summaries must also come from that helper and describe
+current/projected count impact without raw `current / limit` quota math.
That same helper-owned admission-preview contract now also owns required-
preview, unavailable-capacity, and save-blocking messages. Provider settings
panels must map `monitored_system_usage_unavailable` plus backend
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 05694b5dab..03a23fb241 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -460,10 +460,9 @@ work extends shared components instead of creating new local variants.
presentation helper and suppress usage summaries, upgrade pressure, and
upgrade-impression telemetry rather than rendering stale `current/limit`
counts or paid-plan CTAs from banner-local availability checks. When the
- banner does need an upgrade destination, it must scope the operator into
- the cloud-paid plan-selection intent (`intent=self_hosted_plan`) rather
- than reintroducing browser symbols or CTA copy that frame the flow as
- monitored-system-cap expansion.
+ banner does need a review destination, it must scope the operator into the
+ usage-owned policy ledger rather than plan-selection intent or CTA copy
+ that frames the flow as monitored-system-cap expansion.
16. Keep assistant availability bootstrap on the shared app-shell boundary.
`frontend-modern/src/useAppRuntimeState.ts`,
`frontend-modern/src/App.tsx`,
diff --git a/frontend-modern/src/components/Settings/MonitoredSystemAdmissionPreview.tsx b/frontend-modern/src/components/Settings/MonitoredSystemAdmissionPreview.tsx
index 1edf009c1c..8e68bf3448 100644
--- a/frontend-modern/src/components/Settings/MonitoredSystemAdmissionPreview.tsx
+++ b/frontend-modern/src/components/Settings/MonitoredSystemAdmissionPreview.tsx
@@ -2,6 +2,7 @@ import { For, Show, type Component } from 'solid-js';
import type { MonitoredSystemLedgerPreviewResponse } from '@/api/monitoredSystemLedger';
import { CalloutCard } from '@/components/shared/CalloutCard';
import {
+ formatMonitoredSystemAdmissionPreviewSummary,
formatMonitoredSystemSurfaceAttribution,
getMonitoredSystemAdmissionPreviewTitle,
getMonitoredSystemAdmissionPreviewRequiredState,
@@ -14,37 +15,9 @@ interface MonitoredSystemAdmissionPreviewProps {
errorTitle?: string | null;
}
-const formatUsage = (count: number, limit: number): string =>
- limit > 0 ? `${count} / ${limit}` : `${count}`;
-
-const formatDelta = (count: number): string => {
- if (count > 0) return `+${count}`;
- return `${count}`;
-};
-
-const previewUsageDelta = (preview: MonitoredSystemLedgerPreviewResponse): number =>
- preview.projected_count - preview.current_count;
-
const previewTone = (preview: MonitoredSystemLedgerPreviewResponse | null) =>
preview?.would_exceed_limit ? 'warning' : 'info';
-const previewSummary = (preview: MonitoredSystemLedgerPreviewResponse): string => {
- const before = formatUsage(preview.current_count, preview.limit);
- const after = formatUsage(preview.projected_count, preview.limit);
- const delta = previewUsageDelta(preview);
- if (delta > 0) {
- return `Current usage ${before}. Saving this change would move usage to ${after} (${formatDelta(
- delta,
- )}).`;
- }
- if (delta < 0) {
- return `Current usage ${before}. Saving this change would move usage to ${after} (${formatDelta(
- delta,
- )}).`;
- }
- return `Current usage ${before}. Saving this change keeps usage at ${after}.`;
-};
-
export const MonitoredSystemAdmissionPreview: Component<MonitoredSystemAdmissionPreviewProps> = (
props,
) => {
@@ -83,7 +56,7 @@ export const MonitoredSystemAdmissionPreview: Component<MonitoredSystemAdmission
title={getMonitoredSystemAdmissionPreviewTitle(preview())}
description={
<div class="space-y-3 text-sm">
- <p>{previewSummary(preview())}</p>
+ <p>{formatMonitoredSystemAdmissionPreviewSummary(preview())}</p>
<Show when={preview().current_systems.length > 0}>
<div class="space-y-1">
<p class="text-xs font-medium uppercase tracking-wide text-muted">
diff --git a/frontend-modern/src/components/Settings/__tests__/MonitoredSystemAdmissionPreview.test.tsx b/frontend-modern/src/components/Settings/__tests__/MonitoredSystemAdmissionPreview.test.tsx
index 45e5d83f1c..3c04dfdbd9 100644
--- a/frontend-modern/src/components/Settings/__tests__/MonitoredSystemAdmissionPreview.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/MonitoredSystemAdmissionPreview.test.tsx
@@ -32,7 +32,9 @@ describe('MonitoredSystemAdmissionPreview', () => {
screen.getByText('This change keeps monitored-system count unchanged'),
).toBeInTheDocument();
expect(
- screen.getByText('Current usage 4 / 10. Saving this change keeps usage at 4 / 10.'),
+ screen.getByText(
+ 'Pulse currently counts 4 monitored systems. Saving this change would keep the count at 4 monitored systems.',
+ ),
).toBeInTheDocument();
});
@@ -49,7 +51,32 @@ describe('MonitoredSystemAdmissionPreview', () => {
expect(screen.getByText('This change removes monitored systems')).toBeInTheDocument();
expect(
- screen.getByText('Current usage 1 / 10. Saving this change would move usage to 0 / 10 (-1).'),
+ screen.getByText(
+ 'Pulse currently counts 1 monitored system. Saving this change would bring the count to 0 monitored systems (-1).',
+ ),
+ ).toBeInTheDocument();
+ });
+
+ it('describes active-policy failures without slash quota copy', () => {
+ render(() => (
+ <MonitoredSystemAdmissionPreview
+ preview={buildPreview({
+ current_count: 9,
+ projected_count: 11,
+ additional_count: 2,
+ would_exceed_limit: true,
+ effect: 'creates_multiple',
+ })}
+ />
+ ));
+
+ expect(
+ screen.getByText('This change exceeds the active monitored-system policy'),
+ ).toBeInTheDocument();
+ expect(
+ screen.getByText(
+ 'Pulse currently counts 9 monitored systems. Saving this change would bring the count to 11 monitored systems (+2), above the active policy of 10 monitored systems.',
+ ),
).toBeInTheDocument();
});
});
diff --git a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
index fc01ccf1b9..3c807ecb1a 100644
--- a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
@@ -222,6 +222,11 @@ describe('settings architecture guardrails', () => {
expect(monitoredSystemAdmissionPreviewSource).toContain(
'getMonitoredSystemAdmissionPreviewTitle',
);
+ expect(monitoredSystemAdmissionPreviewSource).toContain(
+ 'formatMonitoredSystemAdmissionPreviewSummary',
+ );
+ expect(monitoredSystemAdmissionPreviewSource).not.toContain('Current usage');
+ expect(monitoredSystemAdmissionPreviewSource).not.toContain(' / ');
expect(monitoredSystemAdmissionPreviewSource).not.toContain(
'reuses your current monitored-system capacity',
);
diff --git a/frontend-modern/src/utils/__tests__/monitoredSystemPresentation.test.ts b/frontend-modern/src/utils/__tests__/monitoredSystemPresentation.test.ts
index 8ca8eba31a..6ebde40593 100644
--- a/frontend-modern/src/utils/__tests__/monitoredSystemPresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/monitoredSystemPresentation.test.ts
@@ -8,6 +8,7 @@ import monitoredSystemPresentationSource from '@/utils/monitoredSystemPresentati
import {
buildMonitoredSystemCapacitySectionModel,
buildMonitoredSystemAdmissionPreviewUnavailableState,
+ formatMonitoredSystemAdmissionPreviewSummary,
formatMonitoredSystemAdmissionPreviewUnavailableMessage,
formatMonitoredSystemGroupedSourcesLabel,
formatMonitoredSystemLegacyConnectionBreakdown,
@@ -534,6 +535,28 @@ describe('monitoredSystemPresentation', () => {
).toBe('This change exceeds the active monitored-system policy');
});
+ it('formats monitored-system admission preview summaries without quota math', () => {
+ expect(
+ formatMonitoredSystemAdmissionPreviewSummary({
+ current_count: 4,
+ projected_count: 4,
+ limit: 10,
+ }),
+ ).toBe(
+ 'Pulse currently counts 4 monitored systems. Saving this change would keep the count at 4 monitored systems.',
+ );
+ expect(
+ formatMonitoredSystemAdmissionPreviewSummary({
+ current_count: 9,
+ projected_count: 11,
+ limit: 10,
+ would_exceed_limit: true,
+ }),
+ ).toBe(
+ 'Pulse currently counts 9 monitored systems. Saving this change would bring the count to 11 monitored systems (+2), above the active policy of 10 monitored systems.',
+ );
+ });
+
it('returns canonical monitored-system ledger unavailable copy', () => {
expect(formatMonitoredSystemLedgerUnavailableMessage('supplemental_inventory_unsettled')).toBe(
'Pulse is still collecting the first provider-owned inventory baseline. The monitored-system ledger will appear after that baseline completes.',
diff --git a/frontend-modern/src/utils/monitoredSystemPresentation.ts b/frontend-modern/src/utils/monitoredSystemPresentation.ts
index 4a1c823433..652dd58789 100644
--- a/frontend-modern/src/utils/monitoredSystemPresentation.ts
+++ b/frontend-modern/src/utils/monitoredSystemPresentation.ts
@@ -180,6 +180,20 @@ export type MonitoredSystemAdmissionPreviewTitleInput = {
would_exceed_limit?: boolean | null;
};
+export type MonitoredSystemAdmissionPreviewSummaryInput =
+ MonitoredSystemAdmissionPreviewTitleInput & {
+ limit?: number | null;
+ };
+
+const normalizeAdmissionPreviewCount = (count: number | null | undefined): number =>
+ typeof count === 'number' && Number.isFinite(count) ? Math.max(0, count) : 0;
+
+const formatAdmissionPreviewCount = (count: number): string =>
+ `${count} monitored ${count === 1 ? 'system' : 'systems'}`;
+
+const formatAdmissionPreviewDelta = (delta: number): string =>
+ delta > 0 ? `+${delta}` : `${delta}`;
+
export function getMonitoredSystemLedgerPresentation() {
return MONITORED_SYSTEM_LEDGER_PRESENTATION;
}
@@ -609,13 +623,10 @@ export function getMonitoredSystemAdmissionPreviewTitle(
if (!preview) return presentation.fallbackTitle;
if (preview.would_exceed_limit) return presentation.exceedsPolicyTitle;
- const current =
- typeof preview.current_count === 'number' && Number.isFinite(preview.current_count)
- ? preview.current_count
- : 0;
+ const current = normalizeAdmissionPreviewCount(preview.current_count);
const projected =
typeof preview.projected_count === 'number' && Number.isFinite(preview.projected_count)
- ? preview.projected_count
+ ? normalizeAdmissionPreviewCount(preview.projected_count)
: current;
const delta = projected - current;
@@ -624,6 +635,33 @@ export function getMonitoredSystemAdmissionPreviewTitle(
return presentation.unchangedTitle;
}
+export function formatMonitoredSystemAdmissionPreviewSummary(
+ preview: MonitoredSystemAdmissionPreviewSummaryInput,
+): string {
+ const current = normalizeAdmissionPreviewCount(preview.current_count);
+ const projected =
+ typeof preview.projected_count === 'number' && Number.isFinite(preview.projected_count)
+ ? normalizeAdmissionPreviewCount(preview.projected_count)
+ : current;
+ const limit = normalizeAdmissionPreviewCount(preview.limit);
+ const delta = projected - current;
+ const policySuffix =
+ preview.would_exceed_limit && limit > 0
+ ? `, above the active policy of ${formatAdmissionPreviewCount(limit)}`
+ : '';
+ const currentSummary = `Pulse currently counts ${formatAdmissionPreviewCount(current)}.`;
+
+ if (delta !== 0) {
+ return `${currentSummary} Saving this change would bring the count to ${formatAdmissionPreviewCount(
+ projected,
+ )} (${formatAdmissionPreviewDelta(delta)})${policySuffix}.`;
+ }
+
+ return `${currentSummary} Saving this change would keep the count at ${formatAdmissionPreviewCount(
+ projected,
+ )}${policySuffix}.`;
+}
+
export function formatMonitoredSystemAdmissionPreviewUnavailableMessage(reason?: string): string {
switch (normalizeMonitoredSystemValue(reason)) {
case 'supplemental_inventory_unsettled':