Skip to content

fix(portal): Clear button clears the server-side activity log#11

Open
sthomas69 wants to merge 1 commit into
SensorsIot:mainfrom
sthomas69:fix/activity-log-clear
Open

fix(portal): Clear button clears the server-side activity log#11
sthomas69 wants to merge 1 commit into
SensorsIot:mainfrom
sthomas69:fix/activity-log-clear

Conversation

@sthomas69

Copy link
Copy Markdown

Problem

The Activity Log 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 — the Clear never "stuck".

Fix

  • Add a DELETE /api/log route that calls activity_log.clear().
  • Make the front-end clearLog() issue that DELETE before clearing the DOM and resetting the lastLogTs cursor.

Two small hunks in pi/portal.py; python -m py_compile pi/portal.py is clean.

Verification

This mirrors the fix already running on my bench portal: after clicking Clear, the log empties and stays empty across subsequent polls.

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 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 16, 2026 00:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR makes the dashboard “Clear” action persist by clearing the server-side activity log, preventing the next polling cycle from re-hydrating previously retained log entries.

Changes:

  • Adds a DELETE /api/log endpoint that clears the server-side activity_log.
  • Updates the UI clearLog() handler to call the new endpoint before clearing the DOM/resetting the client-side cursor.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pi/portal.py
Comment on lines +1736 to +1741
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})
Comment thread pi/portal.py
Comment on lines +3625 to 3631
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 = '';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants