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.

Preserve facet counts in resource bundles

rcourtmand99eb911cc11
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index f4914b4af4..c57b182c37 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -72,7 +72,7 @@ Own canonical runtime payload shapes between backend and frontend.
3. Add dedicated contract tests for new stable payloads
4. Route unified resource sensitivity, routing, and `aiSafeSummary` payload changes through `internal/api/resources.go`, `internal/api/contract_test.go`, and the canonical frontend resource consumer proofs together; resource governance metadata must not ship as an API-only or frontend-only heuristic
5. Route unified-resource action, lifecycle, and export audit reads through `internal/api/activity_audit_handlers.go`, `internal/api/router_routes_licensing.go`, and `internal/api/contract_test.go` together so the control-plane execution trail stays on a governed API contract instead of a store-only shape
-6. Route dedicated unified-resource capability, relationship, and timeline facet reads through `frontend-modern/src/api/resources.ts`, `internal/api/resources.go`, and `internal/api/contract_test.go` together so the backend facet contract and the frontend client stay aligned on one governed surface
+6. Route dedicated unified-resource capability, relationship, and timeline facet reads through `frontend-modern/src/api/resources.ts`, `internal/api/resources.go`, and `internal/api/contract_test.go` together so the backend facet contract and the frontend client stay aligned on one governed surface, including the backend-provided facet counts needed to distinguish loaded slices from total history
7. Route frontend API-client parsed error propagation, API-error-status fallback handling, allowed-status handling, custom status-specific error handling, command-trigger success envelope handling, shared response parsing pipelines, missing-resource lookup handling, metadata CRUD routing, stream event consumption, response status, collection normalization, scalar payload coercion, and structured error normalization through canonical shared helpers under `frontend-modern/src/api/`
8. Add or change API token scope, assignment, and revocation presentation through `frontend-modern/src/components/Settings/APITokenManager.tsx`
9. Add or change infrastructure operations token generation, lookup, assignment, and reporting/install presentation through `frontend-modern/src/components/Settings/InfrastructureOperationsController.tsx`
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index b5fa69cce4..e7cc701322 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -182,6 +182,10 @@ table instead of diverging by resource class. The same facet summary now also
appears in the resource drawer's runtime overview card through a shared
`ResourceFacetSummary` component, so table and detail views stay aligned on a
single canonical rendering path for the resource graph counts.
+The drawer's shared facet bundle also preserves the backend counts for the
+loaded capabilities, relationships, and timeline slice, so the overview card
+and history summary can report the total facet history instead of collapsing to
+the currently loaded page when the timeline endpoint is paginated.
The Connected infrastructure settings surface now also depends on a backend
owned `connectedInfrastructure` projection derived from unified resources plus
reporting-ignore state. That projection is now also the only v6 client
diff --git a/frontend-modern/src/api/__tests__/resources.test.ts b/frontend-modern/src/api/__tests__/resources.test.ts
index c529ca542d..3608a8f846 100644
--- a/frontend-modern/src/api/__tests__/resources.test.ts
+++ b/frontend-modern/src/api/__tests__/resources.test.ts
@@ -78,6 +78,11 @@ describe('ResourceAPI', () => {
capabilities: [{ name: 'restart' }],
relationships: [{ sourceId: 'node:1', targetId: 'vm:42' }],
recentChanges: [{ id: 'change-1' }],
+ counts: {
+ capabilities: 1,
+ relationships: 1,
+ recentChanges: 1,
+ },
});
});
diff --git a/frontend-modern/src/api/resources.ts b/frontend-modern/src/api/resources.ts
index fbcce774d5..5b696f3033 100644
--- a/frontend-modern/src/api/resources.ts
+++ b/frontend-modern/src/api/resources.ts
@@ -28,10 +28,17 @@ export interface ResourceTimelineResponse {
count: number;
}
+export interface ResourceFacetCounts {
+ capabilities: number;
+ relationships: number;
+ recentChanges: number;
+}
+
export interface ResourceFacetBundle {
capabilities: ResourceCapability[];
relationships: ResourceRelationship[];
recentChanges: ResourceChange[];
+ counts: ResourceFacetCounts;
}
const normalizeResourceId = (resourceId: string): string => resourceId.trim();
@@ -91,6 +98,11 @@ export class ResourceAPI {
capabilities: capabilities.capabilities ?? [],
relationships: relationships.relationships ?? [],
recentChanges: recentChanges.recentChanges ?? [],
+ counts: {
+ capabilities: capabilities.count ?? 0,
+ relationships: relationships.count ?? 0,
+ recentChanges: recentChanges.count ?? 0,
+ },
};
}
}
diff --git a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx
index ba146c1c4e..495f16e8c1 100644
--- a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx
+++ b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx
@@ -292,6 +292,16 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {
const resourceTimeline = createMemo(
() => resourceFacets()?.recentChanges ?? props.resource.recentChanges ?? [],
);
+ const resourceFacetCounts = createMemo(() => resourceFacets()?.counts ?? null);
+ const resourceCapabilityCount = createMemo(
+ () => resourceFacetCounts()?.capabilities ?? resourceCapabilities().length,
+ );
+ const resourceRelationshipCount = createMemo(
+ () => resourceFacetCounts()?.relationships ?? resourceRelationships().length,
+ );
+ const resourceTimelineCount = createMemo(
+ () => resourceFacetCounts()?.recentChanges ?? resourceTimeline().length,
+ );
const sortedResourceTimeline = createMemo(() =>
[...resourceTimeline()].sort((left, right) => {
const leftTime = Date.parse(left.observedAt || '');
@@ -750,6 +760,7 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {
capabilities={resourceCapabilities()}
relationships={resourceRelationships()}
recentChanges={resourceTimeline()}
+ counts={resourceFacetCounts()}
/>
</div>
</Show>
@@ -1341,19 +1352,19 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {
<div class="rounded border border-border bg-surface-hover px-2 py-1.5">
<div class="text-[10px] text-muted">Capabilities</div>
<div class="text-sm font-semibold text-base-content">
- {resourceCapabilities().length}
+ {resourceCapabilityCount()}
</div>
</div>
<div class="rounded border border-border bg-surface-hover px-2 py-1.5">
<div class="text-[10px] text-muted">Relationships</div>
<div class="text-sm font-semibold text-base-content">
- {resourceRelationships().length}
+ {resourceRelationshipCount()}
</div>
</div>
<div class="rounded border border-border bg-surface-hover px-2 py-1.5">
<div class="text-[10px] text-muted">Timeline Events</div>
<div class="text-sm font-semibold text-base-content">
- {sortedResourceTimeline().length}
+ {resourceTimelineCount()}
</div>
</div>
</div>
diff --git a/frontend-modern/src/components/Infrastructure/ResourceFacetSummary.tsx b/frontend-modern/src/components/Infrastructure/ResourceFacetSummary.tsx
index 8a1bfd5235..d73467e106 100644
--- a/frontend-modern/src/components/Infrastructure/ResourceFacetSummary.tsx
+++ b/frontend-modern/src/components/Infrastructure/ResourceFacetSummary.tsx
@@ -11,10 +11,17 @@ type FacetBadge = {
className: string;
};
+export interface ResourceFacetSummaryCounts {
+ capabilities?: number | null;
+ relationships?: number | null;
+ recentChanges?: number | null;
+}
+
export interface ResourceFacetSummaryProps {
capabilities?: readonly ResourceCapability[] | null;
relationships?: readonly ResourceRelationship[] | null;
recentChanges?: readonly ResourceChange[] | null;
+ counts?: ResourceFacetSummaryCounts | null;
class?: string;
testId?: string;
}
@@ -29,11 +36,12 @@ const buildFacetBadges = (
capabilities?: readonly ResourceCapability[] | null,
relationships?: readonly ResourceRelationship[] | null,
recentChanges?: readonly ResourceChange[] | null,
+ counts?: ResourceFacetSummaryCounts | null,
): FacetBadge[] => {
const badges: FacetBadge[] = [];
- const capabilityCount = capabilities?.length ?? 0;
- const relationshipCount = relationships?.length ?? 0;
- const changeCount = recentChanges?.length ?? 0;
+ const capabilityCount = counts?.capabilities ?? capabilities?.length ?? 0;
+ const relationshipCount = counts?.relationships ?? relationships?.length ?? 0;
+ const changeCount = counts?.recentChanges ?? recentChanges?.length ?? 0;
if (capabilityCount > 0) {
badges.push({
@@ -64,7 +72,7 @@ const buildFacetBadges = (
export const ResourceFacetSummary: Component<ResourceFacetSummaryProps> = (props) => {
const badges = createMemo(() =>
- buildFacetBadges(props.capabilities, props.relationships, props.recentChanges),
+ buildFacetBadges(props.capabilities, props.relationships, props.recentChanges, props.counts),
);
return (
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx
index 83af9cafc8..991eb4471e 100644
--- a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx
+++ b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx
@@ -94,6 +94,11 @@ describe('ResourceDetailDrawer history tab', () => {
reason: 'Routine restart requested',
},
],
+ counts: {
+ capabilities: 1,
+ relationships: 1,
+ recentChanges: 3,
+ },
});
const resource = baseResource({
@@ -110,7 +115,7 @@ describe('ResourceDetailDrawer history tab', () => {
expect(await screen.findByText('Capabilities 1')).toBeInTheDocument();
expect(screen.getByText('Relationships 1')).toBeInTheDocument();
- expect(screen.getByText('Timeline 1')).toBeInTheDocument();
+ expect(screen.getByText('Timeline 3')).toBeInTheDocument();
});
it('renders resource capability, relationship, and timeline facets', async () => {
@@ -162,6 +167,11 @@ describe('ResourceDetailDrawer history tab', () => {
reason: 'Routine restart requested',
},
],
+ counts: {
+ capabilities: 1,
+ relationships: 1,
+ recentChanges: 3,
+ },
});
const resource = baseResource({
@@ -185,6 +195,7 @@ describe('ResourceDetailDrawer history tab', () => {
expect(panel.getAllByText('Capabilities')).toHaveLength(2);
expect(panel.getAllByText('Relationships')).toHaveLength(2);
expect(panel.getByText('Timeline')).toBeInTheDocument();
+ expect(screen.getByText('Timeline 3')).toBeInTheDocument();
expect(panel.getByText('node:pve-1 → vm:42')).toBeInTheDocument();
expect(panel.getByText('Routine restart requested')).toBeInTheDocument();
});