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.

fix(infrastructure): preserve truenas source handoff

rcourtmande136204c244
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 70c10b88f5..b2c7c0e316 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -188,6 +188,11 @@ work extends shared components instead of creating new local variants.
completion CTA language aligned with the governed infrastructure install
workspace instead of regressing to a route jump that leaves the next action
implicit.
+10. Keep shared filter primitives coherent with route-owned option hydration.
+ Feature shells such as `frontend-modern/src/features/infrastructure/`
+ must keep a route-owned canonical option visible in shared selects like
+ `LabeledFilterSelect` even when current results do not contain that
+ option, so provider-scoped handoffs do not flash back to `All`.
10. Keep the first welcome screen in
`frontend-modern/src/components/SetupWizard/steps/WelcomeStep.tsx`
explicit about operator context. The shell must explain that the bootstrap
@@ -1593,6 +1598,13 @@ summary state. `useInfrastructureSettingsState.ts`,
Proxmox/PBS/PMG/TrueNAS counts and availability from one shared infrastructure
settings state source instead of letting the reporting summary and the
provider-specific panel fetch the same TrueNAS connection state separately.
+That same shared filter-presentation boundary also owns infrastructure
+route-filter continuity. `frontend-modern/src/features/infrastructure/`
+must keep a route-owned canonical source option such as `truenas` visible in
+the shared `LabeledFilterSelect` even when current unified-resource results do
+not contain that source, so platform handoffs from settings and other
+surfaces do not flash back to `All` while the operator is still in a
+provider-scoped investigation flow.
That same shared feature-presentation boundary also owns storage disk-detail
fallback messaging in `frontend-modern/src/features/storageBackups/`. Shared
detail presenters must describe the actual capability or identity gap that
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index c3c5e28c94..7272762a60 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -153,6 +153,11 @@ assembly branch.
as the explicit API-backed alternative for Proxmox, TrueNAS, and future
provider-backed platforms instead of regressing to generic settings-root
CTAs or provider-specific one-off routes.
+6. Keep infrastructure route-backed source filters on canonical unified-resource
+ truth. `frontend-modern/src/features/infrastructure/` must preserve a
+ route-owned source such as `truenas` in the filter option set even when the
+ current unified-resource snapshot does not contain that source, so
+ cross-surface handoffs do not silently fall back to `All`.
## Current State
@@ -1306,3 +1311,10 @@ Shared infrastructure consumers such as the unified resource table and detail
drawer must present that owned metadata through shared helpers instead of
reconstructing privacy posture from display names, source types, or other
incidental runtime hints.
+That same infrastructure consumer boundary also owns route-backed source
+selection continuity. `frontend-modern/src/features/infrastructure/`
+must keep a route-owned canonical source such as `truenas` present in the
+source filter option set even when the currently loaded unified-resource
+snapshot does not contain that source yet, so cross-surface handoffs from
+settings, alerts, or findings do not collapse back to `All` during hydration
+or empty-filter states.
diff --git a/frontend-modern/src/features/infrastructure/InfrastructurePageSurface.tsx b/frontend-modern/src/features/infrastructure/InfrastructurePageSurface.tsx
index 185be1a8a5..d08bd7dda5 100644
--- a/frontend-modern/src/features/infrastructure/InfrastructurePageSurface.tsx
+++ b/frontend-modern/src/features/infrastructure/InfrastructurePageSurface.tsx
@@ -14,8 +14,6 @@ import SettingsIcon from 'lucide-solid/icons/settings';
import { ScrollToTopButton } from '@/components/shared/ScrollToTopButton';
import { STORAGE_KEYS } from '@/utils/localStorage';
import { AgentDeployModal } from '@/components/Infrastructure/AgentDeployModal';
-import { DEFAULT_INFRASTRUCTURE_SOURCE_OPTIONS } from '@/utils/sourcePlatformOptions';
-import { normalizeSourcePlatformKey } from '@/utils/sourcePlatforms';
import {
getInfrastructureEmptyState,
getInfrastructureFilterEmptyState,
@@ -25,7 +23,6 @@ import { useInfrastructurePageState, type GroupingMode } from './useInfrastructu
export function InfrastructurePageSurface() {
const navigate = useNavigate();
- const sourceOptions = DEFAULT_INFRASTRUCTURE_SOURCE_OPTIONS;
const {
loading,
error,
@@ -56,7 +53,7 @@ export function InfrastructurePageSurface() {
setFiltersOpen,
activeFilterCount,
kioskMode,
- availableSources,
+ sourceOptions,
statusOptions,
hasActiveFilters,
clearFilters,
@@ -182,12 +179,7 @@ export function InfrastructurePageSurface() {
selectClass="min-w-[8rem]"
>
<option value="">All</option>
- <For
- each={sourceOptions.filter((source) => {
- const normalized = normalizeSourcePlatformKey(source.key);
- return normalized ? availableSources().has(normalized) : false;
- })}
- >
+ <For each={sourceOptions()}>
{(source) => <option value={source.key}>{source.label}</option>}
</For>
</LabeledFilterSelect>
diff --git a/frontend-modern/src/features/infrastructure/__tests__/infrastructurePageModel.test.ts b/frontend-modern/src/features/infrastructure/__tests__/infrastructurePageModel.test.ts
index b77455ba10..d705ed8c6b 100644
--- a/frontend-modern/src/features/infrastructure/__tests__/infrastructurePageModel.test.ts
+++ b/frontend-modern/src/features/infrastructure/__tests__/infrastructurePageModel.test.ts
@@ -37,6 +37,10 @@ describe('infrastructurePageModel', () => {
const derivation = buildInfrastructurePageFilterDerivation(resources, '', '', '');
expect(Array.from(derivation.availableSources)).toEqual(['agent', 'proxmox-pve']);
+ expect(derivation.sourceOptions).toEqual([
+ { key: 'proxmox-pve', label: 'PVE' },
+ { key: 'agent', label: 'Agent' },
+ ]);
expect(derivation.statusOptions).toEqual([
{ key: 'online', label: 'Online' },
{ key: 'warning', label: 'warning' },
@@ -90,4 +94,28 @@ describe('infrastructurePageModel', () => {
expect(derivation.filteredResources).toEqual([]);
expect(derivation.hasFilteredResources).toBe(false);
});
+
+ it('keeps a route-owned source option visible even when no current resources provide it', () => {
+ const derivation = buildInfrastructurePageFilterDerivation(
+ [
+ makeResource({
+ id: 'resource-2',
+ type: 'storage',
+ platformType: 'proxmox-pve',
+ platformData: { sources: ['proxmox'] },
+ }),
+ ],
+ 'truenas',
+ '',
+ '',
+ );
+
+ expect(Array.from(derivation.availableSources)).toEqual(['proxmox-pve']);
+ expect(derivation.sourceOptions).toEqual([
+ { key: 'proxmox-pve', label: 'PVE' },
+ { key: 'truenas', label: 'TrueNAS' },
+ ]);
+ expect(derivation.activeFilterCount).toBe(1);
+ expect(derivation.hasActiveFilters).toBe(true);
+ });
});
diff --git a/frontend-modern/src/features/infrastructure/infrastructurePageModel.ts b/frontend-modern/src/features/infrastructure/infrastructurePageModel.ts
index 3eeb7f9723..5cc5771175 100644
--- a/frontend-modern/src/features/infrastructure/infrastructurePageModel.ts
+++ b/frontend-modern/src/features/infrastructure/infrastructurePageModel.ts
@@ -1,5 +1,6 @@
import type { Resource } from '@/types/resource';
import type { KnownSourcePlatform } from '@/utils/sourcePlatforms';
+import { buildSourcePlatformOptions, type SourcePlatformOption } from '@/utils/sourcePlatformOptions';
import {
buildStatusOptions,
collectAvailableSources,
@@ -11,6 +12,7 @@ import {
export interface InfrastructurePageFilterDerivation {
activeFilterCount: number;
availableSources: Set<KnownSourcePlatform>;
+ sourceOptions: SourcePlatformOption[];
statusOptions: Array<{ key: string; label: string }>;
hasActiveFilters: boolean;
filteredResources: Resource[];
@@ -26,6 +28,11 @@ export function buildInfrastructurePageFilterDerivation(
const activeFilterCount =
(selectedSource !== '' ? 1 : 0) + (selectedStatus !== '' ? 1 : 0);
const availableSources = collectAvailableSources(resources);
+ const sourceKeys = new Set<string>(availableSources);
+ if (selectedSource !== '') {
+ sourceKeys.add(selectedSource);
+ }
+ const sourceOptions = buildSourcePlatformOptions(sourceKeys);
const statusOptions = buildStatusOptions(collectAvailableStatuses(resources));
const hasActiveFilters =
selectedSource !== '' || selectedStatus !== '' || searchQuery.trim().length > 0;
@@ -39,6 +46,7 @@ export function buildInfrastructurePageFilterDerivation(
return {
activeFilterCount,
availableSources,
+ sourceOptions,
statusOptions,
hasActiveFilters,
filteredResources,
diff --git a/frontend-modern/src/features/infrastructure/useInfrastructurePageState.ts b/frontend-modern/src/features/infrastructure/useInfrastructurePageState.ts
index 75906539ea..140a3460b5 100644
--- a/frontend-modern/src/features/infrastructure/useInfrastructurePageState.ts
+++ b/frontend-modern/src/features/infrastructure/useInfrastructurePageState.ts
@@ -54,6 +54,7 @@ export function useInfrastructurePageState() {
);
const activeFilterCount = createMemo(() => filterDerivation().activeFilterCount);
const availableSources = createMemo(() => filterDerivation().availableSources);
+ const sourceOptions = createMemo(() => filterDerivation().sourceOptions);
const statusOptions = createMemo(() => filterDerivation().statusOptions);
const hasActiveFilters = createMemo(() => filterDerivation().hasActiveFilters);
const filteredResources = createMemo(() => filterDerivation().filteredResources);
@@ -107,6 +108,7 @@ export function useInfrastructurePageState() {
activeFilterCount,
kioskMode,
availableSources,
+ sourceOptions,
statusOptions,
hasActiveFilters,
clearFilters,
diff --git a/tests/integration/tests/33-truenas-infrastructure-route-filter.spec.ts b/tests/integration/tests/33-truenas-infrastructure-route-filter.spec.ts
new file mode 100644
index 0000000000..8e959bb950
--- /dev/null
+++ b/tests/integration/tests/33-truenas-infrastructure-route-filter.spec.ts
@@ -0,0 +1,118 @@
+import fs from 'node:fs';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { expect, test as base } from '@playwright/test';
+
+import { createAuthenticatedStorageState } from './helpers';
+
+const __dirname = path.dirname(fileURLToPath(import.meta.url));
+const SCREENSHOT_PATH = '/tmp/truenas-infrastructure-route-filter.png';
+
+type WorkerFixtures = {
+ authStorageStatePath: string;
+};
+
+const test = base.extend<{}, WorkerFixtures>({
+ storageState: async ({ authStorageStatePath }, use) => {
+ await use(authStorageStatePath);
+ },
+ authStorageStatePath: [async ({ browser }, use, workerInfo) => {
+ const storageStatePath = path.resolve(
+ __dirname,
+ '..',
+ '..',
+ 'tmp',
+ 'playwright-auth',
+ `truenas-infrastructure-route-filter-${workerInfo.project.name}.json`,
+ );
+ fs.mkdirSync(path.dirname(storageStatePath), { recursive: true });
+ await createAuthenticatedStorageState(browser, storageStatePath);
+ try {
+ await use(storageStatePath);
+ } finally {
+ fs.rmSync(storageStatePath, { force: true });
+ }
+ }, { scope: 'worker' }],
+});
+
+test.describe('TrueNAS infrastructure route filter', () => {
+ test.setTimeout(180_000);
+
+ test('keeps a route-owned TrueNAS source selection visible when current infrastructure data has no TrueNAS resources', async ({
+ page,
+ }) => {
+ await page.route('**/api/resources**', async (route) => {
+ const requestUrl = new URL(route.request().url());
+ if (requestUrl.pathname !== '/api/resources') {
+ await route.continue();
+ return;
+ }
+
+ await route.fulfill({
+ status: 200,
+ contentType: 'application/json',
+ body: JSON.stringify({
+ data: [
+ {
+ id: 'pve-main',
+ type: 'agent',
+ name: 'pve-main',
+ displayName: 'PVE Main',
+ platformId: 'pve-main',
+ platformType: 'proxmox-pve',
+ sourceType: 'hybrid',
+ sources: ['agent', 'proxmox-pve'],
+ status: 'online',
+ lastSeen: '2026-03-29T22:00:00Z',
+ canonicalIdentity: {
+ displayName: 'PVE Main',
+ hostname: 'pve-main',
+ platformId: 'pve-main',
+ },
+ agent: {
+ hostname: 'pve-main',
+ platform: 'Debian',
+ uptimeSeconds: 86400,
+ },
+ platformData: {
+ sources: ['agent', 'proxmox-pve'],
+ },
+ },
+ ],
+ meta: {
+ page: 1,
+ limit: 200,
+ total: 1,
+ totalPages: 1,
+ },
+ }),
+ });
+ });
+
+ await page.goto('/infrastructure?source=truenas', {
+ waitUntil: 'domcontentloaded',
+ });
+
+ await expect(page).toHaveURL(/\/infrastructure\?source=truenas/);
+ await expect(page.getByTestId('infrastructure-page')).toBeVisible();
+ await expect(page.locator('#infra-source-filter')).toHaveValue('truenas');
+
+ const sourceOptions = await page.locator('#infra-source-filter option').evaluateAll((options) =>
+ options.map((option) => ({
+ value: option.getAttribute('value'),
+ label: option.textContent?.trim(),
+ })),
+ );
+ expect(sourceOptions).toEqual([
+ { value: '', label: 'All' },
+ { value: 'proxmox-pve', label: 'PVE' },
+ { value: 'agent', label: 'Agent' },
+ { value: 'truenas', label: 'TrueNAS' },
+ ]);
+
+ await expect(page.getByText('No resources match filters')).toBeVisible();
+ await expect(page.getByText('Try adjusting the search, source, or status filters.')).toBeVisible();
+
+ await page.screenshot({ path: SCREENSHOT_PATH, fullPage: true });
+ });
+});