[PR #8640] [MERGED] fix(music): an interrupted play() no longer shows as a playback failure (#8618) #8716

Closed
opened 2026-11-07 17:39:12 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8640
Author: @SpicyMarinara
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/music-stale-play-error-8618


📝 Commits (1)

  • 3a9a07b fix(music): an interrupted play() no longer shows as a playback failure

📊 Changes

4 files changed (+100 additions, -5 deletions)

View changed files

📝 packages/client/src/components/chat/LocalMusicPlayer.tsx (+18 -5)
➕ packages/client/src/lib/local-music-playback.ts (+13 -0)
➕ scripts/regressions/local-music-playback-errors.regression.ts (+68 -0)
📝 scripts/regressions/tsconfig.client-lanes.json (+1 -0)

📄 Description

Closes #8618

Why this change

With the custom Music DJ source, the top-bar player could show "The play() request was interrupted by a c…" as its title and "Playback needs attention" as its subtitle while music was audibly playing and the pause control was showing. A transient, deliberate interruption looked like a current failure.

The reporter's diagnosis is right, and the exact sequence is: a resume through togglePlay() is still pending when the DJ picks the next track. Selecting it calls audio.pause() and audio.load(), so the browser rejects the pending play() with an AbortError. togglePlay's .catch set that as the error unconditionally — after the selection had already cleared the error — and nothing cleared it again once the new track started.

What changed

  • playbackErrorMessage(err, attempt, current) (lib/local-music-playback.ts) decides what a rejected play() shows. An AbortError (play cut short by a deliberate pause()/load()), or any rejection from an attempt a newer track superseded, shows nothing. Genuine failures — unsupported or missing file, autoplay blocked by the browser — still show the browser's own message.
  • Both play() paths (the track loader and the resume button) go through it. The resume button now records which source it resumed, so its outcome never overwrites a newer track's state, including marking it as playing.
  • The <audio> element's playing event clears any stale error, on both the desktop and the mobile player: if the element is playing, no earlier failure is current.

Validation

  • scripts/regressions/local-music-playback-errors.regression.ts (client lane): AbortError as an Error and as a DOMException shows nothing; a superseded attempt shows nothing even for a real failure; NotAllowedError, NotSupportedError, and non-Error rejections still show; both play() paths classify their rejections; both players clear on playing. Passes; on the player before this change it fails (neither path classified its rejection).
  • tsc --noEmit for the client and for the client regression lane pass; Prettier clean.

Test plan

  • With Music DJ on the Custom source, let it change tracks across several replies; confirm the title stays the track name and no "Playback needs attention" appears while music plays.
  • Press play/pause rapidly while a reply makes the DJ change track; confirm no interruption error is left behind.
  • Point the DJ at a file the browser cannot decode (or move a file away); confirm the real error still shows.
  • In a browser that blocks autoplay, confirm the "blocked" error still shows, and clears once you press play and music starts.
  • Repeat the first check in the mobile widget.

🤖 Generated with Claude Code


🔄 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/8640 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/music-stale-play-error-8618` --- ### 📝 Commits (1) - [`3a9a07b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3a9a07b8d8f64697fa7c1f1c6c660cd156d9a75f) fix(music): an interrupted play() no longer shows as a playback failure ### 📊 Changes **4 files changed** (+100 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/chat/LocalMusicPlayer.tsx` (+18 -5) ➕ `packages/client/src/lib/local-music-playback.ts` (+13 -0) ➕ `scripts/regressions/local-music-playback-errors.regression.ts` (+68 -0) 📝 `scripts/regressions/tsconfig.client-lanes.json` (+1 -0) </details> ### 📄 Description Closes #8618 ## Why this change With the custom Music DJ source, the top-bar player could show **"The play() request was interrupted by a c…"** as its title and **"Playback needs attention"** as its subtitle while music was audibly playing and the pause control was showing. A transient, deliberate interruption looked like a current failure. The reporter's diagnosis is right, and the exact sequence is: a resume through `togglePlay()` is still pending when the DJ picks the next track. Selecting it calls `audio.pause()` and `audio.load()`, so the browser rejects the pending `play()` with an `AbortError`. `togglePlay`'s `.catch` set that as the error **unconditionally** — after the selection had already cleared the error — and nothing cleared it again once the new track started. ## What changed - **`playbackErrorMessage(err, attempt, current)`** (`lib/local-music-playback.ts`) decides what a rejected `play()` shows. An `AbortError` (play cut short by a deliberate `pause()`/`load()`), or any rejection from an attempt a newer track superseded, shows nothing. Genuine failures — unsupported or missing file, autoplay blocked by the browser — still show the browser's own message. - Both `play()` paths (the track loader and the resume button) go through it. The resume button now records which source it resumed, so its outcome never overwrites a newer track's state, including marking it as playing. - The `<audio>` element's `playing` event clears any stale error, on both the desktop and the mobile player: if the element is playing, no earlier failure is current. ## Validation - `scripts/regressions/local-music-playback-errors.regression.ts` (client lane): `AbortError` as an `Error` and as a `DOMException` shows nothing; a superseded attempt shows nothing even for a real failure; `NotAllowedError`, `NotSupportedError`, and non-`Error` rejections still show; both `play()` paths classify their rejections; both players clear on `playing`. **Passes**; on the player before this change it **fails** (neither path classified its rejection). - `tsc --noEmit` for the client and for the client regression lane pass; Prettier clean. ## Test plan - [ ] With Music DJ on the Custom source, let it change tracks across several replies; confirm the title stays the track name and no "Playback needs attention" appears while music plays. - [ ] Press play/pause rapidly while a reply makes the DJ change track; confirm no interruption error is left behind. - [ ] Point the DJ at a file the browser cannot decode (or move a file away); confirm the real error still shows. - [ ] In a browser that blocks autoplay, confirm the "blocked" error still shows, and clears once you press play and music starts. - [ ] Repeat the first check in the mobile widget. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 17:39:12 +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#8716
No description provided.