From 36570631cf8f4d98cf215aa6f3e1c246eb793079 Mon Sep 17 00:00:00 2001 From: Ruslan Date: Mon, 20 Jul 2026 15:50:54 +0000 Subject: [PATCH] universal-runtime: fix overlay hiding error messages on reconnect --- universal-runtime/entrypoint.sh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/universal-runtime/entrypoint.sh b/universal-runtime/entrypoint.sh index 1f2c0b4..d911fb2 100755 --- a/universal-runtime/entrypoint.sh +++ b/universal-runtime/entrypoint.sh @@ -86,25 +86,22 @@ cat > /opt/portal/index.html <<'HTML' const MAX_RECONNECT_ATTEMPTS = 12; const RECONNECT_DELAYS_MS = [1000, 2000, 3000, 5000, 8000]; let manualDisconnect = false; - - function showOverlay() { - coEl.style.opacity = '1'; - coEl.style.display = 'flex'; - coEl.classList.remove('hidden'); - statusEl.style.display = 'none'; - } + let overlayHidden = false; function hideOverlay() { + if (overlayHidden) return; + overlayHidden = true; coEl.classList.add('hidden'); setTimeout(() => { coEl.style.display = 'none'; }, 520); } function showError(text) { - hideOverlay(); statusEl.textContent = text; statusEl.style.display = 'block'; } + function hideError() { statusEl.style.display = 'none'; } + function clearConnectTimer() { if (connectTimer) { clearTimeout(connectTimer); connectTimer = null; } } @@ -129,6 +126,7 @@ cat > /opt/portal/index.html <<'HTML' clearConnectTimer(); clearReconnectTimer(); if (reconnectAttempts >= MAX_RECONNECT_ATTEMPTS) { + hideOverlay(); showError('Соединение потеряно. Переподключение не удалось. Откройте сервис заново.'); return; } @@ -137,6 +135,7 @@ cat > /opt/portal/index.html <<'HTML' showError(\`\${reasonText} Повтор \${nextAttempt}/\${MAX_RECONNECT_ATTEMPTS} через \${Math.ceil(delayMs/1000)} сек.\`); reconnectTimer = setTimeout(() => { reconnectAttempts = nextAttempt; + hideError(); connectRfb(); }, delayMs); } @@ -153,6 +152,7 @@ cat > /opt/portal/index.html <<'HTML' clearConnectTimer(); clearReconnectTimer(); hideOverlay(); + hideError(); }); rfb.addEventListener('disconnect', () => { connected = false; @@ -164,7 +164,6 @@ cat > /opt/portal/index.html <<'HTML' function connectRfb() { if (manualDisconnect) return; connected = false; - showOverlay(); attachRfb(); scheduleConnectTimeout(); }