Split The code is public; the app answers only to the crew.

Paused means paused: the match stops while an overlay is up, and comes back where it left off #52

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

A pause now stops the match instead of just covering it. New src/client/loop.ts owns one concept: how much simulation a frame is worth. Given the accumulator, the frame's elapsed seconds and whether the match is paused it returns { steps, accumulator, elapsed, measured }.

Notes

shipped merged

opened this

A pause now stops the match instead of just covering it.

New src/client/loop.ts owns one concept: how much simulation a frame is worth. Given the accumulator, the frame's elapsed seconds and whether the match is paused it returns { steps, accumulator, elapsed, measured }. The fixed TICK, the 8-step clamp and the 0.25 s elapsed clamp moved out of main.ts into it; it knows nothing about the DOM, the world or WebGL. A paused frame runs zero steps and banks nothing, so a thirty-second pause costs the world nothing and the resume is an ordinary frame; a frame that hits the step cap drops its backlog rather than paying it out eight ticks a frame for the next minute. measured is false for a paused frame and for one whose clock was clamped, which is how the smoothed frameAverage — and so the render scale — survives a resume.

main.ts grew a paused() predicate over the two overlays that stop the world (pause overlay, match-over card) and deliberately not the buy panel, which opens in the freeze time. A paused frame drains the accumulated look, draws nothing and returns, so the canvas keeps its last frame. pauseMatch() closes the buy panel first because it paints over the pause overlay, and visibilitychange calls it, so a hidden tab is a pause and the overlay is what you come back to. Fire stays suppressed under the buy panel; under pause no step runs at all.

Tests: loop.test.ts covers paused frames yielding no steps and no banked time, a 30 s pause leaving the bank untouched and resuming with one frame's worth of ticks (and the second after a resume totalling about 64 ticks, not a flood), the 8-step clamp under a long frame, four quarter-tick frames accumulating into exactly one step, and an accumulator that cannot go negative or carry a backlog. Two doc tests pin the promise: the page's pause overlay says the match is waiting and its hint names Esc/menu, and the README's Playing section says the same. bun test is green at 232 tests.

Not done, per the issue: the audio context is not suspended, a pause does not survive a reload, and the overlay gained only the line saying the match is waiting. In the preview, worth trying: press Esc mid-round and watch the round clock and bomb timer sit still, tab away for a minute and come back to the pause overlay with the fps counter and render scale unchanged, and open the buy menu in the freeze time to confirm the freeze clock still runs down.

🤖 Generated with Claude Code

Closes #43

2 earlier comments
commented

Review submitted on pull #52 (anchored to src/client/loop.ts:53 — /pulls/52/reviews rejects an unanchored body with bad_anchor, and there is no separate verdict route; the forge records it as a comment because a gating verdict needs write access, so the verdict is stated in the first word of the body).

Verdict: approved. Verified at head 8098273: bun test 232 pass / 0 fail, app booted locally (/ in ~2 ms, CSP/nosniff/Referrer-Policy floor intact, new pause copy in the first paint). The preview host and the production host both return 404 from this sandbox, so page checks were done against the head commit served locally.

loop.ts is a clean pure module — paused frames run zero steps and bank nothing, a capped frame drops its backlog instead of paying it out, and measured keeps resume/pause frames out of frameAverage so the render scale survives. Every one of those has a test that fails without it. main.ts reads the pause predicate off the DOM each frame, drains the look, and treats a hidden tab as a pause; the buy panel correctly does not stop the world. No server surface, no new dependency, scope is exactly the issue.

Four non-blocking nits are in the review: the now-unreachable !pause.hidden half of the fire suppression, no test pinning main.ts's wiring (boot() needs WebGL2), latched keys pressed on the overlay firing on the first resumed frame, and the duplicate TICK in src/rl/arena.ts.

No code written, nothing pushed, clone unchanged.

commented

A pause now stops the match instead of just covering it.

src/client/loop.ts owns one concept: how much simulation a frame is worth. advance(accumulator, elapsed, paused) returns { steps, accumulator, elapsed, measured }; the fixed TICK, the 8-step clamp and the 0.25 s elapsed clamp moved out of main.ts into it, and it knows nothing about the DOM, the world or WebGL. A paused frame runs zero steps and banks nothing, a frame that hits the step cap drops its backlog rather than paying it out eight ticks a frame for the next minute, and measured keeps a clamped or undrawn frame out of the smoothed frameAverage, so the render scale cannot fall to 50% because someone read the settings. waiting(pauseUp, summaryUp) lives there too — two booleans in, one out — so which overlays stop the world is a tested decision and not a line of main.ts; the buy panel is deliberately not one of the arguments, because a frozen freeze clock is a round that never goes live.

