From c17ce052c1a51ac498cffe791fc6d62fed7cf308 Mon Sep 17 00:00:00 2001 From: "khalid@traclabs.com" Date: Thu, 23 Apr 2026 08:44:30 -0500 Subject: [PATCH] Flip between messages for the update. --- src/layouts/BaseLayout.astro | 39 +++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index ab60a3b..5b19661 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -177,6 +177,33 @@ const wsUrl = (process.env.PUBLIC_LIVE_RELOAD_WS_URL ?? import.meta.env.PUBLIC_L if (typeof text === 'string' && text.length > 0) bannerTextEl.textContent = text; } + const updatingMessages = [ + 'Updating website', + 'Reading website sections', + 'Found section to update', + 'Updating found section', + ]; + let updatingMessageIdx = 0; + let updatingTimer = null; + + function stopUpdatingRotation() { + if (updatingTimer) { + clearInterval(updatingTimer); + updatingTimer = null; + } + updatingMessageIdx = 0; + } + + function startUpdatingRotation() { + if (updatingTimer) return; + updatingMessageIdx = 0; + setBanner(true, updatingMessages[updatingMessageIdx] || 'Updating website'); + updatingTimer = setInterval(() => { + updatingMessageIdx = (updatingMessageIdx + 1) % updatingMessages.length; + setBanner(true, updatingMessages[updatingMessageIdx] || 'Updating website'); + }, 30_000); + } + function connect() { const ws = new WebSocket(url); ws.onmessage = (ev) => { @@ -191,9 +218,15 @@ const wsUrl = (process.env.PUBLIC_LIVE_RELOAD_WS_URL ?? import.meta.env.PUBLIC_L if (msg.type === 'update_status') { if (msg.phase === 'request_received') setBanner(true, 'Processing update request'); - else if (msg.phase === 'intent_processing') setBanner(true, 'Processing update request'); - else if (msg.phase === 'updating') setBanner(true, 'Updating website'); - else if (msg.phase === 'update_done') setBanner(false); + else if (msg.phase === 'intent_processing') { + stopUpdatingRotation(); + setBanner(true, 'Processing update request'); + } else if (msg.phase === 'updating') { + startUpdatingRotation(); + } else if (msg.phase === 'update_done') { + stopUpdatingRotation(); + setBanner(false); + } } } catch { // ignore