racer: consistently end the race when the clock flags by Zinkelburger · Pull Request #21965 · lichess-org/lila · GitHub
Skip to content

racer: consistently end the race when the clock flags - #21965

Draft
Zinkelburger wants to merge 1 commit into
lichess-org:masterfrom
Zinkelburger:racer-unfinished-on-flag
Draft

Zinkelburger wants to merge 1 commit into
lichess-org:masterfrom
Zinkelburger:racer-unfinished-on-flag

Conversation

@Zinkelburger

@Zinkelburger Zinkelburger commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

I was having issues/inconsistencies where in puzzle racer, sometimes the last puzzle would be shown as unfinished, and sometimes not shown at all.

AI Description:
Only the clock view's 100ms tick ends a run when time runs out, and that view is only rendered while status() is 'racing'. status() switched to 'post' as soon as the clock flagged, so a redraw landing between the flag and the next tick (the 1s redraw interval, a racerState message) unmounted the clock first: end() never ran, the board stayed movable, and the last puzzle was missing from the history.

Derive 'post' from run.endAt instead, and split end() the way storm does: end() finalises once, endNow() records the puzzle left on the board, for players only. Moves made after the flag end the race rather than counting locally when the server would reject the score. Opening a race that is already over goes straight to 'post' as before.

This also stops the last puzzle being recorded twice when every puzzle is played.


I tested it in a local lila instance

Claude Opus 5.5 prompt:

Puzzle racer sometimes leaves the last puzzle playable after time runs out and doesn't show it as unfinished.
Find the cause and fix it with a small, clear, maintainable change.
Make the end of the race consistent for puzzles I'd started and ones I haven't, copy storm's approach where possible.

Only the clock view's 100ms tick ends a run when time runs out, and that
view is only rendered while status() is 'racing'. status() switched to
'post' as soon as the clock flagged, so a redraw landing between the
flag and the next tick (the 1s redraw interval, a racerState message)
unmounted the clock first: end() never ran, the board stayed movable,
and the last puzzle was missing from the history.

Derive 'post' from run.endAt instead, and split end() the way storm
does: end() finalises once, endNow() records the puzzle left on the
board, for players only. Moves made after the flag end the race rather
than counting locally when the server would reject the score. Opening
a race that is already over goes straight to 'post' as before.

This also stops the last puzzle being recorded twice when every puzzle
is played.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ornicar ornicar added the AI AI-generated (substantially or wholly) label Oct 7, 2026
@ornicar

ornicar commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

@ornicar
ornicar marked this pull request as draft October 8, 2026 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI AI-generated (substantially or wholly)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants