Skip to content

Add update and clear play queue endpoints #4215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 11, 2025

Conversation

deluan
Copy link
Member

@deluan deluan commented Jun 11, 2025

Summary

  • extend PlayQueueRepository with Clear method and optional column updates
  • support partial updates in playQueueRepository.Store
  • implement PUT and DELETE /queue endpoints
  • add new tests for update and clear actions

Testing

  • make test

https://chatgpt.com/codex/tasks/task_b_68498ac868ac832eb393f94994f31b27

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @deluan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces new API functionality to allow users to update specific aspects of their play queue (like current track or position) or clear it entirely, in addition to the existing ability to replace the whole queue. This involved extending the data repository interface and implementation to support partial updates and clearing, and adding new API handlers and tests.

Highlights

  • New API Endpoints: I've added two new endpoints to the native API for managing the user's play queue: PUT /queue for updating specific fields and DELETE /queue for clearing the entire queue.
  • Partial Queue Updates: The PlayQueueRepository.Store method has been modified to support partial updates. It now accepts optional column names, allowing callers (like the new PUT endpoint) to specify which fields (items, current, position) should be updated without replacing the entire queue. If no columns are specified, it behaves like the previous full replacement.
  • Repository Interface & Implementation: The model.PlayQueueRepository interface and its persistence implementation have been extended to include a Clear method, used by the new DELETE endpoint, and the Store method signature was updated to support partial updates.
  • Payload Struct Reuse: The queuePayload struct was renamed to updateQueuePayload and its fields made optional (pointers with omitempty) so it can be reused for both the POST /queue (full save) and PUT /queue (partial update) endpoints.
  • New Tests: Comprehensive tests have been added for the new PUT /queue and DELETE /queue endpoints, covering successful operations and error cases, and existing POST /queue tests were updated to use the new payload struct.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configureGemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request introduces update and clear play queue endpoints. The changes include extending the PlayQueueRepository with a Clear method and supporting partial updates in playQueueRepository.Store. The review suggests adding more test cases for the new endpoints and considering the validation of the current index when updating the queue.

deluan and others added 4 commits June 11, 2025 11:07
@deluan deluan marked this pull request as ready for review June 11, 2025 15:28
@deluan deluan requested a review from Copilot June 11, 2025 15:28
Copilot

This comment was marked as outdated.

Signed-off-by: Deluan <deluan@navidrome.org>
@deluan deluan requested a review from Copilot June 11, 2025 15:58
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds support for partial updates and clearing of the play queue via new repository methods, HTTP endpoints, and tests.

  • Extend PlayQueueRepository with Clear, RetrieveWithMediaFiles, and optional column updates in Store
  • Implement PUT /queue and DELETE /queue handlers and register routes
  • Add comprehensive tests for update and clear actions

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/mock_playqueue_repo.go Update mock to record cols passed and add Clear
server/subsonic/bookmarks.go Use RetrieveWithMediaFiles for full media data
server/nativeapi/queue.go Add updateQueue, clearQueue, payload helpers
server/nativeapi/queue_test.go Add tests for PUT and DELETE /queue endpoints
server/nativeapi/native_api.go Register PUT and DELETE routes for /queue
persistence/playqueue_repository.go Support partial updates, add Clear, RetrieveWithMediaFiles
persistence/playqueue_repository_test.go Add tests covering partial field updates and clearing
model/playqueue.go Update interface with new methods and variadic Store
Comments suppressed due to low confidence (3)

tests/mock_playqueue_repo.go:55

  • copyItems is undefined in Store, causing a compile error. You should initialize and fill copyItems from q.Items, for example:
copyItems := make(model.MediaFiles, len(q.Items))
copy(copyItems, q.Items)
qCopy.Items = copyItems
qCopy.Items = copyItems

server/nativeapi/queue.go:111

  • The max function is not defined, leading to a compile error. You can inline a non-negative check:
pos := V(payload.Position)
if pos < 0 { pos = 0 }
pq.Position = pos
Position:  max(V(payload.Position), 0),

server/nativeapi/queue.go:183

  • The max helper is undefined here, causing a compile error. Replace with an explicit check:
pos := *payload.Position
if pos < 0 { pos = 0 }
pq.Position = pos
pq.Position = max(*payload.Position, 0) // Ensure position is non-negative

@deluan deluan merged commit 410e457 into master Jun 11, 2025
20 checks passed
@deluan deluan deleted the p46aae-codex/add-put-and-delete-methods-to-/api/queue branch June 11, 2025 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant