From cceeaeb5c83a059e58f7fdafc2b8ab6a967248aa Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Fri, 27 Nov 2026 03:06:58 -0500 Subject: [PATCH] fix(web): Next is off at the end of the queue with repeat one, since it only stops there (DRY W1) With repeat one on the last track, the play bar and Now Playing enabled Next, but store.skipNext treats an explicit Next at the end the same for repeat one as for repeat off: it pauses. The button now follows the store: on when there is a track after this one or the queue wraps (repeat all). Co-Authored-By: Claude Opus 5.5 --- web/src/lib/player/controls.test.ts | 3 +++ web/src/lib/player/controls.ts | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/web/src/lib/player/controls.test.ts b/web/src/lib/player/controls.test.ts index 5322f211..2bb832c9 100644 --- a/web/src/lib/player/controls.test.ts +++ b/web/src/lib/player/controls.test.ts @@ -14,6 +14,9 @@ describe('transport rules', () => { expect(canSkipNext({ index: 1, queue, repeat: 'off' })).toBe(true); expect(canSkipNext({ index: 2, queue, repeat: 'off' })).toBe(false); expect(canSkipNext({ index: 2, queue, repeat: 'all' })).toBe(true); + // Repeat one repeats a track as it ends; an explicit Next at the end of + // the queue stops, so the button is off as with repeat off. + expect(canSkipNext({ index: 2, queue, repeat: 'one' })).toBe(false); }); test('repeat labels name each mode', () => { diff --git a/web/src/lib/player/controls.ts b/web/src/lib/player/controls.ts index feb641ad..d0fd60d3 100644 --- a/web/src/lib/player/controls.ts +++ b/web/src/lib/player/controls.ts @@ -16,9 +16,10 @@ export function canSkipPrev(p: { index: number; position: number }): boolean { } /** Whether Next does anything: there is a track after this one, or the - queue wraps round. */ + queue wraps round (repeat all). Repeat one doesn't count: an explicit + Next at the end stops there, as with repeat off (store.skipNext). */ export function canSkipNext(p: { index: number; queue: readonly unknown[]; repeat: RepeatMode }): boolean { - return !(p.index === p.queue.length - 1 && p.repeat === 'off'); + return p.index + 1 < p.queue.length || p.repeat === 'all'; } export function repeatLabel(mode: RepeatMode): string {