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.

Consolidate discovery recency to one line in the tab body

rcourtman893465f55a6d
diff --git a/frontend-modern/src/components/Discovery/DiscoveryTab.tsx b/frontend-modern/src/components/Discovery/DiscoveryTab.tsx
index b67dde6686..0e12499d68 100644
--- a/frontend-modern/src/components/Discovery/DiscoveryTab.tsx
+++ b/frontend-modern/src/components/Discovery/DiscoveryTab.tsx
@@ -728,7 +728,10 @@ export const DiscoveryTab: Component<DiscoveryTabProps> = (props) => {
</a>
</p>
</Show>
- <Show when={discovery()?.updated_at}>
+ {/* Only show recency here when the "Discovery run" control block
+ (which already states "Last run: X ago") isn't rendered, so the
+ tab shows the timestamp once rather than twice. */}
+ <Show when={discovery()?.updated_at && !showManualRunAction()}>
<p class="text-xs text-muted mt-2">
Last scanned: {formatDiscoveryAge(discovery()!.updated_at)}
</p>
@@ -806,7 +809,10 @@ export const DiscoveryTab: Component<DiscoveryTabProps> = (props) => {
</Show>
<div class="mt-3 flex flex-wrap gap-2 text-[10px] text-muted">
<DiscoveryProvenanceMarker label={getDiscoveryObservedSourceLabel()} />
- <Show when={d().updated_at}>
+ {/* Recency is stated once in the "Discovery run" control block
+ ("Last run: X ago") whenever it's rendered; only repeat it
+ here when that block is absent. */}
+ <Show when={d().updated_at && !showManualRunAction()}>
<span class="rounded border border-border bg-surface-alt px-2 py-0.5">
Last observed {formatDiscoveryAge(d().updated_at)}
</span>
diff --git a/frontend-modern/src/components/Discovery/__tests__/DiscoveryTab.test.tsx b/frontend-modern/src/components/Discovery/__tests__/DiscoveryTab.test.tsx
index 289f0850fd..75a5040a5c 100644
--- a/frontend-modern/src/components/Discovery/__tests__/DiscoveryTab.test.tsx
+++ b/frontend-modern/src/components/Discovery/__tests__/DiscoveryTab.test.tsx
@@ -246,6 +246,54 @@ describe('DiscoveryTab', () => {
});
});
+ it('states discovery recency once when the run-control block is present', async () => {
+ // The "Discovery run" control block already states "Last run: X ago", so the
+ // identified-service card must not repeat the same timestamp as
+ // "Last observed X ago" — recency should appear once in the tab body.
+ const discovered: ResourceDiscovery = {
+ id: 'discovery-1',
+ resource_type: 'agent',
+ resource_id: 'agent-1',
+ target_id: 'agent-1',
+ agent_id: 'agent-1',
+ hostname: 'pve1',
+ service_type: 'database',
+ service_name: 'postgresql',
+ service_version: '16.1',
+ category: 'database',
+ cli_access: 'psql',
+ facts: [],
+ config_paths: [],
+ data_paths: [],
+ log_paths: [],
+ ports: [],
+ user_notes: '',
+ user_secrets: {},
+ confidence: 0.72,
+ ai_reasoning: '',
+ discovered_at: '2026-04-15T00:00:00Z',
+ updated_at: '2026-04-15T00:00:00Z',
+ scan_duration: 12,
+ };
+ vi.mocked(discoveryApi.getDiscovery).mockResolvedValue(discovered);
+ vi.mocked(discoveryApi.getDiscoveryInfo).mockResolvedValue(discoveryInfoWithProvider());
+
+ render(() => (
+ <DiscoveryTab
+ resourceType="agent"
+ agentId="agent-1"
+ resourceId="agent-1"
+ hostname="pve1"
+ showManualRunAction
+ />
+ ));
+
+ // Control block states recency.
+ expect(await screen.findByText(/Last run:/i)).toBeInTheDocument();
+ // Service card must not repeat it.
+ expect(screen.queryByText(/Last observed/i)).toBeNull();
+ });
+
it('disables the run action until an AI provider is configured', async () => {
vi.mocked(discoveryApi.getDiscovery).mockResolvedValue(null);
// No provider configured (default getDiscoveryInfo → null): a scan would be