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
Gate realtime tick deferral on all operator input, not just scroll
rcourtman7d34e27b301e
diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.mdindex 968d6d68e3..25f88230fb 100644--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md@@ -261,9 +261,12 @@ consumes realtime projection work. Re-entering an inactive tab must catch upfrom the shared canonical cache rather than replaying every missed delta.Hidden tabs continue advancing the raw baseline without reconciling the estate;all hidden changes are materialized once when the document becomes visible.-Active operator scrolling gates realtime resource work harder still: a tick-arriving mid-gesture queues its delta unapplied, in arrival order, because on-a large estate even the baseline patch walks the whole resource array. The+Active operator input gates realtime resource work harder still — scrolling,+wheel, pointer presses, and typing all count, while bare pointer movement+deliberately does not, so a resting hand cannot starve data freshness. A tick+arriving mid-interaction queues its delta unapplied, in arrival order,+because on a large estate even the baseline patch walks the whole resource+array. Thereporting projection and the realtime tick token (`lastUpdate`) deferlatest-wins alongside — the token is what every downstream realtime consumerkeys on, so holding it keeps unified projections and workload remaps fullydiff --git a/frontend-modern/browser-verification.json b/frontend-modern/browser-verification.jsonindex 0e58006515..554ee5653f 100644--- a/frontend-modern/browser-verification.json+++ b/frontend-modern/browser-verification.json@@ -1,13 +1,13 @@{"version": 1,- "base_sha": "c154fa7aed228ea03d37e35833770940c1858a77",- "verified_at": "2026-08-26T16:18:38Z",+ "base_sha": "99afae02b1af9274697b958d50891ed5d86d5208",+ "verified_at": "2026-08-26T16:33:39Z","result": "passed","changed_paths": ["frontend-modern/src/stores/websocket.ts"],"content_sha256": {- "frontend-modern/src/stores/websocket.ts": "0c28ea223ca92422fe2f64bf8b0db336c29381c00a8300c3993c8d38f8903b46"+ "frontend-modern/src/stores/websocket.ts": "1bcd852509d823c4520a7d55f283fe27955c6881ea175e86516937e79be93d3f"},"routes": ["/proxmox/overview"@@ -23,16 +23,15 @@}],"states": [- "large mock estate: 50 nodes and 929 guests with realtime delta ticks arriving every few seconds over the websocket",- "continuous operator scrolling spanning multiple realtime ticks",- "scroll idle immediately after a gesture with deferred ticks pending",- "narrow-viewport mobile layout scrolling across a realtime tick"+ "large mock estate: 50 nodes and 929 guests with realtime delta ticks arriving every few seconds",+ "sustained simulated typing (keydown burst every 120ms) spanning multiple realtime ticks",+ "input idle immediately after a typing burst with deferred ticks pending",+ "narrow-viewport mobile layout during a typing burst across a realtime tick"],"interactions": [- "long-animation-frame instrumentation across 16-20s continuous scrolls: zero websocket onmessage long frames during scrolling (previously 200-560ms per tick), one coalesced flush landing 300-450ms after scroll idle via the deferral timer",- "store-internal probes confirming mid-scroll ticks queue their resource deltas, defer the reporting projection and lastUpdate token latest-wins, and drain fully at idle",- "per-message section timing showing mid-scroll tick cost at or below ~1ms with alert application still live",- "Last refresh footer observed advancing across scrolls on desktop and narrow viewports, confirming deferred ticks still land and data stays live",+ "long-animation-frame instrumentation across a 12s typing burst on desktop: zero long frames of any kind during input, one coalesced deferral flush (426ms) landing ~520ms after the last keystroke",+ "pointerdown dispatched mid-window extends the input-active gate (unit-tested), keydown and scroll both verified live as gate sources",+ "Last refresh footer observed advancing across typing bursts on desktop and narrow viewports, confirming deferred ticks still land and data stays live","zero console errors across desktop and narrow passes"]}diff --git a/frontend-modern/src/stores/__tests__/websocket-unified.test.ts b/frontend-modern/src/stores/__tests__/websocket-unified.test.tsindex e02693bd0a..94a73d7a44 100644--- a/frontend-modern/src/stores/__tests__/websocket-unified.test.ts+++ b/frontend-modern/src/stores/__tests__/websocket-unified.test.ts@@ -827,6 +827,53 @@ describe('websocket store unified resource contract', () => {}});+ it('defers resource deltas while the operator types and flushes at input idle', async () => {+ const { store, dispose } = await createStoreHarness();+ try {+ await waitForOpenTick();+ emitMessage({+ type: 'initialState',+ data: {+ resources: [+ {+ id: 'vm-1',+ type: 'vm',+ name: 'vm-1',+ status: 'running',+ cpu: { current: 10 },+ },+ ],+ lastUpdate: 100,+ activeAlerts: [],+ recentlyResolved: [],+ },+ });++ // A tick landing mid-keystroke must not delay the input's response.+ window.dispatchEvent(new Event('keydown'));+ emitMessage({+ type: 'rawData',+ data: {+ lastUpdate: 200,+ resourceDelta: { upserts: [{ id: 'vm-1', cpu: { current: 20 } }] },+ },+ });+ expect(store.state.resources[0]?.cpu?.current).toBe(10);++ // A pointer press extends the same input-active window.+ vi.advanceTimersByTime(200);+ window.dispatchEvent(new Event('pointerdown'));+ vi.advanceTimersByTime(200);+ expect(store.state.resources[0]?.cpu?.current).toBe(10);++ vi.advanceTimersByTime(600);+ expect(store.state.resources[0]?.cpu?.current).toBe(20);+ expect(store.state.lastUpdate).toBe(200);+ } finally {+ dispose();+ }+ });+it('holds hidden-tab deferrals through an active scroll and lands them at idle', async () => {const visibility = vi.spyOn(document, 'visibilityState', 'get');visibility.mockReturnValue('visible');diff --git a/frontend-modern/src/stores/websocket.ts b/frontend-modern/src/stores/websocket.tsindex db17d7dd5d..778224edf2 100644--- a/frontend-modern/src/stores/websocket.ts+++ b/frontend-modern/src/stores/websocket.ts@@ -424,15 +424,17 @@ export function createWebSocketStore(url: string) {// Per-key change shapes for deferred ids, unioned across the hidden ticks so// the resume merge can still take the fast path for metrics-only rows.const deferredResourceKeys = new Map<string, readonly string[] | null>();- // Resource ticks defer while the operator is actively scrolling, not just- // while the tab is hidden: on a large estate even the baseline patch walks- // the whole resource array, so a mid-gesture tick blocks the main thread for- // hundreds of milliseconds and hitches input. Scroll-gated ticks queue- // unapplied in arrival order and land at scroll idle, when nothing is- // visually moving. Hidden tabs keep the in-place baseline advance instead:- // a tab can stay hidden for hours, and the queue must stay bounded by one- // gesture's length.- const OPERATOR_SCROLL_ACTIVE_WINDOW_MS = 250;+ // Resource ticks defer while operator input is active (scrolling, wheel,+ // pointer presses, typing), not just while the tab is hidden: on a large+ // estate even the baseline patch walks the whole resource array, so a tick+ // landing mid-interaction blocks the main thread for hundreds of+ // milliseconds and delays the response to that input. Input-gated ticks+ // queue unapplied in arrival order and land at input idle, when nothing is+ // reacting to the operator. Bare pointer movement deliberately does not+ // gate: a resting hand on the mouse must not starve data freshness. Hidden+ // tabs keep the in-place baseline advance instead: a tab can stay hidden+ // for hours, and the queue must stay bounded by one interaction burst.+ const OPERATOR_INPUT_ACTIVE_WINDOW_MS = 250;const DEFERRED_FLUSH_RECHECK_MS = 300;const deferredResourceDeltaQueue: { upserts?: unknown; removed?: unknown; order?: unknown }[] =[];@@ -442,9 +444,9 @@ export function createWebSocketStore(url: string) {let deferredConnectedInfrastructure: ConnectedInfrastructureItem[] | null = null;// lastUpdate is the realtime tick token every downstream consumer keys on// (unified resource projections, workload remaps). It defers with the rest- // so a mid-scroll tick triggers no derived recomputation at all.+ // so a mid-interaction tick triggers no derived recomputation at all.let deferredLastUpdate: number | null = null;- let lastOperatorScrollAt = 0;+ let lastOperatorInputAt = 0;let deferredFlushTimer = 0;// Latest capabilityCatalog from the state payload. Broadcast resources carry// capabilitiesRef instead of inline capability blobs; ingestion expands the@@ -679,8 +681,8 @@ export function createWebSocketStore(url: string) {syncContainerCommands(nextResources, changedResourceIds);};- const isOperatorScrollActive = () =>- Date.now() - lastOperatorScrollAt < OPERATOR_SCROLL_ACTIVE_WINDOW_MS;+ const isOperatorInputActive = () =>+ Date.now() - lastOperatorInputAt < OPERATOR_INPUT_ACTIVE_WINDOW_MS;// Deltas queued during an active scroll apply strictly in arrival order.// Draining advances the raw baseline and unions the change shapes into the@@ -757,7 +759,7 @@ export function createWebSocketStore(url: string) {return;}if (typeof document !== 'undefined' && document.visibilityState === 'hidden') return;- if (!isOperatorScrollActive()) {+ if (!isOperatorInputActive()) {flushDeferredResources();return;}@@ -773,9 +775,10 @@ export function createWebSocketStore(url: string) {scheduleDeferredResourceFlush();};- const handleOperatorScroll = () => {- lastOperatorScrollAt = Date.now();+ const handleOperatorInput = () => {+ lastOperatorInputAt = Date.now();};+ const OPERATOR_INPUT_EVENTS = ['scroll', 'wheel', 'pointerdown', 'keydown'] as const;if (typeof document !== 'undefined') {document.addEventListener('visibilitychange', handleResourceVisibilityChange, {@@ -785,8 +788,11 @@ export function createWebSocketStore(url: string) {if (typeof window !== 'undefined') {// Capture phase: scroll events do not bubble, so a window-level capture// listener is the only way to observe every scroller (app shell, drawers)- // without adding per-surface listeners.- window.addEventListener('scroll', handleOperatorScroll, { capture: true, passive: true });+ // without adding per-surface listeners; the other input events ride the+ // same registration.+ for (const eventName of OPERATOR_INPUT_EVENTS) {+ window.addEventListener(eventName, handleOperatorInput, { capture: true, passive: true });+ }}const beginConnection = () => {@@ -933,7 +939,7 @@ export function createWebSocketStore(url: string) {if (typeof document !== 'undefined' &&document.visibilityState !== 'hidden' &&- isOperatorScrollActive()+ isOperatorInputActive()) {// Latest-wins: a newer payload simply replaces the pending one.deferredConnectedInfrastructure = connectedInfrastructure;@@ -1005,7 +1011,7 @@ export function createWebSocketStore(url: string) {if (typeof document !== 'undefined' &&document.visibilityState !== 'hidden' &&- (isOperatorScrollActive() || deferredResourceDeltaQueue.length > 0)+ (isOperatorInputActive() || deferredResourceDeltaQueue.length > 0)) {// Mid-gesture ticks queue unapplied so they cost nothing// until scroll idle. A non-empty queue keeps queueing even@@ -1118,7 +1124,7 @@ export function createWebSocketStore(url: string) {if (typeof document !== 'undefined' &&document.visibilityState !== 'hidden' &&- isOperatorScrollActive()+ isOperatorInputActive()) {deferredLastUpdate = nextLastUpdate;scheduleDeferredResourceFlush();@@ -1466,7 +1472,9 @@ export function createWebSocketStore(url: string) {pendingAckTimeouts.clear();if (typeof window !== 'undefined') {window.removeEventListener(ALERTS_DETECTION_EVENT, handleAlertsDetectionEvent);- window.removeEventListener('scroll', handleOperatorScroll, { capture: true });+ for (const eventName of OPERATOR_INPUT_EVENTS) {+ window.removeEventListener(eventName, handleOperatorInput, { capture: true });+ }}if (typeof document !== 'undefined') {document.removeEventListener('visibilitychange', handleResourceVisibilityChange);