From 905180efb8318a95de8e045ffa62b1b151826858 Mon Sep 17 00:00:00 2001 From: "Steven (Goshbob)" Date: Tue, 16 Jun 2026 10:53:21 +1000 Subject: [PATCH] fix(portal): Clear button clears the server-side activity log The dashboard "Clear" button only emptied the browser DOM. On the next poll the client re-fetched the retained server-side entries, so the activity log immediately reappeared and the Clear never "stuck". - Add a `DELETE /api/log` route that calls `activity_log.clear()`. - Make `clearLog()` issue that DELETE before clearing the DOM / resetting the lastLogTs cursor. This mirrors the fix already running on the bench (the deployed portal), so the behaviour is confirmed: after Clear, the log empties and stays empty across subsequent polls. Co-Authored-By: Claude Opus 4.8 --- pi/portal.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pi/portal.py b/pi/portal.py index b108cbd..beeded8 100644 --- a/pi/portal.py +++ b/pi/portal.py @@ -1733,6 +1733,12 @@ def do_DELETE(self): if path == "/api/udplog": _udp_log.clear() self._send_json({"ok": True}) + elif path == "/api/log": + # The dashboard "Clear" button only emptied the browser DOM; the next + # poll re-fetched the retained entries so the activity log reappeared. + # Clear the server-side log so the Clear actually sticks. + activity_log.clear() + self._send_json({"ok": True}) elif path == "/api/firmware/delete": self._handle_firmware_delete() else: @@ -3616,7 +3622,10 @@ def _serve_ui(self): setTimeout(() => { btn.disabled = false; btn.textContent = 'Enter Captive Portal'; }, 30000); } -function clearLog() { +async function clearLog() { + // Clear the server-side log first, else the next poll re-fetches the retained + // entries (resetting lastLogTs alone pulls the whole log back). + try { await fetch('/api/log', { method: 'DELETE' }); } catch (e) { /* ignore */ } document.getElementById('log-entries').innerHTML = ''; lastLogTs = ''; }