From 9f6b34b55a6e4e64b5b992fb0c7f027c48352149 Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Mon, 23 Nov 2026 14:24:11 -0500 Subject: [PATCH] Live updates keep the rows brought in with Load More (#17) A live event reloaded only the first page of the Executions list, so rows brought in with Load More vanished whenever Gandalf or anyone else ran something. Live refreshes now fetch as many rows as are shown (up to the server's 1000); search and filters still start from the first page. The rest of #17 was already fixed: reloads are throttled (#10), each tab keeps its own state, and selections survive a refresh. The new UI test fails without this change (100 rows drop to 50). Co-Authored-By: Claude Opus 5.5 --- public/assets/pages/executions.js | 15 +++++++++++---- tests/ui/quick-command.ui.js | 21 +++++++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/public/assets/pages/executions.js b/public/assets/pages/executions.js index 3ad229e..3a6f664 100644 --- a/public/assets/pages/executions.js +++ b/public/assets/pages/executions.js @@ -71,10 +71,13 @@ /* ------------------------------------------------------------------ Loading ------------------------------------------------------------------ */ - async function loadView(view, append) { + // keepLoaded: a live refresh fetches as many rows as are already shown, so + // rows brought in with Load More don't vanish when an event arrives (#17). + async function loadView(view, append, keepLoaded) { const st = state[view]; const offset = append ? st.offset : 0; - const params = new URLSearchParams({ limit: String(LIMIT), offset: String(offset) }); + const limit = keepLoaded ? Math.min(Math.max(LIMIT, st.rows.length), 1000) : LIMIT; + const params = new URLSearchParams({ limit: String(limit), offset: String(offset) }); if (view === 'manual') params.set('hide_internal', 'true'); if (view === 'automated') params.set('only_internal', 'true'); // server-side (#4) const term = searchTerm(); @@ -102,8 +105,12 @@ await loadView(state.view, false); render(); } - // Live events trigger this; coalesce bursts into at most one reload per 2 s (#10). - const reloadCurrent = Pulse.util.throttle(reloadNow, 2000); + // Live events trigger this; coalesce bursts into at most one reload per 2 s (#10), + // keeping however many rows are loaded (#17). + const reloadCurrent = Pulse.util.throttle(async () => { + await loadView(state.view, false, true); + render(); + }, 2000); // Typing in the search box: search on the server once typing pauses (#16). let searchTimer = null; diff --git a/tests/ui/quick-command.ui.js b/tests/ui/quick-command.ui.js index 4d134ce..88174cd 100644 --- a/tests/ui/quick-command.ui.js +++ b/tests/ui/quick-command.ui.js @@ -108,3 +108,24 @@ test('Quick Command remembers the mode and workers after a reload (#31)', async await expect(page.locator('#qc-mode-single')).toBeChecked(); await expect(page.locator('#qc-worker option:checked')).toContainText('node-03'); }); + +test('a live update keeps the rows brought in with Load More (#17)', async ({ page, request }) => { + const workers = await (await request.get('/api/workers')).json(); + const id = workers.find(w => w.name === 'node-01').id; + const send = () => request.post(`/api/workers/${id}/command`, { data: { command: 'true' } }); + for (let i = 0; i < 60; i++) await send(); + + await page.goto('/executions'); + const rows = page.locator('#ex-list-manual .ex-row'); + await expect(rows).toHaveCount(50); + await page.getByRole('button', { name: 'Load More Executions' }).click(); + await expect.poll(() => rows.count()).toBeGreaterThan(50); + const shown = await rows.count(); + + // A live event: the list refreshes with the new run on top, and still shows + // as many rows as before rather than dropping back to the first 50. + const marker = `live-${Date.now().toString(36)}`; + await request.post(`/api/workers/${id}/command`, { data: { command: `echo ${marker}` } }); + await expect(rows.first()).toContainText(marker, { timeout: 10_000 }); + await expect(rows).toHaveCount(shown); +}); -- 2.47.3