v0.16.1 — ISS-007 smooth client-side sim clock with per-snapshot re-sync #18

Merged
kamilkrzywda merged 2 commits from feat/smooth-sim-clock into master 2026-09-19 16:27:21 +02:00
Owner

What (issue #7)

Time update is skipping second — it's only updated server side; render on frontend and sync periodically from backend.

The sim clock in the left pane previously re-rendered once per 1s poll, so seconds jumped. Now:

  • New lib/useSimClock.ts hook (+ pure unit-testable core advanceSimClock): keeps an anchor {clockMs, at, timeScale, paused} updated on every snapshot (re-sync = snap to server truth — error bounded by network latency only) and derives the display clock ~10×/s: anchor.clockMs + (now − at) × timeScale while running, frozen at the anchor while paused. This mirrors the server's own tick-on-read model (clockMs += Δreal × timeScale).
  • LeftPane feeds it effective controls {timeScale: pendingScale ?? snap.timeScale, paused} so pause/scale changes take effect on click/drag without waiting for a confirming snapshot; render shape unchanged ({clock}{paused ? ' (paused)' : ''}).
  • RightPane deadline/penalty previews untouched (snapshot-based). No server/OpenAPI changes.

E2E

New test in e2e/panes.spec.ts: at scale 1000 the displayed clock advances strictly monotonically across three ~1.3s samples, with a total-advance sanity bound. All existing clock assertions pass unchanged (format identical; paused clock frozen).

Version

  • package.json → 0.16.1
  • CHANGELOG.md — v0.16.1 entry at top

Checks (local)

  • tsc --noEmit clean; unit 261/261 green (was 256, +5 core tests); playwright test --list = 35 tests
  • e2e not run locally by design — CI verifies against the isolated stack
## What (issue #7) *Time update is skipping second — it's only updated server side; render on frontend and sync periodically from backend.* The sim clock in the left pane previously re-rendered once per 1s poll, so seconds jumped. Now: - New **`lib/useSimClock.ts`** hook (+ pure unit-testable core `advanceSimClock`): keeps an anchor `{clockMs, at, timeScale, paused}` updated on every snapshot (re-sync = snap to server truth — error bounded by network latency only) and derives the display clock ~10×/s: `anchor.clockMs + (now − at) × timeScale` while running, frozen at the anchor while paused. This mirrors the server's own tick-on-read model (`clockMs += Δreal × timeScale`). - LeftPane feeds it effective controls `{timeScale: pendingScale ?? snap.timeScale, paused}` so pause/scale changes take effect on click/drag without waiting for a confirming snapshot; render shape unchanged (`{clock}{paused ? ' (paused)' : ''}`). - RightPane deadline/penalty previews untouched (snapshot-based). No server/OpenAPI changes. ## E2E New test in `e2e/panes.spec.ts`: at scale 1000 the displayed clock advances strictly monotonically across three ~1.3s samples, with a total-advance sanity bound. All existing clock assertions pass unchanged (format identical; paused clock frozen). ## Version - `package.json` → **0.16.1** - `CHANGELOG.md` — v0.16.1 entry at top ## Checks (local) - `tsc --noEmit` clean; unit **261/261** green (was 256, +5 core tests); `playwright test --list` = 35 tests - e2e not run locally by design — CI verifies against the isolated stack
kamilkrzywda added 1 commit 2026-09-19 16:06:23 +02:00
kamilkrzywda added 1 commit 2026-09-19 16:20:37 +02:00
test: fix ISS-007 clock parse — replace only fixed the first space
CI / build + unit + e2e (pull_request) Successful in 6m4s
3acf471295
kamilkrzywda merged commit eb69359a38 into master 2026-09-19 16:27:21 +02:00
kamilkrzywda deleted branch feat/smooth-sim-clock 2026-09-19 16:27:21 +02:00
Sign in to join this conversation.