fix(web): missing files show greyed in track lists and never enter the queue (#5418)
release / web (push) Failing after 1m23s
release / govulncheck (push) Successful in 25s
release / go (push) Successful in 1m35s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / integration (push) Canceled after 4m34s
release / android (push) Canceled after 4m39s
release / Build signed APK (releases and dev) (push) Canceled after 3m21s

TrackRef gains the unavailable flag the server already sends on album
detail and search. TrackRow greys such a row with '· File missing' and
hides like, radio, add and the menu, as playlist rows already do. Every
player-store entry point (playQueue, enqueue, play next, and a refetched
mix) drops missing files; playQueue keeps the chosen track as the start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 17:28:36 -04:00
co-authored by Claude Opus 5.5
parent 015fe1d3b2
commit 8bd2f66416
5 changed files with 88 additions and 2 deletions
+19 -1
View File
@@ -123,6 +123,12 @@ export function registerAudioEl(el: HTMLAudioElement | null): void {
_audioEl = el;
}
// #5418: a missing file can't stream, so it never enters the queue. Returns
// the same array when nothing is missing.
function playable(tracks: TrackRef[]): TrackRef[] {
return tracks.some((t) => t.unavailable) ? tracks.filter((t) => !t.unavailable) : tracks;
}
export function playQueue(
tracks: TrackRef[],
startIndex = 0,
@@ -138,8 +144,16 @@ export function playQueue(
// rotation-aware order, so no client shuffle in that path).
_queueSource = opts.source ?? null;
// #968: a fresh play replaces the self-heal closure + resets its budget.
_queueRefetch = opts.refetch ?? null;
const refetch = opts.refetch;
_queueRefetch = refetch ? () => refetch().then(playable) : null;
_selfHealAttempts = 0;
// Start on the chosen track's place in the playable list; if the chosen
// one is missing, that place holds the next playable track after it.
const all = tracks;
tracks = playable(all);
if (tracks !== all) {
startIndex = all.slice(0, startIndex).filter((t) => !t.unavailable).length;
}
if (opts.shuffle && tracks.length > 1) {
// Fisher-Yates over the whole list. startIndex is ignored — the
// caller is asking for "random play from this pool," so the first
@@ -391,6 +405,7 @@ function trySelfHeal(): boolean {
export function enqueueTrack(t: TrackRef): void {
_radioSeedId = null; // M4c
if (t.unavailable) return;
_queue = [..._queue, t];
if (_state === 'idle') _index = 0;
}
@@ -402,6 +417,7 @@ export function enqueueTrack(t: TrackRef): void {
*/
export function playNext(t: TrackRef): void {
_radioSeedId = null; // M4c: any user-driven enqueue clears the radio refresh state
if (t.unavailable) return;
if (_queue.length === 0) {
_queue = [t];
_index = 0;
@@ -413,6 +429,7 @@ export function playNext(t: TrackRef): void {
export function enqueueTracks(ts: TrackRef[]): void {
_radioSeedId = null; // M4c
ts = playable(ts);
if (ts.length === 0) return;
_queue = [..._queue, ...ts];
if (_state === 'idle') _index = 0;
@@ -423,6 +440,7 @@ export function enqueueTracks(ts: TrackRef[]): void {
// with the batch at index 0 (mirrors playNext's single-track shape).
export function playNextMany(ts: TrackRef[]): void {
_radioSeedId = null;
ts = playable(ts);
if (ts.length === 0) return;
if (_queue.length === 0) {
_queue = [...ts];