Skip to content

Align timer/stopwatch start to the next whole second - #7

Open
bakedpanda wants to merge 1 commit into
masterfrom
claude/clock-timer-sync-mchrfp
Open

Align timer/stopwatch start to the next whole second#7
bakedpanda wants to merge 1 commit into
masterfrom
claude/clock-timer-sync-mchrfp

Conversation

@bakedpanda

Copy link
Copy Markdown
Owner

Summary

  • Timers and stopwatches used to stamp endAt/startedAt at the exact millisecond you clicked Start, so their seconds digit ticked over out of phase with the clock and with each other — distracting on a broadcast display.
  • /slots/:id/start and /slots/:id/resume now defer the actual state change via a short setTimeout (0–999ms) until the next whole wall-clock second, so all widgets change seconds in lockstep.
  • A queued start/resume is cancelled if pause, reset, or a type change arrives before it fires, to avoid a race where the slot starts running after the operator already changed their mind.

Test plan

  • Ran the server locally, captured the raw SSE stream with wall-clock timestamps around a start call: the HTTP response returned in ~20ms as before, but the mode: "running" broadcast landed within 4ms of the next whole second (remaining: 59999 for a 60s timer, confirming the countdown's zero-point is pinned to the boundary, not the click).
  • Verified pause fired during the pending window cancels the queued start (slot stays idle, never transitions to running).
  • Manual check in a browser: operator /operator + viewer / tabs, confirm timer/stopwatch seconds now change in sync with the clock and with each other.

Generated by Claude Code

Previously endAt/startedAt were stamped at the exact click time, so a
running timer or stopwatch ticked over its seconds digit out of phase
with the clock (and with other slots) — distracting on a broadcast
display. Start/resume now defer the actual state flip via a short
setTimeout until the next whole wall-clock second, so all widgets
change seconds in lockstep. A start/resume queued this way is
cancelled if pause/reset/type-change land before it fires.
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