feat(decoder): alarm banner and warning sound when the decoder drops or goes silent during a heat (1.89.25)

This commit is contained in:
larssand committed 2026-11-14 15:20:31 +01:00
1 parent 259945799d
commit 239cac8033
18 files changed
+225 -5

No files matched your search

+2
View File
@@ -2961,6 +2961,8 @@ Dependency graph: `app.js -> decoder_runtime.js -> decoder_diagnostics.js`; `app
`decoder_diagnostics_view.js` mounts inside a details element outside settingsForm. A one-second timer patches only its own text nodes; it skips closed/paused panels, clears the old timer on remount, and self-clears after detachment. Pause affects display, not collection. Clearing diagnostics preserves socket state and timestamps. Copy uses Clipboard API with a selectable readonly textarea fallback for HTTP. Untrusted payloads are assigned through textContent/value, never interpolated into HTML. No SQLite/localStorage writes, backend endpoint, or public overlay exposure is added. Refresh resets diagnostics independently of saved settings.
`decoder_watch.js` (pure) decides the decoder alarm: `decoderAlarm(decoder, session, { startPending, bestLapMs, now })` returns `ok`, `lost` (main link down 3 s or more during a running heat or start count-down, counted from `state.decoder.disconnectedAt`, set on the first `onclose` and cleared on `onopen`) or `silent` (connected, a non-practice heat past its first 30 s, no PASSING since `state.decoder.lastPassingAt` or the start for `silentLimitMs(bestLapMs)` = max(30 s, 3 × best lap)). `app.js` `checkDecoderAlarm()` runs every second on the race master with a configured `wsUrl` and `settings.raceAudio.decoderAlarm` on; it renders `#decoderAlarm`, plays `timing_disconnected` (or the WebAudio siren when race audio is off) every 30 s until silenced, and shows 10 s of "working again" after recovery. No backend or SQLite change.
Reason codes: invalid_message (not an object), not_passing, no_running_session, missing_transponder, not_registered, already_in_pit, pit_exit_without_entry, split_without_reference, split_locktime, below_min (stored invalid lap). Handled events: pit_entry, pit_exit, split, start_reference, lap_counted or the existing validation warning. invalid_json means parsing failed before processing. The raw frame helps diagnose upstream protocol problems without changing parsing behavior.
Tests: decoder_diagnostics.test.js covers bounds, isolation, snapshots and outcomes; decoder_runtime.test.js exercises socket reception/JSON errors/disconnection/open status without settings rerender. browser_smoke.js verifies live diagnostics update while an edited settings URL remains unchanged. Hardware/network reconnect behavior still requires a real-decoder smoke test.