Repository navigation
Make the Activity Log "Clear" button stick - #36
Open
the-real-orca wants to merge 1 commit into
Open
the-real-orca wants to merge 1 commit into
the-real-orca wants to merge 1 commit into
Conversation
`clearLog()` emptied the panel and then reset `lastLogTs` to ''. That variable is the delta-poll cursor, and `/api/log` without `?since=` returns the whole server-side ring buffer — so the 1.5 s poll put all 200 entries straight back. The button cleared the log for about a second. The cursor now doubles as a watermark. Clear parks it on the newest rendered entry and persists that timestamp in `localStorage` (`wt.log.hideBefore`); the page initialises the cursor from there, so the filtering still happens server-side via `?since=` and the log stays empty across a reload. A new "Show History" button drops the watermark and redisplays everything the bench still holds. Where `localStorage` is unavailable the hide holds for the current page load, which still beats not hiding at all. Deliberately not a server-side wipe. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Make the Activity Log "Clear" button stick
Base:
SensorsIot/Embedded-AI-Harnessmain(b7bc87e) · Head:fix/log-clearDiff: 2 files, +40 / −5 · one commit
Scope: UI only — no new endpoint, no change to
/api/logor the server-side bufferWhy
Clicking Clear under the Activity Log emptied the panel for about a second, then the
next poll put every entry straight back. On a bench with a flapping USB device the button
looked broken, because it was.
lastLogTsis the delta-poll cursor, and an empty cursor means "send everything":clearLog()reset exactly that cursor, sosetInterval(fetchLog, 1500)re-fetched theunfiltered deque — up to 200 entries — one and a half seconds later. A page reload had the
same effect for the same reason: the panel's contents are server state, and the client kept
no record of what the operator had dismissed.
What changed
The cursor now doubles as a watermark, so the filtering stays where it already was —
server-side, via
?since=.portal.py:5471–5486LOG_WATERMARK_KEY+loadLogWatermark()/saveLogWatermark(), andlastLogTsinitialised from storage rather than''portal.py:5536clearLog()parks the cursor on the newest rendered entry and persists it, instead of resetting itportal.py:5544showLogHistory()— new, drops the watermark and redisplays everything the bench still holdsportal.py:5293–5296.log-actions, plustitle=on both spelling out that this is a display state and the bench keeps the entriesdocs/Harness-FSD.mdTwo details worth calling out:
localStorageis wrapped intry/catch. Private browsing and blocked site data makethe accessor itself throw. The clear then holds for the current page load only, which still
beats not clearing.
clearLog()fetches first if the cursor is still empty. A click landing before thefirst poll would otherwise persist an empty watermark, and the bug would be back for that
one case.
Why not a server-side clear
DELETE /api/logwould have been three lines and is the reading of "Clear" a first-time userprobably expects. I did not take it, because the deque is shared:
TestbenchDriver.get_log()reads it, the MCP surface exposes it as
testbench_log, and a second browser tab has its ownidea of what it has already seen. A UI button that wipes the buffer deletes another client's
evidence, possibly mid-run — and the panel is at its most useful exactly when something has
just gone wrong.
Display state was the smaller claim, and it also fixes the reload case, which a server-side
wipe would not have addressed on its own. If you would rather have the bench-wide version, or
both, say so and I will follow up.
Verification
ruff check pi/portal.pyclean ·py_compileOK_UI_HTMLand run throughnode --check— clean/api/logreproducing_handle_get_log's string comparison: initial load, Clear followedby repeated polls, a new event arriving after a Clear, reload with the watermark in place,
Show History, and a Clear racing the first poll. All pass.
mainand checked at the panel: Clear holds through the 1.5 spoll, a fresh USB event shows up on its own, F5 keeps the log empty, Show History brings the
full buffer back with no duplicates.
No test was added to
pytest/testbench_test.py. The change is entirely client-side, andthe suite is HTTP-against-the-portal with no JS or DOM harness.