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.

Reproduce retained machine and Debug status drift

pulse-triage[bot]b9e2390bb70b
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawerDebugTab.relativeAge.test.tsx b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawerDebugTab.relativeAge.test.tsx
index 330007978c..46d278e682 100644
--- a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawerDebugTab.relativeAge.test.tsx
+++ b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawerDebugTab.relativeAge.test.tsx
@@ -1,5 +1,6 @@
import { cleanup, fireEvent, render, within } from '@solidjs/testing-library';
import { createSignal, Show } from 'solid-js';
+import { createStore, reconcile } from 'solid-js/store';
import { afterEach, describe, expect, it, vi } from 'vitest';
import type { Resource } from '@/types/resource';
@@ -65,6 +66,53 @@ afterEach(() => {
});
describe('resource Debug source ages', () => {
+ it('follows arriving status records while payload sections, disclosure and focus stay mounted', () => {
+ vi.useFakeTimers({ now: start });
+ const [resource, setResource] = createStore(
+ makeResource() as Resource & { platformData: PlatformData },
+ );
+ const view = render(() => <Fixture resource={resource} />);
+ const details = [...view.container.querySelectorAll('details')];
+ const summaries = details.map((element) => element.querySelector('summary')!);
+ const payloads = details.map((element) => element.querySelector('pre')!.textContent);
+ details[0].open = true;
+ summaries[0].focus();
+
+ // Only source status is replaced, as in a nested canonical store update.
+ // The real derived-state sourceSections memo keeps its original entries.
+ setResource('platformData', 'sourceStatus', {
+ proxmox: { status: 'available', lastSeen: start },
+ agent: {
+ status: 'error',
+ lastSeen: new Date(start).toISOString(),
+ error: 'Agent unavailable',
+ },
+ });
+ expect(summaries[0]).toHaveTextContent('available • 0s ago');
+ expect(summaries[1]).toHaveTextContent('error • 0s ago');
+ expect(within(view.container).queryByText('Guest read deferred')).not.toBeInTheDocument();
+ expect(within(view.container).getByText('Agent unavailable')).toBeInTheDocument();
+ expect([...view.container.querySelectorAll('details')]).toEqual(details);
+ expect(details[0].open).toBe(true);
+ expect(summaries[0]).toHaveFocus();
+ expect(details.map((element) => element.querySelector('pre')!.textContent)).toEqual(payloads);
+
+ vi.advanceTimersByTime(60_000);
+ expect(summaries[0]).toHaveTextContent('available • 1 min ago');
+ expect(summaries[1]).toHaveTextContent('error • 1 min ago');
+ setResource(
+ 'platformData',
+ 'sourceStatus',
+ reconcile({
+ proxmox: { status: 'deferred', lastSeen: 'invalid', error: 'No usable timestamp' },
+ }),
+ );
+ expect(summaries[0].textContent).toBe('Proxmoxdeferred');
+ expect(summaries[1].textContent).toBe('Agentunknown');
+ expect(within(view.container).queryByText('Agent unavailable')).not.toBeInTheDocument();
+ expect(within(view.container).getByText('No usable timestamp')).toBeInTheDocument();
+ });
+
it('ages held source timestamps with the drawer without receiving another snapshot', () => {
vi.useFakeTimers({ now: start });
const resource = makeResource();
diff --git a/frontend-modern/src/features/standalone/__tests__/AgentsMachinesTable.test.tsx b/frontend-modern/src/features/standalone/__tests__/AgentsMachinesTable.test.tsx
index 128daa6740..105100a569 100644
--- a/frontend-modern/src/features/standalone/__tests__/AgentsMachinesTable.test.tsx
+++ b/frontend-modern/src/features/standalone/__tests__/AgentsMachinesTable.test.tsx
@@ -1,5 +1,5 @@
import { cleanup, fireEvent, render, screen, waitFor, within } from '@solidjs/testing-library';
-import { createSignal } from 'solid-js';
+import { createSignal, Show } from 'solid-js';
import { createStore, reconcile } from 'solid-js/store';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { AgentMetadataAPI } from '@/api/agentMetadata';
@@ -7,9 +7,10 @@ import { MonitoringAPI } from '@/api/monitoring';
import type { Alert } from '@/types/api';
import type { Resource } from '@/types/resource';
import { STORAGE_KEYS } from '@/utils/localStorage';
-import { RELATIVE_TIME_TICK_MS } from '@/utils/relativeTimeClock';
+import { RELATIVE_TIME_TICK_MS, useRelativeTimeNow } from '@/utils/relativeTimeClock';
import { RESOURCE_METADATA_CHANGED_EVENT } from '@/utils/resourceMetadataEvents';
import { AgentsMachinesTable } from '../AgentsMachinesTable';
+import { buildStandalonePostureSummary } from '../standalonePageModel';
vi.mock('@/components/Infrastructure/ResourceDetailDrawer', () => ({
ResourceDetailDrawer: (props: {
@@ -161,6 +162,67 @@ afterEach(() => {
});
describe('AgentsMachinesTable', () => {
+ it('keeps the retained row status in agreement with posture across the five-minute clock boundary', () => {
+ const start = Date.parse('2026-10-11T17:00:00Z');
+ vi.useFakeTimers({ toFake: ['Date', 'setInterval', 'clearInterval'], now: start });
+ try {
+ const [machines, setMachines] = createStore([
+ resource({ id: 'silent', lastSeen: start, cpu: 24, agent: { stale: false } }),
+ ]);
+ const original = JSON.stringify(machines);
+ const [mounted, setMounted] = createSignal(true);
+ const view = render(() => {
+ const now = useRelativeTimeNow();
+ return (
+ <>
+ <output data-testid="posture-attention">
+ {buildStandalonePostureSummary(machines, now()).attention}
+ </output>
+ <Show when={mounted()}>
+ <AgentsMachinesTable
+ resources={machines}
+ emptyIcon={emptyIcon}
+ emptyTitle="No machines"
+ emptyDescription="Install Pulse Agent."
+ />
+ </Show>
+ </>
+ );
+ });
+ const dot = () =>
+ view.container.querySelector('[data-agents-machine-row] span[title="online"]')!;
+ const row = view.container.querySelector('[data-agents-machine-row]');
+ const cpu = screen.getByTestId('agent-machine-cpu-bar');
+ expect(dot()).toHaveClass('bg-emerald-500');
+ vi.advanceTimersByTime(5 * 60_000);
+ expect(dot()).toHaveClass('bg-emerald-500');
+ expect(screen.getByTestId('posture-attention')).toHaveTextContent('0');
+
+ vi.advanceTimersByTime(RELATIVE_TIME_TICK_MS);
+ expect(screen.getByTestId('posture-attention')).toHaveTextContent('1');
+ expect(dot()).toHaveClass('bg-amber-500');
+ expect(view.container.querySelector('[data-agents-machine-row]')).toBe(row);
+ expect(screen.getByTestId('agent-machine-cpu-bar')).toBe(cpu);
+ expect(cpu).toHaveAttribute('data-usage', '24');
+ expect(JSON.stringify(machines)).toBe(original);
+
+ setMounted(false);
+ setMounted(true);
+ expect(dot()).toHaveClass('bg-amber-500');
+ setMachines(0, 'lastSeen', Date.now());
+ expect(dot()).toHaveClass('bg-emerald-500');
+ expect(screen.getByTestId('posture-attention')).toHaveTextContent('0');
+ setMachines(0, 'status', 'offline');
+ expect(
+ view.container.querySelector('[data-agents-machine-row] span[title="offline"]'),
+ ).toHaveClass('bg-red-500');
+ expect(screen.queryByTestId('agent-machine-cpu-bar')).not.toBeInTheDocument();
+ } finally {
+ cleanup();
+ vi.useRealTimers();
+ }
+ });
+
it('keeps disk and last-seen telemetry in the phone column set', () => {
const { container } = render(() => (
<AgentsMachinesTable
diff --git a/frontend-modern/src/features/standalone/__tests__/standalonePageModel.test.ts b/frontend-modern/src/features/standalone/__tests__/standalonePageModel.test.ts
index d43369579f..0fa53e96df 100644
--- a/frontend-modern/src/features/standalone/__tests__/standalonePageModel.test.ts
+++ b/frontend-modern/src/features/standalone/__tests__/standalonePageModel.test.ts
@@ -1,4 +1,4 @@
-import { describe, expect, it } from 'vitest';
+import { describe, expect, it, vi } from 'vitest';
import type { Resource } from '@/types/resource';
import {
buildStandalonePageModel,
@@ -21,6 +21,31 @@ const resource = (overrides: Partial<Resource>): Resource =>
}) as Resource;
describe('standalonePageModel', () => {
+ it('classifies each resource once per attention sort and reclassifies on the next call', () => {
+ const now = 1_700_000_030_000;
+ let firstStatus: Resource['status'] = 'online';
+ const reads = Array.from({ length: 120 }, (_, index) =>
+ vi.fn(() => (index === 0 ? firstStatus : 'online')),
+ );
+ const resources = reads.map((read, index) => {
+ const value = resource({ id: `host-${index}`, displayName: `Host ${119 - index}` });
+ Object.defineProperty(value, 'status', { get: read });
+ return value;
+ });
+ const original = [...resources];
+ const sorted = sortStandaloneResourcesByAttention(resources, now);
+ expect(sorted.map((value) => value.displayName)).toEqual(
+ Array.from({ length: 120 }, (_, index) => `Host ${index}`),
+ );
+ for (const read of reads) expect(read).toHaveBeenCalledTimes(1);
+ expect(resources).toEqual(original);
+
+ firstStatus = 'offline';
+ expect(sortStandaloneResourcesByAttention(resources, now)[0]).toBe(resources[0]);
+ for (const read of reads) expect(read).toHaveBeenCalledTimes(2);
+ expect(sortStandaloneResourcesByAttention([], now)).toEqual([]);
+ });
+
it('summarizes normal, attention, unknown, and freshness posture from canonical status', () => {
const summary = buildStandalonePostureSummary(
[