Delete the persistent events.jsonl log (the “Clear history”
button on Insights). In-session counters are unaffected. Emits
stats:cleared so the renderer can refresh.
Snapshot of the in-flight break event, or None between breaks.
Used by the overlay on cold-mount so it can re-render the right
state if the window was reloaded mid-break.
Seconds since the last keyboard/mouse input. Used by the overlay
to drive the typing-pause feature: while the user is mid-keystroke
the countdown is paused.
Aggregate the persistent event log into a digest for the Insights
tab. range is "week" (default) or "month". Reads events.jsonl
every call — small enough to be cheap, large enough that the
renderer should debounce range toggles.
Atomically replace the scheduler’s in-session counters with their
default and return the snapshot the emit should ship. Extracted as
a separate helper so the lock-then-snapshot ordering can be tested
against a real concurrent writer.
Pure-ish helper: zero the cell under the supplied mutex and return
a snapshot of the post-reset value, both atomic to outside writers.
Tested in isolation because Scheduler is not constructible in unit
tests (it spawns camera/video monitor threads at boot).