[PR #660] [MERGED] fix(spotify/game): target SDK device when no playback session is active #4716

Closed
opened 2026-10-22 04:10:04 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/660
Author: @Romuromylus
Created: 5/10/2026
Status: ✅ Merged
Merged: 5/10/2026
Merged by: @Romuromylus

Base: main ← Head: fix/spotify-game-device-fallback


📝 Commits (1)

  • a4b0941 fix(spotify/game): target SDK device when no playback session is active

📊 Changes

2 files changed (+52 additions, -6 deletions)

View changed files

📝 packages/client/src/components/game/GameSurface.tsx (+1 -1)
📝 packages/server/src/services/spotify/game-spotify-music.service.ts (+51 -5)

📄 Description

Linked issue

Closes #659

Why this change

Game Mode scene music silently fails with a generic "Spotify scene music failed." toast whenever the user has no currently-active Spotify playback session, even when the in-app Web Playback SDK has registered "Marinara Engine" as an available device. The play call is sent without a device_id, so Spotify returns 404 NO_ACTIVE_DEVICE. This is the common case for users on the web build who haven't manually started Spotify elsewhere.

What changed

  • packages/server/src/services/spotify/game-spotify-music.service.ts
    • New findAvailablePlaybackDevice helper that calls GET /me/player/devices and picks a target (active → "Marinara Engine" SDK device by name → any non-restricted device).
    • playGameSpotifyTrack now falls back to this helper when the active-session snapshot has no deviceId, and uses the resolved id consistently in the play request and both setSpotifyRepeat calls.
    • When no device is available, returns 404 with an actionable error message ("Enable the Spotify mini player in Settings, or open Spotify on another device, then try again.") instead of a raw Spotify 404.
  • packages/client/src/components/game/GameSurface.tsx
    • playSpotifySceneTrack now surfaces error.message in the toast instead of the generic "Spotify scene music failed.", so the new actionable hint reaches the user.

The mini-player's manual playback flow (SpotifyMiniPlayer.runControl) already passes a device_id from the SDK ready event and is unaffected.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Manually verify on a fresh Spotify connection with the mini player enabled and no other Spotify app running: enter Game Mode with source = Liked Songs (or Any Spotify), trigger a scene, and confirm music plays through the in-browser SDK device. Without this fix the toast reads "Spotify scene music failed."; with it, audio plays.
  • Manually verify the "no device at all" path: disable the mini player and don't open Spotify anywhere else, then trigger a scene — the toast should now read "No Spotify device is available. Enable the Spotify mini player in Settings, or open Spotify on another device, then try again." instead of the generic failure.
  • Manually verify the existing-active-session path still works (e.g. Spotify desktop already playing): the snapshot path still provides deviceId and the fallback isn't invoked.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

N/A — the visible change is the toast text path; no layout or theming changes.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced Spotify error messaging to display specific error details instead of generic fallback messages.
    • Improved device selection for Spotify playback with additional fallback options.
    • Strengthened repeat state handling for game music with automatic retry logic.

Review Change Stack


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/660 **Author:** [@Romuromylus](https://github.com/Romuromylus) **Created:** 5/10/2026 **Status:** ✅ Merged **Merged:** 5/10/2026 **Merged by:** [@Romuromylus](https://github.com/Romuromylus) **Base:** `main` ← **Head:** `fix/spotify-game-device-fallback` --- ### 📝 Commits (1) - [`a4b0941`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a4b0941e1788b22ed195fecd511bf6851197d4b3) fix(spotify/game): target SDK device when no playback session is active ### 📊 Changes **2 files changed** (+52 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/game/GameSurface.tsx` (+1 -1) 📝 `packages/server/src/services/spotify/game-spotify-music.service.ts` (+51 -5) </details> ### 📄 Description ## Linked issue Closes #659 ## Why this change Game Mode scene music silently fails with a generic "Spotify scene music failed." toast whenever the user has no currently-active Spotify playback session, even when the in-app Web Playback SDK has registered "Marinara Engine" as an available device. The play call is sent without a `device_id`, so Spotify returns 404 `NO_ACTIVE_DEVICE`. This is the common case for users on the web build who haven't manually started Spotify elsewhere. ## What changed - `packages/server/src/services/spotify/game-spotify-music.service.ts` - New `findAvailablePlaybackDevice` helper that calls `GET /me/player/devices` and picks a target (active → "Marinara Engine" SDK device by name → any non-restricted device). - `playGameSpotifyTrack` now falls back to this helper when the active-session snapshot has no `deviceId`, and uses the resolved id consistently in the play request and both `setSpotifyRepeat` calls. - When no device is available, returns 404 with an actionable error message ("Enable the Spotify mini player in Settings, or open Spotify on another device, then try again.") instead of a raw Spotify 404. - `packages/client/src/components/game/GameSurface.tsx` - `playSpotifySceneTrack` now surfaces `error.message` in the toast instead of the generic "Spotify scene music failed.", so the new actionable hint reaches the user. The mini-player's manual playback flow (`SpotifyMiniPlayer.runControl`) already passes a `device_id` from the SDK `ready` event and is unaffected. ## Validation - [x] `pnpm check` passes locally - [x] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [x] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes - Manually verify on a fresh Spotify connection with the mini player enabled and no other Spotify app running: enter Game Mode with source = Liked Songs (or Any Spotify), trigger a scene, and confirm music plays through the in-browser SDK device. Without this fix the toast reads "Spotify scene music failed."; with it, audio plays. - Manually verify the "no device at all" path: disable the mini player and don't open Spotify anywhere else, then trigger a scene — the toast should now read "No Spotify device is available. Enable the Spotify mini player in Settings, or open Spotify on another device, then try again." instead of the generic failure. - Manually verify the existing-active-session path still works (e.g. Spotify desktop already playing): the snapshot path still provides `deviceId` and the fallback isn't invoked. ## Docs and release impact - [x] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) N/A — the visible change is the toast text path; no layout or theming changes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Enhanced Spotify error messaging to display specific error details instead of generic fallback messages. * Improved device selection for Spotify playback with additional fallback options. * Strengthened repeat state handling for game music with automatic retry logic. [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Pasta-Devs/Marinara-Engine/pull/660) <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:10:04 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#4716
No description provided.