Align timer/stopwatch start to the next whole second - #7
Open
bakedpanda wants to merge 1 commit into
Open
Conversation
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.
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
endAt/startedAtat 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/startand/slots/:id/resumenow defer the actual state change via a shortsetTimeout(0–999ms) until the next whole wall-clock second, so all widgets change seconds in lockstep.Test plan
startcall: the HTTP response returned in ~20ms as before, but themode: "running"broadcast landed within 4ms of the next whole second (remaining: 59999for a 60s timer, confirming the countdown's zero-point is pinned to the boundary, not the click)./operator+ viewer/tabs, confirm timer/stopwatch seconds now change in sync with the clock and with each other.Generated by Claude Code