fix(ui): turn navigator no-op when re-selecting the on-screen turn #57

Merged
developer merged 1 commits from feature/issue-45-turn-navigator-noop into development 2026-05-26 05:13:24 +00:00
Owner

What

In the header turn navigator, clicking the current-turn row of the
dropdown while it is already the turn on screen routed through
returnToCurrent()viewTurn(currentTurn), which re-fetches the live
report and flips the view through loading. At turn 0 the only row
is the live turn, so opening the dropdown and clicking it always fired
a pointless backend round-trip and a redraw of the identical snapshot.

Fix

goToTurn() now guards against re-selecting the turn already on screen
(turn === viewedTurn): it closes the popover and stops. The guard is
written against viewedTurn rather than special-casing turn 0, so it
also drops the redundant re-fetch when re-picking a history turn you are
already viewing. Leaving history is unaffected — there the viewed turn
differs from the target, so returnToCurrent() / viewTurn(N) still run.

Tests

  • ui/frontend/tests/turn-navigator.test.ts: two regression tests — the
    live row at turn 0 is a no-op (neither viewTurn nor returnToCurrent
    fires, popover still closes), and re-selecting the already-viewed
    history row is a no-op.
  • Full Vitest suite green locally (79 files, 776 tests); svelte-check
    clean (0 errors / 0 warnings).

Docs

  • ui/docs/navigation.md and the component header comment updated to
    describe the no-op.

Closes #45

## What In the header turn navigator, clicking the **current-turn** row of the dropdown while it is already the turn on screen routed through `returnToCurrent()` → `viewTurn(currentTurn)`, which re-fetches the live report and flips the view through `loading`. At **turn 0** the only row *is* the live turn, so opening the dropdown and clicking it always fired a pointless backend round-trip and a redraw of the identical snapshot. ## Fix `goToTurn()` now guards against re-selecting the turn already on screen (`turn === viewedTurn`): it closes the popover and stops. The guard is written against `viewedTurn` rather than special-casing turn 0, so it also drops the redundant re-fetch when re-picking a history turn you are already viewing. Leaving history is unaffected — there the viewed turn differs from the target, so `returnToCurrent()` / `viewTurn(N)` still run. ## Tests - `ui/frontend/tests/turn-navigator.test.ts`: two regression tests — the live row at turn 0 is a no-op (neither `viewTurn` nor `returnToCurrent` fires, popover still closes), and re-selecting the already-viewed history row is a no-op. - Full Vitest suite green locally (79 files, 776 tests); `svelte-check` clean (0 errors / 0 warnings). ## Docs - `ui/docs/navigation.md` and the component header comment updated to describe the no-op. Closes #45
developer added 1 commit 2026-05-25 22:18:41 +00:00
fix(ui): no-op when re-selecting the turn already on screen
Tests · UI / test (push) Waiting to run
Tests · UI / test (pull_request) Successful in 3m35s
e82c9f8bbd
Clicking the current-turn row in the header turn navigator while
already viewing it routed through returnToCurrent() →
viewTurn(currentTurn), which re-fetches the live report and flips the
view through `loading`. At turn 0 the only row is the live turn, so
the dropdown always fired a pointless backend round-trip and redraw.

Guard goToTurn() against re-selecting the on-screen turn
(turn === viewedTurn): just close the popover and stop. Leaving
history is unaffected — there the viewed turn differs from the target.

Closes #45

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
developer requested review from owner 2026-05-25 22:18:45 +00:00
owner approved these changes 2026-05-25 22:30:13 +00:00
developer merged commit 1f6791549a into development 2026-05-26 05:13:24 +00:00
developer deleted branch feature/issue-45-turn-navigator-noop 2026-05-26 05:13:24 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: developer/galaxy-game#57