[GH-ISSUE #2795] [Issue]: Mobile: Music DJ YouTube mini-player is open/visible by default (obstructive leftover state) #1420

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

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

Summary

On mobile, the floating Music DJ YouTube mini-player widget is visible by default on a fresh install — and on most upgraded installs — with no track playing and zero user opt-in. It floats over the empty Chats/CONVO screen, obstructing the UI. Two distinct defects combine: (1) the music-player defaults ship on, and (2) the visible-chrome render guard ignores playback state and ignores the very flag (youtubePlayerEnabled) whose JSDoc says the pill should only appear "when Music DJ plays a track."

AI-investigated against released 2.0.0. Verify before fixing.

Symptom & UX impact (mobile)

  • On a mobile viewport (≤ 767px), the draggable YouTube mini-player appears pinned in the corner immediately on app load.
  • It shows before the Music DJ has played anything — there is no nowPlaying, no loading, no error — yet the widget chrome renders.
  • It is mounted in the app chrome independently of any open conversation, so it floats over the empty Chats/CONVO screen (matches the user screenshot).
  • On small phones the always-on, top-of-stack (z-[60]) floating widget overlaps content and controls, and the user has no obvious way to understand why it is there (they never enabled music).

Steps to reproduce

  1. Clear site data / use a fresh profile (no marinara-engine-ui localStorage), or upgrade from a pre-v44 build without ever touching music settings.
  2. Open Marinara Engine on a mobile viewport (≤ 767px).
  3. Land on the Chats/CONVO screen with no conversation open; never invoke the Music DJ.
  4. Observe: the floating YouTube mini-player widget is already visible/obstructive in the corner, with no track playing, despite never being enabled.

Root cause (exact file:line trace)

Both the mount gate and the visible-chrome gate are musicPlayerEnabled && musicPlayerSource === "youtube" — and both of those defaults ship on — so the widget renders for every fresh (and most upgraded) installs with nothing playing.

  1. Defaults ship on — packages/client/src/stores/ui.store.ts:1077-1080:

    musicPlayerEnabled: true,                          // :1077
    musicPlayerSource: "youtube" as MusicPlayerSource, // :1078
    spotifyPlayerEnabled: false,                       // :1079
    youtubePlayerEnabled: true,                        // :1080
    

    On a brand-new install there is no persisted blob, so zustand persist does not run migrate; these initial values are the live state directly.

  2. Always mounted, ungated on conversation — packages/client/src/components/layout/AppShell.tsx:975 renders <YouTubeMobileWidget /> in the app chrome regardless of whether any chat is open.

  3. Mobile mount gate — packages/client/src/components/chat/YouTubePlayer.tsx:640-643:

    const enabled = useUIStore((s) => s.musicPlayerEnabled && s.musicPlayerSource === "youtube"); // true && true
    const isMobileViewport = useMediaQuery("(max-width: 767px)");
    if (!enabled || !isMobileViewport) return null; // does NOT short-circuit on mobile
    
  4. Visible-chrome gate ignores playback — inside the player:

    • YouTubePlayer.tsx:148 const musicPlayerActive = useUIStore((s) => s.musicPlayerEnabled && s.musicPlayerSource === "youtube");
    • YouTubePlayer.tsx:181 const active = musicPlayerActive && (mobile || desktopViewport);
    • Mobile render block YouTubePlayer.tsx:540 {active && ( — renders the floating draggable widget.
    • Desktop pill render block YouTubePlayer.tsx:607 {active && ( — same problem on desktop top bar.

    There is no gate on a track actually playing. The component already computes const hasPlayerContent = !!nowPlaying || loading || !!error; at YouTubePlayer.tsx:385, but it is never used to gate the render. So the widget is visible the moment the app loads.

  5. youtubePlayerEnabled is dead code — its JSDoc at ui.store.ts:481 says: "When true, show the Music DJ YouTube mini player when Music DJ plays a track." It is persisted, has a setter, and is maintained by migrations and the source/enabled setters, but it is never read in YouTubePlayer.tsx (grep: 0 matches). The implemented gate ignores both playback state and this flag — the opposite of the documented intent.

  6. Upgrade path inherits the widget — migration ui.store.ts:2137-2148 (version <= 44):

    const youtubeEnabled = persisted.youtubePlayerEnabled !== false; // true unless explicitly false
    if (persisted.musicPlayerEnabled === undefined) {
      persisted.musicPlayerEnabled = spotifyEnabled || youtubeEnabled; // → true
    }
    persisted.youtubePlayerEnabled = persisted.musicPlayerEnabled && persisted.musicPlayerSource === "youtube";
    

    So even users who never touched music get musicPlayerEnabled: true + musicPlayerSource: "youtube" and inherit the visible widget.

Convergent trace: ui.store.ts:481 (JSDoc intent) → ui.store.ts:1077-1080 (defaults on) / ui.store.ts:2137-2148 (upgrade derives on) → AppShell.tsx:975 (always mounted) → YouTubePlayer.tsx:640-643 (mount gate = enabled, no playback check) → YouTubePlayer.tsx:148,181 (active, no playback check) → YouTubePlayer.tsx:540/:607 ({active && ( renders chrome with nothing playing).

Suggested fix (concrete)

PRIMARY — intent-honoring, keeps the DJ working (recommended, fixes both mobile and desktop):

In packages/client/src/components/chat/YouTubePlayer.tsx, gate the visible chrome on real content using the already-computed hasPlayerContent (:385). Change the render guards from active && to active && hasPlayerContent &&:

  • Mobile block YouTubePlayer.tsx:540:
    -        {active && (
    +        {active && hasPlayerContent && (
    
  • Desktop pill block YouTubePlayer.tsx:607:
    -      {active && (
    +      {active && hasPlayerContent && (
    

This leaves the component mounted so the play effect (YouTubePlayer.tsx:217, which early-returns if (!active) return) still reacts to the DJ's youtubePlay intent, but renders no visible chrome until nowPlaying/loading/error is set. This alone resolves the user complaint ("player open/visible by default with nothing playing") on both mobile and desktop, and matches the ui.store.ts:481 JSDoc.

OPTIONAL — make music opt-in (only if the team also wants music off until enabled):

Flip defaults in ui.store.ts:1077-1080:

musicPlayerEnabled: false,            // was true
musicPlayerSource: "youtube" as MusicPlayerSource,
spotifyPlayerEnabled: false,
youtubePlayerEnabled: false,          // was true

Add a migration using the CORRECT persist version. The store is currently version: 62 (ui.store.ts:1775) with migration blocks running through version <= 61. A version <= 47 block would never run for an existing v62 install, so it must be:

if (version <= 62) {
  // Music player is now opt-in; reset everyone to off (no prior "explicitly enabled" flag exists).
  persisted.musicPlayerEnabled = false;
  persisted.spotifyPlayerEnabled = false;
  persisted.youtubePlayerEnabled = false;
}

and bump version: 62 → version: 63 at ui.store.ts:1775.

Note: with the optional defaults applied, the user must enable music via the settings panel before the DJ can play YouTube — nothing in the DJ play path (use-generate.ts → agent.store.ts setYoutubePlay) auto-enables musicPlayerEnabled. This is acceptable for opt-in but should be stated in the PR description.

DO NOT add youtubePlayerEnabled to the mount gate at YouTubePlayer.tsx:643 together with defaulting youtubePlayerEnabled: false. The DJ play path sets only youtubePlay, never youtubePlayerEnabled; if the widget is gated out of mounting it will never see the play intent, permanently breaking YouTube Music DJ playback.

Alternatives: ship PRIMARY alone (smallest, safest, fixes the reported symptom on both viewports). Add OPTIONAL only if the product decision is for music to be fully opt-in.

Affected files

  • packages/client/src/components/chat/YouTubePlayer.tsx — render guards at :540 (mobile) and :607 (desktop); hasPlayerContent at :385; gates at :148, :181, :640-643; play effect at :217.
  • packages/client/src/stores/ui.store.ts — defaults :1077-1080; JSDoc :481; persist version :1775; migrations :2137-2148 and the migration block list near :2155-2194. (Only touched if the OPTIONAL opt-in fix is applied.)
  • packages/client/src/components/layout/AppShell.tsx — mount site :975 (no change needed; reference for the always-mounted behavior).

Validation

  • Apply the PRIMARY fix (active && hasPlayerContent && at :540 and :607).
  • pnpm install then pnpm check passes (TypeScript + ESLint). No pnpm db:push needed (client-only).
  • Fresh profile (cleared marinara-engine-ui localStorage): on load with no track playing, no YouTube widget chrome is visible.
  • Trigger the Music DJ to play a track: the YouTube mini-player widget appears (PRIMARY fix keeps the component mounted and reactive).
  • Loading and error states still surface the widget (hasPlayerContent covers loading and error).
  • Desktop top-bar pill: hidden when nothing is playing; appears when the DJ plays a track.
  • If OPTIONAL opt-in applied: defaults flipped, version bumped 62 → 63, version <= 62 migration resets existing installs; confirm an upgraded profile with no explicit music choice loads with music off.
  • If OPTIONAL opt-in applied: enabling music in settings, then triggering the DJ, plays YouTube (confirm DJ playback is not broken).
  • Mobile-viewport manual check at each Display Size (≤ 767px): widget is not visible on the empty Chats/CONVO screen before playback.
    • Display Size: Small phone (~320–375px width)
    • Display Size: Standard phone (~390–414px width)
    • Display Size: Large phone / phablet (~430px width)
    • Display Size: Mobile landscape / small tablet boundary (~700–767px width)
  • Manually verify the floating widget no longer overlaps chat controls or obstructs the empty Chats screen on a real device.
  • Target the staging branch per CLAUDE.md.

AI-investigated against released 2.0.0; verify before fixing.

Originally created by @kolacheee on GitHub (Jun 22, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2795 ## Summary On mobile, the floating Music DJ **YouTube mini-player** widget is visible by default on a fresh install — and on most upgraded installs — with **no track playing and zero user opt-in**. It floats over the empty Chats/CONVO screen, obstructing the UI. Two distinct defects combine: (1) the music-player defaults ship **on**, and (2) the visible-chrome render guard ignores playback state and ignores the very flag (`youtubePlayerEnabled`) whose JSDoc says the pill should only appear "when Music DJ plays a track." > AI-investigated against released 2.0.0. Verify before fixing. ## Symptom & UX impact (mobile) - On a mobile viewport (≤ 767px), the draggable YouTube mini-player appears pinned in the corner immediately on app load. - It shows before the Music DJ has played anything — there is no `nowPlaying`, no loading, no error — yet the widget chrome renders. - It is mounted in the app chrome independently of any open conversation, so it floats over the empty **Chats/CONVO** screen (matches the user screenshot). - On small phones the always-on, top-of-stack (`z-[60]`) floating widget overlaps content and controls, and the user has no obvious way to understand why it is there (they never enabled music). ## Steps to reproduce 1. Clear site data / use a fresh profile (no `marinara-engine-ui` localStorage), **or** upgrade from a pre-v44 build without ever touching music settings. 2. Open Marinara Engine on a mobile viewport (≤ 767px). 3. Land on the Chats/CONVO screen with no conversation open; never invoke the Music DJ. 4. **Observe:** the floating YouTube mini-player widget is already visible/obstructive in the corner, with no track playing, despite never being enabled. ## Root cause (exact file:line trace) Both the mount gate and the visible-chrome gate are `musicPlayerEnabled && musicPlayerSource === "youtube"` — and both of those defaults ship **on** — so the widget renders for every fresh (and most upgraded) installs with nothing playing. 1. **Defaults ship on** — `packages/client/src/stores/ui.store.ts:1077-1080`: ```ts musicPlayerEnabled: true, // :1077 musicPlayerSource: "youtube" as MusicPlayerSource, // :1078 spotifyPlayerEnabled: false, // :1079 youtubePlayerEnabled: true, // :1080 ``` On a brand-new install there is no persisted blob, so zustand `persist` does not run `migrate`; these initial values are the live state directly. 2. **Always mounted, ungated on conversation** — `packages/client/src/components/layout/AppShell.tsx:975` renders `<YouTubeMobileWidget />` in the app chrome regardless of whether any chat is open. 3. **Mobile mount gate** — `packages/client/src/components/chat/YouTubePlayer.tsx:640-643`: ```ts const enabled = useUIStore((s) => s.musicPlayerEnabled && s.musicPlayerSource === "youtube"); // true && true const isMobileViewport = useMediaQuery("(max-width: 767px)"); if (!enabled || !isMobileViewport) return null; // does NOT short-circuit on mobile ``` 4. **Visible-chrome gate ignores playback** — inside the player: - `YouTubePlayer.tsx:148` `const musicPlayerActive = useUIStore((s) => s.musicPlayerEnabled && s.musicPlayerSource === "youtube");` - `YouTubePlayer.tsx:181` `const active = musicPlayerActive && (mobile || desktopViewport);` - Mobile render block `YouTubePlayer.tsx:540` `{active && (` — renders the floating draggable widget. - Desktop pill render block `YouTubePlayer.tsx:607` `{active && (` — same problem on desktop top bar. There is **no** gate on a track actually playing. The component already computes `const hasPlayerContent = !!nowPlaying || loading || !!error;` at `YouTubePlayer.tsx:385`, but it is never used to gate the render. So the widget is visible the moment the app loads. 5. **`youtubePlayerEnabled` is dead code** — its JSDoc at `ui.store.ts:481` says: *"When true, show the Music DJ YouTube mini player **when Music DJ plays a track**."* It is persisted, has a setter, and is maintained by migrations and the source/enabled setters, but it is **never read** in `YouTubePlayer.tsx` (grep: 0 matches). The implemented gate ignores both playback state and this flag — the opposite of the documented intent. 6. **Upgrade path inherits the widget** — migration `ui.store.ts:2137-2148` (`version <= 44`): ```ts const youtubeEnabled = persisted.youtubePlayerEnabled !== false; // true unless explicitly false if (persisted.musicPlayerEnabled === undefined) { persisted.musicPlayerEnabled = spotifyEnabled || youtubeEnabled; // → true } persisted.youtubePlayerEnabled = persisted.musicPlayerEnabled && persisted.musicPlayerSource === "youtube"; ``` So even users who never touched music get `musicPlayerEnabled: true` + `musicPlayerSource: "youtube"` and inherit the visible widget. **Convergent trace:** `ui.store.ts:481` (JSDoc intent) → `ui.store.ts:1077-1080` (defaults on) / `ui.store.ts:2137-2148` (upgrade derives on) → `AppShell.tsx:975` (always mounted) → `YouTubePlayer.tsx:640-643` (mount gate = enabled, no playback check) → `YouTubePlayer.tsx:148,181` (active, no playback check) → `YouTubePlayer.tsx:540`/`:607` (`{active && (` renders chrome with nothing playing). ## Suggested fix (concrete) **PRIMARY — intent-honoring, keeps the DJ working (recommended, fixes both mobile and desktop):** In `packages/client/src/components/chat/YouTubePlayer.tsx`, gate the **visible chrome** on real content using the already-computed `hasPlayerContent` (`:385`). Change the render guards from `active &&` to `active && hasPlayerContent &&`: - Mobile block `YouTubePlayer.tsx:540`: ```diff - {active && ( + {active && hasPlayerContent && ( ``` - Desktop pill block `YouTubePlayer.tsx:607`: ```diff - {active && ( + {active && hasPlayerContent && ( ``` This leaves the component **mounted** so the play effect (`YouTubePlayer.tsx:217`, which early-returns `if (!active) return`) still reacts to the DJ's `youtubePlay` intent, but renders **no visible chrome** until `nowPlaying`/`loading`/`error` is set. This alone resolves the user complaint ("player open/visible by default with nothing playing") on both mobile and desktop, and matches the `ui.store.ts:481` JSDoc. **OPTIONAL — make music opt-in (only if the team also wants music off until enabled):** Flip defaults in `ui.store.ts:1077-1080`: ```ts musicPlayerEnabled: false, // was true musicPlayerSource: "youtube" as MusicPlayerSource, spotifyPlayerEnabled: false, youtubePlayerEnabled: false, // was true ``` Add a migration using the **CORRECT** persist version. The store is currently `version: 62` (`ui.store.ts:1775`) with migration blocks running through `version <= 61`. A `version <= 47` block would **never** run for an existing v62 install, so it must be: ```ts if (version <= 62) { // Music player is now opt-in; reset everyone to off (no prior "explicitly enabled" flag exists). persisted.musicPlayerEnabled = false; persisted.spotifyPlayerEnabled = false; persisted.youtubePlayerEnabled = false; } ``` and bump `version: 62` → `version: 63` at `ui.store.ts:1775`. Note: with the optional defaults applied, the user must enable music via the settings panel before the DJ can play YouTube — nothing in the DJ play path (`use-generate.ts` → `agent.store.ts setYoutubePlay`) auto-enables `musicPlayerEnabled`. This is acceptable for opt-in but should be stated in the PR description. **DO NOT** add `youtubePlayerEnabled` to the mount gate at `YouTubePlayer.tsx:643` together with defaulting `youtubePlayerEnabled: false`. The DJ play path sets only `youtubePlay`, never `youtubePlayerEnabled`; if the widget is gated out of mounting it will never see the play intent, **permanently breaking YouTube Music DJ playback**. **Alternatives:** ship PRIMARY alone (smallest, safest, fixes the reported symptom on both viewports). Add OPTIONAL only if the product decision is for music to be fully opt-in. ## Affected files - `packages/client/src/components/chat/YouTubePlayer.tsx` — render guards at `:540` (mobile) and `:607` (desktop); `hasPlayerContent` at `:385`; gates at `:148`, `:181`, `:640-643`; play effect at `:217`. - `packages/client/src/stores/ui.store.ts` — defaults `:1077-1080`; JSDoc `:481`; persist `version` `:1775`; migrations `:2137-2148` and the migration block list near `:2155-2194`. (Only touched if the OPTIONAL opt-in fix is applied.) - `packages/client/src/components/layout/AppShell.tsx` — mount site `:975` (no change needed; reference for the always-mounted behavior). ## Validation - [ ] Apply the PRIMARY fix (`active && hasPlayerContent &&` at `:540` and `:607`). - [ ] `pnpm install` then `pnpm check` passes (TypeScript + ESLint). No `pnpm db:push` needed (client-only). - [ ] Fresh profile (cleared `marinara-engine-ui` localStorage): on load with no track playing, **no** YouTube widget chrome is visible. - [ ] Trigger the Music DJ to play a track: the YouTube mini-player widget appears (PRIMARY fix keeps the component mounted and reactive). - [ ] Loading and error states still surface the widget (`hasPlayerContent` covers `loading` and `error`). - [ ] Desktop top-bar pill: hidden when nothing is playing; appears when the DJ plays a track. - [ ] If OPTIONAL opt-in applied: defaults flipped, `version` bumped 62 → 63, `version <= 62` migration resets existing installs; confirm an upgraded profile with no explicit music choice loads with music off. - [ ] If OPTIONAL opt-in applied: enabling music in settings, then triggering the DJ, plays YouTube (confirm DJ playback is not broken). - [ ] Mobile-viewport manual check at each Display Size (≤ 767px): widget is **not** visible on the empty Chats/CONVO screen before playback. - [ ] Display Size: Small phone (~320–375px width) - [ ] Display Size: Standard phone (~390–414px width) - [ ] Display Size: Large phone / phablet (~430px width) - [ ] Display Size: Mobile landscape / small tablet boundary (~700–767px width) - [ ] Manually verify the floating widget no longer overlaps chat controls or obstructs the empty Chats screen on a real device. - [ ] Target the `staging` branch per CLAUDE.md. --- AI-investigated against released 2.0.0; verify before fixing.
Author
Owner

@SpicyMarinara commented on GitHub (Jun 22, 2026):

Addressed in PR #2790 / commit acab1fba: the YouTube mini-player chrome now requires actual player content/loading/error state before it appears, so the saved YouTube source alone no longer shows an empty obstructive player.

<!-- gh-comment-id:4772440950 --> @SpicyMarinara commented on GitHub (Jun 22, 2026): Addressed in PR #2790 / commit acab1fba: the YouTube mini-player chrome now requires actual player content/loading/error state before it appears, so the saved YouTube source alone no longer shows an empty obstructive player.
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#1420
No description provided.