Skip to content

Add the locked part of the queue to the player queue - #495

Merged
marcelveldt merged 1 commit into
mainfrom
add-queue-last-locked-index
Nov 27, 2026
Merged

marcelveldt merged 1 commit into
mainfrom
add-queue-last-locked-index

Conversation

@marcelveldt

@marcelveldt marcelveldt commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

What does this implement/fix?

Sendspin players can swap the next track they already received (music-assistant/server#8084), so which queue items are locked no longer follows from index_in_buffer. The server works that out and clients now get the result as one queue field.

Changes

  • PlayerQueue.last_locked_index: the items up to and including this index can't be moved or removed, None while nothing is locked. Set by the server at runtime, not persisted.

Related issue (if applicable):

Types of changes

  • Bugfix (non-breaking change which fixes an issue) — bugfix
  • New feature (non-breaking change which adds functionality) — new-feature
  • Enhancement to an existing feature — enhancement
  • Breaking change (fix or feature that would cause existing functionality to not work as expected) — breaking-change
  • Refactor (no behaviour change) — refactor
  • Documentation only — documentation
  • Maintenance / chore — maintenance
  • CI / workflow change — ci
  • Dependencies bump — dependencies

Checklist

  • The code change is tested and works locally.
  • pre-commit run --all-files passes.
  • pytest passes, and tests have been added/updated under tests/ where applicable.
  • Any consumer of a changed model is updated, and the companion PR in music-assistant/server is linked.
  • I have read and complied with the project's AI Policy for any AI-assisted contributions.

@github-actions github-actions Bot added the maintenance Code readability, documentation or other change to maintain the codebase label Nov 27, 2026
@marcelveldt

Copy link
Copy Markdown
Member Author

@Bot-MArley review

@Bot-MArley Bot-MArley left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

This comment was written by Claude and posted by Bot-MArley on behalf of the Music Assistant maintainers.

Thanks @marcelveldt, this looks good. The new last_locked_index field sits right next to current_index / index_in_buffer, defaults to None, and needs no special serialization handling. It means the same thing in music-assistant/server#8246, which sets it in signal_update and keeps it out of the queue cache. Older payloads without the key still deserialize fine.

No changes requested. Two optional nits:

  • The ticked type is "Maintenance", but this adds a new field that clients can read. Earlier field additions like ended (#339) were labelled enhancement, so that label would put it in the right section of the release notes.
  • Other new queue fields came with a small default / round-trip test in tests/test_player_queue.py. One here would keep that consistent, but it's not required for a plain int | None field.

Next step: a maintainer can merge this. It needs to be released before music-assistant/server#8246 (and #8084 under it) can bump the models dependency.

@marcelveldt
marcelveldt marked this pull request as ready for review November 27, 2026 13:35
@marcelveldt
marcelveldt merged commit 9f9f086 into main Nov 27, 2026
14 checks passed
@marcelveldt
marcelveldt deleted the add-queue-last-locked-index branch November 27, 2026 13:36
marcelveldt added a commit to music-assistant/server that referenced this pull request Nov 27, 2026
# What does this implement/fix?

<!-- Quick description and explanation of changes. -->

Stacked on #8084. Clients get the locked part of the queue as one queue
field, `last_locked_index`, instead of an `extra_attributes` key next to
`index_in_buffer`. That one value tells every client which items it may
move or remove, so none of them has to combine it with `index_in_buffer`
or repeat a server rule.

## Changes

- The queue publishes the lock as `PlayerQueue.last_locked_index`
(music-assistant/models#495).
- The buffered next track counts as replaceable only while a track
follows it. The lock covers the "last track can't be deleted" rule
itself, so `delete_item` needs no special case. "Play next" while the
next track is the last one lands after it.
- The MCP queue tools follow the same lock.
- API schema version 128, models 1.1.254.

**Related issue (if applicable):**

- stacked on #8084
- models music-assistant/models#495
- frontend music-assistant/frontend#3360 (stacked on
music-assistant/frontend#3326)

## Types of changes

<!--
Tick exactly one box. CI (.github/workflows/pr-labels.yaml) derives
the label from the ticked box and applies it automatically; the
release-notes generator uses that same label to slot this change
into the next release notes.
-->

- [ ] Bugfix (non-breaking change which fixes an issue) — `bugfix`
- [ ] New feature (non-breaking change which adds functionality) —
`new-feature`
- [ ] Enhancement to an existing feature — `enhancement`
- [ ] New music/player/metadata/plugin provider — `new-provider`
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected) — `breaking-change`
- [ ] Refactor (no behaviour change) — `refactor`
- [ ] Documentation only — `documentation`
- [x] Maintenance / chore — `maintenance`
- [ ] CI / workflow change — `ci`
- [ ] Dependencies bump — `dependencies`

## Checklist

- [x] The code change is tested and works locally.
- [x] `pre-commit run --all-files` passes.
- [x] `pytest` passes, and tests have been added/updated under `tests/`
where applicable.
- [x] For changes to shared models, the companion PR in
`music-assistant/models` is linked.
- [x] For changes affecting the UI, the companion PR in
`music-assistant/frontend` is linked.
- [x] I have read and complied with the project's [AI
Policy](https://github.com/music-assistant/.github/blob/main/AI_POLICY.md)
for any AI-assisted contributions.
- [ ] I have [raised a PR against the documentation
repository](https://github.com/music-assistant/music-assistant.io/blob/main/CONTRIBUTING.md)
targeting the main or beta branch as appropriate.
balloobbot pushed a commit to balloobbot/server that referenced this pull request Nov 27, 2026
Update music-assistant-models to version
[1.1.254](https://github.com/music-assistant/models/releases/tag/1.1.254)


## 🧰 Maintenance and dependency bumps

- Add the locked part of the queue to the player queue (by @marcelveldt
in [music-assistant#495](music-assistant/models#495))


## 🙇 Contributors

@marcelveldt

Co-authored-by: musicassistant-bot[bot] <304008617+musicassistant-bot[bot]@users.noreply.github.com>
balloobbot pushed a commit to balloobbot/server that referenced this pull request Nov 27, 2026
…tant#8084)

# What does this implement/fix?

<!-- Quick description and explanation of changes. -->

Sendspin players can now drop a next track they already received and
play another one in its place. "Play next", moving, deleting and
shuffling then also change the next track on them, up to 5 seconds
before it starts. Unless a crossfade into the old next track was already
prepared, the switch happens inside the running stream without a gap or
restart.

Players opt in with the new `replaces_enqueued_media` property on
`PlayerProtocol`. Sendspin sets it while "Allow legacy clients" is off
and every group member supports the cut, so groups with a bridged
Squeezelite or Cast speaker keep the existing lock. The queue publishes
the last queue index the player holds as the
`PlayerQueue.last_locked_index` field, and the frontend locks the queue
up to that index instead of up to the buffered track. A buffered track
stays locked while no playable track follows it, since the player can
only replace it with one that does.

Tested with `sendspin-cli` 1.0.1 (sendspin-cpp v0.10.0) and Python
scripts built on the aiosendspin client: "Play next", move, delete and
shuffle near the end of a track all switched to the new next track
without a gap.

**Related issue (if applicable):**

- related issue Sendspin/backlog#82
- frontend music-assistant/frontend#3326
- models music-assistant/models#495

## Types of changes

<!--
Tick exactly one box. CI (.github/workflows/pr-labels.yaml) derives
the label from the ticked box and applies it automatically; the
release-notes generator uses that same label to slot this change
into the next release notes.
-->

- [ ] Bugfix (non-breaking change which fixes an issue) — `bugfix`
- [ ] New feature (non-breaking change which adds functionality) —
`new-feature`
- [x] Enhancement to an existing feature — `enhancement`
- [ ] New music/player/metadata/plugin provider — `new-provider`
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected) — `breaking-change`
- [ ] Refactor (no behaviour change) — `refactor`
- [ ] Documentation only — `documentation`
- [ ] Maintenance / chore — `maintenance`
- [ ] CI / workflow change — `ci`
- [ ] Dependencies bump — `dependencies`

## Checklist

- [x] The code change is tested and works locally.
- [x] `pre-commit run --all-files` passes.
- [x] `pytest` passes, and tests have been added/updated under `tests/`
where applicable.
- [x] For changes to shared models, the companion PR in
`music-assistant/models` is linked.
- [x] For changes affecting the UI, the companion PR in
`music-assistant/frontend` is linked.
- [x] I have read and complied with the project's [AI
Policy](https://github.com/music-assistant/.github/blob/main/AI_POLICY.md)
for any AI-assisted contributions.
- [ ] I have [raised a PR against the documentation
repository](https://github.com/music-assistant/music-assistant.io/blob/main/CONTRIBUTING.md)
targeting the main or beta branch as appropriate.

---------

Co-authored-by: Marcel van der Veldt <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Code readability, documentation or other change to maintain the codebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants