Fix index_in_buffer or current_index treating index 0 as unset (#3160)
authorDavid Bishop <teancom@users.noreply.github.com>
Mon, 16 Feb 2026 09:08:35 +0000 (01:08 -0800)
committerGitHub <noreply@github.com>
Mon, 16 Feb 2026 09:08:35 +0000 (10:08 +0100)
commitfe2e1dfdb18e430f12f78bfa1470ef603573e547
treee049ef8ee94eabc05bad623665fe4396bbf0425d
parentfdf1ad5e6ad69dfbb8361cc753cc1e21bd3a05d0
Fix index_in_buffer or current_index treating index 0 as unset (#3160)

index_in_buffer and current_index are int | None where 0 is a valid
value (first track in queue). Two locations use chained `or` to
select between them:

- set_shuffle: `queue.index_in_buffer or queue.current_index`
- play_media_from_queue: `queue.index_in_buffer or queue.current_index or 0`

When index_in_buffer is 0 (first track buffered), Python's `or`
treats it as falsy and falls through to current_index. This causes
shuffle reshuffling and queue insertion to use the wrong position.

Replace with explicit `is not None` checks in both locations.

Co-authored-by: David Bishop <git@gnuconsulting.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
music_assistant/controllers/player_queues.py