feat(gamebanners): smooth 1Hz round_duration ticker between polls - #8
Merged
Merged
Conversation
Previously the round-duration display stepped 4s at a time on each upstream fetch — at 4-second intervals the user saw the clock jump 00:01:24 -> 00:01:28 every poll. Now a local setInterval increments the displayed time every second using (now - last_fetch_ms)/1000 as an offset on the most recent server-reported round_duration, so the clock reads as a live tick and re-syncs naturally on each poll (if the prediction was right, there's no visible jump; if drift, a 1-second snap). Implementation: - Pull the .status string builder out of renderBanner into buildStatusString(d, extraSec). - renderBanner stores the last server payload on banner._statusData and the wall-clock fetch time on banner._fetchedAt. - New setInterval(1000) iterates banners and recomputes only the .status line; everything else (version, map, revision, state classes) is fetch-driven as before. - setUnavailable and setNetworkError clear _statusData so the ticker can't drift over a stale payload while we're disconnected. shuttle_timer is intentionally NOT ticked locally — the sign / direction depends on shuttle_mode (called counts down, recalled counts up, etc.) and we don't carry that semantics client-side. It re-syncs every server poll, which is good enough. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
s950tx16wasr10
added a commit
to ReduxStation/infrastructure
that referenced
this pull request
May 18, 2026
Matches the landing-page poll cadence (data-poll-interval=4000ms in _data/site.yaml). At 30s, every 7th browser fetch hit fresh upstream data and the other 6 returned a stale cached JSON, so player counts and round durations stepped 30s at a time on the page. DD-side cost is negligible: - /world/Topic ?status is a sync proc, sub-millisecond per call - 7.5x more calls = ~0.025% of one core on DD main thread - One additional 700-byte atomic file write every 4s The public-log-parser also polls this same file (every 60s per its config) for ongoing-round protection; its semantics are unchanged. Companion change: ReduxStation/website#8 adds a 1Hz client-side ticker so the displayed round_duration increments smoothly between the 4s server polls. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
What
Adds a local 1Hz `setInterval` that recomputes only the `.status`
line on each game banner using `Math.floor((Date.now() - fetchedAt) / 1000)`
as an offset on the last server-reported `round_duration`. With server
polls every 4s, the clock reads as a live tick and re-syncs naturally
(no visible jump when the prediction matches; one-second snap when it
drifts).
Why
Previously `round_duration` only updated on each upstream fetch, so
the user saw the clock step 4s at a time. UX feels frozen between
polls for a value that's nominally a second-by-second timer.
Notes
`renderBanner`. Same code path on the initial render (`extraSec=0`)
and on every ticker iteration.
depends on `shuttle_mode` (`called` counts down, `recalled` counts
up, etc.) and we don't carry that mapping client-side. It re-syncs
every server poll, which is fine for the shuttle's <5min lifetime.
ticker can't drift over stale data while disconnected.
Companion
`ReduxStation/infrastructure#3` — server polls drop from 30s to 4s
so the banner re-syncs at the same cadence the local ticker assumes.