Skip to content

feat(api-server): Improved api-server volume and like/dislike state #3592

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

rewhex
Copy link

@rewhex rewhex commented Jul 10, 2025

This PR includes a couple of small but useful improvements to the api-server:

Volume State Endpoint:
The volume state endpoint now includes a new isMuted boolean. It was a single state volume level before, now it also has isMuted property, to detect whether volume button is pressed (just what the /v1/toggle-mute does).

New Like State Endpoint:
Added a new endpoint: GET /v1/like-state
It returns the current song's like/dislike status, using the same values: LIKE, DISLIKE, INDIFFERENT as YouTube Music already has.

@JellyBrick JellyBrick requested a review from Copilot July 11, 2025 14:42
@JellyBrick JellyBrick added the enhancement New feature or request label Jul 11, 2025
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 enhances the API server by extending volume state with mute information and introducing a new like/dislike state endpoint.

  • Add VolumeState type with isMuted
  • Introduce setup and IPC for like/dislike changes in the front-end provider
  • Update MPRIS, song-controls, and backend routes to handle LikeType and VolumeState

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/types/datahost-get-state.ts Add VolumeState interface alongside existing enums
src/providers/song-info-front.ts Implement setupLikeChangedListener and enrich volume IPC with isMuted
src/providers/song-controls.ts Use LikeType enums for update-like IPC calls
src/plugins/shortcuts/mpris.ts Adapt MPRIS handler to consume VolumeState and mute logic
src/plugins/api-server/backend/types.ts Extend backend context type with LikeType and VolumeState
src/plugins/api-server/backend/routes/control.ts Define new getLikeState route and update getVolumeState schema
src/plugins/api-server/backend/main.ts Wire up ytmd:like-changed IPC and pass new getters to route registration
Comments suppressed due to low confidence (2)

src/plugins/api-server/backend/routes/control.ts:90

  • Add tests for the new GET /api/v1/like-state endpoint and update tests for GET /api/v1/volume-state to verify the isMuted field is returned correctly.
  getLikeState: createRoute({

src/types/datahost-get-state.ts:48

  • [nitpick] Consider adding a TSDoc comment above VolumeState to describe its purpose and fields (state vs isMuted) for clearer code documentation.
export interface VolumeState {

@rewhex
Copy link
Author

rewhex commented Jul 13, 2025

@JellyBrick hello, I've fixed copilot's comments, can you please merge this PR?

: LikeType.Indifferent;

export const setupLikeChangedListener = singleton(() => {
const likeDislikeObserver = new MutationObserver((mutations) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the use of MutationObserver strictly necessary in this part?

Copy link
Author

Choose a reason for hiding this comment

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

Hmm, I don't think we can trigger state change by something else. Like any other controls (volume for example) we can get the buttons state with this and show it to the user.

Screenshot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants