From a259587bf992f7365bfc80dac93ec12d6835b708 Mon Sep 17 00:00:00 2001 From: d00f <8052722+DrDoof@users.noreply.github.com> Date: Thu, 13 Aug 2026 22:42:32 +0200 Subject: [PATCH] system: do not let a failed console request look like an empty answer fetch() does not throw on 4xx, so a request that came back 401 after the session had timed out reached the same line as a successful one: the window showed the prompt and nothing under it, and the input was cleared as if the command had run. The session lasts 200 seconds, so leaving the tab open is enough to hit it. A 401 now goes to the login page instead. The transcript also gets a trailing newline when the answer lacks one, so the next prompt does not run into the last line of output, and it is capped so a long session does not keep growing the node. --- html/system.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/html/system.js b/html/system.js index 0160b8b2..c52acd03 100644 --- a/html/system.js +++ b/html/system.js @@ -43,7 +43,16 @@ async function cmdSub() { method: 'POST', body: cmd }); - out.textContent += "> " + cmd + "\n" + await response.text(); + if (response.status == 401) { + window.location.href = 'login.html'; + return; + } + let text = await response.text(); + if (text != "" && !text.endsWith("\n")) + text += "\n"; + if (out.textContent.length > 20000) + out.textContent = out.textContent.slice(-16000); + out.textContent += "> " + cmd + "\n" + text; out.scrollTop = out.scrollHeight; input.value = ""; } catch(err) {