-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add update and clear play queue endpoints #4215
Conversation
There was a problem hiding this 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 andDELETE /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 itspersistence
implementation have been extended to include aClear
method, used by the new DELETE endpoint, and theStore
method signature was updated to support partial updates. - Payload Struct Reuse: The
queuePayload
struct was renamed toupdateQueuePayload
and its fields made optional (pointers withomitempty
) so it can be reused for both thePOST /queue
(full save) andPUT /queue
(partial update) endpoints. - New Tests: Comprehensive tests have been added for the new
PUT /queue
andDELETE /queue
endpoints, covering successful operations and error cases, and existingPOST /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
-
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. ↩
There was a problem hiding this 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.
Signed-off-by: Deluan <deluan@navidrome.org>
Signed-off-by: Deluan <deluan@navidrome.org>
There was a problem hiding this 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
withClear
,RetrieveWithMediaFiles
, and optional column updates inStore
- Implement
PUT /queue
andDELETE /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 fillcopyItems
fromq.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
Summary
PlayQueueRepository
withClear
method and optional column updatesplayQueueRepository.Store
/queue
endpointsTesting
make test
https://chatgpt.com/codex/tasks/task_b_68498ac868ac832eb393f94994f31b27