From e33f4b570a4854fabff0ddcc41d8d4d41ff58158 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 13 Apr 2026 23:38:45 +0000 Subject: [PATCH 1/2] Initial plan From a6dc3fd6471f9f64000121c4357591d34cb629d6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 13 Apr 2026 23:41:33 +0000 Subject: [PATCH 2/2] Fix reboot button and overlay bugs on local machine and LAN Agent-Logs-Url: https://github.com/naturallaw777/staging_alpha/sessions/c8d3bf30-c3ea-40e7-8da0-b4baa28eaf36 Co-authored-by: naturallaw777 <99053422+naturallaw777@users.noreply.github.com> --- app/sovran_systemsos_web/static/js/constants.js | 3 +++ app/sovran_systemsos_web/static/js/security.js | 10 +++++----- app/sovran_systemsos_web/static/js/update.js | 16 +++++++++------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/app/sovran_systemsos_web/static/js/constants.js b/app/sovran_systemsos_web/static/js/constants.js index a13e52a..c1a49c3 100644 --- a/app/sovran_systemsos_web/static/js/constants.js +++ b/app/sovran_systemsos_web/static/js/constants.js @@ -6,6 +6,9 @@ const POLL_INTERVAL_SERVICES = 5000; const POLL_INTERVAL_UPDATES = 1800000; const UPDATE_POLL_INTERVAL = 2000; const REBOOT_CHECK_INTERVAL = 5000; +const REBOOT_FETCH_TIMEOUT = 12000; +const REBOOT_REQUEST_TIMEOUT = 4000; +const REBOOT_INITIAL_DELAY = 25000; const SUPPORT_TIMER_INTERVAL = 1000; const CATEGORY_ORDER = [ diff --git a/app/sovran_systemsos_web/static/js/security.js b/app/sovran_systemsos_web/static/js/security.js index 7f1394f..3a92efd 100644 --- a/app/sovran_systemsos_web/static/js/security.js +++ b/app/sovran_systemsos_web/static/js/security.js @@ -157,14 +157,14 @@ function openSecurityModal() { } }, 1000); - rebootBtn.addEventListener("click", async function() { + rebootBtn.addEventListener("click", function() { rebootBtn.disabled = true; rebootBtn.textContent = "Rebooting\u2026"; - try { - await apiFetch("/api/reboot", { method: "POST" }); - } catch (_) {} if ($rebootOverlay) $rebootOverlay.classList.add("visible"); - setTimeout(waitForServerReboot, REBOOT_CHECK_INTERVAL); + setTimeout(waitForServerReboot, REBOOT_INITIAL_DELAY); + var rebootCtrl = new AbortController(); + setTimeout(function() { rebootCtrl.abort(); }, REBOOT_REQUEST_TIMEOUT); + fetch("/api/reboot", { method: "POST", signal: rebootCtrl.signal }).catch(function() {}); }, { once: true }); } } catch (err) { diff --git a/app/sovran_systemsos_web/static/js/update.js b/app/sovran_systemsos_web/static/js/update.js index ac2e2b9..a109612 100644 --- a/app/sovran_systemsos_web/static/js/update.js +++ b/app/sovran_systemsos_web/static/js/update.js @@ -174,26 +174,28 @@ function doReboot() { if ($rebootOverlay) $rebootOverlay.classList.add("visible"); _rebootStartTime = Date.now(); _serverWentDown = false; - apiFetch("/api/reboot", { method: "POST" }).catch(function() {}); - // Wait 15 seconds before the first check — give the system time to actually shut down - setTimeout(waitForServerReboot, 15000); + var rebootCtrl = new AbortController(); + setTimeout(function() { rebootCtrl.abort(); }, REBOOT_REQUEST_TIMEOUT); + fetch("/api/reboot", { method: "POST", signal: rebootCtrl.signal }).catch(function() {}); + // Wait before the first check — NixOS shutdown after an update can take 20-40s + setTimeout(waitForServerReboot, REBOOT_INITIAL_DELAY); } function waitForServerReboot() { var controller = new AbortController(); - var timeoutId = setTimeout(function() { controller.abort(); }, REBOOT_CHECK_INTERVAL); + var timeoutId = setTimeout(function() { controller.abort(); }, REBOOT_FETCH_TIMEOUT); - fetch("/api/config", { cache: "no-store", signal: controller.signal }) + fetch("/api/config", { cache: "no-store", signal: controller.signal, headers: { "Connection": "close" } }) .then(function(res) { clearTimeout(timeoutId); if (res.ok && _serverWentDown) { // Server is back after having been down — reboot is complete window.location.reload(); - } else if (res.ok && !_serverWentDown && (Date.now() - _rebootStartTime) < 30000) { + } else if (res.ok && !_serverWentDown && (Date.now() - _rebootStartTime) < 90000) { // Server still responding but hasn't gone down yet — keep waiting setTimeout(waitForServerReboot, REBOOT_CHECK_INTERVAL); } else if (res.ok) { - // Been over 30 seconds and server is responding — just reload + // Been over 90 seconds and server is responding — just reload window.location.reload(); } else { _serverWentDown = true;