fix(slideshow): rebuild buffer sequentially when pausing a shuffle run#297
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 sequentialresolveOffsetlogic 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, callresetAllSlides(). 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 readsslideState.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:resetAllSlidescalled)resetAllSlidesnot called)Full frontend suite passes; lint and prettier clean.
🤖 Generated with Claude Code