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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Stabilize large-estate workload scrolling
rcourtmand8fe2a935875
diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.mdindex e68ac5e47f..0a665ac87a 100644--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md@@ -794,6 +794,18 @@ change may globally weaken the Task 03 lifecycle-state idempotency invariant.bounded app scroll container, or fall back to the window, so scrolling alarge mobile estate advances the mounted row window and removes the finalbottom spacer when the operator reaches the end.+ Grouped virtualization must represent every node header in exactly one+ place: a leading spacer, the mounted window, or a trailing spacer. The+ inverse offset-to-guest calculation must use that same guest-row plus+ group-header geometry, and a partially mounted group must not reinsert its+ already-spaced header. This keeps total table height stable while groups+ cross the virtual window and prevents the visible estate from bumping by a+ header row during continuous scrolling.+ That same viewport-sync owner may expose one passive app-shell scroll+ position signal and a smooth back-to-top action for the Workloads surface.+ The control must remain absent near the top, sit above the mobile navigation+ when present, and reuse the existing viewport listener rather than adding a+ second page-local scroll observer or any per-row work.25. Extend workload table shell ownership through `frontend-modern/src/components/Workloads/WorkloadTableHeader.tsx` and `frontend-modern/src/components/Workloads/WorkloadPanel.tsx` rather than rebuilding sortable header markup, grouped node rows, row expansion, or guest-drawer rendering inside `frontend-modern/src/components/Workloads/WorkloadsTable.tsx``WorkloadPanel` owns the mutually exclusive host/guest drawer handoff:clicking a grouped host row while a guest drawer is open must clear thediff --git a/frontend-modern/browser-verification.json b/frontend-modern/browser-verification.jsonindex 75428e206e..fe02243e98 100644--- a/frontend-modern/browser-verification.json+++ b/frontend-modern/browser-verification.json@@ -1,41 +1,52 @@{"version": 1,- "base_sha": "3bc613c9157d1c6769ca25a0a5c3eec9c6694887",- "verified_at": "2026-08-23T14:51:12Z",+ "base_sha": "4040a79f4f5ffc465131fb75c31146d93e45c8d5",+ "verified_at": "2026-08-23T15:31:26Z","result": "passed","changed_paths": [- "frontend-modern/src/components/Workloads/useWorkloadViewportSync.ts"+ "frontend-modern/src/components/Workloads/WorkloadPanel.tsx",+ "frontend-modern/src/components/Workloads/WorkloadsSurface.tsx",+ "frontend-modern/src/components/Workloads/useGroupedTableWindowing.ts",+ "frontend-modern/src/components/Workloads/useWorkloadViewportSync.ts",+ "frontend-modern/src/components/Workloads/useWorkloadsDerivedState.ts",+ "frontend-modern/src/components/Workloads/useWorkloadsState.ts"],"content_sha256": {- "frontend-modern/src/components/Workloads/useWorkloadViewportSync.ts": "5c5fd2650df7dfe6228e14cb033e8f22ec9866b3b5310cb6bb076757a4d09a1b"+ "frontend-modern/src/components/Workloads/WorkloadPanel.tsx": "eb8ddd4c5f03efa629ba480fa9cbe4bbd8293834e6d0e6bf05e3fbb81d247edf",+ "frontend-modern/src/components/Workloads/WorkloadsSurface.tsx": "765e4185fea10dd2e6da0c9e3de53ee53293ae6e1e0e19d6171fb01748fa5b8d",+ "frontend-modern/src/components/Workloads/useGroupedTableWindowing.ts": "792a66e9f01fa1ab731413527255c631ccd20bc26bcef24a74208f1e61f76d58",+ "frontend-modern/src/components/Workloads/useWorkloadViewportSync.ts": "b12b4a1df25c88a5468e867aa2b58f10a452d65be846dcfd1bcaa4942e506a96",+ "frontend-modern/src/components/Workloads/useWorkloadsDerivedState.ts": "ecfc505a901c65b7ed8e7d17d828961d1409c948c6f78bf2528ea907cf484343",+ "frontend-modern/src/components/Workloads/useWorkloadsState.ts": "d67a6b5d5f2de1ff3c0fe100652cf2e3d8ed2f74cda767a1bdb7462dea243b28"},"routes": ["/proxmox/overview"],"viewports": [{- "width": 375,- "height": 812+ "width": 1280,+ "height": 720},{- "width": 1440,- "height": 900+ "width": 375,+ "height": 812}],"states": [- "The authenticated Proxmox overview renders 50 nodes and 929 guests from the large local mock estate",- "At 375x812 the initial virtual window keeps one trailing spacer while the first 140 guest rows are mounted",- "At the absolute bottom of the app scroll shell the virtual spacer is the leading row at index zero, the final workload row is last, and no trailing spacer remains",- "The Nodes card and footer follow the final guest row without a blank virtualized section",- "At 1440x900 the 929-guest table also reaches its final wireguard-edge-78 row with only a leading spacer and no trailing blank section",- "The verified phone load reported no browser console errors"+ "The Proxmox overview renders the large local mock estate with grouped workload virtualization active",+ "At 1280x720 the app scroll height remains exactly 29470 pixels at scroll positions 0, 1800, and 5000",+ "At 375x812 the app scroll height remains exactly 36372 pixels at scroll positions 0, 2800, and 7000",+ "All mounted phone guest rows measure 37 pixels and grouped node headers remain a single 28-pixel line",+ "Back to top is absent near the top and appears after the 640-pixel threshold",+ "The phone control is a 44-pixel fixed button positioned above the bottom navigation",+ "The verified desktop and phone journeys reported no browser console errors"],"interactions": [- "Claimed the open local Proxmox overview and applied a temporary 375x812 viewport override",- "Reloaded the 929-guest mock estate and measured the initial virtual spacer and mounted row count",- "Scrolled the app-owned vertical container to its maximum scroll position and inspected spacer row placement plus the final workload row",- "Captured the bottom viewport showing the final guest rows followed immediately by the Nodes card and footer",- "Repeated the absolute-bottom spacer and final-row inspection at 1440x900",- "Reset the temporary viewport override after verification"+ "Scrolled repeatedly through the desktop mock estate and compared the app-owned scroll shell height at multiple virtual windows",+ "Activated Back to top on desktop and confirmed the smooth scroll completed at zero and the control disappeared",+ "Applied a temporary 375x812 viewport override and repeated the multi-position scroll-height measurements",+ "Captured and visually inspected the phone viewport with the control above the mobile navigation",+ "Activated Back to top on phone and confirmed the app scroll shell returned to zero while retaining the same total height",+ "Reset the temporary viewport override and closed the temporary test tab after verification"]}diff --git a/frontend-modern/src/components/Workloads/WorkloadPanel.tsx b/frontend-modern/src/components/Workloads/WorkloadPanel.tsxindex cb8e464f12..9d12dfb7d0 100644--- a/frontend-modern/src/components/Workloads/WorkloadPanel.tsx+++ b/frontend-modern/src/components/Workloads/WorkloadPanel.tsx@@ -362,8 +362,8 @@ export function WorkloadPanel(props: WorkloadPanelProps) {return (<TableBody ref={props.setTableBodyRef} class="divide-y divide-border"><Show when={props.groupedWindowing.isWindowed() && props.topSpacerHeight() > 0}>- <TableRow aria-hidden="true">- <TableCell colspan={props.totalColumns()} class="p-0 border-0">+ <TableRow aria-hidden="true" class="h-0 !border-0">+ <TableCell colspan={props.totalColumns()} class="h-0 !p-0 !border-0 leading-[0]"><svgaria-hidden="true"width="1"@@ -424,7 +424,11 @@ export function WorkloadPanel(props: WorkloadPanelProps) {return (<>- <Show when={props.groupingMode() === 'grouped'}>+ <Show+ when={+ props.groupingMode() === 'grouped' && groupGuests()[0] === fullGroupGuests()[0]+ }+ ><Showwhen={node()}fallback={@@ -487,8 +491,8 @@ export function WorkloadPanel(props: WorkloadPanelProps) {}trClass={canOpenNodeDrawer()- ? 'cursor-pointer select-none duration-150'- : 'select-none duration-150'+ ? 'cursor-pointer select-none duration-150 [&>td>div]:flex-nowrap'+ : 'select-none duration-150 [&>td>div]:flex-nowrap'}trProps={{'aria-expanded': canOpenNodeDrawer()@@ -608,8 +612,8 @@ export function WorkloadPanel(props: WorkloadPanelProps) {}}</Index><Show when={props.groupedWindowing.isWindowed() && props.bottomSpacerHeight() > 0}>- <TableRow aria-hidden="true">- <TableCell colspan={props.totalColumns()} class="p-0 border-0">+ <TableRow aria-hidden="true" class="h-0 !border-0">+ <TableCell colspan={props.totalColumns()} class="h-0 !p-0 !border-0 leading-[0]"><svgaria-hidden="true"width="1"diff --git a/frontend-modern/src/components/Workloads/WorkloadsSurface.tsx b/frontend-modern/src/components/Workloads/WorkloadsSurface.tsxindex 2bcfe250b4..591fad7f7f 100644--- a/frontend-modern/src/components/Workloads/WorkloadsSurface.tsx+++ b/frontend-modern/src/components/Workloads/WorkloadsSurface.tsx@@ -1,8 +1,10 @@+import ArrowUpIcon from 'lucide-solid/icons/arrow-up';import { For, Show, createMemo } from 'solid-js';+import { Portal } from 'solid-js/web';import { buildInfrastructureWorkspacePath } from '@/components/Settings/infrastructureWorkspaceModel';import { EmptyState } from '@/components/shared/EmptyState';-import { ButtonLink } from '@/components/shared/Button';+import { ActionIconButton, ButtonLink } from '@/components/shared/Button';import { TableCard } from '@/components/shared/TableCard';import { sessionCanReadInfrastructureSettings } from '@/stores/sessionSettingsCapabilities';import { getWorkloadsNoInventoryState } from '@/utils/workloadEmptyStatePresentation';@@ -107,6 +109,20 @@ export function WorkloadsSurface(props: WorkloadsSurfaceComponentProps) {return (<div ref={state.setClearSurfaceRootRef} class="space-y-3" data-testid="workloads-page">+ <Show when={state.isScrollToTopVisible?.() ?? false}>+ <Portal>+ <ActionIconButton+ label="Back to top"+ tone="outline"+ size="lg"+ class="fixed right-3 bottom-[calc(var(--pulse-mobile-nav-height)+0.75rem)] z-[70] !h-11 !w-11 rounded-full bg-surface/95 shadow-lg backdrop-blur-sm xl:right-6 xl:bottom-6"+ data-testid="workloads-scroll-to-top"+ onClick={() => state.scrollToTop?.()}+ >+ <ArrowUpIcon class="h-5 w-5" aria-hidden="true" />+ </ActionIconButton>+ </Portal>+ </Show><div class="space-y-3" data-testid="workloads-interaction-surface"><Showwhen={diff --git a/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.performance.contract.test.tsx b/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.performance.contract.test.tsxindex fdd6ec82c8..382f465cc3 100644--- a/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.performance.contract.test.tsx+++ b/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.performance.contract.test.tsx@@ -909,6 +909,23 @@ describe('Workloads performance contract', () => {});describe('Workload windowing contracts', () => {+ it('keeps grouped virtual height stable and owns the back-to-top control in viewport sync', () => {+ expect(workloadsWorkloadDerivedStateSource).toContain('estimatedGroupHeaderHeight');+ expect(workloadsWorkloadDerivedStateSource).toContain('countGroupStartsBefore');+ expect(workloadsWorkloadDerivedStateSource).toContain('guestIndexAtVirtualOffset');+ expect(workloadsWorkloadDerivedStateSource).toContain('WORKLOADS_TABLE_DIVIDER_HEIGHT');+ expect(groupedTableWindowingSource).toContain('rowIndexAtOffset');+ expect(workloadPanelSource).toContain('groupGuests()[0] === fullGroupGuests()[0]');+ expect(workloadPanelSource).toContain('class="h-0 !p-0 !border-0 leading-[0]"');+ expect(workloadsWorkloadViewportSyncSource).toContain(+ 'SCROLL_TO_TOP_VISIBILITY_THRESHOLD_PX',+ );+ expect(workloadsWorkloadViewportSyncSource).toContain(+ "scrollContainer.scrollTo({ top: 0, behavior: 'smooth' })",+ );+ expect(workloadsSource).toContain('data-testid="workloads-scroll-to-top"');+ });+it('Profile M: caps mounted guest rows when windowing is active', async () => {mockLocationSearch = '?type=all';mockWorkloads = makeGuests(PROFILES.M);diff --git a/frontend-modern/src/components/Workloads/__tests__/useGroupedTableWindowing.test.ts b/frontend-modern/src/components/Workloads/__tests__/useGroupedTableWindowing.test.tsindex 9910437f49..f47e3f079e 100644--- a/frontend-modern/src/components/Workloads/__tests__/useGroupedTableWindowing.test.ts+++ b/frontend-modern/src/components/Workloads/__tests__/useGroupedTableWindowing.test.ts@@ -1,5 +1,5 @@import { createRoot, createSignal } from 'solid-js';-import { describe, it, expect, afterEach } from 'vitest';+import { describe, it, expect, afterEach, vi } from 'vitest';import {useGroupedTableWindowing,@@ -24,6 +24,7 @@ function createHook(windowSize: opts.windowSize,enabled: opts.enabled,revealIndex: opts.revealIndex,+ rowIndexAtOffset: opts.rowIndexAtOffset,});return dispose;});@@ -251,6 +252,35 @@ describe('useGroupedTableWindowing', () => {// firstVisible = 800/40 = 20, start = 20-20 = 0expect(hook.startIndex()).toBe(0);});++ it('uses grouped virtual geometry when decorations add height between rows', () => {+ const rowIndexAtOffset = vi.fn(() => 80);+ const hook = setup({+ totalRowCount: () => 1000,+ enabled: () => true,+ windowSize: 100,+ rowIndexAtOffset,+ });++ hook.onScroll(3200, 400, 32);++ expect(rowIndexAtOffset).toHaveBeenCalledWith(3200, 32);+ expect(hook.startIndex()).toBe(60);+ expect(hook.endIndex()).toBe(160);+ });++ it('falls back to fixed row math when the grouped offset resolver is non-finite', () => {+ const hook = setup({+ totalRowCount: () => 1000,+ enabled: () => true,+ windowSize: 100,+ rowIndexAtOffset: () => Number.NaN,+ });++ hook.onScroll(2000, 400, 40);++ expect(hook.startIndex()).toBe(30);+ });});// ──────────────────────────────────────────────────────────────diff --git a/frontend-modern/src/components/Workloads/__tests__/useWorkloadViewportSync.test.tsx b/frontend-modern/src/components/Workloads/__tests__/useWorkloadViewportSync.test.tsxindex 35838397e4..d27cefa5d9 100644--- a/frontend-modern/src/components/Workloads/__tests__/useWorkloadViewportSync.test.tsx+++ b/frontend-modern/src/components/Workloads/__tests__/useWorkloadViewportSync.test.tsx@@ -31,7 +31,7 @@ describe('useWorkloadViewportSync', () => {useWorkloadViewportSync({filteredGuestCount: () => 640,groupedWindowing,- rowHeight: 32,+ rowHeight: () => 32,tableBodyRef: bodyRef,});@@ -99,7 +99,7 @@ describe('useWorkloadViewportSync', () => {useWorkloadViewportSync({filteredGuestCount: () => 640,groupedWindowing,- rowHeight: 32,+ rowHeight: () => 32,tableBodyRef: bodyRef,});@@ -170,4 +170,70 @@ describe('useWorkloadViewportSync', () => {horizontalTableWrapper.dispatchEvent(new Event('scroll'));expect(onScroll).toHaveBeenCalledTimes(2);});++ it('exposes one app-shell back-to-top action after sustained workload scrolling', async () => {+ let appScrollContainer!: HTMLDivElement;+ let viewportSync!: ReturnType<typeof useWorkloadViewportSync>;+ const scrollTo = vi.fn();+ const groupedWindowing: UseGroupedTableWindowingResult = {+ endIndex: () => 20,+ getVisibleSlice: (_groupKey, guests) => guests,+ isWindowed: () => false,+ mountedCount: () => 20,+ onScroll: vi.fn(),+ revealIndex: vi.fn(),+ startIndex: () => 0,+ };++ const Harness = () => {+ const [bodyRef, setBodyRef] = createSignal<HTMLTableSectionElement | null>(null);+ viewportSync = useWorkloadViewportSync({+ filteredGuestCount: () => 20,+ groupedWindowing,+ rowHeight: () => 32,+ tableBodyRef: bodyRef,+ });++ return (+ <div+ ref={(element) => {+ appScrollContainer = element;+ Object.defineProperty(element, 'clientHeight', { configurable: true, value: 400 });+ Object.defineProperty(element, 'scrollHeight', { configurable: true, value: 1600 });+ Object.defineProperty(element, 'scrollTo', { configurable: true, value: scrollTo });+ vi.spyOn(element, 'getBoundingClientRect').mockReturnValue({+ bottom: 400,+ height: 400,+ left: 0,+ right: 800,+ toJSON: () => ({}),+ top: 0,+ width: 800,+ x: 0,+ y: 0,+ } as DOMRect);+ }}+ style={{ 'overflow-y': 'scroll' }}+ >+ <table>+ <tbody ref={setBodyRef} />+ </table>+ </div>+ );+ };++ render(() => <Harness />);+ expect(viewportSync.isScrollToTopVisible()).toBe(false);++ appScrollContainer.scrollTop = 700;+ appScrollContainer.dispatchEvent(new Event('scroll'));+ await waitFor(() => expect(viewportSync.isScrollToTopVisible()).toBe(true));++ viewportSync.scrollToTop();+ expect(scrollTo).toHaveBeenCalledWith({ top: 0, behavior: 'smooth' });++ appScrollContainer.scrollTop = 0;+ appScrollContainer.dispatchEvent(new Event('scroll'));+ await waitFor(() => expect(viewportSync.isScrollToTopVisible()).toBe(false));+ });});diff --git a/frontend-modern/src/components/Workloads/useGroupedTableWindowing.ts b/frontend-modern/src/components/Workloads/useGroupedTableWindowing.tsindex 655eb8e53b..a6431d5f8c 100644--- a/frontend-modern/src/components/Workloads/useGroupedTableWindowing.ts+++ b/frontend-modern/src/components/Workloads/useGroupedTableWindowing.ts@@ -10,6 +10,8 @@ export interface UseGroupedTableWindowingOptions {enabled?: () => boolean;/** Index to ensure is visible (selection/deep-link reveal) */revealIndex?: () => number | null;+ /** Resolve a row index from a virtual offset when grouped decorations add height. */+ rowIndexAtOffset?: (offset: number, rowHeight: number) => number;}export interface UseGroupedTableWindowingResult {@@ -92,7 +94,13 @@ export const useGroupedTableWindowing = (DEFAULT_OVERSCAN_ROWS,Math.max(0, normalizedWindowSize() - rowsInView),);- const firstVisibleRow = Math.floor(Math.max(0, scrollTop) / safeRowHeight);+ const resolvedFirstVisibleRow = options.rowIndexAtOffset?.(+ Math.max(0, scrollTop),+ safeRowHeight,+ );+ const firstVisibleRow = Number.isFinite(resolvedFirstVisibleRow)+ ? Math.max(0, Math.floor(resolvedFirstVisibleRow!))+ : Math.floor(Math.max(0, scrollTop) / safeRowHeight);setClampedStart(firstVisibleRow - overscan);};diff --git a/frontend-modern/src/components/Workloads/useWorkloadViewportSync.ts b/frontend-modern/src/components/Workloads/useWorkloadViewportSync.tsindex 73e5d0e946..83accb4397 100644--- a/frontend-modern/src/components/Workloads/useWorkloadViewportSync.ts+++ b/frontend-modern/src/components/Workloads/useWorkloadViewportSync.ts@@ -1,9 +1,10 @@-import { createEffect, onCleanup, type Accessor } from 'solid-js';+import { createEffect, createSignal, onCleanup, type Accessor } from 'solid-js';import type { UseGroupedTableWindowingResult } from './useGroupedTableWindowing';const SCROLLABLE_OVERFLOW_PATTERN = /(?:auto|scroll|overlay)/;const MIN_VERTICAL_SCROLL_RANGE_PX = 1;+const SCROLL_TO_TOP_VISIBILITY_THRESHOLD_PX = 640;const findScrollContainer = (element: HTMLElement): HTMLElement | null => {let parent = element.parentElement;@@ -26,53 +27,91 @@ const findScrollContainer = (element: HTMLElement): HTMLElement | null => {interface WorkloadsWorkloadViewportSyncOptions {filteredGuestCount: Accessor<number>;groupedWindowing: UseGroupedTableWindowingResult;- rowHeight: number;+ onRowGeometryChange?: (geometry: { groupHeaderHeight?: number; rowHeight?: number }) => void;+ rowHeight: Accessor<number>;tableBodyRef: Accessor<HTMLTableSectionElement | null>;}export function useWorkloadViewportSync(options: WorkloadsWorkloadViewportSyncOptions) {- const syncGuestWindowToViewport = () => {- if (!options.groupedWindowing.isWindowed() || typeof window === 'undefined') return;+ const [isScrollToTopVisible, setIsScrollToTopVisible] = createSignal(false);++ const syncGuestWindowToViewport = (measureRows = false) => {+ if (typeof window === 'undefined') return;const body = options.tableBodyRef();if (!body) return;+ if (measureRows) {+ const guestRowHeight = body+ .querySelector<HTMLTableRowElement>(':scope > tr.workload-row')+ ?.getBoundingClientRect().height;+ const groupHeaderHeight = body+ .querySelector<HTMLTableRowElement>(':scope > tr[data-summary-group-id]')+ ?.getBoundingClientRect().height;+ options.onRowGeometryChange?.({+ groupHeaderHeight:+ groupHeaderHeight && groupHeaderHeight > 0 ? groupHeaderHeight : undefined,+ rowHeight: guestRowHeight && guestRowHeight > 0 ? guestRowHeight : undefined,+ });+ }const rect = body.getBoundingClientRect();const scrollContainer = findScrollContainer(body);if (scrollContainer) {+ setIsScrollToTopVisible(scrollContainer.scrollTop > SCROLL_TO_TOP_VISIBILITY_THRESHOLD_PX);+ if (!options.groupedWindowing.isWindowed()) return;const containerRect = scrollContainer.getBoundingClientRect();const scrollTop = Math.max(0, containerRect.top - rect.top);options.groupedWindowing.onScroll(scrollTop,scrollContainer.clientHeight || window.innerHeight,- options.rowHeight,+ options.rowHeight(),);return;}+ setIsScrollToTopVisible(window.scrollY > SCROLL_TO_TOP_VISIBILITY_THRESHOLD_PX);+ if (!options.groupedWindowing.isWindowed()) return;options.groupedWindowing.onScroll(Math.max(0, -rect.top),window.innerHeight,- options.rowHeight,+ options.rowHeight(),);};createEffect(() => {if (typeof window === 'undefined') return;options.filteredGuestCount();- if (!options.groupedWindowing.isWindowed()) return;if (!options.tableBodyRef()) return;- const handleViewportChange = () => {+ const handleViewportScroll = () => {syncGuestWindowToViewport();};+ const handleViewportResize = () => {+ syncGuestWindowToViewport(true);+ };- handleViewportChange();+ handleViewportResize();const scrollContainer = findScrollContainer(options.tableBodyRef()!);const scrollTarget = scrollContainer ?? window;- scrollTarget.addEventListener('scroll', handleViewportChange, { passive: true });- window.addEventListener('resize', handleViewportChange);+ scrollTarget.addEventListener('scroll', handleViewportScroll, { passive: true });+ window.addEventListener('resize', handleViewportResize);onCleanup(() => {- scrollTarget.removeEventListener('scroll', handleViewportChange);- window.removeEventListener('resize', handleViewportChange);+ scrollTarget.removeEventListener('scroll', handleViewportScroll);+ window.removeEventListener('resize', handleViewportResize);});});++ const scrollToTop = () => {+ if (typeof window === 'undefined') return;+ const body = options.tableBodyRef();+ const scrollContainer = body ? findScrollContainer(body) : null;+ if (scrollContainer) {+ scrollContainer.scrollTo({ top: 0, behavior: 'smooth' });+ return;+ }+ window.scrollTo({ top: 0, behavior: 'smooth' });+ };++ return {+ isScrollToTopVisible,+ scrollToTop,+ } as const;}diff --git a/frontend-modern/src/components/Workloads/useWorkloadsDerivedState.ts b/frontend-modern/src/components/Workloads/useWorkloadsDerivedState.tsindex 4c3f902ec5..44952c5161 100644--- a/frontend-modern/src/components/Workloads/useWorkloadsDerivedState.ts+++ b/frontend-modern/src/components/Workloads/useWorkloadsDerivedState.ts@@ -1,4 +1,4 @@-import { createMemo, type Accessor } from 'solid-js';+import { createMemo, createSignal, type Accessor } from 'solid-js';import type { Alert, Node } from '@/types/api';import type { WorkloadGuest } from '@/types/workloads';@@ -17,7 +17,11 @@ import { useGroupedTableWindowing } from './useGroupedTableWindowing';type GroupingMode = 'grouped' | 'flat';-const WORKLOADS_TABLE_ESTIMATED_ROW_HEIGHT = 32;+const DESKTOP_WORKLOAD_ROW_HEIGHT = 32;+const DESKTOP_WORKLOAD_GROUP_HEADER_HEIGHT = 33;+const PHONE_WORKLOAD_ROW_HEIGHT = 37;+const PHONE_WORKLOAD_GROUP_HEADER_HEIGHT = 28;+const WORKLOADS_TABLE_DIVIDER_HEIGHT = 1;interface WorkloadsWorkloadDerivedStateOptions {activeAlerts: Accessor<Record<string, Alert>>;@@ -35,6 +39,13 @@ interface WorkloadsWorkloadDerivedStateOptions {export function useWorkloadsDerivedState(options: WorkloadsWorkloadDerivedStateOptions) {const filteredGuests = createMemo<WorkloadGuest[]>(() => options.filteredGuests() ?? []);+ const phoneRowGeometry = typeof window !== 'undefined' && window.innerWidth < 640;+ const [estimatedRowHeight, setEstimatedRowHeight] = createSignal(+ phoneRowGeometry ? PHONE_WORKLOAD_ROW_HEIGHT : DESKTOP_WORKLOAD_ROW_HEIGHT,+ );+ const [estimatedGroupHeaderHeight, setEstimatedGroupHeaderHeight] = createSignal(+ phoneRowGeometry ? PHONE_WORKLOAD_GROUP_HEADER_HEIGHT : DESKTOP_WORKLOAD_GROUP_HEADER_HEIGHT,+ );const nodeByInstance = createMemo(() => buildNodeByInstance(options.nodes()));const guestParentNodeMap = createMemo(() =>@@ -72,6 +83,65 @@ export function useWorkloadsDerivedState(options: WorkloadsWorkloadDerivedStateO});});+ const groupStartIndices = createMemo(() => {+ if (options.groupingMode() !== 'grouped') return [];+ const groups = groupedGuests();+ let guestIndex = 0;+ return sortedGroupKeys().map((groupKey) => {+ const start = guestIndex;+ guestIndex += (groups[groupKey] || []).length;+ return start;+ });+ });++ // Group headers are real rows in the virtual table. Account for every+ // header in either a spacer or the mounted window so scroll height cannot+ // grow and shrink as groups cross the window boundary.+ const countGroupStartsBefore = (guestIndex: number) => {+ const starts = groupStartIndices();+ let low = 0;+ let high = starts.length;+ while (low < high) {+ const middle = Math.floor((low + high) / 2);+ if (starts[middle] < guestIndex) low = middle + 1;+ else high = middle;+ }+ return low;+ };++ const countGroupStartsAtOrBefore = (guestIndex: number) => {+ const starts = groupStartIndices();+ let low = 0;+ let high = starts.length;+ while (low < high) {+ const middle = Math.floor((low + high) / 2);+ if (starts[middle] <= guestIndex) low = middle + 1;+ else high = middle;+ }+ return low;+ };++ const guestIndexAtVirtualOffset = (offset: number, rowHeight: number) => {+ const totalGuests = filteredGuests().length;+ if (totalGuests <= 1) return 0;++ let low = 0;+ let high = totalGuests - 1;+ let resolved = 0;+ while (low <= high) {+ const middle = Math.floor((low + high) / 2);+ const guestTop =+ middle * rowHeight + countGroupStartsAtOrBefore(middle) * estimatedGroupHeaderHeight();+ if (guestTop <= offset) {+ resolved = middle;+ low = middle + 1;+ } else {+ high = middle - 1;+ }+ }+ return resolved;+ };+const guestGlobalIndexById = createMemo(() => {const indexById = new Map<string, number>();const groups = groupedGuests();@@ -101,6 +171,7 @@ export function useWorkloadsDerivedState(options: WorkloadsWorkloadDerivedStateOconst groupedWindowing = useGroupedTableWindowing({totalRowCount: () => filteredGuests().length,revealIndex: revealGuestIndex,+ rowIndexAtOffset: guestIndexAtVirtualOffset,});const groupStartIndexByKey = createMemo(() => {@@ -143,22 +214,37 @@ export function useWorkloadsDerivedState(options: WorkloadsWorkloadDerivedStateOreturn keys.filter((groupKey) => (groups[groupKey] || []).length > 0);});- const topSpacerHeight = createMemo(() =>- groupedWindowing.isWindowed()- ? groupedWindowing.startIndex() * WORKLOADS_TABLE_ESTIMATED_ROW_HEIGHT- : 0,- );+ const topSpacerHeight = createMemo(() => {+ if (!groupedWindowing.isWindowed() || groupedWindowing.startIndex() <= 0) return 0;+ const virtualHeight =+ groupedWindowing.startIndex() * estimatedRowHeight() ++ countGroupStartsBefore(groupedWindowing.startIndex()) * estimatedGroupHeaderHeight();++ // The table's divide-y rule adds one border when a leading spacer is+ // mounted. Keep that border inside the virtual height instead of letting+ // the document grow by one pixel after the first scroll.+ return Math.max(0, virtualHeight - WORKLOADS_TABLE_DIVIDER_HEIGHT);+ });const bottomSpacerHeight = createMemo(() =>groupedWindowing.isWindowed()- ? Math.max(0, (filteredGuests().length - groupedWindowing.endIndex()) * 32)+ ? Math.max(+ 0,+ (filteredGuests().length - groupedWindowing.endIndex()) * estimatedRowHeight() ++ (groupStartIndices().length - countGroupStartsBefore(groupedWindowing.endIndex())) *+ estimatedGroupHeaderHeight(),+ ): 0,);- useWorkloadViewportSync({+ const workloadViewport = useWorkloadViewportSync({filteredGuestCount: () => filteredGuests().length,groupedWindowing,- rowHeight: WORKLOADS_TABLE_ESTIMATED_ROW_HEIGHT,+ onRowGeometryChange: (geometry) => {+ if (geometry.rowHeight) setEstimatedRowHeight(geometry.rowHeight);+ if (geometry.groupHeaderHeight) setEstimatedGroupHeaderHeight(geometry.groupHeaderHeight);+ },+ rowHeight: estimatedRowHeight,tableBodyRef: options.tableBodyRef,});@@ -173,8 +259,10 @@ export function useWorkloadsDerivedState(options: WorkloadsWorkloadDerivedStateOgroupedWindowing,guestParentNodeMap,inventoryStats,+ isScrollToTopVisible: workloadViewport.isScrollToTopVisible,nodeByInstance,topSpacerHeight,+ scrollToTop: workloadViewport.scrollToTop,totalStats,visibleGroupKeys,windowedGroupedGuests,diff --git a/frontend-modern/src/components/Workloads/useWorkloadsState.ts b/frontend-modern/src/components/Workloads/useWorkloadsState.tsindex 027bd22c61..084fb7c6be 100644--- a/frontend-modern/src/components/Workloads/useWorkloadsState.ts+++ b/frontend-modern/src/components/Workloads/useWorkloadsState.ts@@ -505,8 +505,10 @@ export function useWorkloadsState(props: WorkloadsSurfaceProps) {groupedWindowing,guestParentNodeMap,inventoryStats,+ isScrollToTopVisible,nodeByInstance,topSpacerHeight,+ scrollToTop,totalStats,visibleGroupKeys,windowedGroupedGuests,@@ -530,6 +532,7 @@ export function useWorkloadsState(props: WorkloadsSurfaceProps) {alertsEnabled,allGuests,inventoryStats,+ isScrollToTopVisible,activeSummaryWorkloadGroupScope,activeSummaryWorkloadId,clearPinnedSummaryScope,@@ -581,6 +584,7 @@ export function useWorkloadsState(props: WorkloadsSurfaceProps) {reconnect,reconnectSurface,search,+ scrollToTop,selectedCluster,selectedGuestId,selectedHostHint,