Skip to content

feat(ui): add Now Playing panel and integrate now playing count updates #4209

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 8 commits into from
Jun 10, 2025

Conversation

deluan
Copy link
Member

@deluan deluan commented Jun 10, 2025

Summary

This PR adds a "Now Playing" panel to the Navidrome UI that displays currently playing tracks from all users. The panel shows real-time information about what music is being played across the system. This panel is only visible to admins.

Features

  • Now Playing Panel: A new slide-out panel accessible from the app bar
  • Real-time Updates: Uses server-sent events to update the count of currently playing tracks
  • Responsive Design: Works on both desktop and mobile with appropriate styling
  • User Information: Displays username, player name, and current track information
  • Artist Navigation: Clicking on artist names navigates to the artist page

Technical Implementation

Backend Changes

  • Enhanced the play tracker to send NowPlayingCount events via the event broker
  • Added proper event handling for tracking when tracks start/stop playing
  • Integrated with the existing scrobbler system for seamless operation

Frontend Changes

  • Added NowPlayingPanel component with Material-UI design
  • Implemented event stream handling for real-time count updates
  • Added responsive panel behavior (full-screen on mobile, sidebar on desktop)
  • Integrated with existing navigation and artist linking functionality

Key Components

  • NowPlayingPanel.jsx: Main panel component with data fetching and display logic
  • Enhanced event stream handling for nowPlayingCount events
  • Proper loading states and error handling

Testing

  • Added comprehensive tests for the new components
  • Fixed race conditions in existing test suites
  • All linting and formatting checks pass
  • Full test suite passes including race condition detection

Breaking Changes

None. This is a purely additive feature that doesn't modify existing functionality.

@Copilot Copilot AI review requested due to automatic review settings June 10, 2025 19:41
gemini-code-assist[bot]

This comment was marked as duplicate.

Copilot

This comment was marked as outdated.

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

This pull request introduces a "Now Playing" panel to the UI, providing real-time updates on currently playing tracks across all users. The backend changes involve enhancing the play tracker to send NowPlayingCount events, and the frontend adds the NowPlayingPanel component with Material-UI, event stream handling for count updates, and responsive design.

Overall, the changes are well-implemented, particularly the backend event handling and the structure of the new UI component. The tests for both backend and frontend additions are comprehensive.

There are a couple of areas to consider for improvement:

  • The conditional rendering of the NowPlayingPanel in the AppBar seems to restrict its visibility to admins under a development flag, which might not align with the feature's goal of system-wide visibility. This should be clarified.
  • Error handling in the fetchList method within NowPlayingPanel.jsx could be enhanced to provide better diagnostics during development or to inform the user if data fetching fails.

@deluan deluan linked an issue Jun 10, 2025 that may be closed by this pull request
deluan added 4 commits June 10, 2025 15:48
Signed-off-by: Deluan <deluan@navidrome.org>
…ndling

Signed-off-by: Deluan <deluan@navidrome.org>
…layout

Signed-off-by: Deluan <deluan@navidrome.org>
…garbage collection

Signed-off-by: Deluan <deluan@navidrome.org>
@deluan deluan requested a review from Copilot June 10, 2025 21:19
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

This PR introduces a new “Now Playing” panel to the Navidrome UI that displays real‐time information about currently playing tracks, and it also integrates corresponding backend event updates. Key changes include updates to the cache with expiration callbacks, expanded event stream handling with a new nowPlayingCount event, and new frontend components and tests for the panel.

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
utils/cache/simple_cache_test.go Added tests for the OnExpiration callback in the cache
utils/cache/simple_cache.go Added Len() and OnExpiration methods to the generic cache
ui/src/subsonic/index.js & index.test.js Introduced getNowPlaying and getAvatarUrl with respective tests
ui/src/reducers/activityReducer(.js/.test.js) Added nowPlayingCount support in Redux state and tests
ui/src/layout/NowPlayingPanel(.jsx/.test.jsx) Implemented the main panel component with supporting tests
ui/src/layout/AppBar.jsx Integrated the Now Playing panel into the admin’s app bar
ui/src/eventStream.js Subscribed to nowPlayingCount events
ui/src/actions/serverEvents.js Added action and event type for nowPlayingCount
server/events/events.go Added a NowPlayingCount event type
core/scrobbler/play_tracker(.go/.test.go) Updated play tracker to emit nowPlayingCount events on changes
i18n and translation files Added new translation keys for the Now Playing panel
Comments suppressed due to low confidence (1)

ui/src/layout/AppBar.jsx:123

  • [nitpick] Consider using a more descriptive configuration flag (e.g., config.showNowPlayingPanel) to clearly indicate that the feature toggles the Now Playing panel rather than activity in general.
{config.devActivityPanel && permissions === 'admin' && (<NowPlayingPanel />)}

@deluan deluan merged commit 76042ba into master Jun 10, 2025
20 checks passed
@deluan deluan deleted the now-playing branch June 10, 2025 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show What Other Users Are Playing
1 participant