Skip to content

Add setting to hide already-played tracks in play queue - #893

Open
belzebub40k wants to merge 10 commits into
supersonic-app:mainfrom
belzebub40k:hide-played-tracks
Open

Add setting to hide already-played tracks in play queue#893
belzebub40k wants to merge 10 commits into
supersonic-app:mainfrom
belzebub40k:hide-played-tracks

Conversation

@belzebub40k

@belzebub40k belzebub40k commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add a setting to hide already-played tracks from the play queue, so the current track stays at the top and the queue shows what is coming up
  • The toggle is available both in Settings > General ("Hide played tracks from queue") and directly in the play queue popup ("Hide played tracks")
  • All queue views (Now Playing page, sidebar, popup) follow the setting and update immediately when it is toggled
  • Displayed track numbers keep the track's position in the full queue instead of restarting from 1
  • Clicking, removing and drag-reordering a row in the filtered view act on the intended track

Changes

  • Added HidePlayedQueueTracks config option
  • Added the checkbox to Settings > General and to the play queue popup, kept in sync with each other
  • PlayQueueList owns the play queue and the playing index: SetQueue, SetNowPlayingIndex and SetHidePlayed apply the filter internally, and the indexes reported to OnPlayItemAt, OnRemoveFromQueue and OnReorderItems are translated back into full-queue indexes. Queue() exposes the unfiltered queue to the handlers that receive those indexes
  • A track change only rebuilds the displayed rows when it changes which rows are hidden, so an ordinary track transition doesn't discard the user's selection
  • The views are notified of a setting change through Controller.HidePlayedTracksChangedFunc, injected by MainWindow alongside its other view-level callbacks
  • Fixed track numbers resetting to 1 when tracks are hidden
  • Fixed scroll position on initial load, page reload and widget-pool recycling

Tests

ui/widgets/playqueuelist_test.go covers the display/queue index translation, the displayed track numbers, the reorder contract, selection preservation across a track change, and the cases where nothing should be hidden (nothing playing, first track, playing index past the end of the queue, empty queue).

Manual testing

  • Toggle the setting in Settings > General and in the queue popup, and verify all queue views update immediately and the two checkboxes stay in sync
  • With played tracks hidden: click a row to play it, remove a selection, and drag to reorder — verify the intended tracks are affected and that no tracks disappear from the queue
  • Verify displayed track numbers continue from the current track
  • Navigate between pages and reload, verifying scroll position behaves correctly

@belzebub40k
belzebub40k force-pushed the hide-played-tracks branch 2 times, most recently from d81a416 to 818e461 Compare April 7, 2026 07:01
@belzebub40k

Copy link
Copy Markdown
Contributor Author

Updated to retain track number in queue.

@belzebub40k
belzebub40k force-pushed the hide-played-tracks branch 2 times, most recently from 92badd6 to 50a40b9 Compare May 12, 2026 06:54
@belzebub40k

Copy link
Copy Markdown
Contributor Author

Added checkbox to quickly toggle the setting in the play queue popup.

Screenshot_20260512_085844

@belzebub40k
belzebub40k force-pushed the hide-played-tracks branch 2 times, most recently from 48fe78d to 2c32d74 Compare June 10, 2026 05:19
@belzebub40k

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (the module rename and the now-padded settings dialog were the only conflicts) and went back over the whole diff. A few real bugs turned up:

  • "Remove from queue" removed the wrong tracks. It passed indexes of the filtered list to RemoveTracksFromQueue, which reads them as indexes into the full queue, so it deleted already-hidden tracks instead of the selected ones.
  • Drag-reordering could crash the app. OnReorderItems reports full-queue indexes but the handler paired them with the displayed items: index out of range [9] with length 5. When it didn't panic it moved the wrong track and rebuilt the queue from the visible items alone, silently dropping every already-played track.
  • The queue list was rebuilt on every track change even with the setting off, which recreates the track models and so cleared the user's selection — that one affected people not using the feature.
  • The Now Playing queue jumped to the top on any queue change, because the scroll reset sat in Reload(), which is also the queue-change handler. It now only runs on first load, which is what it was for.
  • The two new strings were missing from en.json, and the popup checkbox didn't persist the setting.

Cleanups:

  • The filter now lives in PlayQueueList rather than being re-applied by each of the three queue views, which all had to call SetPlayIndexOffset and SetItems together and in the right order or the displayed rows and the engine-facing indexes would disagree. That coupling is what caused both index bugs. FilterQueueForHidePlayed and SetPlayIndexOffset are gone.
  • Dropped PlaybackManager.TriggerQueueChangeCallback. Having the backend fabricate a queue-change event for a UI-only setting was the wrong shape; the views are notified from MainWindow now, like the Controller's other view-level callbacks.

Added ui/widgets/playqueuelist_test.go (8 tests) covering the display↔queue index translation, the displayed track numbers, the reorder contract, and the cases where nothing should be hidden. I checked each test fails when the corresponding bug is put back.

The settings checkbox now reads "Hide played tracks from queue"; the popup keeps the shorter "Hide played tracks".

Pushed on top of the existing commits, and I've updated the description above to match.

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