-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add artist play button #4204
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 artist play button #4204
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.
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!
Summary of Changes
Hello! gemini-code-assist here, providing a summary of this pull request. This PR introduces a new 'Play' button to the Artist actions toolbar. Clicking this button will fetch the top 50 songs for the current artist using the Subsonic API and then add them to the playback queue, starting playback. The changes involve adding the button UI, implementing the logic to call the Subsonic API and handle the response, integrating the new API call into the Subsonic client module, adding necessary internationalization strings, and including corresponding tests for the new functionality.
Highlights
- New 'Play' Button: Adds a new 'Play' button to the
ArtistActions
component, displayed alongside the existing 'Shuffle' and 'Radio' buttons. - Fetch Top Songs: Implements a new handler (
handlePlay
) that uses the Subsonic API'sgetTopSongs
endpoint to retrieve the top 50 tracks for the selected artist. - Playback Integration: Upon successfully fetching top songs, the PR dispatches the
playTracks
action to add the retrieved songs to the player queue and begin playback. - Subsonic API Client Update: Adds a new function (
getTopSongs
) to thesubsonic
client module to encapsulate the API call for fetching top songs. - Internationalization: Includes new translation keys in the English language file for the 'Play' button label and a message for when no top songs are found.
- Testing: Adds unit tests for the
ArtistActions
component to verify that clicking the new 'Play' button correctly calls thegetTopSongs
API and dispatches theplayTracks
action.
Changelog
Click here to see the changelog
- ui/src/artist/ArtistActions.jsx
- Imported
PlayArrowIcon
for the new button. - Imported the
subsonic
client module. - Added a new
handlePlay
asynchronous function. - The
handlePlay
function callssubsonic.getTopSongs
with the artist name and a count of 50. - Includes error handling and notification logic for the API call and when no songs are found.
- Processes the API response to extract song data and IDs.
- Dispatches the
playTracks
action with the fetched song data and IDs. - Added a new
Button
component for the 'Play' action, using thehandlePlay
handler and a translated label.
- Imported
- ui/src/artist/ArtistActions.test.jsx
- Modified the
subsonic
mock to include thegetTopSongs
function. - Added a mock resolved value for
subsonic.getTopSongs
in thebeforeEach
block. - Added a new test case 'plays top songs when Play is clicked'.
- The new test renders the component, clicks the 'Play' button, and asserts that
subsonic.getTopSongs
was called with the correct arguments andmockDispatch
was called.
- Modified the
- ui/src/i18n/en.json
- Added the translation key
resources.artist.actions.play
with the value 'Play'. - Added the translation key
message.noTopSongsFound
with the value 'No top songs found'.
- Added the translation key
- ui/src/subsonic/index.js
- Added a new function
getTopSongs
that constructs and performs an HTTP GET request to the 'getTopSongs' Subsonic endpoint. - Exported the new
getTopSongs
function.
- Added a new function
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 configure Gemini 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
This pull request introduces a 'Play' button for artists, allowing users to quickly play an artist's top songs. The changes include fetching data from the Subsonic API, handling internationalization, and adding corresponding tests. The implementation is generally clear and follows existing patterns.
I've focused my review on correctness and test coverage, adhering to common JavaScript and React best practices as no specific style guide was provided.
A few suggestions are provided to enhance API response handling and test completeness. Addressing these would further improve the robustness of the new feature.
Summary of Findings
- API Response Robustness: Suggested an improvement in
ArtistActions.jsx
for handling the Subsonic API response structure more robustly, specifically by checking if thedata
object (fromres.json['subsonic-response']
) is valid before accessing its properties. This aims to provide more specific error messages for malformed API responses. - Test Coverage: Recommended adding further test cases in
ArtistActions.test.jsx
for thehandlePlay
function. Specifically, tests for scenarios where the API call togetTopSongs
fails and where the API call succeeds but returns no songs would enhance the test suite's completeness. - Magic Number (Low Severity - Not commented): The number
50
used for fetching top songs inArtistActions.jsx
(line 60) and its corresponding test (line 100) is a magic number. For improved maintainability and clarity, consider defining this as a named constant. (This was not added as a direct review comment due to severity settings.) - Console Logging (Low Severity - Not commented):
console.error
is used for logging errors inArtistActions.jsx
(e.g., line 84). While acceptable, especially during development, for a production environment, integrating with a more structured logging service or utility could offer better error tracking and diagnostics. This is consistent with existing code in the file. (This was not added as a direct review comment due to severity settings.)
Merge Readiness
The pull request successfully adds the 'Play' button functionality for artists. The code is well-structured and includes tests for the primary success path.
I have made a couple of suggestions with medium
severity related to improving the robustness of API response handling and expanding test coverage for edge cases. Addressing these points would strengthen the new feature.
As I am an AI assistant, I am not authorized to approve pull requests. Please ensure these changes are reviewed and approved by a repository maintainer before merging. I recommend addressing the medium-severity issues before merging.
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
This PR adds a Play button to the artist toolbar, fetches and plays an artist’s top tracks via the Subsonic API, wires up translations, and covers the new behavior with tests.
- Introduce
getTopSongs
in the Subsonic client and aplayTopSongs
helper inartist/utils.js
- Add a Play button in
ArtistActions.jsx
and its translation keys - Extend tests to cover Play action and refactor MUI theme import
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
ui/src/utils/playSimilar.js | Removed unused legacy playSimilar utility |
ui/src/utils/index.js | Dropped export for playSimilar |
ui/src/subsonic/index.js | Added getTopSongs API wrapper |
ui/src/i18n/en.json | Added “play” and “noTopSongsFound” translation keys |
ui/src/artist/utils.js | New helpers: playTopSongs , playSimilar , playShuffle |
ui/src/artist/ArtistActions.jsx | Imported PlayArrowIcon, added Play button and handler |
ui/src/artist/ArtistActions.test.jsx | Updated tests for Play action, renamed createMuiTheme |
Comments suppressed due to low confidence (1)
ui/src/artist/utils.js:4
- The parameter
id
in playTopSongs is ambiguous and is actually used for the artist identifier. Rename it toartistId
(orartistName
) and adjust usages so it takesrecord.id
consistently.
export const playTopSongs = async (dispatch, notify, id) => {
Signed-off-by: Deluan <deluan@navidrome.org>
b9cbe8a
to
b346fc6
Compare
* ui: add Play button to artist toolbar * refactor Signed-off-by: Deluan <deluan@navidrome.org> * test(ui): add tests for Play button functionality in ArtistActions Signed-off-by: Deluan <deluan@navidrome.org> * ui: update Play button label to Top Songs in ArtistActions Signed-off-by: Deluan <deluan@navidrome.org> --------- Signed-off-by: Deluan <deluan@navidrome.org>
Summary
Testing
npm run lint
npm run check-formatting
npm test
npm run type-check
make test
https://chatgpt.com/codex/tasks/task_b_68475a045d58832e806aedb0c71466d1