[PR #3951] [MERGED] Fix background streaming and Music DJ rotation #6171

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/3951
Author: @SpicyMarinara
Created: 7/22/2026
Status: ✅ Merged
Merged: 7/22/2026
Merged by: @SpicyMarinara

Base: staging ← Head: agent/fix-streaming-music-dj


📝 Commits (4)

  • e326c60 Fix background streaming and Music DJ rotation
  • 4ee8149 Merge branch 'staging' into agent/fix-streaming-music-dj
  • d5a4d81 test: strengthen streaming and Spotify regressions
  • 9a3e6d9 Merge remote-tracking branch 'origin/staging' into agent/fix-streaming-music-dj

📊 Changes

8 files changed (+216 additions, -22 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 packages/client/src/components/game/GameSurface.tsx (+4 -4)
📝 packages/client/src/lib/api-client.ts (+43 -14)
📝 packages/server/src/routes/game.routes.ts (+4 -1)
📝 packages/server/src/services/tools/tool-executor.ts (+4 -2)
📝 packages/shared/src/types/spotify.ts (+3 -0)
📝 scripts/regressions/prompt.regression.ts (+70 -0)
📝 scripts/regressions/roleplay-streaming.regression.ts (+86 -1)

📄 Description

Why

A healthy streamed reply could be replaced by the fully persisted message when Marinara regained visibility after being backgrounded, making the reply appear all at once. Music DJ also retained only a small, inconsistent recent-track window, so 50-song candidate batches from very large playlists could recycle the same choices too quickly.

No linked issue. This is a maintainer-directed fix from direct user reports.

What changed

  • Keep healthy SSE readers connected after tab resume and wait through a 20-second no-progress grace period before using persisted-response recovery.
  • Preserve the stalled-stream fallback when a resumed connection truly stops making progress.
  • Use one shared 250-track Spotify recent-history limit across Game state, server metadata, and Music DJ candidate selection.
  • Add deterministic regression coverage for both behaviors.

Validation

  • pnpm check passed on the integrated worktree before the PR split.
  • pnpm regression:prompt passed, including the 50-candidate large-playlist case.
  • pnpm regression:roleplay passed, including healthy and stalled visibility-resume streams.
  • git diff --check passed for this branch.

Manual verification

  • Manually verify a reply keeps visibly streaming while Marinara is backgrounded on another monitor and after focus returns.
  • Manually verify Music DJ rotates choices across a real large Spotify playlist over repeated selections.

Risk

The automated tests cover the stream state machine and candidate exclusion window. Real multi-monitor browser scheduling and live Spotify playback remain manual verification items.

Summary by CodeRabbit

  • Bug Fixes
    • Improved recovery for live responses when a backgrounded tab becomes visible again.
    • Added a grace period to allow stalled streams to recover before restoring the saved full response.
    • Expanded Music DJ recent-track history to 250 Spotify tracks, reducing near-term repeats across larger playlists.

🔄 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/3951 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 7/22/2026 **Status:** ✅ Merged **Merged:** 7/22/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `agent/fix-streaming-music-dj` --- ### 📝 Commits (4) - [`e326c60`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e326c606513f04bb90e83c6cbcc97c250be539d5) Fix background streaming and Music DJ rotation - [`4ee8149`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4ee8149298fa8313a70de1cff1d5a7d604011449) Merge branch 'staging' into agent/fix-streaming-music-dj - [`d5a4d81`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d5a4d81610b4894e3ab153d4356948b9317055c1) test: strengthen streaming and Spotify regressions - [`9a3e6d9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9a3e6d92e8415cd2875e96c4ec1cab02e87f5432) Merge remote-tracking branch 'origin/staging' into agent/fix-streaming-music-dj ### 📊 Changes **8 files changed** (+216 additions, -22 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `packages/client/src/components/game/GameSurface.tsx` (+4 -4) 📝 `packages/client/src/lib/api-client.ts` (+43 -14) 📝 `packages/server/src/routes/game.routes.ts` (+4 -1) 📝 `packages/server/src/services/tools/tool-executor.ts` (+4 -2) 📝 `packages/shared/src/types/spotify.ts` (+3 -0) 📝 `scripts/regressions/prompt.regression.ts` (+70 -0) 📝 `scripts/regressions/roleplay-streaming.regression.ts` (+86 -1) </details> ### 📄 Description ## Why A healthy streamed reply could be replaced by the fully persisted message when Marinara regained visibility after being backgrounded, making the reply appear all at once. Music DJ also retained only a small, inconsistent recent-track window, so 50-song candidate batches from very large playlists could recycle the same choices too quickly. No linked issue. This is a maintainer-directed fix from direct user reports. ## What changed - Keep healthy SSE readers connected after tab resume and wait through a 20-second no-progress grace period before using persisted-response recovery. - Preserve the stalled-stream fallback when a resumed connection truly stops making progress. - Use one shared 250-track Spotify recent-history limit across Game state, server metadata, and Music DJ candidate selection. - Add deterministic regression coverage for both behaviors. ## Validation - `pnpm check` passed on the integrated worktree before the PR split. - `pnpm regression:prompt` passed, including the 50-candidate large-playlist case. - `pnpm regression:roleplay` passed, including healthy and stalled visibility-resume streams. - `git diff --check` passed for this branch. ## Manual verification - [ ] Manually verify a reply keeps visibly streaming while Marinara is backgrounded on another monitor and after focus returns. - [ ] Manually verify Music DJ rotates choices across a real large Spotify playlist over repeated selections. ## Risk The automated tests cover the stream state machine and candidate exclusion window. Real multi-monitor browser scheduling and live Spotify playback remain manual verification items. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved recovery for live responses when a backgrounded tab becomes visible again. * Added a grace period to allow stalled streams to recover before restoring the saved full response. * Expanded Music DJ recent-track history to 250 Spotify tracks, reducing near-term repeats across larger playlists. <!-- 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-23 04:07:47 +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#6171
No description provided.