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:
@@ -2123,6 +2123,12 @@ def test_rollback_keeps_future_and_sets_head(session):
|
||||
assert game.rollback_head_checkpoint_id == cp1.id
|
||||
assert game.rollback_timeline_version == v0
|
||||
|
||||
def test_latest_checkpoint_id(session):
|
||||
game, deep, _, cp1, cp2 = _scene_with_two_checkpoints(session)
|
||||
# Drives the "you are here" button-hiding: during live play this is the current point.
|
||||
assert crud.latest_checkpoint_id(session, game.id) == cp2.id
|
||||
assert crud.latest_checkpoint_id(session, crud.create_game(session).id) is None
|
||||
|
||||
def test_redo_after_rollback_clears_head(session):
|
||||
game, deep, _, cp1, cp2 = _scene_with_two_checkpoints(session)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user