Fix off-by-one in rollback button placement

A rollback button on event E restores the state just after E. So the
button on the latest event was a no-op (you're already there), while the
scene-start event -- a valid earliest target -- correctly has one. The
visible set was effectively shifted one event late.

Hide the button on whichever event sits at the current position (the
rollback head if set, else the latest checkpoint, now supplied by the
backend as state.latest_checkpoint_id since the frontend's own reduce
over the async-populated accumulator wasn't reliably reactive). In live
play the latest event loses its redundant button; when rolled back, the
"you are here" event has none while earlier events show rollback and
later ones show redo.

Verified in a browser across live, rolled-back, and redo states.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-13 09:03:52 -07:00
parent 6964aeabb6
commit 56cdebdeda
4 changed files with 25 additions and 2 deletions

View File

@@ -135,6 +135,8 @@ def get_game_state(game_id: str, player_id: str, db: Session = Depends(get_sessi
"votes": [v.model_dump() for v in game.votes],
"events": [e.model_dump() for e in events],
"events_have_more": events_have_more,
# The newest checkpoint id, so the log can tell which event is "you are here".
"latest_checkpoint_id": crud.latest_checkpoint_id(db, game_id),
}
@api.get("/game/{game_id}/events")