From f1b0f0eab2dcaf380c36a6b6b6bfad11830da182 Mon Sep 17 00:00:00 2001 From: "alexei.dolgolyov" Date: Sat, 16 May 2026 12:28:57 +0300 Subject: [PATCH] fix(ui): repaint transport-bar uptime as soon as /health responds The inline transport-uptime ticker only repainted on its 1 s setInterval, so the field could sit on - for up to ~1 s after page load (and much longer if init's first /health response landed between ticks - the next seed then had to wait for the 10 s connection-monitor poll). Dispatch a serverUptimeChanged DOM event when window.__serverUptime is seeded and let the inline IIFE re-render on receipt, so the value appears as soon as the response arrives. --- server/src/ledgrab/static/js/core/api.ts | 7 +++++++ server/src/ledgrab/templates/index.html | 3 +++ 2 files changed, 10 insertions(+) diff --git a/server/src/ledgrab/static/js/core/api.ts b/server/src/ledgrab/static/js/core/api.ts index f186ec1..02a25fe 100644 --- a/server/src/ledgrab/static/js/core/api.ts +++ b/server/src/ledgrab/static/js/core/api.ts @@ -344,6 +344,13 @@ export async function loadServerInfo() { uptimeSec: data.uptime_seconds, recordedAtPerf: performance.now(), }; + // Wake the inline transport-uptime ticker immediately instead of + // waiting up to a full second for its setInterval tick. Without + // this nudge the field can stay on "—" for ~1 s after page load + // (and up to 10 s if init's first /health response arrives just + // after a tick and the user has to wait for the next connection- + // monitor poll to seed it). + document.dispatchEvent(new CustomEvent('serverUptimeChanged')); } // Demo mode detection diff --git a/server/src/ledgrab/templates/index.html b/server/src/ledgrab/templates/index.html index 63a6821..d968bd6 100644 --- a/server/src/ledgrab/templates/index.html +++ b/server/src/ledgrab/templates/index.html @@ -570,6 +570,9 @@ } render(); setInterval(render, 1000); + // Repaint as soon as api.ts seeds window.__serverUptime, so the + // field doesn't have to wait up to a second for the next tick. + document.addEventListener('serverUptimeChanged', render); })(); // Transport-bar poll-interval control — cycles through 1/2/5/10s