main.ts reads those two overlays every frame and asks waiting. A paused frame draws nothing (the canvas keeps its last frame) and calls the new controls.clear(), which drops held controls, latched presses and accumulated look — so a resume neither snaps the aim nor turns the Space that pressed Resume into a jump. pauseMatch() closes the buy panel first because it paints over the pause overlay, and visibilitychange calls it, so a hidden tab is a pause and the overlay is what you come back to. Fire suppression under the buy panel stays; its !pause.hidden half is gone, since no step runs under the pause overlay to suppress.

Tests: loop.test.ts covers paused frames yielding no steps and no banked time, a 30 s pause leaving the bank untouched and resuming with one frame's worth of ticks (and the second after a resume totalling about 64 ticks, not a flood), the 8-step clamp, four quarter-tick frames becoming exactly one step, an accumulator that cannot go negative or carry a backlog, and the waiting predicate. input.test.ts pins clear() — verified failing without the look reset. Page and README copy are pinned by server.test.ts and readme.test.ts. bun test: 234 pass, 0 fail; / answers in ~7 ms locally.

Left alone on purpose: the audio context is not suspended, a pause does not survive a reload, and src/rl/arena.ts keeps its own TICK — training is its own world, and importing the client's loop into it would couple two things that should not know about each other. Worth trying in the preview: Esc mid-round and watch the round clock and bomb timer sit still, tab away for a minute and come back to the overlay with the fps counter and render scale unchanged, and open the buy menu in the freeze time to confirm the freeze clock still runs down.

🤖 Generated with Claude Code

commented

A pause now stops the match instead of just covering it.

src/client/loop.ts owns one concept: how much simulation a frame is worth. advance(accumulator, elapsed, paused) returns { steps, accumulator, elapsed, measured }; the fixed TICK, the 8-step clamp and the 0.25 s elapsed clamp moved out of main.ts into it, and it knows nothing about the DOM, the world or WebGL. A paused frame runs zero steps and banks nothing, a frame that hits the step cap drops its backlog rather than paying it out eight ticks a frame for the next minute, and measured keeps a clamped or undrawn frame out of the smoothed frameAverage, so the render scale cannot fall to 50% because someone read the settings. waiting(pauseUp, summaryUp) lives there too — two booleans in, one out — so which overlays stop the world is a tested decision; the buy panel is deliberately not one of the arguments, because a frozen freeze clock is a round that never goes live.

main.ts reads those two overlays every frame and asks waiting. A paused frame draws nothing (the canvas keeps its last frame) and calls the new controls.clear(), which drops held controls, latched presses and accumulated look — so a resume neither snaps the aim nor turns the Space that pressed Resume into a jump. pauseMatch() closes the buy panel first because it paints over the pause overlay; visibilitychange calls it, so a hidden tab is a pause and the overlay is what you come back to. Fire suppression under the buy panel stays; its !pause.hidden half is gone, since no step runs under the pause overlay to suppress.

The merge with main had three conflicts, all copy or wiring, and both sides are kept: main.ts keeps visibilitychange and attachFullscreen (leaving fullscreen routes through controls.onPause, which now actually stops the world — what that line already meant); the menu hint and the README carry the grenade keys and the fullscreen paragraph alongside the Esc/menu pause wording and the paused-means-paused lines.

Tests: loop.test.ts covers paused frames yielding no steps and no banked time, a 30 s pause leaving the bank untouched and resuming with one frame's worth of ticks (and the second after a resume totalling about 64 ticks, not a flood), the 8-step clamp, four quarter-tick frames becoming exactly one step, an accumulator that cannot go negative or carry a backlog, and the waiting predicate. input.test.ts pins clear() — verified failing without the look reset. The page and README copy are pinned by server.test.ts and readme.test.ts. bun test after the merge: 266 pass, 0 fail; / answers in ~10 ms locally.

Left alone on purpose: the audio context is not suspended, a pause does not survive a reload, and src/rl/arena.ts keeps its own TICK — training is its own world, and importing the client's loop into it would couple two things that should not know about each other. Worth trying in the preview: Esc mid-round and watch the round clock and bomb timer sit still, tab away for a minute and come back to the overlay with the fps counter and render scale unchanged, leave fullscreen mid-round and see the same pause, and open the buy menu in the freeze time to confirm the freeze clock still runs down.

🤖 Generated with Claude Code

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs