[PR #1751] [MERGED] Fix Spotify DJ malformed scene fallback #5260

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1751
Author: @cha1latte
Created: 5/31/2026
Status: ✅ Merged
Merged: 5/31/2026
Merged by: @cha1latte

Base: refactor ← Head: fix/issue-1540-spotify-dj-malformed-recovery


📝 Commits (2)

  • 41ab234 Fix Spotify DJ malformed scene fallback
  • e9a4772 Address Spotify candidate review feedback

📊 Changes

3 files changed (+316 additions, -10 deletions)

View changed files

➕ src/engine/modes/game/scene/game-scene-analysis.service.test.ts (+274 -0)
📝 src/engine/modes/game/scene/game-scene-analysis.service.ts (+39 -7)
📝 src/engine/modes/game/scene/scene-postprocess.ts (+3 -3)

📄 Description

## Linked issue

Closes #1540

Why this change

  • Game Spotify DJ scene analysis could return malformed JSON and lose playback selection even when valid Spotify candidate tracks were already fetched.

What changed

  • Distinguish malformed scene-analysis JSON from valid empty analysis.
  • Fall back to the first Spotify candidate only when game Spotify music is enabled and parsing fails.
  • Added regression coverage for malformed output, explicit null selection, no-candidate fallback, and Spotify-disabled fallback.

Refactor impact

Primary owner:

Engine game scene analysis.

Impact areas reviewed:

  • Game mode Spotify scene music selection.
  • Game surface playback consumer path.

Boundary notes:

  • Kept the fix in src/engine.
  • Did not change generic agent executor behavior.
  • Did not add a UI-only fallback.

Pressure points touched:

  • Game scene analysis service.

Validation

  • Matching validation command passes locally (for example pnpm typecheck, pnpm build, pnpm check:architecture, pnpm check:docs, or full pnpm check when warranted)
  • pnpm check passes locally before PR push/handoff, including the unused-code check
  • pnpm typecheck passes locally
  • pnpm build passes locally
  • pnpm check:architecture passes locally
  • pnpm check:docs passes locally
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passes locally
  • Rust clippy/tests were run for Rust behavior changes
  • Browser or Tauri app manual verification completed
  • Browser screenshot/recording evidence added when UI/browser state is the claim
  • Remote runtime smoke checked when relevant

Manual verification notes

Codex ran:

  • pnpm test src/engine/modes/game/scene/game-scene-analysis.service.test.ts
  • pnpm typecheck
  • pnpm check

No browser/Tauri manual verification was run; this is engine logic covered by unit tests.

Docs and release impact

  • No docs changes needed
  • Updated README.md
  • Updated CONTRIBUTING.md
  • Updated docs/developer/
  • Updated repo skills or AGENTS.md
  • Confirmed this PR does not restore old staging/package-workspace/release claims

UI evidence

N/A; no visible UI changes.

Summary by CodeRabbit

  • Bug Fixes

    • Improved scene analysis robustness by better handling malformed responses from the AI model.
    • Enhanced fallback logic for music selection when scene analysis data is incomplete or invalid.
  • Tests

    • Added comprehensive test coverage for scene analysis, including edge cases for data validation and fallback behavior.

🔄 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/1751 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/31/2026 **Status:** ✅ Merged **Merged:** 5/31/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/issue-1540-spotify-dj-malformed-recovery` --- ### 📝 Commits (2) - [`41ab234`](https://github.com/Pasta-Devs/Marinara-Engine/commit/41ab2342236ab842918758c5c437f1323a7e9b04) Fix Spotify DJ malformed scene fallback - [`e9a4772`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e9a47728e4d3c00fed4ae9f8c2cdcda7c5837ed9) Address Spotify candidate review feedback ### 📊 Changes **3 files changed** (+316 additions, -10 deletions) <details> <summary>View changed files</summary> ➕ `src/engine/modes/game/scene/game-scene-analysis.service.test.ts` (+274 -0) 📝 `src/engine/modes/game/scene/game-scene-analysis.service.ts` (+39 -7) 📝 `src/engine/modes/game/scene/scene-postprocess.ts` (+3 -3) </details> ### 📄 Description ## Linked issue Closes #1540 ## Why this change - Game Spotify DJ scene analysis could return malformed JSON and lose playback selection even when valid Spotify candidate tracks were already fetched. ## What changed - Distinguish malformed scene-analysis JSON from valid empty analysis. - Fall back to the first Spotify candidate only when game Spotify music is enabled and parsing fails. - Added regression coverage for malformed output, explicit null selection, no-candidate fallback, and Spotify-disabled fallback. ## Refactor impact Primary owner: Engine game scene analysis. Impact areas reviewed: - Game mode Spotify scene music selection. - Game surface playback consumer path. Boundary notes: - Kept the fix in `src/engine`. - Did not change generic agent executor behavior. - Did not add a UI-only fallback. Pressure points touched: - Game scene analysis service. ## Validation - [ ] Matching validation command passes locally (for example `pnpm typecheck`, `pnpm build`, `pnpm check:architecture`, `pnpm check:docs`, or full `pnpm check` when warranted) - [ ] `pnpm check` passes locally before PR push/handoff, including the unused-code check - [ ] `pnpm typecheck` passes locally - [ ] `pnpm build` passes locally - [ ] `pnpm check:architecture` passes locally - [ ] `pnpm check:docs` passes locally - [ ] `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passes locally - [ ] Rust clippy/tests were run for Rust behavior changes - [ ] Browser or Tauri app manual verification completed - [ ] Browser screenshot/recording evidence added when UI/browser state is the claim - [ ] Remote runtime smoke checked when relevant ### Manual verification notes Codex ran: - `pnpm test src/engine/modes/game/scene/game-scene-analysis.service.test.ts` - `pnpm typecheck` - `pnpm check` No browser/Tauri manual verification was run; this is engine logic covered by unit tests. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [ ] Confirmed this PR does not restore old staging/package-workspace/release claims ## UI evidence N/A; no visible UI changes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved scene analysis robustness by better handling malformed responses from the AI model. * Enhanced fallback logic for music selection when scene analysis data is incomplete or invalid. * **Tests** * Added comprehensive test coverage for scene analysis, including edge cases for data validation and fallback behavior. <!-- 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:14:41 +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#5260
No description provided.