An attempt at catching some state drift bugs (and adding logging as well)
I recently noticed a letter get "stuck" in the center area, (it appeared
to be there, but did not allow any interaction).
This commit is by claude which it described as follows, (note: in the
below, rAF is requestAnimationFrame):
* Fixed the likely culprit — rAF loop using stale state:
The old code checked this.state.revealing[tile.id] synchronously
after an async setState to decide whether to keep animating. Now it
uses a local running flag, and the loop termination is decided
inside the setState callback where it has access to the actual
current state.
* Defensive cleanup in receive_center:
When the server sends an authoritative center update, any revealing
entries for tiles no longer in center are now cleaned up. This
prevents ghost revealing state from accumulating.
* Periodic consistency check (every 5s):
- Detects stale revealing entries for tiles not in center, logs a
warning, and auto-cleans them
- Detects inconsistent claim state
The combination of the rAF fix and the defensive cleanup in
receive_center should prevent the stuck-tile scenario. And if
something else causes drift in the future, the console warnings will
help diagnose it.