Skip to content

fix(slideshow): rebuild buffer sequentially when pausing a shuffle run#297

Merged
lstein merged 2 commits into
masterfrom
lstein/fix/shuffle-stop-sequential-nav
Jun 4, 2026
Merged

fix(slideshow): rebuild buffer sequentially when pausing a shuffle run#297
lstein merged 2 commits into
masterfrom
lstein/fix/shuffle-stop-sequential-nav

Conversation

@lstein
Copy link
Copy Markdown
Owner

@lstein lstein commented Jun 4, 2026

Problem

When the user runs the slideshow in shuffle mode, then stops it and navigates with the forward/back buttons, navigation showed the shuffled neighborhood instead of the current image's sequential neighbors.

Root cause

During a shuffle run the swiper buffer fills with slides in random order (the shuffle "bag"). When the slideshow stops, pauseSlideshow() only halts autoplay — it never rebuilds the buffer. The nav buttons (slideNext/slidePrev) then walk that stale shuffled buffer; only at the buffer edges does the sequential resolveOffset logic kick in.

Fix

In the pause branch of toggleSlideshowWithIndicator (play/pause button and spacebar — the "stop the slideshow" action), when the run being stopped was in shuffle mode, call resetAllSlides(). That rebuilds the buffer in album order around the current image, so forward/back navigation immediately walks real sequential neighbors. Sequential runs are skipped since they already leave an in-order buffer.

resetAllSlides() is safe here: it reads slideState.getCurrentSlide() (kept in sync with the on-screen image during shuffle), rebuilds prev/current/next sequentially, and won't restart autoplay since it was just paused.

Intended behavior, not changed

Navigating during a still-running shuffle slideshow continues to walk the shuffle order — that is intended.

Tests

Added two cases to tests/frontend/slideshow.test.js:

  • pausing a shuffle run rebuilds the buffer (resetAllSlides called)
  • pausing a sequential run does not (resetAllSlides not called)

Full frontend suite passes; lint and prettier clean.

🤖 Generated with Claude Code

lstein and others added 2 commits June 4, 2026 19:43
After a shuffle slideshow stops, the swiper buffer is still in random
order, so the forward/back buttons walked that leftover shuffle instead
of the current image's real sequential neighbors. pauseSlideshow() only
halts autoplay and never rebuilds the buffer, so the stale shuffled
slides surrounding the current one drove manual navigation.

Rebuild the buffer in album order around the current slide when a
shuffle run is paused via the play/pause button (or spacebar). Sequential
runs already leave an in-order buffer, so only shuffle needs this.

Note: navigating *during* a running shuffle slideshow still walks the
shuffle order — that is intended.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lstein lstein enabled auto-merge (squash) June 4, 2026 23:43
@lstein lstein merged commit 7a7f0a6 into master Jun 4, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant