[PR #2560] [MERGED] feat(agents): add YouTube DJ agent with in-app embedded player #5657

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2560
Author: @Romuromylus
Created: 6/14/2026
Status: ✅ Merged
Merged: 6/14/2026
Merged by: @SpicyMarinara

Base: staging ← Head: yt-dj-pr


📝 Commits (3)

  • 2e9ba56 feat(agents): add YouTube DJ agent with in-app embedded player
  • b6147ce fix(youtube-dj): mutually exclusive game music sources + immediate stop
  • 80bd963 fix(youtube-dj): count YouTube DJ in the game agents badge

📊 Changes

22 files changed (+934 additions, -16 deletions)

View changed files

📝 packages/client/src/components/agents/AgentEditor.tsx (+153 -1)
📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+96 -2)
➕ packages/client/src/components/chat/YouTubePlayer.tsx (+272 -0)
📝 packages/client/src/components/game/GameSurface.tsx (+70 -9)
📝 packages/client/src/components/layout/TopBar.tsx (+2 -0)
📝 packages/client/src/components/panels/SettingsPanel.tsx (+8 -0)
📝 packages/client/src/hooks/use-generate.ts (+44 -0)
📝 packages/client/src/stores/agent.store.ts (+16 -0)
📝 packages/client/src/stores/ui.store.ts (+12 -1)
📝 packages/server/src/middleware/security-headers.ts (+2 -2)
📝 packages/server/src/routes/generate/retry-agents-route.ts (+13 -0)
📝 packages/server/src/routes/index.ts (+2 -0)
➕ packages/server/src/routes/youtube.routes.ts (+187 -0)
📝 packages/server/src/services/agents/agent-executor.ts (+9 -0)
📝 packages/server/src/services/storage/agents.storage.ts (+2 -0)
📝 packages/shared/scripts/generate-feature-registries.mjs (+1 -0)
📝 packages/shared/src/constants/agent-prompts.ts (+24 -0)
📝 packages/shared/src/constants/chat-mode-capabilities.ts (+2 -1)
📝 packages/shared/src/features/agents/agent-registry.generated.ts (+2 -0)
➕ packages/shared/src/features/agents/youtube/manifest.ts (+15 -0)

...and 2 more files

📄 Description

Linked issue

Closes #2559

Why this change

  • Spotify DJ is the only built-in "music that matches the scene" agent, but it requires a Spotify account, OAuth, and Premium for playback. Players who don't use Spotify (or lack Premium) had no in-app mood-music option, which is most noticeable for Game Mode ambient music.

What changed

  • shared: YouTube DJ agent manifest (pure-JSON, post_processing, off by default), youtube_control result type, and a regenerated agent registry (added youtube to the generator order, right after spotify).
  • server: /api/youtube routes — encrypted API-key storage, server-side search so the key never reaches the browser, and friendly, actionable Google API error messages (API-not-enabled, invalid/expired key, referrer restriction, quota). Agent-executor constraint bridge (<youtube_dj_constraints>, mirroring Spotify's), plus game-mode "Retry YouTube DJ" wiring.
  • client: top-bar mini player (audio survives collapsing the video), a Settings toggle, a Game Mode toggle, a "Retry YouTube DJ" entry in the game retry menu, and muting of the built-in Game Mode music library while active.
  • security: CSP allowlist for youtube.com / s.ytimg.com (script + frame).
  • Off by default; no behavior change for Spotify or any other agent.

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

pnpm check passes locally (Impeccable guard + lint + all tsc + production build). Boxes left unticked while this is a draft, pending a final maintainer pass.

Verified end-to-end on a self-hosted Docker deployment of this feature:

  • Added a free YouTube Data API key in the YouTube DJ agent settings; the key saves via "Save Key" without first needing the separate top-right Save.
  • Enabled "YouTube DJ Music" in Game Mode, started a new game, and used "Retry YouTube DJ" — the agent picked a mood-matched track, the server search returned results, and the track loaded and played in the top-bar mini player.
  • Confirmed the built-in Game Mode music library is muted while YouTube DJ is active.
  • Confirmed the Settings mini-player toggle shows/hides the player, and that hiding the video keeps audio playing.
  • Confirmed Spotify DJ still works unchanged.

Still to verify before marking ready: light/dark + mobile viewport pass, and the error paths surfaced through the friendly-error messages (invalid key, quota).

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)

No existing doc is made misleading by this additive agent. A short YouTube DJ mention could be added alongside the Spotify DJ docs if desired.

UI evidence (if applicable)

image image

Summary by CodeRabbit

  • New Features
    • YouTube DJ music generation and playback for games and chat modes
    • YouTube DJ mini-player with play/pause and volume controls
    • YouTube DJ Settings panel for API key configuration and management
    • YouTube DJ toggle in app preferences
    • Automatic mutual exclusivity between YouTube DJ and Spotify DJ in games
    • Retry option for YouTube DJ music generation

🔄 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/2560 **Author:** [@Romuromylus](https://github.com/Romuromylus) **Created:** 6/14/2026 **Status:** ✅ Merged **Merged:** 6/14/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `yt-dj-pr` --- ### 📝 Commits (3) - [`2e9ba56`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2e9ba56b0d97f6f8c36bdc90a240b19cccff11ac) feat(agents): add YouTube DJ agent with in-app embedded player - [`b6147ce`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b6147ce728867fa76df6e512c2fb2cd1a87b3bad) fix(youtube-dj): mutually exclusive game music sources + immediate stop - [`80bd963`](https://github.com/Pasta-Devs/Marinara-Engine/commit/80bd96320ebd65e72baa6cc9312035fa82a967bc) fix(youtube-dj): count YouTube DJ in the game agents badge ### 📊 Changes **22 files changed** (+934 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/agents/AgentEditor.tsx` (+153 -1) 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+96 -2) ➕ `packages/client/src/components/chat/YouTubePlayer.tsx` (+272 -0) 📝 `packages/client/src/components/game/GameSurface.tsx` (+70 -9) 📝 `packages/client/src/components/layout/TopBar.tsx` (+2 -0) 📝 `packages/client/src/components/panels/SettingsPanel.tsx` (+8 -0) 📝 `packages/client/src/hooks/use-generate.ts` (+44 -0) 📝 `packages/client/src/stores/agent.store.ts` (+16 -0) 📝 `packages/client/src/stores/ui.store.ts` (+12 -1) 📝 `packages/server/src/middleware/security-headers.ts` (+2 -2) 📝 `packages/server/src/routes/generate/retry-agents-route.ts` (+13 -0) 📝 `packages/server/src/routes/index.ts` (+2 -0) ➕ `packages/server/src/routes/youtube.routes.ts` (+187 -0) 📝 `packages/server/src/services/agents/agent-executor.ts` (+9 -0) 📝 `packages/server/src/services/storage/agents.storage.ts` (+2 -0) 📝 `packages/shared/scripts/generate-feature-registries.mjs` (+1 -0) 📝 `packages/shared/src/constants/agent-prompts.ts` (+24 -0) 📝 `packages/shared/src/constants/chat-mode-capabilities.ts` (+2 -1) 📝 `packages/shared/src/features/agents/agent-registry.generated.ts` (+2 -0) ➕ `packages/shared/src/features/agents/youtube/manifest.ts` (+15 -0) _...and 2 more files_ </details> ### 📄 Description ## Linked issue Closes #2559 ## Why this change - Spotify DJ is the only built-in "music that matches the scene" agent, but it requires a Spotify account, OAuth, and Premium for playback. Players who don't use Spotify (or lack Premium) had no in-app mood-music option, which is most noticeable for Game Mode ambient music. ## What changed - **shared:** YouTube DJ agent manifest (pure-JSON, `post_processing`, off by default), `youtube_control` result type, and a regenerated agent registry (added `youtube` to the generator order, right after `spotify`). - **server:** `/api/youtube` routes — encrypted API-key storage, server-side search so the key never reaches the browser, and friendly, actionable Google API error messages (API-not-enabled, invalid/expired key, referrer restriction, quota). Agent-executor constraint bridge (`<youtube_dj_constraints>`, mirroring Spotify's), plus game-mode "Retry YouTube DJ" wiring. - **client:** top-bar mini player (audio survives collapsing the video), a Settings toggle, a Game Mode toggle, a "Retry YouTube DJ" entry in the game retry menu, and muting of the built-in Game Mode music library while active. - **security:** CSP allowlist for `youtube.com` / `s.ytimg.com` (script + frame). - Off by default; no behavior change for Spotify or any other agent. ## 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 `pnpm check` passes locally (Impeccable guard + lint + all `tsc` + production build). Boxes left unticked while this is a draft, pending a final maintainer pass. Verified end-to-end on a self-hosted Docker deployment of this feature: - Added a free YouTube Data API key in the YouTube DJ agent settings; the key saves via "Save Key" without first needing the separate top-right Save. - Enabled "YouTube DJ Music" in Game Mode, started a new game, and used "Retry YouTube DJ" — the agent picked a mood-matched track, the server search returned results, and the track loaded and played in the top-bar mini player. - Confirmed the built-in Game Mode music library is muted while YouTube DJ is active. - Confirmed the Settings mini-player toggle shows/hides the player, and that hiding the video keeps audio playing. - Confirmed Spotify DJ still works unchanged. Still to verify before marking ready: light/dark + mobile viewport pass, and the error paths surfaced through the friendly-error messages (invalid key, quota). ## 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) No existing doc is made misleading by this additive agent. A short YouTube DJ mention could be added alongside the Spotify DJ docs if desired. ## UI evidence (if applicable) <img width="2538" height="568" alt="image" src="https://github.com/user-attachments/assets/8ac4264f-778f-4b30-9c8e-ca3cb767a4e9" /> <img width="2539" height="645" alt="image" src="https://github.com/user-attachments/assets/d86101cb-497b-4557-9454-e7150b79bf8b" /> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * YouTube DJ music generation and playback for games and chat modes * YouTube DJ mini-player with play/pause and volume controls * YouTube DJ Settings panel for API key configuration and management * YouTube DJ toggle in app preferences * Automatic mutual exclusivity between YouTube DJ and Spotify DJ in games * Retry option for YouTube DJ music generation <!-- 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:18:13 +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#5657
No description provided.