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 table responsive resizing

rcourtmanaf2db1f63c9c
diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
index d3dc7c3dbf..9ccaac3e4e 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -205,6 +205,15 @@ regression protection.
is previewed or pinned, member rows should take a restrained shared
preview/pinned wash via `data-summary-group-member-active` rather than
per-surface outlines, secondary buttons, or full-strength row fills.
+ Infrastructure table responsive behavior belongs to that same hot-path
+ owner. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts`
+ must derive column visibility from the measured table surface width, with
+ `frontend-modern/src/components/Infrastructure/unifiedResourceTableStateModel.ts`
+ owning the column-priority breakpoints. It must not rely on global viewport
+ width alone, because app chrome can leave the table with tablet-sized space
+ while the window still reports a desktop breakpoint. Live resize proof must
+ show the host and service tables dropping lower-priority columns without
+ introducing horizontal overflow.
28. Keep summary-card hover emphasis on one bounded rendering budget: when a summary row is active, shared sparkline and density-map primitives must promote the selected series and demote background series through the same active-series ID rather than layering a second page-local highlight pass, so zoom-range and hover scrubbing stay visually coherent without reintroducing multi-series overdraw on the hot summary cards. Density maps on that hot path must stay overview-first under focus: preserve the multi-entity heatmap rows, layer focused-entity detail inside the card, and avoid swapping transient hover into a separate single-series chart path.
29. Keep public self-hosted checkout handoff endpoints on the adjacent
commercial/router boundary, not the summary-chart hot path. When
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 0722d2f2fa..3b6bd18e3d 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -226,7 +226,15 @@ assembly branch.
`Analysis`, `Analysis Reasoning`, and `Safe Summary` rather than reviving
generic `AI` or `AI-Safe` branding inside the resource drawer or discovery
shell.
-14. Keep shared policy-posture framing on the unified-resource card owner.
+14. Keep the operator-facing unified resource table width-aware at the table
+ surface, not just at the browser viewport. `frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx`
+ must route its root ref through `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts`,
+ and `frontend-modern/src/components/Infrastructure/unifiedResourceTableStateModel.ts`
+ owns the column-priority breakpoints for host and service infrastructure
+ rows. When the app shell leaves tablet-sized space during live resize, the
+ table must hide lower-priority resource metadata columns rather than
+ publishing a horizontally scrolling canonical resource list.
+15. Keep shared policy-posture framing on the unified-resource card owner.
`frontend-modern/src/components/Infrastructure/ResourcePolicySummary.tsx`
may accept caller-owned subtitle or resource-count wording when Patrol or
another shared surface needs to explain how the same governed policy counts
diff --git a/frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx b/frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx
index ef85f10dc6..6c5a45ce13 100644
--- a/frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx
+++ b/frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx
@@ -11,7 +11,7 @@ export const UnifiedResourceTable: Component<UnifiedResourceTableProps> = (props
return (
<div
- ref={props.setTableRootRef}
+ ref={table.setTableRootRef}
class="space-y-4"
data-summary-clear-surface
data-testid="infrastructure-table-surface"
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx b/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx
index 9675b882ef..119cb20389 100644
--- a/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx
+++ b/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx
@@ -34,14 +34,23 @@ import {
} from '@/components/Infrastructure/infrastructureSelectors';
const resourceDetailDrawerMock = vi.hoisted(() => vi.fn());
const frontendIndexCssSource = readFileSync(join(process.cwd(), 'src/index.css'), 'utf8');
-// Stub ResizeObserver for jsdom
-if (typeof globalThis.ResizeObserver === 'undefined') {
- globalThis.ResizeObserver = class ResizeObserver {
- observe() {}
- unobserve() {}
- disconnect() {}
- } as unknown as typeof ResizeObserver;
-}
+const resizeObserverCallbacks: ResizeObserverCallback[] = [];
+globalThis.ResizeObserver = class ResizeObserver {
+ constructor(callback: ResizeObserverCallback) {
+ resizeObserverCallbacks.push(callback);
+ }
+ observe() {}
+ unobserve() {}
+ disconnect() {}
+} as unknown as typeof ResizeObserver;
+const emitResizeObserverWidth = (width: number) => {
+ for (const callback of resizeObserverCallbacks) {
+ callback(
+ [{ contentRect: { width } } as ResizeObserverEntry],
+ {} as ResizeObserver,
+ );
+ }
+};
if (typeof Element.prototype.scrollIntoView !== 'function') {
Element.prototype.scrollIntoView = vi.fn();
}
@@ -115,6 +124,7 @@ const getBodyRowCount = (container: HTMLElement) => container.querySelectorAll('
describe('UnifiedResourceTable performance contract', () => {
beforeEach(() => {
vi.clearAllMocks();
+ resizeObserverCallbacks.length = 0;
localStorage.clear();
});
@@ -177,6 +187,54 @@ describe('UnifiedResourceTable performance contract', () => {
expect(container.querySelector('[style]')).toBeNull();
});
+ it('adapts host columns from the measured table surface width instead of the window width', async () => {
+ const resources = [
+ makeResource(1, {
+ network: { rxBytes: 1200, txBytes: 3400 },
+ diskIO: { readRate: 2000, writeRate: 800 },
+ uptime: 86400,
+ temperature: 42,
+ }),
+ ];
+ const { getByText } = render(() => (
+ <UnifiedResourceTable
+ resources={resources}
+ expandedResourceId={null}
+ onExpandedResourceChange={vi.fn()}
+ groupingMode="flat"
+ />
+ ));
+
+ await waitFor(() => {
+ expect(getByText('Net I/O')).toBeInTheDocument();
+ });
+
+ emitResizeObserverWidth(900);
+
+ await waitFor(() => {
+ expect(getByText('Net I/O').closest('th')).toHaveClass('hidden');
+ expect(getByText('Source').closest('th')).toHaveClass('hidden');
+ });
+ expect(getByText('CPU').closest('th')).not.toHaveClass('hidden');
+ expect(getByText('Memory')).toBeInTheDocument();
+ expect(getByText('Disk').closest('th')).not.toHaveClass('hidden');
+
+ emitResizeObserverWidth(1200);
+
+ await waitFor(() => {
+ expect(getByText('Net I/O').closest('th')).not.toHaveClass('hidden');
+ expect(getByText('Source').closest('th')).not.toHaveClass('hidden');
+ expect(getByText('Uptime').closest('th')).toHaveClass('hidden');
+ });
+
+ emitResizeObserverWidth(1400);
+
+ await waitFor(() => {
+ expect(getByText('Uptime').closest('th')).not.toHaveClass('hidden');
+ expect(getByText('Temp').closest('th')).not.toHaveClass('hidden');
+ });
+ });
+
it('renders the shared facet summary component in timeline-only mode for canonical resource counts', async () => {
const { getByText, queryByText } = render(() => (
<ResourceFacetSummary
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/unifiedResourceTableStateModel.test.ts b/frontend-modern/src/components/Infrastructure/__tests__/unifiedResourceTableStateModel.test.ts
index f5eaee997d..5c251d9687 100644
--- a/frontend-modern/src/components/Infrastructure/__tests__/unifiedResourceTableStateModel.test.ts
+++ b/frontend-modern/src/components/Infrastructure/__tests__/unifiedResourceTableStateModel.test.ts
@@ -13,7 +13,10 @@ import {
getUnifiedResourceTableSortIndicator,
getUnifiedSources,
getVisibleHostTableItems,
+ isUnifiedResourceTableColumnVisible,
+ normalizeUnifiedResourceTableLayoutWidth,
shouldShowUnifiedResourceHostTable,
+ shouldUseUnifiedResourceTableMobileLayout,
} from '@/components/Infrastructure/unifiedResourceTableStateModel';
const makeResource = (id: string, overrides: Partial<Resource> = {}): Resource =>
@@ -131,6 +134,18 @@ describe('unifiedResourceTableStateModel', () => {
expect(shouldShowUnifiedResourceHostTable(3, 2)).toBe(true);
});
+ it('derives infrastructure table breakpoints from the measured table surface width', () => {
+ expect(normalizeUnifiedResourceTableLayoutWidth(820.4)).toBe(820);
+ expect(normalizeUnifiedResourceTableLayoutWidth(null, 700)).toBe(700);
+ expect(shouldUseUnifiedResourceTableMobileLayout(767)).toBe(true);
+ expect(shouldUseUnifiedResourceTableMobileLayout(768)).toBe(false);
+ expect(isUnifiedResourceTableColumnVisible('primary', 700)).toBe(true);
+ expect(isUnifiedResourceTableColumnVisible('secondary', 1119)).toBe(false);
+ expect(isUnifiedResourceTableColumnVisible('secondary', 1120)).toBe(true);
+ expect(isUnifiedResourceTableColumnVisible('supplementary', 1359)).toBe(false);
+ expect(isUnifiedResourceTableColumnVisible('supplementary', 1360)).toBe(true);
+ });
+
it('reads unified source tags from platform data without hook state', () => {
expect(getUnifiedSources(makeResource('a', { platformData: { sources: ['proxmox', 'agent'] } }))).toEqual([
'proxmox',
diff --git a/frontend-modern/src/components/Infrastructure/unifiedResourceTableStateModel.ts b/frontend-modern/src/components/Infrastructure/unifiedResourceTableStateModel.ts
index 5f14ed3cab..b0c44be6d1 100644
--- a/frontend-modern/src/components/Infrastructure/unifiedResourceTableStateModel.ts
+++ b/frontend-modern/src/components/Infrastructure/unifiedResourceTableStateModel.ts
@@ -1,4 +1,5 @@
import type { Resource } from '@/types/resource';
+import type { ColumnPriority } from '@/hooks/useBreakpoint';
import { getPreferredInfrastructureDisplayName } from '@/utils/resourceIdentity';
import {
sortResources,
@@ -34,6 +35,38 @@ export type HostTableItem = HostTableHeaderItem | HostTableResourceItem;
export const HOST_TABLE_ESTIMATED_ROW_HEIGHT = 40;
export const HOST_TABLE_WINDOW_SIZE = 137;
+export const UNIFIED_RESOURCE_TABLE_DEFAULT_LAYOUT_WIDTH = 1024;
+export const UNIFIED_RESOURCE_TABLE_MOBILE_LAYOUT_WIDTH = 768;
+export const UNIFIED_RESOURCE_TABLE_COLUMN_BREAKPOINTS: Record<ColumnPriority, number> = {
+ essential: 0,
+ primary: 640,
+ secondary: 1120,
+ supplementary: 1360,
+ detailed: 1536,
+};
+
+export const normalizeUnifiedResourceTableLayoutWidth = (
+ width: number | null | undefined,
+ fallback: number = UNIFIED_RESOURCE_TABLE_DEFAULT_LAYOUT_WIDTH,
+): number => {
+ if (typeof width === 'number' && Number.isFinite(width) && width > 0) {
+ return Math.round(width);
+ }
+ if (Number.isFinite(fallback) && fallback > 0) {
+ return Math.round(fallback);
+ }
+ return UNIFIED_RESOURCE_TABLE_DEFAULT_LAYOUT_WIDTH;
+};
+
+export const shouldUseUnifiedResourceTableMobileLayout = (layoutWidth: number): boolean =>
+ normalizeUnifiedResourceTableLayoutWidth(layoutWidth) < UNIFIED_RESOURCE_TABLE_MOBILE_LAYOUT_WIDTH;
+
+export const isUnifiedResourceTableColumnVisible = (
+ priority: ColumnPriority,
+ layoutWidth: number,
+): boolean =>
+ normalizeUnifiedResourceTableLayoutWidth(layoutWidth) >=
+ UNIFIED_RESOURCE_TABLE_COLUMN_BREAKPOINTS[priority];
export const buildResourceLabelById = (resources: Resource[]): Map<string, string> => {
const map = new Map<string, string>();
diff --git a/frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts b/frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts
index 2dcfda1b59..512e3f0740 100644
--- a/frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts
+++ b/frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts
@@ -1,5 +1,6 @@
-import { createMemo, createSignal } from 'solid-js';
+import { createEffect, createMemo, createSignal, onCleanup } from 'solid-js';
import type { Resource } from '@/types/resource';
+import type { ColumnPriority } from '@/hooks/useBreakpoint';
import { useBreakpoint } from '@/hooks/useBreakpoint';
import {
buildInfrastructureSummaryGroupScope,
@@ -19,13 +20,16 @@ import {
getHostSpacerHeights,
getNextUnifiedResourceTableSortState,
getUnifiedResourceTableColumnPresentations,
+ isUnifiedResourceTableColumnVisible,
getUnifiedResourceTableShellClass,
getUnifiedResourceTableSortIndicator,
getUnifiedSources,
getVisibleHostTableItems,
HOST_TABLE_ESTIMATED_ROW_HEIGHT,
HOST_TABLE_WINDOW_SIZE,
+ normalizeUnifiedResourceTableLayoutWidth,
shouldShowUnifiedResourceHostTable,
+ shouldUseUnifiedResourceTableMobileLayout,
sortServiceResources,
type HostTableItem,
type UnifiedResourceTableSortKey as SortKey,
@@ -52,10 +56,55 @@ export interface UnifiedResourceTableProps {
}
export function useUnifiedResourceTableState(props: UnifiedResourceTableProps) {
- const { isMobile, isVisible } = useBreakpoint();
+ const breakpoint = useBreakpoint();
+ const [tableContainerWidth, setTableContainerWidth] = createSignal<number | null>(null);
+ const [tableRootElement, setTableRootElement] = createSignal<HTMLDivElement | null>(null);
const [sortKey, setSortKey] = createSignal<SortKey>('default');
const [sortDirection, setSortDirection] = createSignal<'asc' | 'desc'>('asc');
+ const updateTableContainerWidth = (width: number | null | undefined) => {
+ if (typeof width === 'number' && Number.isFinite(width) && width > 0) {
+ setTableContainerWidth(Math.round(width));
+ }
+ };
+
+ const setTableRootRef = (element: HTMLDivElement | undefined) => {
+ setTableRootElement(element ?? null);
+ props.setTableRootRef?.(element);
+ if (element) {
+ updateTableContainerWidth(element.clientWidth);
+ } else {
+ setTableContainerWidth(null);
+ }
+ };
+
+ createEffect(() => {
+ const element = tableRootElement();
+ if (!element || typeof ResizeObserver === 'undefined') return;
+
+ const observer = new ResizeObserver((entries) => {
+ const entryWidth = entries[0]?.contentRect.width;
+ updateTableContainerWidth(entryWidth ?? element.clientWidth);
+ });
+ observer.observe(element);
+ onCleanup(() => observer.disconnect());
+ });
+
+ const fallbackViewportWidth = () => {
+ const widthAccessor = breakpoint.width as (() => number) | undefined;
+ const width = widthAccessor?.();
+ return normalizeUnifiedResourceTableLayoutWidth(
+ width,
+ typeof window !== 'undefined' ? window.innerWidth : undefined,
+ );
+ };
+ const tableLayoutWidth = createMemo(() =>
+ normalizeUnifiedResourceTableLayoutWidth(tableContainerWidth(), fallbackViewportWidth()),
+ );
+ const isMobile = createMemo(() => shouldUseUnifiedResourceTableMobileLayout(tableLayoutWidth()));
+ const isVisible = (priority: ColumnPriority) =>
+ isUnifiedResourceTableColumnVisible(priority, tableLayoutWidth());
+
const split = createMemo(() => splitPrimaryAndServiceResources(props.resources));
const primaryResources = createMemo(() => split().primaryResources);
const serviceResources = createMemo(() => split().services);
@@ -151,6 +200,7 @@ export function useUnifiedResourceTableState(props: UnifiedResourceTableProps) {
handleSort,
renderSortIndicator,
resolveResourceLabel,
+ setTableRootRef,
visibleHostTableItems,
hostTopSpacerHeight: () => hostSpacerHeights().top,
hostBottomSpacerHeight: () => hostSpacerHeights().bottom,