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.

Scope provider inventory hydration by route

Richard Courtman87fda2a235a3
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index f37d5dd9de..87aca9bab8 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -3112,6 +3112,14 @@ lifecycle surfaces must not treat these members as enrollable, updatable, or
doctorable agents — the Pulse Agent fleet remains exactly the set of
SourceAgent-backed connections and structured fleet diagnostics.
+Provider route scoping does not change that separation. Compact resource-list
+type facets and route-specific Docker, Kubernetes, TrueNAS, or VMware inventory
+queries are read-side presentation evidence only. A provider-owned canonical
+agent row may remain in the active route query so the page can render its
+system or update posture, but neither the row nor its facet count creates
+enrollment, token binding, command, update, removal, or re-enrollment
+authority.
+
### Agent Doctor covers exactly the Pulse Agent fleet
The connections ledger no longer fabricates agent-type rows for
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 1a609a105b..2ae4194cd4 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -4256,6 +4256,24 @@ auto-register mutation boundary.
## Current State
+### Resource-list facets preserve scoped navigation evidence
+
+`GET /api/resources` returns a compact `facets` object beside the paged row
+payload. `facets.byType` and `facets.incidentCount` are computed from the same
+canonical presentation resource set as the list, after every requested filter
+except `type` has been applied. This lets a provider workflow request only the
+row types its active route renders while still proving that adjacent
+evidence-gated routes exist. Source, `excludeSource`, search, status, and other
+non-type filters remain authoritative for the facet scope; facets must not
+become an unscoped estate summary or a second resource projection. The
+existing global `aggregations` payload retains its current whole-estate
+semantics, and pagination continues to affect rows only.
+
+`TestResourceListTypeFacetsRespectNonTypeScope` pins the contract that a
+type-filtered request receives only its selected rows while the facet bundle
+retains other types inside the same source scope and excludes resources outside
+that scope.
+
### Unified resource source exclusion is canonical query policy
`GET /api/resources` accepts `excludeSource` as a comma-separated negative
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index e051aa11e5..a785774f87 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -3138,6 +3138,18 @@ resolves late` in
## Current State
+### Provider tabs use compact canonical evidence during route hydration
+
+Evidence-gated provider tabs consume the unified-resource owner's
+source-scoped type facets while rendering only the active workflow inventory.
+The shell keeps requested direct routes available during first hydration, then
+uses the settled facet bundle as the navigation truth. A temporarily absent row
+payload is loading state, not proof that the provider or workflow is empty;
+provider empty states may render only after the active route query settles.
+Docker / Podman, Kubernetes, TrueNAS, and VMware continue to reuse the shared
+platform tabs, loading, error, and empty-state primitives rather than adding a
+provider-local skeleton or navigation model.
+
### Patrol objectives reuse the shared dialog, button, badge, and resource picker contracts
The Patrol retained-objective surface composes the existing shared `Dialog`,
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 952a051667..86766a552b 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -2406,15 +2406,20 @@ vdev layout is reported` in
## Current State
-### TrueNAS protection inventory hydrates only on its owning route
+### TrueNAS workflows hydrate only their owning inventory
The TrueNAS Protection tab is a first-class workflow once a TrueNAS system is
present, so route discovery no longer depends on preloading recovery points.
`TrueNASPageSurface.tsx` requests the platform-scoped recovery inventory only
when `/truenas/protection` is active; Overview, Storage, Services, Apps, VMs,
and Shares do not compete with that independent request during first paint.
-The surface contract pins both the inactive null query and the direct-route
-query parameters.
+The unified-resource query follows the same route ownership: Overview retains
+the complete TrueNAS incident-bearing resource set, while the detail workflows
+hydrate only their system anchor and rendered storage, disk, app, VM, or share
+types. Source-scoped type facets preserve evidence-gated navigation without
+turning inactive rows into recovery state or preloading their inventories. The
+surface contract pins the route query map, the inactive recovery null query,
+and the direct Protection query parameters.
### Fresh agent command policy preserves the existing recovery authority boundary
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 05fb886969..25f8a40592 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -2043,6 +2043,25 @@ served clones. Proof: `TestClonedResourcesPreservePlatformAdmission` and
## Current State
+### Provider workflows hydrate only their active route inventory
+
+Docker / Podman, Kubernetes, TrueNAS, and VMware surfaces declare an explicit
+canonical resource-type query for each workflow route. Only the active route's
+query may hydrate or subscribe to realtime inventory; inactive routes use the
+source-scoped `facets.byType` evidence returned with that active query to keep
+their navigation visibility truthful. A direct route may remain visible while
+its first request is in flight, but a settled facet bundle is authoritative and
+must remove workflows for which the provider has no canonical evidence.
+
+The shared `useUnifiedResources` boundary retains the REST facet bundle in the
+same query cache as the rows. When a canonical WebSocket generation arrives,
+it recomputes those facets from the complete snapshot after applying the
+query's source and exclusion scope but before applying its type selection. A
+realtime update therefore cannot undo REST scoping, hide an adjacent workflow,
+or force every provider type back into the active route payload. Docker,
+Kubernetes, TrueNAS, and VMware surface contract tests pin their route query
+maps, and the shared hook test pins facet normalization.
+
### Canonical REST facets preserve realtime workload evidence
The frontend REST projection retains the complete source-authored Proxmox
diff --git a/frontend-modern/browser-verification.json b/frontend-modern/browser-verification.json
index 5fd95e583c..1b9644a80c 100644
--- a/frontend-modern/browser-verification.json
+++ b/frontend-modern/browser-verification.json
@@ -1,49 +1,62 @@
{
"version": 1,
- "base_sha": "ee6bb64d727572efd7ded3c5812200c371a7cdc3",
- "verified_at": "2026-08-30T01:13:52Z",
+ "base_sha": "36dd5b9119971620a5cdd3cc791f4d555f71160e",
+ "verified_at": "2026-08-30T08:31:50Z",
"result": "passed",
"changed_paths": [
+ "frontend-modern/src/features/docker/DockerPageSurface.tsx",
+ "frontend-modern/src/features/docker/dockerPageModel.ts",
+ "frontend-modern/src/features/kubernetes/KubernetesPageSurface.tsx",
+ "frontend-modern/src/features/kubernetes/kubernetesPageModel.ts",
"frontend-modern/src/features/truenas/TrueNASPageSurface.tsx",
- "frontend-modern/src/features/truenas/TrueNASStorageTopologyTable.tsx",
- "frontend-modern/src/features/truenas/truenasPageModel.ts"
+ "frontend-modern/src/features/truenas/truenasPageModel.ts",
+ "frontend-modern/src/features/vmware/VmwarePageSurface.tsx",
+ "frontend-modern/src/features/vmware/vmwarePageModel.ts",
+ "frontend-modern/src/hooks/useUnifiedResources.ts",
+ "frontend-modern/src/types/api.ts"
],
"content_sha256": {
- "frontend-modern/src/features/truenas/TrueNASPageSurface.tsx": "087236d017558f9fe0990530cd8153f738e764c0ee3ddd77e558b92592fc6f20",
- "frontend-modern/src/features/truenas/TrueNASStorageTopologyTable.tsx": "16f808fc87d03ceee9466214f1397e5746f468bc8a96c6ddde280a6d7f6044d3",
- "frontend-modern/src/features/truenas/truenasPageModel.ts": "fb4434ed88e6677449eb4b4b85bd8f3c108be45e3605aff2acb33996f230c932"
+ "frontend-modern/src/features/docker/DockerPageSurface.tsx": "9e3ae4cf49e50ce5870ddfed517057423ed00d4efdf6a3cbcd669497bda526b6",
+ "frontend-modern/src/features/docker/dockerPageModel.ts": "a6f64a80a91e0f75f0f13397c9eb25ee5c993e012c08da3fd43888d3d99ccdc3",
+ "frontend-modern/src/features/kubernetes/KubernetesPageSurface.tsx": "f464792ae1301cb7db93b904b9a544d046268cc3cabaa179f647aeb3fbf6a8f7",
+ "frontend-modern/src/features/kubernetes/kubernetesPageModel.ts": "3b79fb6f9eddc5d3b593fc78412c94310175bf7a15f41fa44e9c06319608111a",
+ "frontend-modern/src/features/truenas/TrueNASPageSurface.tsx": "db085a6496c5af4dae90bf7cb8583270e528e1de23e399088486706cafce36ff",
+ "frontend-modern/src/features/truenas/truenasPageModel.ts": "2e7bf5d00bd4570524faeac6bb27a4714364d0796a598801729d2e1a113c5d6f",
+ "frontend-modern/src/features/vmware/VmwarePageSurface.tsx": "40f325c9e2dc7f67d0db748475a9da0000fb75bfcccbb8cfeb4a16a0935eb7de",
+ "frontend-modern/src/features/vmware/vmwarePageModel.ts": "1b01b0655575d477a60aa030eeb2ec793a9404934959b0234e75f65b568187cc",
+ "frontend-modern/src/hooks/useUnifiedResources.ts": "44c4dcaa542bf0775c9c53f18769b28a1ef5ecba0cb5c62174b89cdf5416ab4b",
+ "frontend-modern/src/types/api.ts": "c4c830f7796a4dab8abad12cef96872581f2ac4e5ef5eb72840a3031db57069e"
},
"routes": [
- "/truenas/storage",
- "/truenas/storage?kind=disks",
- "/truenas/storage?kind=volumes"
+ "/vmware/overview",
+ "/vmware/storage",
+ "/docker/images",
+ "/kubernetes/configuration",
+ "/truenas/vms"
],
"viewports": [
{
"width": 1280,
"height": 720
},
- {
- "width": 393,
- "height": 851
- },
{
"width": 390,
"height": 844
}
],
"states": [
- "populated mixed TrueNAS storage inventory with 21 volume and physical-disk rows",
- "physical-disk scope with 8 rows and contextual Endurance, Temperature, and Health columns",
- "physical-disk scope after direct reload from the shareable kind query",
- "volume scope containing pools and datasets with physical disks excluded",
- "narrow physical-disk scope with the mobile filter controls expanded and the fixed navigation present"
+ "vSphere Overview settled with 7 ESXi hosts and 18 virtual machines without rendering the false No vSphere VMs state",
+ "vSphere Datastores settled with 8 rows while retaining all evidence-gated VMware workflow tabs",
+ "Docker Images settled with 10 image rows while retaining Overview, Storage, Networks, and Swarm navigation",
+ "Kubernetes Configuration settled with 10 configuration and policy rows while retaining all Kubernetes workflows",
+ "TrueNAS VMs settled with 2 rows and did not preload recovery inventory",
+ "narrow vSphere Overview retained the complete tab strip, responsive host columns, VM table rows, and no false empty state"
],
"interactions": [
- "expanded mobile Filters and selected the counted Physical disks scope with pointer activation",
- "confirmed Physical disks sets ?kind=disks, marks the control pressed, and removes pool rows",
- "reloaded the scoped URL and confirmed the Physical disks selection persists",
- "selected Volumes and confirmed ?kind=volumes while every physical-disk row is removed",
- "inspected full-page rendered screenshots at desktop, Pixel 5, and iPhone 12 widths for fit, clipping, selected state, and evidence readability"
+ "loaded each provider workflow as a direct route against the exact isolated frontend and backend build",
+ "traced network requests and confirmed each sampled route issued only its declared resource-type query",
+ "confirmed VMware used a one-row activity evidence request on non-Activity routes instead of preloading the 100-row timeline",
+ "confirmed TrueNAS VMs issued no recovery request outside Protection",
+ "inspected the rendered desktop routes and a 390 by 844 vSphere screenshot for populated state, tab continuity, fit, and clipping"
]
}
diff --git a/frontend-modern/src/features/docker/DockerPageSurface.tsx b/frontend-modern/src/features/docker/DockerPageSurface.tsx
index 30198da2c6..3a8aa4f3e9 100644
--- a/frontend-modern/src/features/docker/DockerPageSurface.tsx
+++ b/frontend-modern/src/features/docker/DockerPageSurface.tsx
@@ -1,9 +1,9 @@
import { useLocation, useSearchParams } from '@solidjs/router';
-import { Show, createMemo, createSignal } from 'solid-js';
+import { Show, createEffect, createMemo, createSignal } from 'solid-js';
import BoxIcon from 'lucide-solid/icons/box';
import { ButtonLink } from '@/components/shared/Button';
import { getPlatformIcon } from '@/features/platformPage/platformIcon';
-import { useUnifiedResources } from '@/hooks/useUnifiedResources';
+import { useUnifiedResources, type UnifiedResourceFacets } from '@/hooks/useUnifiedResources';
import {
PLATFORM_HEALTH_FILTER_OPTIONS,
PlatformErrorState,
@@ -26,6 +26,7 @@ import { DockerSwarmNodesTable } from './DockerSwarmNodesTable';
import { DockerTasksTable } from './DockerTasksTable';
import { DockerVolumesTable } from './DockerVolumesTable';
import {
+ DOCKER_TAB_SPECS,
buildDockerPageModel,
filterDockerResources,
getDockerPageTabSpecs,
@@ -56,8 +57,15 @@ import { isPulseAgentPlatformResource } from '@/utils/agentResources';
import type { Resource } from '@/types/resource';
import { buildPlatformResourceSearchSuggestions } from '@/features/platformPage/platformSearchSuggestions';
-const DOCKER_RESOURCE_QUERY =
- 'type=agent,docker-host,app-container,docker-service,docker-image,docker-volume,docker-network,docker-task,docker-swarm-node,docker-secret,docker-config&source=docker';
+const DOCKER_RESOURCE_QUERY_BY_TAB: Record<DockerPageTabId, string> = {
+ overview: 'type=agent,docker-host,app-container&source=docker',
+ images: 'type=agent,docker-host,app-container,docker-image&source=docker',
+ storage: 'type=agent,docker-host,docker-volume&source=docker',
+ networks:
+ 'type=agent,docker-host,app-container,docker-service,docker-task,docker-network&source=docker',
+ swarm:
+ 'type=agent,docker-host,docker-service,docker-task,docker-swarm-node,docker-secret,docker-config&source=docker',
+};
const DockerIcon = getPlatformIcon('docker');
const dockerIcon = () => <DockerIcon class="h-6 w-6 text-slate-400" />;
@@ -65,20 +73,85 @@ const dockerIcon = () => <DockerIcon class="h-6 w-6 text-slate-400" />;
export function DockerPageSurface() {
const location = useLocation();
const [searchParams] = useSearchParams();
- const { resources, loading, error, refetch } = useUnifiedResources({
- query: DOCKER_RESOURCE_QUERY,
- cacheKey: 'docker-workspace',
- initialHydration: 'prefer-ws-then-rest',
- });
const requestedTab = createMemo<DockerPageTabId>(() => {
const segment = location.pathname.split('/').filter(Boolean)[1];
return resolveDockerPageTabId(segment);
});
- const model = createMemo(() => buildDockerPageModel(resources()));
- const tabs = createMemo(() => getDockerPageTabSpecs(model()));
+ const [navigationResources, setNavigationResources] = createSignal<Resource[]>([]);
+ const [resourceFacets, setResourceFacets] = createSignal<UnifiedResourceFacets | null>(null);
+ const navigationModel = createMemo(() => buildDockerPageModel(navigationResources()));
+ const tabs = createMemo(() => {
+ const facets = resourceFacets();
+ return facets
+ ? getDockerPageTabSpecs(navigationModel(), facets.byType)
+ : navigationResources().length > 0
+ ? getDockerPageTabSpecs(navigationModel())
+ : DOCKER_TAB_SPECS;
+ });
const activeTab = createMemo<DockerPageTabId>(() =>
tabs().some((tab) => tab.id === requestedTab()) ? requestedTab() : 'overview',
);
+ const shouldHydrateTab = (tab: DockerPageTabId) => activeTab() === tab;
+ const overviewResources = useUnifiedResources({
+ query: DOCKER_RESOURCE_QUERY_BY_TAB.overview,
+ cacheKey: 'docker-overview',
+ initialHydration: 'prefer-ws-then-rest',
+ enabled: () => shouldHydrateTab('overview'),
+ realtimeEnabled: () => shouldHydrateTab('overview'),
+ });
+ const imageResources = useUnifiedResources({
+ query: DOCKER_RESOURCE_QUERY_BY_TAB.images,
+ cacheKey: 'docker-images',
+ initialHydration: 'prefer-ws-then-rest',
+ enabled: () => shouldHydrateTab('images'),
+ realtimeEnabled: () => shouldHydrateTab('images'),
+ });
+ const storageResources = useUnifiedResources({
+ query: DOCKER_RESOURCE_QUERY_BY_TAB.storage,
+ cacheKey: 'docker-storage',
+ initialHydration: 'prefer-ws-then-rest',
+ enabled: () => shouldHydrateTab('storage'),
+ realtimeEnabled: () => shouldHydrateTab('storage'),
+ });
+ const networkResources = useUnifiedResources({
+ query: DOCKER_RESOURCE_QUERY_BY_TAB.networks,
+ cacheKey: 'docker-networks',
+ initialHydration: 'prefer-ws-then-rest',
+ enabled: () => shouldHydrateTab('networks'),
+ realtimeEnabled: () => shouldHydrateTab('networks'),
+ });
+ const swarmResources = useUnifiedResources({
+ query: DOCKER_RESOURCE_QUERY_BY_TAB.swarm,
+ cacheKey: 'docker-swarm',
+ initialHydration: 'prefer-ws-then-rest',
+ enabled: () => shouldHydrateTab('swarm'),
+ realtimeEnabled: () => shouldHydrateTab('swarm'),
+ });
+ const resourceState = createMemo(() => {
+ switch (activeTab()) {
+ case 'images':
+ return imageResources;
+ case 'storage':
+ return storageResources;
+ case 'networks':
+ return networkResources;
+ case 'swarm':
+ return swarmResources;
+ default:
+ return overviewResources;
+ }
+ });
+ const resources = () => resourceState().resources();
+ const loading = () => resourceState().loading();
+ const error = () => resourceState().error();
+ const refetch = () => resourceState().refetch();
+ createEffect(() => {
+ const state = resourceState();
+ setNavigationResources(state.resources());
+ const nextFacets = state.facets?.();
+ if (nextFacets) setResourceFacets(nextFacets);
+ });
+ const model = createMemo(() => buildDockerPageModel(resources()));
const hostFilter = createMemo(() => {
const rawHost = searchParams[DOCKER_QUERY_PARAMS.host];
diff --git a/frontend-modern/src/features/docker/__tests__/DockerPageSurface.test.tsx b/frontend-modern/src/features/docker/__tests__/DockerPageSurface.test.tsx
index 814881a800..3d63129c64 100644
--- a/frontend-modern/src/features/docker/__tests__/DockerPageSurface.test.tsx
+++ b/frontend-modern/src/features/docker/__tests__/DockerPageSurface.test.tsx
@@ -439,6 +439,28 @@ describe('DockerPageSurface', () => {
);
});
+ it('hydrates only the active Docker workflow resource family', () => {
+ mocks.pathname = '/docker/storage';
+ mocks.useUnifiedResources.mockReturnValue({
+ error: () => null,
+ loading: () => false,
+ refetch: vi.fn(),
+ resources: () => [makeDockerHost(), makeDockerVolume()],
+ });
+
+ render(() => <DockerPageSurface />);
+
+ const activeCall = mocks.useUnifiedResources.mock.calls.find(([options]) =>
+ (options as { enabled: () => boolean }).enabled(),
+ );
+ expect(activeCall?.[0]).toEqual(
+ expect.objectContaining({
+ cacheKey: 'docker-storage',
+ query: 'type=agent,docker-host,docker-volume&source=docker',
+ }),
+ );
+ });
+
it('keeps the legacy containers route on the Overview landing surface', () => {
mocks.pathname = '/docker/containers';
diff --git a/frontend-modern/src/features/docker/__tests__/dockerPageModel.test.ts b/frontend-modern/src/features/docker/__tests__/dockerPageModel.test.ts
index e634dbdcf1..a49ed9ada3 100644
--- a/frontend-modern/src/features/docker/__tests__/dockerPageModel.test.ts
+++ b/frontend-modern/src/features/docker/__tests__/dockerPageModel.test.ts
@@ -336,6 +336,21 @@ describe('dockerPageModel', () => {
expect(getDockerPageTabSpecs(swarmModel).map((tab) => tab.id)).toEqual(['overview', 'swarm']);
});
+ it('keeps workflow tabs evidence-gated when the active route loads a partial row model', () => {
+ const activeRouteModel = buildDockerPageModel([
+ makeResource({ id: 'docker-host-1', type: 'agent' }),
+ ]);
+
+ expect(
+ getDockerPageTabSpecs(activeRouteModel, {
+ 'docker-image': 3,
+ 'docker-volume': 2,
+ 'docker-network': 1,
+ 'docker-service': 1,
+ }).map((tab) => tab.id),
+ ).toEqual(['overview', 'images', 'storage', 'networks', 'swarm']);
+ });
+
it('shows the Storage workflow tab when engine disk usage exists without volume rows', () => {
const model = buildDockerPageModel([
makeResource({
diff --git a/frontend-modern/src/features/docker/dockerPageModel.ts b/frontend-modern/src/features/docker/dockerPageModel.ts
index 44a5aa58ce..bffdfdae96 100644
--- a/frontend-modern/src/features/docker/dockerPageModel.ts
+++ b/frontend-modern/src/features/docker/dockerPageModel.ts
@@ -775,23 +775,45 @@ export const hasDockerSwarmInventory = (model: DockerPageModel): boolean =>
model.secrets.length > 0 ||
model.configs.length > 0;
-const hasDockerTabInventory = (model: DockerPageModel, tab: DockerPageTabId): boolean => {
+const hasDockerTypeEvidence = (
+ typeCounts: Partial<Record<ResourceType, number>> | undefined,
+ ...types: ResourceType[]
+): boolean => types.some((type) => (typeCounts?.[type] ?? 0) > 0);
+
+const hasDockerTabInventory = (
+ model: DockerPageModel,
+ tab: DockerPageTabId,
+ typeCounts?: Partial<Record<ResourceType, number>>,
+): boolean => {
switch (tab) {
case 'overview':
return true;
case 'images':
- return model.images.length > 0;
+ return model.images.length > 0 || hasDockerTypeEvidence(typeCounts, 'docker-image');
case 'storage':
- return hasDockerStorageInventory(model);
+ return hasDockerStorageInventory(model) || hasDockerTypeEvidence(typeCounts, 'docker-volume');
case 'networks':
- return model.networks.length > 0;
+ return model.networks.length > 0 || hasDockerTypeEvidence(typeCounts, 'docker-network');
case 'swarm':
- return hasDockerSwarmInventory(model);
+ return (
+ hasDockerSwarmInventory(model) ||
+ hasDockerTypeEvidence(
+ typeCounts,
+ 'docker-service',
+ 'docker-task',
+ 'docker-swarm-node',
+ 'docker-secret',
+ 'docker-config',
+ )
+ );
}
};
-export const getDockerPageTabSpecs = (model: DockerPageModel): readonly DockerTabSpec[] =>
- DOCKER_TAB_SPECS.filter((tab) => hasDockerTabInventory(model, tab.id));
+export const getDockerPageTabSpecs = (
+ model: DockerPageModel,
+ typeCounts?: Partial<Record<ResourceType, number>>,
+): readonly DockerTabSpec[] =>
+ DOCKER_TAB_SPECS.filter((tab) => hasDockerTabInventory(model, tab.id, typeCounts));
const RUNTIME_ONLY_SYSTEM_LABELS = new Set(['docker', 'docker / podman', 'podman']);
diff --git a/frontend-modern/src/features/kubernetes/KubernetesPageSurface.tsx b/frontend-modern/src/features/kubernetes/KubernetesPageSurface.tsx
index ea38d7683a..0ef2d7cc0d 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesPageSurface.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesPageSurface.tsx
@@ -1,5 +1,5 @@
import { useLocation, useSearchParams } from '@solidjs/router';
-import { Show, createMemo, type Accessor } from 'solid-js';
+import { Show, createEffect, createMemo, createSignal, type Accessor } from 'solid-js';
import { ButtonLink } from '@/components/shared/Button';
import { buildInfrastructureAgentUpdatesPath } from '@/components/Settings/infrastructureWorkspaceModel';
import type { FilterDef } from '@/components/shared/FilterBar';
@@ -9,7 +9,7 @@ import {
collectOutdatedAgentHosts,
formatAgentVersionDisplay,
} from '@/features/platformPage/agentVersion';
-import { useUnifiedResources } from '@/hooks/useUnifiedResources';
+import { useUnifiedResources, type UnifiedResourceFacets } from '@/hooks/useUnifiedResources';
import { buildKubernetesPath, KUBERNETES_QUERY_PARAMS } from '@/routing/resourceLinks';
import { updateStore } from '@/stores/updates';
import {
@@ -37,6 +37,7 @@ import { KubernetesPolicyTable } from './KubernetesPolicyTable';
import { KubernetesServicesTable } from './KubernetesServicesTable';
import { KubernetesStorageTable } from './KubernetesStorageTable';
import {
+ KUBERNETES_TAB_SPECS,
buildKubernetesPageModel,
buildKubernetesOverviewPosture,
filterKubernetesResources,
@@ -51,28 +52,88 @@ import {
// the linked agent host (sources=['agent','kubernetes']) still appear in the
// Nodes section of the Overview stack; the page model filters them down to
// those tagged kubernetes.
-const KUBERNETES_RESOURCE_QUERY =
- 'type=k8s-cluster,k8s-node,pod,k8s-deployment,k8s-replicaset,k8s-namespace,k8s-service,k8s-statefulset,k8s-daemonset,k8s-job,k8s-cronjob,k8s-ingress,k8s-endpoint-slice,k8s-network-policy,k8s-persistent-volume,k8s-persistent-volume-claim,k8s-storage-class,k8s-configmap,k8s-secret,k8s-serviceaccount,k8s-role,k8s-cluster-role,k8s-role-binding,k8s-cluster-role-binding,k8s-resource-quota,k8s-limit-range,k8s-pod-disruption-budget,k8s-horizontal-pod-autoscaler,k8s-event,agent&source=kubernetes';
+const KUBERNETES_RESOURCE_QUERY_BY_TAB: Record<KubernetesPageTabId, string> = {
+ overview:
+ 'type=agent,k8s-cluster,k8s-node,pod,k8s-deployment,k8s-replicaset,k8s-statefulset,k8s-daemonset,k8s-job,k8s-cronjob,k8s-horizontal-pod-autoscaler&source=kubernetes',
+ nodes: 'type=agent,k8s-cluster,k8s-node&source=kubernetes',
+ workloads:
+ 'type=agent,k8s-cluster,k8s-node,pod,k8s-deployment,k8s-replicaset,k8s-statefulset,k8s-daemonset,k8s-job,k8s-cronjob,k8s-horizontal-pod-autoscaler&source=kubernetes',
+ services: 'type=agent,k8s-cluster,k8s-service,k8s-ingress,k8s-endpoint-slice&source=kubernetes',
+ storage:
+ 'type=agent,k8s-cluster,k8s-persistent-volume,k8s-persistent-volume-claim,k8s-storage-class&source=kubernetes',
+ configuration:
+ 'type=agent,k8s-cluster,k8s-namespace,k8s-configmap,k8s-secret,k8s-serviceaccount,k8s-role,k8s-cluster-role,k8s-role-binding,k8s-cluster-role-binding,k8s-resource-quota,k8s-limit-range,k8s-network-policy,k8s-pod-disruption-budget&source=kubernetes',
+ events: 'type=agent,k8s-cluster,k8s-event&source=kubernetes',
+};
const KubernetesIcon = getPlatformIcon('kubernetes');
const k8sIcon = () => <KubernetesIcon class="h-6 w-6 text-slate-400" />;
export function KubernetesPageSurface() {
const location = useLocation();
- const { resources, loading, error, refetch } = useUnifiedResources({
- query: KUBERNETES_RESOURCE_QUERY,
- cacheKey: 'kubernetes-workspace',
- initialHydration: 'prefer-ws-then-rest',
- });
const requestedTab = createMemo<KubernetesPageTabId>(() => {
const segment = location.pathname.split('/').filter(Boolean)[1];
return resolveKubernetesPageTabId(segment);
});
- const model = createMemo(() => buildKubernetesPageModel(resources()));
- const tabs = createMemo(() => getKubernetesPageTabSpecs(model()));
+ const [navigationResources, setNavigationResources] = createSignal<Resource[]>([]);
+ const [resourceFacets, setResourceFacets] = createSignal<UnifiedResourceFacets | null>(null);
+ const navigationModel = createMemo(() => buildKubernetesPageModel(navigationResources()));
+ const tabs = createMemo(() => {
+ const facets = resourceFacets();
+ return facets
+ ? getKubernetesPageTabSpecs(navigationModel(), facets.byType)
+ : navigationResources().length > 0
+ ? getKubernetesPageTabSpecs(navigationModel())
+ : KUBERNETES_TAB_SPECS;
+ });
const activeTab = createMemo<KubernetesPageTabId>(() =>
tabs().some((tab) => tab.id === requestedTab()) ? requestedTab() : 'overview',
);
+ const shouldHydrateTab = (tab: KubernetesPageTabId) => activeTab() === tab;
+ const createTabResources = (tab: KubernetesPageTabId) =>
+ useUnifiedResources({
+ query: KUBERNETES_RESOURCE_QUERY_BY_TAB[tab],
+ cacheKey: `kubernetes-${tab}`,
+ initialHydration: 'prefer-ws-then-rest',
+ enabled: () => shouldHydrateTab(tab),
+ realtimeEnabled: () => shouldHydrateTab(tab),
+ });
+ const overviewResources = createTabResources('overview');
+ const nodeResources = createTabResources('nodes');
+ const workloadResources = createTabResources('workloads');
+ const serviceResources = createTabResources('services');
+ const storageResources = createTabResources('storage');
+ const configurationResources = createTabResources('configuration');
+ const eventResources = createTabResources('events');
+ const resourceState = createMemo(() => {
+ switch (activeTab()) {
+ case 'nodes':
+ return nodeResources;
+ case 'workloads':
+ return workloadResources;
+ case 'services':
+ return serviceResources;
+ case 'storage':
+ return storageResources;
+ case 'configuration':
+ return configurationResources;
+ case 'events':
+ return eventResources;
+ default:
+ return overviewResources;
+ }
+ });
+ const resources = () => resourceState().resources();
+ const loading = () => resourceState().loading();
+ const error = () => resourceState().error();
+ const refetch = () => resourceState().refetch();
+ createEffect(() => {
+ const state = resourceState();
+ setNavigationResources(state.resources());
+ const nextFacets = state.facets?.();
+ if (nextFacets) setResourceFacets(nextFacets);
+ });
+ const model = createMemo(() => buildKubernetesPageModel(resources()));
const controllerResources = createMemo(() => getKubernetesControllerResources(model()));
const agentUpdateTargetVersion = createMemo(
() => updateStore.versionInfo()?.agentUpdateTargetVersion,
diff --git a/frontend-modern/src/features/kubernetes/__tests__/KubernetesPageSurface.contract.test.tsx b/frontend-modern/src/features/kubernetes/__tests__/KubernetesPageSurface.contract.test.tsx
index d769a1471c..bceef968f2 100644
--- a/frontend-modern/src/features/kubernetes/__tests__/KubernetesPageSurface.contract.test.tsx
+++ b/frontend-modern/src/features/kubernetes/__tests__/KubernetesPageSurface.contract.test.tsx
@@ -219,6 +219,26 @@ describe('KubernetesPageSurface contract', () => {
expect(screen.queryByTestId('services-table')).toBeNull();
});
+ it('hydrates only the active Kubernetes workflow resource family', () => {
+ mockPathname.mockReturnValue('/kubernetes/events');
+ setResources([
+ makeResource({ id: 'cluster-1', type: 'k8s-cluster' }),
+ makeResource({ id: 'event-1', type: 'k8s-event' }),
+ ]);
+
+ renderSurface();
+
+ const activeCall = mockUseUnifiedResources.mock.calls.find(([options]) =>
+ (options as { enabled: () => boolean }).enabled(),
+ );
+ expect(activeCall?.[0]).toEqual(
+ expect.objectContaining({
+ cacheKey: 'kubernetes-events',
+ query: 'type=agent,k8s-cluster,k8s-event&source=kubernetes',
+ }),
+ );
+ });
+
it('surfaces stale agent-backed Kubernetes nodes', () => {
mockVersionInfo.mockReturnValue({
version: 'v6.0.0-rc.6',
diff --git a/frontend-modern/src/features/kubernetes/__tests__/kubernetesPageModel.test.ts b/frontend-modern/src/features/kubernetes/__tests__/kubernetesPageModel.test.ts
index 3fd648b556..1fec5c9a4d 100644
--- a/frontend-modern/src/features/kubernetes/__tests__/kubernetesPageModel.test.ts
+++ b/frontend-modern/src/features/kubernetes/__tests__/kubernetesPageModel.test.ts
@@ -94,6 +94,23 @@ describe('kubernetesPageModel', () => {
]);
});
+ it('keeps workflow tabs visible from source-scoped type facets on partial routes', () => {
+ const activeRouteModel = buildKubernetesPageModel([
+ makeResource({ id: 'cluster-1', type: 'k8s-cluster' }),
+ ]);
+
+ expect(
+ getKubernetesPageTabSpecs(activeRouteModel, {
+ 'k8s-node': 2,
+ pod: 12,
+ 'k8s-service': 3,
+ 'k8s-storage-class': 1,
+ 'k8s-configmap': 4,
+ 'k8s-event': 6,
+ }).map((tab) => tab.id),
+ ).toEqual(['overview', 'nodes', 'workloads', 'services', 'storage', 'configuration', 'events']);
+ });
+
it('summarizes actionable Kubernetes overview posture from native resource states', () => {
const model = buildKubernetesPageModel([
makeResource({ id: 'cluster-1', type: 'k8s-cluster' }),
diff --git a/frontend-modern/src/features/kubernetes/kubernetesPageModel.ts b/frontend-modern/src/features/kubernetes/kubernetesPageModel.ts
index 00b0f1747d..b57654b700 100644
--- a/frontend-modern/src/features/kubernetes/kubernetesPageModel.ts
+++ b/frontend-modern/src/features/kubernetes/kubernetesPageModel.ts
@@ -592,29 +592,69 @@ export const resolveKubernetesPageTabId = (segment: string | undefined): Kuberne
const hasKubernetesTabInventory = (
model: KubernetesPageModel,
tab: KubernetesPageTabId,
+ typeCounts?: Partial<Record<ResourceType, number>>,
): boolean => {
+ const hasType = (...types: ResourceType[]) => types.some((type) => (typeCounts?.[type] ?? 0) > 0);
switch (tab) {
case 'overview':
return true;
case 'nodes':
- return model.nodes.length > 0;
+ return model.nodes.length > 0 || hasType('k8s-node', 'agent');
case 'workloads':
- return model.workloads.length > 0 || model.autoscaling.length > 0;
+ return (
+ model.workloads.length > 0 ||
+ model.autoscaling.length > 0 ||
+ hasType(
+ 'pod',
+ 'k8s-deployment',
+ 'k8s-replicaset',
+ 'k8s-statefulset',
+ 'k8s-daemonset',
+ 'k8s-job',
+ 'k8s-cronjob',
+ 'k8s-horizontal-pod-autoscaler',
+ )
+ );
case 'services':
- return model.services.length > 0 || model.serviceNetworking.length > 0;
+ return (
+ model.services.length > 0 ||
+ model.serviceNetworking.length > 0 ||
+ hasType('k8s-service', 'k8s-ingress', 'k8s-endpoint-slice')
+ );
case 'storage':
- return model.storage.length > 0;
+ return (
+ model.storage.length > 0 ||
+ hasType('k8s-persistent-volume', 'k8s-persistent-volume-claim', 'k8s-storage-class')
+ );
case 'configuration':
- return model.config.length > 0 || model.policy.length > 0;
+ return (
+ model.config.length > 0 ||
+ model.policy.length > 0 ||
+ hasType(
+ 'k8s-namespace',
+ 'k8s-configmap',
+ 'k8s-secret',
+ 'k8s-serviceaccount',
+ 'k8s-role',
+ 'k8s-cluster-role',
+ 'k8s-role-binding',
+ 'k8s-cluster-role-binding',
+ 'k8s-resource-quota',
+ 'k8s-limit-range',
+ 'k8s-network-policy',
+ 'k8s-pod-disruption-budget',
+ )
+ );
case 'events':
- return model.events.length > 0;
+ return model.events.length > 0 || hasType('k8s-event');
}
};
export const getKubernetesPageTabSpecs = (
model: KubernetesPageModel,
+ typeCounts?: Partial<Record<ResourceType, number>>,
): readonly KubernetesTabSpec[] =>
- KUBERNETES_TAB_SPECS.filter((tab) => hasKubernetesTabInventory(model, tab.id));
+ KUBERNETES_TAB_SPECS.filter((tab) => hasKubernetesTabInventory(model, tab.id, typeCounts));
const KUBERNETES_RESOURCE_TYPES = new Set<ResourceType>([
'k8s-cluster',
diff --git a/frontend-modern/src/features/truenas/TrueNASPageSurface.tsx b/frontend-modern/src/features/truenas/TrueNASPageSurface.tsx
index f3313b54e3..df6df6a535 100644
--- a/frontend-modern/src/features/truenas/TrueNASPageSurface.tsx
+++ b/frontend-modern/src/features/truenas/TrueNASPageSurface.tsx
@@ -1,5 +1,5 @@
import { useLocation, useSearchParams } from '@solidjs/router';
-import { Show, createMemo, type Accessor } from 'solid-js';
+import { Show, createEffect, createMemo, createSignal, type Accessor } from 'solid-js';
import { buildInfrastructureAgentUpdatesPath } from '@/components/Settings/infrastructureWorkspaceModel';
import { getPlatformIcon } from '@/features/platformPage/platformIcon';
import { PlatformOutdatedAgentNotice } from '@/features/platformPage/PlatformOutdatedAgentNotice';
@@ -8,8 +8,9 @@ import {
formatAgentVersionDisplay,
} from '@/features/platformPage/agentVersion';
import { useRecoveryPoints } from '@/hooks/useRecoveryPoints';
-import { useUnifiedResources } from '@/hooks/useUnifiedResources';
+import { useUnifiedResources, type UnifiedResourceFacets } from '@/hooks/useUnifiedResources';
import { updateStore } from '@/stores/updates';
+import type { Resource } from '@/types/resource';
import {
PlatformErrorState,
PlatformSectionTabs,
@@ -40,8 +41,15 @@ import {
// client-side. Canonical TrueNAS systems retain `truenas` in their merged
// source set even when a Pulse agent enriches the same appliance, so the page
// can stay provider-scoped without hydrating every agent in the estate.
-const TRUENAS_RESOURCE_QUERY =
- 'source=truenas&type=agent,vm,app-container,network-share,storage,physical_disk';
+const TRUENAS_RESOURCE_QUERY_BY_TAB: Record<TrueNASPageTabId, string> = {
+ overview: 'source=truenas&type=agent,vm,app-container,network-share,storage,physical_disk',
+ storage: 'source=truenas&type=agent,storage,physical_disk',
+ services: 'source=truenas&type=agent',
+ apps: 'source=truenas&type=agent,app-container',
+ vms: 'source=truenas&type=agent,vm',
+ shares: 'source=truenas&type=agent,network-share',
+ protection: 'source=truenas&type=agent',
+};
const TRUENAS_PLATFORM_FILTER = 'truenas';
const VALID_TABS = new Set<TrueNASPageTabId>(TRUENAS_TAB_SPECS.map((tab) => tab.id));
@@ -51,15 +59,71 @@ const truenasIcon = () => <TrueNASIcon class="h-6 w-6 text-slate-400" />;
export function TrueNASPageSurface() {
const location = useLocation();
const [searchParams, setSearchParams] = useSearchParams();
- const { resources, loading, error, refetch } = useUnifiedResources({
- query: TRUENAS_RESOURCE_QUERY,
- cacheKey: 'truenas-workspace',
- initialHydration: 'prefer-ws-then-rest',
- });
const requestedTab = createMemo<TrueNASPageTabId>(() => {
const segment = location.pathname.split('/').filter(Boolean)[1] as TrueNASPageTabId | undefined;
return segment && VALID_TABS.has(segment) ? segment : 'overview';
});
+ const [navigationResources, setNavigationResources] = createSignal<Resource[]>([]);
+ const [resourceFacets, setResourceFacets] = createSignal<UnifiedResourceFacets | null>(null);
+ const navigationModel = createMemo(() => buildTrueNASPageModel(navigationResources()));
+ const tabs = createMemo(() => {
+ const facets = resourceFacets();
+ if (!facets) {
+ return navigationResources().length > 0
+ ? getTrueNASPageTabSpecs(navigationModel())
+ : TRUENAS_TAB_SPECS;
+ }
+ return getTrueNASPageTabSpecs(navigationModel(), {
+ typeCounts: facets.byType,
+ });
+ });
+ const activeTab = createMemo<TrueNASPageTabId>(() =>
+ tabs().some((tab) => tab.id === requestedTab()) ? requestedTab() : 'overview',
+ );
+ const shouldHydrateTab = (tab: TrueNASPageTabId) => activeTab() === tab;
+ const createTabResources = (tab: TrueNASPageTabId) =>
+ useUnifiedResources({
+ query: TRUENAS_RESOURCE_QUERY_BY_TAB[tab],
+ cacheKey: `truenas-${tab}`,
+ initialHydration: 'prefer-ws-then-rest',
+ enabled: () => shouldHydrateTab(tab),
+ realtimeEnabled: () => shouldHydrateTab(tab),
+ });
+ const overviewResources = createTabResources('overview');
+ const storageResources = createTabResources('storage');
+ const serviceResources = createTabResources('services');
+ const appResources = createTabResources('apps');
+ const vmResources = createTabResources('vms');
+ const shareResources = createTabResources('shares');
+ const protectionResources = createTabResources('protection');
+ const resourceState = createMemo(() => {
+ switch (activeTab()) {
+ case 'storage':
+ return storageResources;
+ case 'services':
+ return serviceResources;
+ case 'apps':
+ return appResources;
+ case 'vms':
+ return vmResources;
+ case 'shares':
+ return shareResources;
+ case 'protection':
+ return protectionResources;
+ default:
+ return overviewResources;
+ }
+ });
+ const resources = () => resourceState().resources();
+ const loading = () => resourceState().loading();
+ const error = () => resourceState().error();
+ const refetch = () => resourceState().refetch();
+ createEffect(() => {
+ const state = resourceState();
+ setNavigationResources(state.resources());
+ const nextFacets = state.facets?.();
+ if (nextFacets) setResourceFacets(nextFacets);
+ });
const model = createMemo(() => buildTrueNASPageModel(resources()));
const protection = useRecoveryPoints(() =>
requestedTab() === 'protection' && model().systems.length > 0
@@ -70,14 +134,6 @@ export function TrueNASPageSurface() {
}
: null,
);
- const tabs = createMemo(() =>
- getTrueNASPageTabSpecs(model(), {
- hasProtectionInventory: protection.meta().total > 0 || protection.points().length > 0,
- }),
- );
- const activeTab = createMemo<TrueNASPageTabId>(() =>
- tabs().some((tab) => tab.id === requestedTab()) ? requestedTab() : 'overview',
- );
const storageKindFilter = (): TrueNASStorageKindFilter => {
const value = searchParams.kind;
return value === 'volumes' || value === 'disks' ? value : 'all';
diff --git a/frontend-modern/src/features/truenas/__tests__/TrueNASPageSurface.contract.test.tsx b/frontend-modern/src/features/truenas/__tests__/TrueNASPageSurface.contract.test.tsx
index ec7fe02ec8..6fd68a146a 100644
--- a/frontend-modern/src/features/truenas/__tests__/TrueNASPageSurface.contract.test.tsx
+++ b/frontend-modern/src/features/truenas/__tests__/TrueNASPageSurface.contract.test.tsx
@@ -209,6 +209,30 @@ describe('TrueNASPageSurface contract', () => {
expect(screen.getByTestId('protection-table')).toBeInTheDocument();
});
+ it('hydrates only the active TrueNAS workflow resource family', () => {
+ mockPathname.mockReturnValue('/truenas/storage');
+ setResources([
+ makeResource({ id: 'truenas-system', type: 'agent' }),
+ makeResource({
+ id: 'pool:tank',
+ type: 'storage',
+ storage: { topology: 'pool', platform: 'truenas' },
+ }),
+ ]);
+
+ render(() => <TrueNASPageSurface />);
+
+ const activeCall = mockUseUnifiedResources.mock.calls.find(([options]) =>
+ (options as { enabled: () => boolean }).enabled(),
+ );
+ expect(activeCall?.[0]).toEqual(
+ expect.objectContaining({
+ cacheKey: 'truenas-storage',
+ query: 'source=truenas&type=agent,storage,physical_disk',
+ }),
+ );
+ });
+
it('round-trips the storage kind scope through the route query', () => {
mockPathname.mockReturnValue('/truenas/storage');
mockSearchParams.value = { kind: 'volumes' };
diff --git a/frontend-modern/src/features/truenas/__tests__/truenasPageModel.test.ts b/frontend-modern/src/features/truenas/__tests__/truenasPageModel.test.ts
index c272572ae1..fa48cc92e1 100644
--- a/frontend-modern/src/features/truenas/__tests__/truenasPageModel.test.ts
+++ b/frontend-modern/src/features/truenas/__tests__/truenasPageModel.test.ts
@@ -119,6 +119,23 @@ describe('truenasPageModel', () => {
).toEqual(['overview', 'storage', 'services', 'apps', 'vms', 'shares', 'protection']);
});
+ it('keeps TrueNAS workflow tabs visible from source-scoped facets on partial routes', () => {
+ const activeRouteModel = buildTrueNASPageModel([
+ makeResource({ id: 'truenas-system', type: 'agent' }),
+ ]);
+
+ expect(
+ getTrueNASPageTabSpecs(activeRouteModel, {
+ typeCounts: {
+ storage: 2,
+ 'app-container': 1,
+ vm: 2,
+ 'network-share': 3,
+ },
+ }).map((tab) => tab.id),
+ ).toEqual(['overview', 'storage', 'apps', 'vms', 'shares', 'protection']);
+ });
+
it('buckets systems, workloads, and native storage inventory by TrueNAS API facet', () => {
const model = buildTrueNASPageModel([
makeResource({
diff --git a/frontend-modern/src/features/truenas/truenasPageModel.ts b/frontend-modern/src/features/truenas/truenasPageModel.ts
index aa085cea2e..925e1a2405 100644
--- a/frontend-modern/src/features/truenas/truenasPageModel.ts
+++ b/frontend-modern/src/features/truenas/truenasPageModel.ts
@@ -49,6 +49,7 @@ export const TRUENAS_TAB_SPECS: readonly TrueNASTabSpec[] = [
export type TrueNASTabInventoryOptions = {
hasProtectionInventory?: boolean;
+ typeCounts?: Partial<Record<ResourceType, number>>;
};
const TRUENAS_RESOURCE_TYPES = new Set<ResourceType>([
@@ -183,19 +184,21 @@ const hasTrueNASTabInventory = (
tab: TrueNASPageTabId,
options: TrueNASTabInventoryOptions = {},
): boolean => {
+ const hasType = (...types: ResourceType[]) =>
+ types.some((type) => (options.typeCounts?.[type] ?? 0) > 0);
switch (tab) {
case 'overview':
return true;
case 'storage':
- return hasTrueNASStorageInventory(model);
+ return hasTrueNASStorageInventory(model) || hasType('storage', 'physical_disk');
case 'services':
return model.services.length > 0;
case 'apps':
- return model.apps.length > 0;
+ return model.apps.length > 0 || hasType('app-container');
case 'vms':
- return model.vms.length > 0;
+ return model.vms.length > 0 || hasType('vm');
case 'shares':
- return model.shares.length > 0;
+ return model.shares.length > 0 || hasType('network-share');
case 'protection':
// Protection is a first-class TrueNAS workflow. Keep the route visible
// once a system exists so the page can defer the recovery inventory
diff --git a/frontend-modern/src/features/vmware/VmwarePageSurface.tsx b/frontend-modern/src/features/vmware/VmwarePageSurface.tsx
index 908ca3df57..fbf4b50ff6 100644
--- a/frontend-modern/src/features/vmware/VmwarePageSurface.tsx
+++ b/frontend-modern/src/features/vmware/VmwarePageSurface.tsx
@@ -1,5 +1,13 @@
import { useLocation } from '@solidjs/router';
-import { For, Show, createMemo, createResource, type Accessor } from 'solid-js';
+import {
+ For,
+ Show,
+ createEffect,
+ createMemo,
+ createResource,
+ createSignal,
+ type Accessor,
+} from 'solid-js';
import AlertTriangle from 'lucide-solid/icons/triangle-alert';
import { buildInfrastructureAgentUpdatesPath } from '@/components/Settings/infrastructureWorkspaceModel';
import { getPlatformIcon } from '@/features/platformPage/platformIcon';
@@ -13,7 +21,7 @@ import {
RuntimeInventorySourcesAPI,
type RuntimeInventorySource,
} from '@/api/runtimeInventorySources';
-import { useUnifiedResources } from '@/hooks/useUnifiedResources';
+import { useUnifiedResources, type UnifiedResourceFacets } from '@/hooks/useUnifiedResources';
import { createNonSuspendingQuery } from '@/hooks/createNonSuspendingQuery';
import { updateStore } from '@/stores/updates';
import {
@@ -58,7 +66,13 @@ import { VsphereNetworksTable } from './VsphereNetworksTable';
// as canonical `vm`, datastores as canonical `storage`, and vCenter networks
// as canonical `network`; provider-native topology stays in VMware metadata
// under those shared resources.
-const VMWARE_RESOURCE_QUERY = 'type=agent,vm,storage,network&source=vmware-vsphere';
+const VMWARE_RESOURCE_QUERY_BY_TAB: Record<VmwarePageTabId, string> = {
+ overview: 'type=agent,vm&source=vmware-vsphere',
+ storage: 'type=agent,storage&source=vmware-vsphere',
+ networks: 'type=agent,network&source=vmware-vsphere',
+ health: 'type=agent,vm,storage,network&source=vmware-vsphere',
+ activity: 'type=agent&source=vmware-vsphere',
+};
const VALID_TABS = new Set<VmwarePageTabId>(VMWARE_TAB_SPECS.map((tab) => tab.id));
const VMWARE_PLATFORM_FILTER = 'vmware-vsphere';
@@ -152,11 +166,6 @@ function VmwareInventoryCompletenessNotice(props: {
export function VmwarePageSurface() {
const location = useLocation();
- const { resources, loading, error, refetch } = useUnifiedResources({
- query: VMWARE_RESOURCE_QUERY,
- cacheKey: 'vmware-workspace',
- initialHydration: 'prefer-ws-then-rest',
- });
const inventorySources = createNonSuspendingQuery({
source: () => 'enabled',
fetcher: () => RuntimeInventorySourcesAPI.list(),
@@ -168,8 +177,75 @@ export function VmwarePageSurface() {
const segment = location.pathname.split('/').filter(Boolean)[1] as VmwarePageTabId | undefined;
return segment && VALID_TABS.has(segment) ? segment : 'overview';
});
+ const [navigationResources, setNavigationResources] = createSignal<Resource[]>([]);
+ const [resourceFacets, setResourceFacets] = createSignal<UnifiedResourceFacets | null>(null);
+ const [activityEvidence] = createResource(async () =>
+ ResourceAPI.getGlobalTimeline({
+ limit: 1,
+ kind: 'activity',
+ sourceType: 'platform_event',
+ sourceAdapter: 'vmware_adapter',
+ }),
+ );
+ const navigationModel = createMemo(() => buildVmwarePageModel(navigationResources(), []));
+ const tabs = createMemo(() => {
+ const facets = resourceFacets();
+ if (!facets || activityEvidence.loading || activityEvidence.error) {
+ return navigationResources().length > 0
+ ? getVmwarePageTabSpecs(navigationModel(), {
+ hasActivityInventory: (activityEvidence()?.recentChanges?.length ?? 0) > 0,
+ })
+ : VMWARE_TAB_SPECS;
+ }
+ return getVmwarePageTabSpecs(navigationModel(), {
+ typeCounts: facets.byType,
+ incidentCount: facets.incidentCount,
+ hasActivityInventory: (activityEvidence()?.recentChanges?.length ?? 0) > 0,
+ });
+ });
+ const activeTab = createMemo<VmwarePageTabId>(() =>
+ tabs().some((tab) => tab.id === requestedTab()) ? requestedTab() : 'overview',
+ );
+ const shouldHydrateTab = (tab: VmwarePageTabId) => activeTab() === tab;
+ const createTabResources = (tab: VmwarePageTabId) =>
+ useUnifiedResources({
+ query: VMWARE_RESOURCE_QUERY_BY_TAB[tab],
+ cacheKey: `vmware-${tab}`,
+ initialHydration: 'prefer-ws-then-rest',
+ enabled: () => shouldHydrateTab(tab),
+ realtimeEnabled: () => shouldHydrateTab(tab),
+ });
+ const overviewResources = createTabResources('overview');
+ const storageResources = createTabResources('storage');
+ const networkResources = createTabResources('networks');
+ const healthResources = createTabResources('health');
+ const activityResources = createTabResources('activity');
+ const resourceState = createMemo(() => {
+ switch (activeTab()) {
+ case 'storage':
+ return storageResources;
+ case 'networks':
+ return networkResources;
+ case 'health':
+ return healthResources;
+ case 'activity':
+ return activityResources;
+ default:
+ return overviewResources;
+ }
+ });
+ const resources = () => resourceState().resources();
+ const loading = () => resourceState().loading();
+ const error = () => resourceState().error();
+ const refetch = () => resourceState().refetch();
+ createEffect(() => {
+ const state = resourceState();
+ setNavigationResources(state.resources());
+ const nextFacets = state.facets?.();
+ if (nextFacets) setResourceFacets(nextFacets);
+ });
const [activityTimeline, { refetch: refetchActivityTimeline }] = createResource(
- () => (resources().length > 0 ? 'vmware-activity' : undefined),
+ () => (activeTab() === 'activity' ? 'vmware-activity' : undefined),
async () => {
const response = await ResourceAPI.getGlobalTimeline({
limit: 100,
@@ -181,10 +257,6 @@ export function VmwarePageSurface() {
},
);
const model = createMemo(() => buildVmwarePageModel(resources(), activityTimeline() ?? []));
- const tabs = createMemo(() => getVmwarePageTabSpecs(model()));
- const activeTab = createMemo<VmwarePageTabId>(() =>
- tabs().some((tab) => tab.id === requestedTab()) ? requestedTab() : 'overview',
- );
const agentUpdateTargetVersion = createMemo(
() => updateStore.versionInfo()?.agentUpdateTargetVersion,
);
diff --git a/frontend-modern/src/features/vmware/__tests__/VmwarePageSurface.contract.test.tsx b/frontend-modern/src/features/vmware/__tests__/VmwarePageSurface.contract.test.tsx
index 0e0fc3e422..74dfaace69 100644
--- a/frontend-modern/src/features/vmware/__tests__/VmwarePageSurface.contract.test.tsx
+++ b/frontend-modern/src/features/vmware/__tests__/VmwarePageSurface.contract.test.tsx
@@ -204,8 +204,8 @@ describe('VmwarePageSurface contract', () => {
expect(mockUseUnifiedResources).toHaveBeenCalledWith(
expect.objectContaining({
- query: 'type=agent,vm,storage,network&source=vmware-vsphere',
- cacheKey: 'vmware-workspace',
+ query: 'type=agent,vm&source=vmware-vsphere',
+ cacheKey: 'vmware-overview',
}),
);
const stateOptions = mockUseWorkloadsState.mock.calls[0]?.[0] as {
@@ -221,6 +221,34 @@ describe('VmwarePageSurface contract', () => {
expect(refetch).toHaveBeenCalledTimes(1);
});
+ it('hydrates only the active vSphere workflow resource family', () => {
+ mockPathname.mockReturnValue('/vmware/networks');
+ setResources([
+ makeResource({
+ id: 'esxi-host-1',
+ type: 'agent',
+ vmware: { entityType: 'host', managedObjectId: 'host-1' },
+ }),
+ makeResource({
+ id: 'network-1',
+ type: 'network',
+ vmware: { entityType: 'network', managedObjectId: 'network-1' },
+ }),
+ ]);
+
+ render(() => <VmwarePageSurface />);
+
+ const activeCall = mockUseUnifiedResources.mock.calls.find(([options]) =>
+ (options as { enabled: () => boolean }).enabled(),
+ );
+ expect(activeCall?.[0]).toEqual(
+ expect.objectContaining({
+ cacheKey: 'vmware-networks',
+ query: 'type=agent,network&source=vmware-vsphere',
+ }),
+ );
+ });
+
it('does not treat vSphere ESXi API host resources as Pulse agent update targets', () => {
mockVersionInfo.mockReturnValue({
version: 'v6.0.0-rc.6',
diff --git a/frontend-modern/src/features/vmware/__tests__/vmwarePageModel.test.ts b/frontend-modern/src/features/vmware/__tests__/vmwarePageModel.test.ts
index 17b7d500a1..1201018f67 100644
--- a/frontend-modern/src/features/vmware/__tests__/vmwarePageModel.test.ts
+++ b/frontend-modern/src/features/vmware/__tests__/vmwarePageModel.test.ts
@@ -105,6 +105,20 @@ describe('vmwarePageModel', () => {
]);
});
+ it('keeps vSphere workflow tabs visible from scoped facets on partial routes', () => {
+ const activeRouteModel = buildVmwarePageModel([
+ makeResource({ id: 'esxi-host-1', type: 'agent' }),
+ ]);
+
+ expect(
+ getVmwarePageTabSpecs(activeRouteModel, {
+ typeCounts: { storage: 2, network: 3 },
+ incidentCount: 1,
+ hasActivityInventory: true,
+ }).map((tab) => tab.id),
+ ).toEqual(['overview', 'storage', 'networks', 'health', 'activity']);
+ });
+
it('buckets canonical vSphere hosts, VMs, datastores, and networks', () => {
const model = buildVmwarePageModel([
makeResource({ id: 'esxi-host-1', type: 'agent' }),
diff --git a/frontend-modern/src/features/vmware/vmwarePageModel.ts b/frontend-modern/src/features/vmware/vmwarePageModel.ts
index dc72da71cb..0b8ec7c1fa 100644
--- a/frontend-modern/src/features/vmware/vmwarePageModel.ts
+++ b/frontend-modern/src/features/vmware/vmwarePageModel.ts
@@ -130,23 +130,36 @@ export function buildVmwarePageModel(
};
}
-const hasVmwareTabInventory = (model: VmwarePageModel, tab: VmwarePageTabId): boolean => {
+export type VmwareTabInventoryEvidence = {
+ typeCounts?: Partial<Record<ResourceType, number>>;
+ incidentCount?: number;
+ hasActivityInventory?: boolean;
+};
+
+const hasVmwareTabInventory = (
+ model: VmwarePageModel,
+ tab: VmwarePageTabId,
+ evidence: VmwareTabInventoryEvidence = {},
+): boolean => {
switch (tab) {
case 'overview':
return true;
case 'storage':
- return model.datastores.length > 0;
+ return model.datastores.length > 0 || (evidence.typeCounts?.storage ?? 0) > 0;
case 'networks':
- return model.networks.length > 0;
+ return model.networks.length > 0 || (evidence.typeCounts?.network ?? 0) > 0;
case 'health':
- return model.incidents.length > 0;
+ return model.incidents.length > 0 || (evidence.incidentCount ?? 0) > 0;
case 'activity':
- return model.activity.length > 0;
+ return model.activity.length > 0 || Boolean(evidence.hasActivityInventory);
}
};
-export const getVmwarePageTabSpecs = (model: VmwarePageModel): readonly VmwareTabSpec[] =>
- VMWARE_TAB_SPECS.filter((tab) => hasVmwareTabInventory(model, tab.id));
+export const getVmwarePageTabSpecs = (
+ model: VmwarePageModel,
+ evidence: VmwareTabInventoryEvidence = {},
+): readonly VmwareTabSpec[] =>
+ VMWARE_TAB_SPECS.filter((tab) => hasVmwareTabInventory(model, tab.id, evidence));
const normalize = (value: unknown): string =>
typeof value === 'string' ? value.trim().toLowerCase() : '';
diff --git a/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts b/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts
index 22b829430b..c5c5e8bfec 100644
--- a/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts
+++ b/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts
@@ -1949,6 +1949,45 @@ describe('useUnifiedResources', () => {
dispose();
});
+ it('normalizes source-scoped type and incident facets for route navigation', async () => {
+ apiFetchMock.mockResolvedValueOnce({
+ ok: true,
+ json: async () => ({
+ data: [v2Resource],
+ facets: {
+ byType: {
+ agent: 1,
+ vm: 18,
+ storage: 3,
+ },
+ incidentCount: 4,
+ },
+ }),
+ });
+
+ let dispose = () => {};
+ let result: ReturnType<UseUnifiedResourcesModule['useUnifiedResources']> | undefined;
+ createRoot((d) => {
+ dispose = d;
+ result = useUnifiedResources({
+ query: 'type=agent,vm&source=vmware-vsphere',
+ cacheKey: 'vmware-overview-facets',
+ });
+ });
+
+ await waitForValue(() => result!.facets()?.incidentCount, 4);
+ expect(result!.facets()).toEqual({
+ byType: {
+ agent: 1,
+ vm: 18,
+ storage: 3,
+ },
+ incidentCount: 4,
+ });
+
+ dispose();
+ });
+
it('normalizes legacy k8s discovery targets to pod for frontend consumers', async () => {
apiFetchMock.mockResolvedValue({
ok: true,
diff --git a/frontend-modern/src/hooks/useUnifiedResources.ts b/frontend-modern/src/hooks/useUnifiedResources.ts
index c75eeb5933..53faac0f36 100644
--- a/frontend-modern/src/hooks/useUnifiedResources.ts
+++ b/frontend-modern/src/hooks/useUnifiedResources.ts
@@ -37,6 +37,7 @@ import { canonicalDiscoveryResourceType } from '@/utils/discoveryTarget';
import { canonicalizeFrontendResourceType } from '@/utils/resourceTypeCompat';
import { getPreferredNormalizedPlatformId } from '@/utils/resourceIdentity';
import { getExplicitResourceClusterName } from '@/utils/agentResources';
+import type { ResourceListFacetsPayload } from '@/types/api';
import {
buildFastResourceStorePatchOps,
getFastResourceMergePatchKeys,
@@ -551,6 +552,7 @@ type APIListResponse = {
byType?: Partial<Record<string, number>>;
policyPosture?: APIResourcePolicyPostureSummary;
};
+ facets?: ResourceListFacetsPayload;
};
export type UnifiedResourceAggregations = {
@@ -558,6 +560,11 @@ export type UnifiedResourceAggregations = {
byType: Partial<Record<ResourceType, number>>;
};
+export type UnifiedResourceFacets = {
+ byType: Partial<Record<ResourceType, number>>;
+ incidentCount: number;
+};
+
type APIResourcePolicyPostureSummary = {
totalResources?: number;
sensitivityCounts?: Partial<Record<string, number>>;
@@ -569,12 +576,14 @@ type UnifiedResourcesSnapshot = {
resources: Resource[];
policyPosture: ResourcePolicyPostureSummary | null;
aggregations: UnifiedResourceAggregations | null;
+ facets: UnifiedResourceFacets | null;
};
type UnifiedResourcesCacheEntry = {
resources: Resource[];
policyPosture: ResourcePolicyPostureSummary | null;
aggregations: UnifiedResourceAggregations | null;
+ facets: UnifiedResourceFacets | null;
hasSnapshot: boolean;
cachedAt: number;
lastFetchAt: number;
@@ -1030,6 +1039,22 @@ const normalizeUnifiedResourceAggregations = (
};
};
+const normalizeUnifiedResourceFacets = (
+ value: APIListResponse['facets'],
+): UnifiedResourceFacets | null => {
+ if (!value || typeof value !== 'object' || Array.isArray(value)) return null;
+ const byType: Partial<Record<ResourceType, number>> = {};
+ for (const [rawType, rawCount] of Object.entries(value.byType ?? {})) {
+ const count = normalizeNonNegativeCount(rawCount);
+ if (count === undefined) continue;
+ byType[resolveType(rawType)] = count;
+ }
+ return {
+ byType,
+ incidentCount: normalizeNonNegativeCount(value.incidentCount) ?? 0,
+ };
+};
+
const resolveResourcesPayload = (
payload: unknown,
): {
@@ -1037,6 +1062,7 @@ const resolveResourcesPayload = (
totalPages: number;
policyPosture: ResourcePolicyPostureSummary | null;
aggregations: UnifiedResourceAggregations | null;
+ facets: UnifiedResourceFacets | null;
} => {
if (Array.isArray(payload)) {
return {
@@ -1044,10 +1070,17 @@ const resolveResourcesPayload = (
totalPages: 1,
policyPosture: null,
aggregations: null,
+ facets: null,
};
}
if (!payload || typeof payload !== 'object') {
- return { data: [], totalPages: 1, policyPosture: null, aggregations: null };
+ return {
+ data: [],
+ totalPages: 1,
+ policyPosture: null,
+ aggregations: null,
+ facets: null,
+ };
}
const record = payload as APIListResponse;
const data = Array.isArray(record.data)
@@ -1063,6 +1096,7 @@ const resolveResourcesPayload = (
totalPages,
policyPosture: normalizeResourcePolicyPosture(record.aggregations?.policyPosture),
aggregations: normalizeUnifiedResourceAggregations(record.aggregations),
+ facets: normalizeUnifiedResourceFacets(record.facets),
};
};
@@ -1086,6 +1120,7 @@ const getUnifiedResourcesCacheEntry = (cacheKey: string): UnifiedResourcesCacheE
resources: [],
policyPosture: null,
aggregations: null,
+ facets: null,
hasSnapshot: false,
cachedAt: 0,
lastFetchAt: 0,
@@ -1105,10 +1140,12 @@ const setUnifiedResourcesCache = (
at = Date.now(),
policyPosture: ResourcePolicyPostureSummary | null = entry.policyPosture,
aggregations: UnifiedResourceAggregations | null = entry.aggregations,
+ facets: UnifiedResourceFacets | null = entry.facets,
) => {
entry.resources = resources;
entry.policyPosture = policyPosture;
entry.aggregations = aggregations;
+ entry.facets = facets;
entry.hasSnapshot = true;
entry.cachedAt = at;
};
@@ -1234,6 +1271,17 @@ const filterCanonicalUnifiedResources = (
});
};
+const buildUnifiedResourceFacets = (resources: readonly Resource[]): UnifiedResourceFacets => {
+ const byType: Partial<Record<ResourceType, number>> = {};
+ let incidentCount = 0;
+ for (const resource of resources) {
+ const type = resolveType(resource.type);
+ byType[type] = (byType[type] ?? 0) + 1;
+ incidentCount += resource.incidentCount ?? 0;
+ }
+ return { byType, incidentCount };
+};
+
/**
* Resolve the small set of store rows that need reconciliation for one
* canonical realtime revision. A structural mismatch returns `null` so the
@@ -1292,6 +1340,10 @@ const seedUnifiedResourcesCacheFromAllResources = (
filterCanonicalUnifiedResources(allResourcesEntry.resources, query, localFilter) ?? [];
entry.policyPosture = allResourcesEntry.policyPosture;
entry.aggregations = allResourcesEntry.aggregations;
+ // The all-resources cache cannot supply source-scoped type facets without
+ // replaying the server's non-type filter semantics. Keep them unknown until
+ // the scoped REST revalidation returns the authoritative facet bundle.
+ entry.facets = null;
entry.hasSnapshot = true;
entry.cachedAt = allResourcesEntry.cachedAt;
entry.lastFetchAt = allResourcesEntry.lastFetchAt;
@@ -1345,16 +1397,19 @@ async function fetchUnifiedResources(query: string): Promise<UnifiedResourcesSna
const allRawResources: APIResource[] = [];
let policyPosture: ResourcePolicyPostureSummary | null = null;
let aggregations: UnifiedResourceAggregations | null = null;
+ let facets: UnifiedResourceFacets | null = null;
for (const resolved of pages) {
allRawResources.push(...resolved.data);
policyPosture = policyPosture ?? resolved.policyPosture;
aggregations = aggregations ?? resolved.aggregations;
+ facets = facets ?? resolved.facets;
}
return {
resources: dedupeResources(allRawResources).map((resource) => toResource(resource)),
policyPosture,
aggregations,
+ facets,
};
}
@@ -1380,6 +1435,7 @@ const fetchUnifiedResourcesShared = async (
now,
fetched.policyPosture,
fetched.aggregations,
+ fetched.facets,
);
entry.lastFetchAt = now;
return fetched.resources;
@@ -1450,6 +1506,7 @@ export function useUnifiedResources(options?: UseUnifiedResourcesOptions) {
const initialResources = cacheEntry.resources;
const initialPolicyPosture = cacheEntry.policyPosture;
const initialAggregations = cacheEntry.aggregations;
+ const initialFacets = cacheEntry.facets;
const hasCachedResources = cacheEntry.hasSnapshot;
const [resources, setResources] = createStore<Resource[]>(initialResources);
@@ -1459,6 +1516,7 @@ export function useUnifiedResources(options?: UseUnifiedResourcesOptions) {
const [aggregations, setAggregations] = createSignal<UnifiedResourceAggregations | null>(
initialAggregations,
);
+ const [facets, setFacets] = createSignal<UnifiedResourceFacets | null>(initialFacets);
const [loading, setLoading] = createSignal(!hasCachedResources);
const [error, setError] = createSignal<unknown>(undefined);
const wsStore = getGlobalWebSocketStore();
@@ -1482,6 +1540,7 @@ export function useUnifiedResources(options?: UseUnifiedResourcesOptions) {
setResources(reconcile(next, { key: 'id' }));
setPolicyPosture(targetEntry.policyPosture);
setAggregations(targetEntry.aggregations);
+ setFacets(targetEntry.facets);
};
const runRefetch = async (options?: {
@@ -1827,6 +1886,20 @@ export function useUnifiedResources(options?: UseUnifiedResourcesOptions) {
query,
localFilter,
);
+ const projectedFacetResources = filterCanonicalUnifiedResources(
+ mergedWsResources,
+ query,
+ localFilter
+ ? {
+ ...localFilter,
+ types: new Set<ResourceType>(),
+ }
+ : null,
+ );
+ const projectedFacets =
+ projectedFacetResources === null
+ ? cacheEntry.facets
+ : buildUnifiedResourceFacets(projectedFacetResources);
const now = Date.now();
clearInitialHydrationTimeout();
setUnifiedResourcesCache(allResourcesEntry, mergedWsResources, now);
@@ -1882,7 +1955,14 @@ export function useUnifiedResources(options?: UseUnifiedResourcesOptions) {
// Captured before the cache write below replaces it: the fast-commit
// eligibility check needs the row the instance store currently mirrors.
const previousProjectedResources = cacheEntry.resources;
- setUnifiedResourcesCache(cacheEntry, resolvedProjectedResources, now);
+ setUnifiedResourcesCache(
+ cacheEntry,
+ resolvedProjectedResources,
+ now,
+ cacheEntry.policyPosture,
+ cacheEntry.aggregations,
+ projectedFacets,
+ );
cacheEntry.lastFetchAt = now;
cacheEntry.realtimeVersion = resourceChange.version;
batch(() => {
@@ -1927,6 +2007,7 @@ export function useUnifiedResources(options?: UseUnifiedResourcesOptions) {
}
setPolicyPosture(cacheEntry.policyPosture);
setAggregations(cacheEntry.aggregations);
+ setFacets(cacheEntry.facets);
setError(undefined);
setLoading(false);
});
@@ -2002,11 +2083,13 @@ export function useUnifiedResources(options?: UseUnifiedResourcesOptions) {
const scopedResources = cacheEntry.resources;
const scopedPolicyPosture = cacheEntry.policyPosture;
const scopedAggregations = cacheEntry.aggregations;
+ const scopedFacets = cacheEntry.facets;
batch(() => {
setError(undefined);
setResources(reconcile(scopedResources, { key: 'id' }));
setPolicyPosture(scopedPolicyPosture);
setAggregations(scopedAggregations);
+ setFacets(scopedFacets);
setLoading(enabled() && !cacheEntry.hasSnapshot);
});
@@ -2053,6 +2136,7 @@ export function useUnifiedResources(options?: UseUnifiedResourcesOptions) {
resources: () => resources,
policyPosture,
aggregations,
+ facets,
refetch,
mutate,
loading,
diff --git a/frontend-modern/src/types/api.ts b/frontend-modern/src/types/api.ts
index 0498bd157a..cd986bd5ab 100644
--- a/frontend-modern/src/types/api.ts
+++ b/frontend-modern/src/types/api.ts
@@ -3,6 +3,11 @@
import type { Resource, ResourceCapability, ResourcePolicy } from './resource';
import type { EvidenceEnvelope, LifecycleTransition, OperationalRecord } from './operationalTrust';
+export interface ResourceListFacetsPayload {
+ byType?: Partial<Record<string, number>>;
+ incidentCount?: number;
+}
+
export interface APITokenRecord {
id: string;
name: string;
diff --git a/internal/api/resourceapi/resources.go b/internal/api/resourceapi/resources.go
index 212752a054..3a835608f1 100644
--- a/internal/api/resourceapi/resources.go
+++ b/internal/api/resourceapi/resources.go
@@ -172,6 +172,13 @@ func (h *QueryService) HandleListResources(w http.ResponseWriter, r *http.Reques
}
filters := parseListFilters(r)
+ facetFilters := filters
+ // Type facets drive evidence-gated workflow navigation. They must honor the
+ // rest of the request scope (especially source and excludeSource) while
+ // ignoring the active route's type selection, otherwise a storage-only
+ // query could never prove that an Images or Networks workflow also exists.
+ facetFilters.types = nil
+ facetResources := applyFilters(allResources, facetFilters)
resources = applyFilters(resources, filters)
applySorting(resources, filters.sortField, filters.sortOrder)
@@ -193,6 +200,7 @@ func (h *QueryService) HandleListResources(w http.ResponseWriter, r *http.Reques
response.Data = paged
response.Meta = meta
response.Aggregations = stats
+ response.Facets = buildResourceListFacets(facetResources)
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(response.NormalizeCollections())
@@ -1389,6 +1397,27 @@ type ResourcesResponse struct {
Data []unified.Resource `json:"data"`
Meta ResourcesMeta `json:"meta"`
Aggregations unified.ResourceStats `json:"aggregations"`
+ Facets ResourceListFacets `json:"facets"`
+}
+
+// ResourceListFacets describes the complete resource scope selected by the
+// non-type filters on a list request. The paged rows remain type-filtered;
+// these compact counts let clients evidence-gate adjacent workflow routes
+// without hydrating every row from every resource type.
+type ResourceListFacets struct {
+ ByType map[unified.ResourceType]int `json:"byType"`
+ IncidentCount int `json:"incidentCount"`
+}
+
+func buildResourceListFacets(resources []unified.Resource) ResourceListFacets {
+ facets := ResourceListFacets{
+ ByType: make(map[unified.ResourceType]int, 8),
+ }
+ for _, resource := range resources {
+ facets.ByType[resourceContractType(resource)]++
+ facets.IncidentCount += resource.IncidentCount
+ }
+ return facets
}
func EmptyResourcesResponse() ResourcesResponse {
@@ -1413,6 +1442,9 @@ func (r ResourcesResponse) NormalizeCollections() ResourcesResponse {
if r.Aggregations.BySource == nil {
r.Aggregations.BySource = map[unified.DataSource]int{}
}
+ if r.Facets.ByType == nil {
+ r.Facets.ByType = map[unified.ResourceType]int{}
+ }
return r
}
diff --git a/internal/api/resourceapi/resources_test.go b/internal/api/resourceapi/resources_test.go
index e42423decd..bab6e7f42d 100644
--- a/internal/api/resourceapi/resources_test.go
+++ b/internal/api/resourceapi/resources_test.go
@@ -255,6 +255,75 @@ func TestResourceListRejectsLegacyHostTypeFilter(t *testing.T) {
}
}
+func TestResourceListTypeFacetsRespectNonTypeScope(t *testing.T) {
+ now := time.Now().UTC()
+ cfg := &config.Config{DataPath: t.TempDir()}
+ h := NewQueryService(cfg)
+ h.SetStateProvider(resourceUnifiedSeedProvider{
+ snapshot: models.StateSnapshot{LastUpdate: now},
+ resources: []unified.Resource{
+ {
+ ID: "truenas-system",
+ Type: unified.ResourceTypeAgent,
+ Status: unified.StatusOnline,
+ Sources: []unified.DataSource{unified.SourceTrueNAS},
+ },
+ {
+ ID: "truenas-vm",
+ Type: unified.ResourceTypeVM,
+ Status: unified.StatusWarning,
+ Sources: []unified.DataSource{unified.SourceTrueNAS},
+ Incidents: []unified.ResourceIncident{
+ {Code: "vmware.alarm"},
+ {Code: "vmware.task"},
+ },
+ },
+ {
+ ID: "truenas-storage",
+ Type: unified.ResourceTypeStorage,
+ Status: unified.StatusOnline,
+ Sources: []unified.DataSource{unified.SourceTrueNAS},
+ },
+ {
+ ID: "docker-volume",
+ Type: unified.ResourceTypeDockerVolume,
+ Status: unified.StatusOnline,
+ Sources: []unified.DataSource{unified.SourceDocker},
+ },
+ },
+ })
+
+ rec := httptest.NewRecorder()
+ req := httptest.NewRequest(
+ http.MethodGet,
+ "/api/resources?source=truenas&type=agent&page=1&limit=100",
+ nil,
+ )
+ h.HandleListResources(rec, req)
+ if rec.Code != http.StatusOK {
+ t.Fatalf("status = %d, body=%s", rec.Code, rec.Body.String())
+ }
+
+ var response ResourcesResponse
+ if err := json.NewDecoder(rec.Body).Decode(&response); err != nil {
+ t.Fatalf("decode response: %v", err)
+ }
+ if len(response.Data) != 1 || response.Data[0].Type != unified.ResourceTypeAgent {
+ t.Fatalf("type-filtered rows = %#v, want the TrueNAS agent only", response.Data)
+ }
+ wantTypes := map[unified.ResourceType]int{
+ unified.ResourceTypeAgent: 1,
+ unified.ResourceTypeVM: 1,
+ unified.ResourceTypeStorage: 1,
+ }
+ if !reflect.DeepEqual(response.Facets.ByType, wantTypes) {
+ t.Fatalf("facets.byType = %#v, want %#v", response.Facets.ByType, wantTypes)
+ }
+ if response.Facets.IncidentCount != 2 {
+ t.Fatalf("facets.incidentCount = %d, want 2", response.Facets.IncidentCount)
+ }
+}
+
func TestResourceListMergesLinkedHost(t *testing.T) {
now := time.Now().UTC()
node := models.Node{