mesh,web: add central event log for GenericEvent history - #451
Merged
Conversation
Records GenericEvent broadcasts (buzzer presses, resets, ...) in receipt order in a fixed-size RAM ring buffer, with a read endpoint and live WebSocket push for a web UI viewer. #436 (shared ApiRequest/ApiResponse dispatch table for serial reachability) is still an open, unmerged PR, so GET /api/events is registered directly against AsyncWebServerRequest for now instead of the shared dispatch table the issue's design calls for — it should move onto that table once #436 lands. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CMsq87s9e7zRUvfLYKxqvk
PreviewURL: https://batterylight-pr-451.blackpond-ef672c92.germanywestcentral.azurecontainerapps.io Hosted on Azure Container Apps — accessible from the internet. |
…clear Adds a persisted eventLogLimit device setting (default 10) capping how many of the most recent matching entries GET /api/events returns, and a POST /api/events/clear endpoint that wipes the device's ring buffer and restarts arrival order at 0, broadcasting to connected WebSocket clients so other open viewers stay in sync. Adds matching UI: a "Max displayed" field in the Settings save flow and a confirm-gated "Clear event log" button. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CMsq87s9e7zRUvfLYKxqvk
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CMsq87s9e7zRUvfLYKxqvk
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.
Summary
Closes #442.
EventLog(src/events/EventLog.h): a fixed-size (128-entry, ~9.5KB) RAM ring buffer recordingGenericEventbroadcasts (e.g. buzzer presses/resets) in receipt order, with sender name resolved viaPeerRegistry::nameFor(new).GET /api/events?eventType=to read the log, optionally filtered by event type, capped to theeventLogLimitdevice setting (default 10, most-recent-first).POST /api/events/clearto wipe the device's ring buffer and restart arrival order at 0, broadcastingt:'eventsCleared'so other open viewers stay in sync.eventLogLimitdevice setting (1–128, default 10) controlling how many of the most recent matching entries the endpoint above returns — configurable from Settings, applied live (no reboot).t:'event'message, alongsidet:'log'|'peers'|'groups'.server/index.js) per the repo's device/mock/UI parity checklist.Deviation from the issue's design: the issue calls for registering
/api/eventsin the shared(ApiRequest, ApiResponse)dispatch table introduced by #436, so it's automatically reachable over serial. #436 is still an open, unmerged PR, so this endpoint (and the new clear endpoint) are registered directly againstAsyncWebServerRequestfor now (matching every other current endpoint) — they should move onto the shared dispatch table once #436 lands, at which point they'll also become serial-reachable.Test plan
npm test(mock server test suite, 36/36) passesnpm run lint(ESLint) passesclang-format --dry-run --Werrorpasses across the touchedsrc/filesGET /api/eventsrender, eventType filter narrowing the list (including the empty-result case), changing/savingeventLogLimitand confirming the backend persists and applies it (most-recent-N slicing verified after reload), and the clear button (confirm dialog, backend ring buffer actually emptied, cancel path leaves everything untouched) — no console errors_onEventPush,eventsClearedhandler) by direct review, since the mock server's dashboard WebSocket is intentionally never opened when served fromlocalhost(pre-existing behavior, seedata/index.html:3010)GenericEventbroadcasts arriving and being recorded/pushed end-to-end on hardware