[GH-ISSUE #1810] [Issue]: Spotify DJ source and playback parity regressions in refactor #890

Closed
opened 2026-10-21 05:23:00 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Xelvanis on GitHub (Jun 1, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1810

Originally assigned to: @cha1latte on GitHub.

Summary

Spotify DJ and mini-player behavior on the refactor line appears to have lost several legacy behaviors around source constraints, playback fallback, and token storage.

Key gaps found by static comparison:

  • Game Mode Spotify DJ source choices are saved, but runtime candidate lookup ignores Liked Songs, Playlist, Artist, and Any Spotify constraints and always performs generic Spotify search.
  • Scene music playback and mini-player controls do not retry/fallback across active or available Spotify devices the way legacy did, so idle or stale Spotify Connect state can fail playback/control actions.
  • Spotify OAuth tokens are persisted as plain strings in agent settings JSON, while legacy encrypted stored Spotify tokens before persistence.

Expected behavior

  • Game Mode Spotify DJ honors the selected music source: liked songs, configured playlist, configured artist, or broad Spotify search.
  • Scene music playback finds an available Spotify device when /me/player has no active device, gives a clear no-device error when none exists, and sets repeat-track behavior for scene music.
  • Mini-player controls retry against the active Spotify device when a selected device is stale or restricted.
  • Spotify tokens are protected at rest, or any plaintext local-storage decision is documented as intentional.

Actual behavior

  • src/features/modes/game/api/game-api.ts maps enableSpotifyDj, gameSpotifySourceType, gameSpotifyPlaylistId, and gameSpotifyArtist into chat metadata, but spotifyCandidates() only calls spotifyApi.searchTracks() with a simple text query and recent URI filter. It does not pass or apply the saved source metadata.
  • src-tauri/src/commands/storage/integrations/spotify.rs game_spotify_play() sends one /me/player/play request with the optional deviceId; it does not find an available device, clear/set repeat state, or retry after Spotify settles.
  • The same Rust integration's player_control(), player_volume(), player_shuffle(), and player_repeat() send one Spotify API request with the supplied deviceId; they do not retry without device_id on stale-device or restriction errors.
  • save_spotify_tokens() writes spotifyAccessToken and spotifyRefreshToken directly into agent settings. FileStorage persists collections as pretty JSON files.

Legacy reference points from the old server/client implementation:

  • packages/server/src/services/spotify/game-spotify-music.service.ts honored liked, playlist, artist, and any source types, indexed/scored source tracks, excluded recent tracks, and returned source labels/modes.
  • packages/server/src/services/spotify/game-spotify-music.service.ts found available playback devices, handled mobile-only device selection, cleared repeat before scene track playback, then set repeat to track after playback settled.
  • packages/server/src/routes/spotify-auth.routes.ts used a shared player-control helper that retried against the active Spotify device when a requested device was not found or hit a restriction error.
  • packages/server/src/routes/spotify-auth.routes.ts and packages/server/src/services/spotify/spotify.service.ts encrypted Spotify access and refresh tokens before writing settings.

Steps to reproduce

  1. Create or edit a Game Mode setup with Spotify DJ music enabled.
  2. Choose Playlist or Artist as the Spotify music source and save the game.
  3. Start or continue a scene where Spotify candidates are requested.
  4. Observe that the refactor candidate path uses generic Spotify search rather than the configured source.
  5. Try scene playback or mini-player controls when Spotify has no active playback device or a stale selected device.
  6. Inspect the persisted Spotify agent settings after connecting Spotify.

Impact area

  • App shell, navigation, startup, or providers
  • Catalog resources
  • Chat mode
  • Roleplay mode
  • Game mode
  • Shared mode UI
  • Runtime systems: generation, world-state, visuals, tracker, or haptics
  • Professor Mari or shell tools
  • React-free engine behavior, contracts, agents, or capability ports
  • Shared API wrapper or remote runtime routing
  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime
  • Docs, contributor workflow, or templates

Environment

  • Branch or commit: refactor-line worktree at 6cc9d086
  • Run mode: not run; static code comparison only
  • OS + version: not relevant to static comparison
  • Node + pnpm versions: not run
  • Rust version, if relevant: not run
  • Remote Runtime URL configured? not relevant to static comparison
  • Provider, model, or integration, if relevant: Spotify integration, Spotify DJ agent, Spotify mini player

Logs, screenshots, or video

No runtime logs or screenshots. Evidence is static source comparison between current refactor files and the legacy implementation paths listed above.

Regression notes

This appears to be a legacy parity regression. The legacy implementation supported source-aware candidate selection, Spotify device fallback/retry behavior, scene repeat-track handling, and encrypted Spotify token persistence.

Additional context

Suggested repair order:

  1. Restore source-aware Game Mode candidate lookup and scene playback fallback/repeat behavior.
  2. Add a focused Rust helper for Spotify player-control retry and reuse it for mini-player controls and game playback.
  3. Decide token-at-rest policy for the refactor runtime; encrypt/migrate tokens or document plaintext storage as intentional.
  4. Review Spotify redirect behavior and docs separately, since the refactor hardcodes http://127.0.0.1:8754/spotify/callback while UI copy still references SPOTIFY_REDIRECT_URI.

Template check

Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Xelvanis on GitHub (Jun 1, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1810 Originally assigned to: @cha1latte on GitHub. ## Summary Spotify DJ and mini-player behavior on the refactor line appears to have lost several legacy behaviors around source constraints, playback fallback, and token storage. Key gaps found by static comparison: - Game Mode Spotify DJ source choices are saved, but runtime candidate lookup ignores `Liked Songs`, `Playlist`, `Artist`, and `Any Spotify` constraints and always performs generic Spotify search. - Scene music playback and mini-player controls do not retry/fallback across active or available Spotify devices the way legacy did, so idle or stale Spotify Connect state can fail playback/control actions. - Spotify OAuth tokens are persisted as plain strings in agent settings JSON, while legacy encrypted stored Spotify tokens before persistence. ## Expected behavior - Game Mode Spotify DJ honors the selected music source: liked songs, configured playlist, configured artist, or broad Spotify search. - Scene music playback finds an available Spotify device when `/me/player` has no active device, gives a clear no-device error when none exists, and sets repeat-track behavior for scene music. - Mini-player controls retry against the active Spotify device when a selected device is stale or restricted. - Spotify tokens are protected at rest, or any plaintext local-storage decision is documented as intentional. ## Actual behavior - `src/features/modes/game/api/game-api.ts` maps `enableSpotifyDj`, `gameSpotifySourceType`, `gameSpotifyPlaylistId`, and `gameSpotifyArtist` into chat metadata, but `spotifyCandidates()` only calls `spotifyApi.searchTracks()` with a simple text query and recent URI filter. It does not pass or apply the saved source metadata. - `src-tauri/src/commands/storage/integrations/spotify.rs` `game_spotify_play()` sends one `/me/player/play` request with the optional `deviceId`; it does not find an available device, clear/set repeat state, or retry after Spotify settles. - The same Rust integration's `player_control()`, `player_volume()`, `player_shuffle()`, and `player_repeat()` send one Spotify API request with the supplied `deviceId`; they do not retry without `device_id` on stale-device or restriction errors. - `save_spotify_tokens()` writes `spotifyAccessToken` and `spotifyRefreshToken` directly into agent settings. `FileStorage` persists collections as pretty JSON files. Legacy reference points from the old server/client implementation: - `packages/server/src/services/spotify/game-spotify-music.service.ts` honored `liked`, `playlist`, `artist`, and `any` source types, indexed/scored source tracks, excluded recent tracks, and returned source labels/modes. - `packages/server/src/services/spotify/game-spotify-music.service.ts` found available playback devices, handled mobile-only device selection, cleared repeat before scene track playback, then set repeat to `track` after playback settled. - `packages/server/src/routes/spotify-auth.routes.ts` used a shared player-control helper that retried against the active Spotify device when a requested device was not found or hit a restriction error. - `packages/server/src/routes/spotify-auth.routes.ts` and `packages/server/src/services/spotify/spotify.service.ts` encrypted Spotify access and refresh tokens before writing settings. ## Steps to reproduce 1. Create or edit a Game Mode setup with Spotify DJ music enabled. 2. Choose `Playlist` or `Artist` as the Spotify music source and save the game. 3. Start or continue a scene where Spotify candidates are requested. 4. Observe that the refactor candidate path uses generic Spotify search rather than the configured source. 5. Try scene playback or mini-player controls when Spotify has no active playback device or a stale selected device. 6. Inspect the persisted Spotify agent settings after connecting Spotify. ## Impact area - [x] App shell, navigation, startup, or providers - [ ] Catalog resources - [ ] Chat mode - [ ] Roleplay mode - [x] Game mode - [ ] Shared mode UI - [x] Runtime systems: generation, world-state, visuals, tracker, or haptics - [x] Professor Mari or shell tools - [x] React-free engine behavior, contracts, agents, or capability ports - [x] Shared API wrapper or remote runtime routing - [x] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime - [ ] Docs, contributor workflow, or templates ## Environment - Branch or commit: refactor-line worktree at `6cc9d086` - Run mode: not run; static code comparison only - OS + version: not relevant to static comparison - Node + pnpm versions: not run - Rust version, if relevant: not run - Remote Runtime URL configured? not relevant to static comparison - Provider, model, or integration, if relevant: Spotify integration, Spotify DJ agent, Spotify mini player ## Logs, screenshots, or video No runtime logs or screenshots. Evidence is static source comparison between current refactor files and the legacy implementation paths listed above. ## Regression notes This appears to be a legacy parity regression. The legacy implementation supported source-aware candidate selection, Spotify device fallback/retry behavior, scene repeat-track handling, and encrypted Spotify token persistence. ## Additional context Suggested repair order: 1. Restore source-aware Game Mode candidate lookup and scene playback fallback/repeat behavior. 2. Add a focused Rust helper for Spotify player-control retry and reuse it for mini-player controls and game playback. 3. Decide token-at-rest policy for the refactor runtime; encrypt/migrate tokens or document plaintext storage as intentional. 4. Review Spotify redirect behavior and docs separately, since the refactor hardcodes `http://127.0.0.1:8754/spotify/callback` while UI copy still references `SPOTIFY_REDIRECT_URI`. ## Template check Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:23:00 +07:00
Author
Owner

@cha1latte commented on GitHub (Jun 1, 2026):

fixed in #1845

<!-- gh-comment-id:4596833174 --> @cha1latte commented on GitHub (Jun 1, 2026): fixed in #1845
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#890
No description provided.