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.

fix(web): discard obsolete import impact previews

pulse-triage[bot]50270c24992f
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index ce06890833..38af7e1ffb 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -15,6 +15,20 @@
## Purpose
+### Import preview lifetime and setup authority
+
+The node credential editor binds each monitored-system impact preview to the
+current import-plan generation. Changing that plan (including changing away
+and back to the same endpoint), or disposing the editor, invalidates outstanding
+requests. Obsolete success, error and completion handlers cannot update the
+preview or end a newer request's loading state.
+
+Preview completion does not approve an import or grant setup-command authority.
+Plan changes still clear explicit approval; generating setup commands and saving
+remain subject to the existing approval guard. Preview generation is local UI
+state, not an agent identity, enrollment token or liveness signal.
+
+
### Explicit filesystem selections survive the report boundary
Disk reports carry optional `explicitlyIncluded` evidence when the collector
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 00afa859c6..545a8e1bec 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -20,6 +20,21 @@
## Purpose
+### Node import preview response ownership
+
+The node credential editor calls the existing monitored-system-ledger preview
+endpoint with the current plan's preview request. It accepts asynchronous
+response state only for the request's still-current local generation. A plan
+change or unmount retires that generation, including for error and loading-state
+updates; returning to the same endpoint does not revive a retired request.
+
+This is a consumer-side response-lifetime rule, not a wire-schema or server
+cancellation change. Current-request errors remain visible and retryable.
+A preview is informational: it cannot approve setup or mutate a connection.
+The focused NodeCredentialSlot regression and settings architecture boundary
+check accompany desktop/narrow browser interaction proof.
+
+
The delivery-log response redacts embedded webhook URLs in errorMessage rather than treating the entire diagnostic as a URL. Non-secret operation and failure context survive alongside notificationId, destinationId, outcome, failureClass and attempts; malformed URL diagnostics fail closed. The HTTP payload proof is TestContract_DeliveryDiagnosticPayload; notification handler tests pin plain, credential-bearing and malformed errors. No response keys or route permissions change.
### Canonical incident-history query contract
diff --git a/frontend-modern/browser-verification.json b/frontend-modern/browser-verification.json
index b0f5509715..e6aba4ffc5 100644
--- a/frontend-modern/browser-verification.json
+++ b/frontend-modern/browser-verification.json
@@ -1,42 +1,38 @@
{
"version": 1,
- "base_sha": "14a109444c6d1cad420797ea30f279e77b6fc517",
- "verified_at": "2026-09-09T10:42:06.278902Z",
+ "base_sha": "a61f1c7c82ad5c3229618a71b379b2deca0538bd",
+ "verified_at": "2026-09-09T23:36:48.909107Z",
"result": "passed",
"changed_paths": [
- "frontend-modern/src/AppLayout.tsx"
+ "frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/NodeCredentialSlot.tsx"
],
"content_sha256": {
- "frontend-modern/src/AppLayout.tsx": "71cbc527fae0dbae3891174bb8a140d90f50917405d6c15a3b0d8ae7dcb31644"
+ "frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/NodeCredentialSlot.tsx": "842afd8a7cd6a96309896c15ab9a428e27078f1d4176feaa24982fbae94acf9a"
},
"routes": [
- "/settings/organization",
- "/settings/organization/access",
- "/settings/organization/sharing"
+ "/settings/infrastructure",
+ "/settings/infrastructure?add=pve"
],
"viewports": [
{
- "width": 320,
- "height": 568
+ "width": 1280,
+ "height": 844
},
{
"width": 390,
"height": 844
- },
- {
- "width": 1280,
- "height": 720
}
],
"states": [
- "Signed entitled default and created organizations; non-demo Community backend",
- "Access invitation and outgoing sharing fixture",
- "Desktop incoming share pending then accepted"
+ "Managed source-built Community backend with authenticated local session; discovery and impact API responses controlled by Playwright fixtures",
+ "Candidate review with explicit approval; pending preview; edited endpoint; current success/error; disposed editor"
],
"interactions": [
- "Chromium and mobile WebKit: switch organization; audit three routes at both phone widths; reach shell bottom and assert page/shell width within one pixel",
- "Desktop Chromium Scenario 6: verify owner identity relationships, editor/viewer roles and pending approval; click Accept and verify accepted state via API"
+ "At both widths: discover candidate, open review, request preview, approve then edit endpoint and assert approval resets",
+ "Start replacement preview, deliver obsolete error, retain new loading state; resolve current success",
+ "Request preview then change endpoint away and back; obsolete success stays hidden; current error is visible and retry enabled",
+ "Close editor during pending request, resolve response, assert no preview appears outside disposed editor"
],
- "command": "pulse-heavy-run -- bash -c \"cd tests/integration && PULSE_E2E_USE_LOCAL_BACKEND=true node scripts/with-offline-entitlements.mjs node scripts/run-playwright.mjs tests/05-settings-mobile-audit.spec.ts --project=chromium --project=mobile-safari --grep settings/organization --workers=1 --retries=0\"; separate diagnostic config Scenario 6 desktop run",
- "notes": "Exact actual mobile grep: settings/organization(/(sharing|access))?$ . Six mobile route tests passed (53.0s); desktop sharing scenario passed (3.8s). Source-built real Community backend, ephemeral loopback signing issuer, no mock mode or signature bypass. Phone Chromium/WebKit and desktop acceptance screenshots inspected. Evidence retained in Web20260909T103517Z outcome directory browser-proof, org-fixed.log and scenario6-desktop.log. Not private RBAC, hosted probation clearance or release qualification."
+ "command": "pulse-heavy-run -- bash -c 'cd tests/integration && PULSE_E2E_USE_LOCAL_BACKEND=true node scripts/run-playwright.mjs tests/68-infrastructure-onboarding.spec.ts --project=chromium --grep \"import preview ignores\" --workers=1 --retries=0'",
+ "notes": "Final current production build and both Chromium cases passed (8.1s). Desktop and narrow screenshots inspected. Real managed backend; discovery/impact are synthetic API fixtures, not appliance or reporter acceptance. Evidence: Web20260909T232514Z outcome browser-proof. No release qualification claim."
}
diff --git a/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/NodeCredentialSlot.tsx b/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/NodeCredentialSlot.tsx
index b1d4e70a51..d99cb05ece 100644
--- a/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/NodeCredentialSlot.tsx
+++ b/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/NodeCredentialSlot.tsx
@@ -1,4 +1,4 @@
-import { Component, createEffect, createMemo, createSignal } from 'solid-js';
+import { Component, createEffect, createMemo, createSignal, onCleanup } from 'solid-js';
import {
MonitoredSystemLedgerAPI,
type MonitoredSystemLedgerPreviewResponse,
@@ -103,6 +103,10 @@ export const NodeCredentialSlot: Component<NodeCredentialSlotProps> = (props) =>
buildNodeImportPlan(props.nodeType, state.formData(), props.importCandidate),
);
+ let previewGeneration = 0;
+ onCleanup(() => {
+ previewGeneration += 1;
+ });
let previousImportPlanSignature = '';
createEffect(() => {
@@ -111,6 +115,9 @@ export const NodeCredentialSlot: Component<NodeCredentialSlotProps> = (props) =>
return;
}
previousImportPlanSignature = signature;
+ // Pending results belong to the old plan, including an A → B → A edit.
+ previewGeneration += 1;
+ setPreviewingImportImpact(false);
setImportApproved(false);
setImportImpactPreview(null);
setImportImpactPreviewError(null);
@@ -125,19 +132,22 @@ export const NodeCredentialSlot: Component<NodeCredentialSlotProps> = (props) =>
return;
}
+ const generation = ++previewGeneration;
setPreviewingImportImpact(true);
setImportImpactPreviewError(null);
try {
const preview = await MonitoredSystemLedgerAPI.preview(plan.previewRequest);
+ if (generation !== previewGeneration) return;
setImportImpactPreview(preview);
} catch (error) {
+ if (generation !== previewGeneration) return;
logger.error('[Infrastructure Import Plan] Impact preview failed', error);
setImportImpactPreview(null);
setImportImpactPreviewError(
error instanceof Error ? error.message : 'Unable to calculate import impact right now.',
);
} finally {
- setPreviewingImportImpact(false);
+ if (generation === previewGeneration) setPreviewingImportImpact(false);
}
};
diff --git a/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/__tests__/NodeCredentialSlot.test.tsx b/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/__tests__/NodeCredentialSlot.test.tsx
index 8f857dd473..c36fb7276d 100644
--- a/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/__tests__/NodeCredentialSlot.test.tsx
+++ b/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/__tests__/NodeCredentialSlot.test.tsx
@@ -3,6 +3,7 @@ import { createSignal } from 'solid-js';
import { afterEach, describe, expect, it, vi } from 'vitest';
import type { InfrastructurePlatformSettingsProps } from '@/components/Settings/proxmoxSettingsModel';
import type { NodeConfigWithStatus } from '@/types/nodes';
+import { MonitoredSystemLedgerAPI } from '@/api/monitoredSystemLedger';
import { NodeCredentialSlot } from '../NodeCredentialSlot';
const importApprovalRequiredMessage =
@@ -20,7 +21,10 @@ const createSettings = (): InfrastructurePlatformSettingsProps =>
}) as unknown as InfrastructurePlatformSettingsProps;
describe('NodeCredentialSlot', () => {
- afterEach(() => cleanup());
+ afterEach(() => {
+ cleanup();
+ vi.restoreAllMocks();
+ });
it('syncs an untouched mounted editor to a refreshed node snapshot', async () => {
const settings = createSettings();
@@ -160,6 +164,43 @@ describe('NodeCredentialSlot', () => {
expect(settings.saveNode).not.toHaveBeenCalled();
});
+ it('discards an obsolete preview error after the endpoint changes', async () => {
+ let rejectPreview!: (error: Error) => void;
+ const pending = new Promise<never>((_, reject) => {
+ rejectPreview = reject;
+ });
+ vi.spyOn(MonitoredSystemLedgerAPI, 'preview').mockReturnValueOnce(pending);
+ render(() => (
+ <NodeCredentialSlot
+ nodeType="pve"
+ settings={createSettings()}
+ prefillNode={{ name: 'tower', host: 'https://tower.local:8006' }}
+ importCandidate={{
+ kind: 'discovery',
+ server: {
+ type: 'pve',
+ ip: '10.0.0.10',
+ hostname: 'tower.local',
+ port: 8006,
+ version: '9.0',
+ },
+ }}
+ onCancel={vi.fn()}
+ onSaved={vi.fn()}
+ />
+ ));
+ fireEvent.click(screen.getByRole('button', { name: 'Preview impact' }));
+ fireEvent.input(screen.getByLabelText(/^Endpoint URL/), {
+ target: { value: 'https://replacement.local:8006' },
+ });
+ rejectPreview(new Error('Obsolete endpoint failure'));
+ await pending.catch(() => undefined);
+ await waitFor(() => {
+ expect(screen.queryByText('Obsolete endpoint failure')).not.toBeInTheDocument();
+ expect(screen.getByRole('button', { name: 'Preview impact' })).toBeEnabled();
+ });
+ });
+
it('requires candidate import plan approval before guided setup handoff or manual save', () => {
render(() => (
<NodeCredentialSlot
diff --git a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
index 828c5df0f4..5251f0ac31 100644
--- a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
@@ -2094,3 +2094,20 @@ describe('organisation principal shell boundary', () => {
}
});
});
+
+describe('node import preview authority boundary', () => {
+ it('keeps preview responses informational and setup approval explicit', () => {
+ const previewHandler = nodeCredentialSlotSource.slice(
+ nodeCredentialSlotSource.indexOf('const handlePreviewImportImpact'),
+ nodeCredentialSlotSource.indexOf('const handleSubmit'),
+ );
+ expect(previewHandler).toContain('MonitoredSystemLedgerAPI.preview(plan.previewRequest)');
+ expect(previewHandler).not.toContain('setImportApproved');
+ expect(previewHandler).not.toContain('saveNode');
+ expect(previewHandler).not.toContain('handleSubmit');
+ expect(nodeCredentialSlotSource).toContain(
+ 'setupHandoffDisabled: () => Boolean(props.importCandidate && !importApproved())',
+ );
+ expect(nodeCredentialSlotSource).toContain('if (saveBlockedByImportPlan())');
+ });
+});
diff --git a/tests/integration/tests/68-infrastructure-onboarding.spec.ts b/tests/integration/tests/68-infrastructure-onboarding.spec.ts
index d47b5d78cd..81c1bc47ff 100644
--- a/tests/integration/tests/68-infrastructure-onboarding.spec.ts
+++ b/tests/integration/tests/68-infrastructure-onboarding.spec.ts
@@ -459,6 +459,187 @@ test.describe("Infrastructure onboarding", () => {
).toHaveValue("https://discovered-pve.lab:8006");
});
+ for (const width of [1280, 390]) {
+ test(`import preview ignores obsolete responses at ${width}px`, async ({
+ page,
+ }, testInfo) => {
+ await page.setViewportSize({ width, height: 844 });
+
+ await prepareOnboardingPage(page);
+
+ // The "Run discovery" scan button only renders when discovery is enabled.
+ // Enable it by passing the real system-settings response through with
+ // discoveryEnabled flipped on, so this test can exercise the scan flow.
+ await page.route("**/api/system/settings", async (route) => {
+ if (route.request().method() !== "GET") {
+ await route.continue();
+ return;
+ }
+ const response = await route.fetch();
+ const body = await response.json();
+ body.discoveryEnabled = true;
+ await route.fulfill({ response, json: body });
+ });
+
+ await page.route("**/api/discover", async (route) => {
+ const requestUrl = new URL(route.request().url());
+ if (requestUrl.pathname !== "/api/discover") {
+ await route.continue();
+ return;
+ }
+
+ if (route.request().method() === "GET") {
+ await route.fulfill({
+ status: 200,
+ contentType: "application/json",
+ body: JSON.stringify({
+ servers: [],
+ errors: [],
+ cached: true,
+ updated: 0,
+ age: 0,
+ }),
+ });
+ return;
+ }
+
+ if (route.request().method() === "POST") {
+ await route.fulfill({
+ status: 200,
+ contentType: "application/json",
+ body: JSON.stringify({
+ servers: [
+ {
+ ip: "10.0.0.55",
+ port: 8006,
+ type: "pve",
+ version: "8.2.2",
+ hostname: "discovered-pve.lab",
+ },
+ ],
+ errors: [],
+ cached: false,
+ scanning: false,
+ timestamp: 1_700_000_000_000,
+ }),
+ });
+ return;
+ }
+
+ await route.continue();
+ });
+
+ await page.goto("/settings/infrastructure", {
+ waitUntil: "domcontentloaded",
+ });
+ await page.waitForURL(/\/settings\/infrastructure(?:\?.*)?$/, {
+ timeout: 15_000,
+ });
+
+ await page.getByRole("button", { name: /Run discovery/i }).click();
+
+ await expect(
+ page.getByText("discovered-pve.lab", { exact: true }),
+ ).toBeVisible();
+ await expect(
+ page.getByRole("button", { name: /^Review$/i }),
+ ).toBeVisible();
+
+ await page.getByRole("button", { name: /^Review$/i }).click();
+ await page.waitForURL(/\/settings\/infrastructure\?add=pve$/, {
+ timeout: 15_000,
+ });
+
+ await expect(page.getByRole("dialog")).toBeVisible();
+ await expect(
+ page
+ .getByRole("dialog")
+ .getByRole("heading", { name: "Add Proxmox VE", exact: true }),
+ ).toBeVisible();
+ await expect(
+ page.getByPlaceholder("https://proxmox.example.com:8006"),
+ ).toHaveValue("https://discovered-pve.lab:8006");
+
+ const dialog = page.getByRole("dialog");
+ const endpoint = dialog.getByLabel(/^Endpoint URL/);
+ const previewButton = dialog.getByRole("button", {
+ name: "Preview impact",
+ exact: true,
+ });
+ const requests: import("@playwright/test").Route[] = [];
+ await page.route(
+ "**/api/license/monitored-system-ledger/preview",
+ (route) => {
+ requests.push(route);
+ },
+ );
+ const success = {
+ current_count: 1,
+ projected_count: 1,
+ additional_count: 0,
+ effect: "unchanged",
+ current_systems: [],
+ projected_systems: [],
+ current_system: null,
+ projected_system: null,
+ };
+ await previewButton.click();
+ await expect.poll(() => requests.length).toBe(1);
+ await dialog.getByLabel(/Approve this import plan/i).check();
+ await endpoint.fill("https://replacement.lab:8006");
+ await expect(
+ dialog.getByLabel(/Approve this import plan/i),
+ ).not.toBeChecked();
+ await expect(previewButton).toBeEnabled();
+ await previewButton.click();
+ await expect.poll(() => requests.length).toBe(2);
+ await requests[0].fulfill({
+ status: 400,
+ json: { error: "Obsolete endpoint failure" },
+ });
+ await expect(
+ dialog.getByText("Calculating monitored-system impact…"),
+ ).toBeVisible();
+ await expect(dialog.getByText("Obsolete endpoint failure")).toHaveCount(
+ 0,
+ );
+ await requests[1].fulfill({ json: success });
+ await expect(
+ dialog.getByText("This change keeps monitored-system count unchanged"),
+ ).toBeVisible();
+
+ // An obsolete success must not reappear even after returning to the same endpoint.
+ await previewButton.click();
+ await expect.poll(() => requests.length).toBe(3);
+ await endpoint.fill("https://third.lab:8006");
+ await endpoint.fill("https://replacement.lab:8006");
+ await requests[2].fulfill({ json: success });
+ await expect(
+ dialog.getByText("This change keeps monitored-system count unchanged"),
+ ).toHaveCount(0);
+ await previewButton.click();
+ await expect.poll(() => requests.length).toBe(4);
+ await requests[3].fulfill({
+ status: 400,
+ json: { error: "Current endpoint failure" },
+ });
+ await expect(dialog.getByText("Current endpoint failure")).toBeVisible();
+ await expect(previewButton).toBeEnabled();
+ await page.screenshot({
+ path: testInfo.outputPath(`preview-${width}.png`),
+ fullPage: true,
+ });
+ await previewButton.click();
+ await expect.poll(() => requests.length).toBe(5);
+ await dialog.getByRole("button", { name: /^(Cancel|Close)$/ }).click();
+ await expect(dialog).not.toBeVisible();
+ await requests[4].fulfill({ json: success });
+ await expect(
+ page.getByText("This change keeps monitored-system count unchanged"),
+ ).toHaveCount(0);
+ });
+ }
+
test("desktop detect utility offers no-match agent fallback from the add-infrastructure picker", async ({
page,
}, testInfo) => {