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.

Show unavailable infrastructure reads instead of empty onboarding

pulse-triage[bot]f15c72aa273a
diff --git a/frontend-modern/src/components/Settings/InfrastructureSourceManager.tsx b/frontend-modern/src/components/Settings/InfrastructureSourceManager.tsx
index 6fc8a7fd6c..a30c95bb61 100644
--- a/frontend-modern/src/components/Settings/InfrastructureSourceManager.tsx
+++ b/frontend-modern/src/components/Settings/InfrastructureSourceManager.tsx
@@ -19,6 +19,7 @@ import {
SlidersHorizontal,
} from 'lucide-solid';
import { Button } from '@/components/shared/Button';
+import { getAPIReadAccessErrorMessage } from '@/utils/apiAccessError';
import SettingsPanel from '@/components/shared/SettingsPanel';
import {
Table,
@@ -56,6 +57,9 @@ import { ClusterAgentDeployDialog } from './ClusterAgentDeployDialog';
interface InfrastructureSourceManagerProps {
rows: Accessor<readonly InfrastructureSystemRow[]>;
+ inventoryLoading?: boolean;
+ inventoryError?: unknown;
+ onRetryInventory?: () => void;
discoveredNodes: Accessor<readonly DiscoveredServer[]>;
discoveryEnabled: boolean;
discoveryScanStatus: Accessor<DiscoveryScanStatus>;
@@ -326,6 +330,7 @@ const agentHostProfileGroupLabel = (row: InfrastructureSystemRow): string | null
export const InfrastructureSourceManager: Component<InfrastructureSourceManagerProps> = (props) => {
let layoutContainerRef: HTMLDivElement | undefined;
const products = createMemo(() => getInfrastructureSourceManagerProducts());
+ const inventoryReadUncertain = () => Boolean(props.inventoryLoading || props.inventoryError);
const infrastructureRows = createMemo(() =>
props.rows().filter((row) => row.ownerType !== 'availability'),
);
@@ -355,7 +360,8 @@ export const InfrastructureSourceManager: Component<InfrastructureSourceManagerP
next.set(product.type, []);
}
- for (const server of props.discoveredNodes()) {
+ // A failed inventory cannot establish that a discovered system is new.
+ for (const server of inventoryReadUncertain() ? [] : props.discoveredNodes()) {
const productRows = next.get(server.type as InfrastructureOnboardingConnectionType);
if (!productRows) continue;
productRows.push(server);
@@ -855,6 +861,49 @@ export const InfrastructureSourceManager: Component<InfrastructureSourceManagerP
</div>
);
+ const inventoryReadNotice = () => (
+ <Show
+ when={props.inventoryError}
+ fallback={
+ <Show when={props.inventoryLoading}>
+ <div role="status" class="border-b border-border px-4 py-4 text-sm text-muted">
+ {hasAnyConfigured()
+ ? 'Refreshing connected systems...'
+ : 'Loading connected systems...'}
+ </div>
+ </Show>
+ }
+ >
+ <div
+ role="alert"
+ class="flex flex-col gap-3 border-b border-amber-300 bg-amber-50 px-4 py-4 text-sm text-amber-900 sm:flex-row sm:items-center sm:justify-between dark:border-amber-900/25 dark:bg-amber-950/25 dark:text-amber-200"
+ >
+ <div class="min-w-0 space-y-1">
+ <p class="font-semibold">Connected systems unavailable</p>
+ <p>
+ {getAPIReadAccessErrorMessage(props.inventoryError) ??
+ 'Pulse could not read the connection list. Retry to check your saved systems.'}
+ </p>
+ <Show when={hasAnyConfigured()}>
+ <p>Showing the last loaded list. Connection status may be out of date.</p>
+ </Show>
+ </div>
+ <Show when={props.onRetryInventory}>
+ <Button
+ type="button"
+ variant="secondary"
+ size="mdCompact"
+ class="min-h-11 shrink-0 self-start sm:self-center lg:min-h-9"
+ disabled={props.inventoryLoading}
+ onClick={() => props.onRetryInventory?.()}
+ >
+ {props.inventoryLoading ? 'Retrying...' : 'Retry'}
+ </Button>
+ </Show>
+ </div>
+ </Show>
+ );
+
return (
<div ref={layoutContainerRef} class="min-w-0">
<SettingsPanel
@@ -875,9 +924,10 @@ export const InfrastructureSourceManager: Component<InfrastructureSourceManagerP
) : undefined
}
>
- {setupSummaryBand()}
+ {inventoryReadNotice()}
+ <Show when={!inventoryReadUncertain()}>{setupSummaryBand()}</Show>
- <Show when={!useCardLayout()}>
+ <Show when={!useCardLayout() && (hasAnyConfigured() || !inventoryReadUncertain())}>
<Table class="w-full min-w-[820px] table-fixed text-sm">
<TableHeader class="">
<TableRow>
@@ -1445,7 +1495,7 @@ export const InfrastructureSourceManager: Component<InfrastructureSourceManagerP
</Table>
</Show>
- <Show when={useCardLayout()}>
+ <Show when={useCardLayout() && (hasAnyConfigured() || !inventoryReadUncertain())}>
<div class="space-y-3 p-3">
<For each={sortedProducts()}>
{(product) => {
@@ -1860,7 +1910,7 @@ export const InfrastructureSourceManager: Component<InfrastructureSourceManagerP
</Show>
</div>
</Show>
- {discoveryMonitorBand()}
+ <Show when={!inventoryReadUncertain()}>{discoveryMonitorBand()}</Show>
{/* Keyed so the dialog gets plain values: an install it started keeps
running after close, and must not read a stale <Show> accessor. */}
<Show when={clusterDeploy()} keyed>
diff --git a/frontend-modern/src/components/Settings/InfrastructureWorkspace.tsx b/frontend-modern/src/components/Settings/InfrastructureWorkspace.tsx
index afdc957ccb..9b488a2562 100644
--- a/frontend-modern/src/components/Settings/InfrastructureWorkspace.tsx
+++ b/frontend-modern/src/components/Settings/InfrastructureWorkspace.tsx
@@ -987,6 +987,9 @@ const InfrastructureWorkspaceContent: Component<InfrastructureWorkspaceProps> =
<div class="space-y-6">
<InfrastructureSourceManager
rows={rows}
+ inventoryLoading={!ledger.resolvedOnce() || ledger.loading()}
+ inventoryError={ledger.error()}
+ onRetryInventory={() => ledger.reload()}
discoveredNodes={visibleDiscoveredNodes}
discoveryEnabled={props.discoveryEnabled()}
discoveryScanStatus={props.discoveryScanStatus}
diff --git a/frontend-modern/src/components/Settings/__tests__/InfrastructureSourceManager.test.tsx b/frontend-modern/src/components/Settings/__tests__/InfrastructureSourceManager.test.tsx
index d9602f1031..ad14d2c822 100644
--- a/frontend-modern/src/components/Settings/__tests__/InfrastructureSourceManager.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/InfrastructureSourceManager.test.tsx
@@ -22,6 +22,7 @@ import {
type InfrastructureSystemRow,
} from '../connectionsTableModel';
import type { Connection } from '@/api/connections';
+import { eventBus } from '@/stores/events';
import { ConnectionsAPI } from '@/api/connections';
import { resetCreateNonSuspendingQueryCacheForTest } from '@/hooks/createNonSuspendingQuery';
import { useConnectionsLedger } from '../useConnectionsLedger';
@@ -128,6 +129,151 @@ describe('InfrastructureSourceManager setup summary', () => {
Object.defineProperty(window, 'innerWidth', { configurable: true, value: 1024 });
});
+ const renderReadState = (readOnly = false, withCandidate = false) => {
+ const { result: ledger } = renderHook(() => useConnectionsLedger());
+ const onOpenConnection = vi.fn();
+ render(() => (
+ <InfrastructureSourceManager
+ rows={ledger.rows}
+ inventoryLoading={!ledger.resolvedOnce() || ledger.loading()}
+ inventoryError={ledger.error()}
+ onRetryInventory={ledger.reload}
+ discoveredNodes={() =>
+ withCandidate ? [{ ip: '192.0.2.1', port: 8006, type: 'pve' }] : []
+ }
+ discoveryEnabled={false}
+ discoveryScanStatus={() => ({ scanning: false })}
+ readOnly={readOnly}
+ onOpenConnection={onOpenConnection}
+ />
+ ));
+ return { ledger, onOpenConnection };
+ };
+
+ it('distinguishes an unread list from empty and keeps a failed read visible during retry', async () => {
+ let failFirst!: (error: unknown) => void;
+ let recover!: (value: Awaited<ReturnType<typeof ConnectionsAPI.list>>) => void;
+ const list = vi
+ .spyOn(ConnectionsAPI, 'list')
+ .mockImplementationOnce(
+ () =>
+ new Promise((_, reject) => {
+ failFirst = reject;
+ }),
+ )
+ .mockImplementationOnce(
+ () =>
+ new Promise((resolve) => {
+ recover = resolve;
+ }),
+ );
+ const { onOpenConnection } = renderReadState(false, true);
+ expect(screen.getByRole('status')).toHaveTextContent('Loading connected systems...');
+ expect(screen.queryByText('0 systems connected')).toBeNull();
+ expect(screen.queryByText('Start monitoring infrastructure')).toBeNull();
+
+ failFirst({ status: 503 });
+ await waitFor(() =>
+ expect(screen.getByRole('alert')).toHaveTextContent('Connected systems unavailable'),
+ );
+ expect(screen.queryByText('0 systems connected')).toBeNull();
+ expect(screen.queryByText('Start monitoring infrastructure')).toBeNull();
+ // Discovery cannot safely deduplicate candidates against unread inventory.
+ expect(screen.queryByText('192.0.2.1')).toBeNull();
+ fireEvent.click(screen.getByRole('button', { name: 'Retry' }));
+ expect(screen.getByRole('button', { name: 'Retrying...' })).toBeDisabled();
+ expect(screen.getByRole('alert')).toHaveTextContent('Connected systems unavailable');
+ expect(list).toHaveBeenCalledTimes(2);
+
+ const saved = connectionFixture({
+ id: 'pve:saved',
+ type: 'pve',
+ name: 'Saved scoped PVE',
+ state: 'paused',
+ enabled: false,
+ address: 'https://saved.invalid:8006',
+ scope: { vms: false, storage: true },
+ });
+ recover({ connections: [saved], systems: [] });
+ await waitFor(() => expect(screen.queryByRole('alert')).toBeNull());
+ expect(screen.getByText('Saved scoped PVE')).toBeInTheDocument();
+ expect(screen.getByText('Paused')).toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: 'Manage' }));
+ expect(onOpenConnection.mock.calls[0][0].connection).toEqual(saved);
+ expect(list).toHaveBeenCalledTimes(2);
+ });
+
+ it('labels retained rows as old after a transient failure and restores posture only on success', async () => {
+ const saved = connectionFixture({ name: 'Last saved host' });
+ const list = vi
+ .spyOn(ConnectionsAPI, 'list')
+ .mockResolvedValue({ connections: [saved], systems: [] });
+ const { ledger } = renderReadState();
+ await waitFor(() => expect(screen.getByText('1 system connected')).toBeInTheDocument());
+ list.mockRejectedValueOnce({ status: 503 });
+ ledger.reload();
+ await waitFor(() =>
+ expect(screen.getByRole('alert')).toHaveTextContent(
+ 'Showing the last loaded list. Connection status may be out of date.',
+ ),
+ );
+ expect(screen.getByText('Last saved host')).toBeInTheDocument();
+ expect(screen.queryByText('All active')).toBeNull();
+ expect(screen.queryByText('1 system connected')).toBeNull();
+ fireEvent.click(screen.getByRole('button', { name: 'Retry' }));
+ await waitFor(() => expect(screen.getByText('1 system connected')).toBeInTheDocument());
+ expect(screen.queryByRole('alert')).toBeNull();
+ expect(list).toHaveBeenCalledTimes(3);
+ });
+
+ it.each([401, 403])(
+ 'withdraws retained rows on HTTP %s without claiming absence',
+ async (status) => {
+ const list = vi
+ .spyOn(ConnectionsAPI, 'list')
+ .mockResolvedValue({
+ connections: [connectionFixture({ name: 'Private host' })],
+ systems: [],
+ });
+ const { ledger } = renderReadState(true);
+ await waitFor(() => expect(screen.getByText('Private host')).toBeInTheDocument());
+ list.mockRejectedValueOnce({ status });
+ ledger.reload();
+ await waitFor(() =>
+ expect(screen.getByRole('alert')).toHaveTextContent(
+ status === 401 ? 'Sign in again' : 'Access denied',
+ ),
+ );
+ expect(screen.queryByText('Private host')).toBeNull();
+ expect(screen.queryByText('0 systems connected')).toBeNull();
+ expect(screen.queryByText('Start monitoring infrastructure')).toBeNull();
+ // Reading is still available without a configuration-write grant.
+ expect(screen.getByRole('button', { name: 'Retry' })).toBeEnabled();
+ },
+ );
+
+ it('withdraws the old organisation while its replacement is unread, then permits genuine empty onboarding', async () => {
+ const list = vi
+ .spyOn(ConnectionsAPI, 'list')
+ .mockResolvedValueOnce({
+ connections: [connectionFixture({ name: 'Old org host' })],
+ systems: [],
+ });
+ const { ledger } = renderReadState();
+ await waitFor(() => expect(screen.getByText('Old org host')).toBeInTheDocument());
+ list.mockRejectedValueOnce({ status: 503 });
+ eventBus.emit('org_switched', 'org-b');
+ expect(screen.queryByText('Old org host')).toBeNull();
+ await waitFor(() => expect(screen.getByRole('alert')).toBeInTheDocument());
+ expect(ledger.rows()).toEqual([]);
+ expect(screen.queryByText('0 systems connected')).toBeNull();
+ list.mockResolvedValueOnce({ connections: [], systems: [] });
+ fireEvent.click(screen.getByRole('button', { name: 'Retry' }));
+ await waitFor(() => expect(screen.getByText('0 systems connected')).toBeInTheDocument());
+ expect(screen.getByText('Start monitoring infrastructure')).toBeInTheDocument();
+ expect(screen.queryByRole('alert')).toBeNull();
+ });
+
it('renders the canonical first-report label through the real connection ledger', async () => {
resetCreateNonSuspendingQueryCacheForTest();
vi.spyOn(ConnectionsAPI, 'list').mockResolvedValue({
diff --git a/frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx b/frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx
index 3452aaedab..c809d43257 100644
--- a/frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx
@@ -34,6 +34,11 @@ const connectionState = vi.hoisted(() => {
notifyChanged: () => notifyChanged(),
};
});
+const ledgerReadState = vi.hoisted(() => ({
+ error: null as unknown,
+ loading: false,
+ reload: vi.fn(),
+}));
const nodeCredentialSlotState = vi.hoisted(() => ({ mountCount: 0 }));
const emptyFleetRow = vi.hoisted(
() =>
@@ -160,9 +165,10 @@ vi.mock('../useConnectionsLedger', () => ({
})),
findById: (id: string) =>
connectionState.connections.find((connection) => connection.id === id),
- reload: vi.fn(),
- loading: () => false,
- error: () => null,
+ reload: ledgerReadState.reload,
+ loading: () => ledgerReadState.loading,
+ error: () => ledgerReadState.error,
+ resolvedOnce: () => true,
}),
}));
@@ -304,6 +310,9 @@ const baseProps = () =>
describe('InfrastructureWorkspace', () => {
beforeEach(() => {
navigateSpy.mockReset();
+ ledgerReadState.error = null;
+ ledgerReadState.loading = false;
+ ledgerReadState.reload.mockReset();
presentationPolicyIsReadOnlyMock.mockReset();
presentationPolicyIsReadOnlyMock.mockReturnValue(false);
routeState.pathname = '/settings/infrastructure';
@@ -853,6 +862,20 @@ describe('InfrastructureWorkspace', () => {
expect(screen.getByText('Active')).toBeInTheDocument();
});
+ it('forwards an unavailable ledger and its read-only retry instead of onboarding', async () => {
+ connectionState.connections = [];
+ connectionState.rows = [];
+ ledgerReadState.error = { status: 503 };
+ presentationPolicyIsReadOnlyMock.mockReturnValue(true);
+ renderWorkspace();
+
+ expect(screen.getByRole('alert')).toHaveTextContent('Connected systems unavailable');
+ expect(screen.queryByText('0 systems connected')).not.toBeInTheDocument();
+ expect(screen.queryByText('Start monitoring infrastructure')).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: 'Retry' }));
+ expect(ledgerReadState.reload).toHaveBeenCalledTimes(1);
+ });
+
it('keeps onboarding copy visible in the empty infrastructure state', async () => {
connectionState.connections = [];
connectionState.rows = [];
diff --git a/frontend-modern/src/components/Settings/useConnectionsLedger.ts b/frontend-modern/src/components/Settings/useConnectionsLedger.ts
index 45623ea45d..270f049e96 100644
--- a/frontend-modern/src/components/Settings/useConnectionsLedger.ts
+++ b/frontend-modern/src/components/Settings/useConnectionsLedger.ts
@@ -518,6 +518,7 @@ export interface ConnectionsLedger {
reload: () => void;
loading: () => boolean;
error: () => unknown;
+ resolvedOnce: () => boolean;
}
interface ConnectionsLedgerSnapshot {
@@ -663,5 +664,6 @@ export const useConnectionsLedger = (): ConnectionsLedger => {
},
loading: ledgerSnapshot.loading,
error: ledgerSnapshot.error,
+ resolvedOnce: ledgerSnapshot.resolvedOnce,
};
};