Skip to content

Fix "Save each run as new playlist" toggle never saving - #229

Closed
Gabriel-Lewis wants to merge 1 commit into
LumePart:devfrom
Gabriel-Lewis:fix/replace-playlist-toggle
Closed

Gabriel-Lewis wants to merge 1 commit into
LumePart:devfrom
Gabriel-Lewis:fix/replace-playlist-toggle

Conversation

@Gabriel-Lewis

Copy link
Copy Markdown

The Save each run as new playlist toggle in the playlist card flips back on its own and the setting is never written to .env.

Cause

saveReplacePlaylist() posts {name, replace}:

body: JSON.stringify({ name, replace }),

but HandleSaveReplacePlaylist resolves the playlist from body.ID:

if def, ok := defs.PlaylistDefs[body.ID]; ok {
    ...
} else if defs.CustomIDRe.MatchString(body.ID) {
    ...
} else {
    http.Error(w, "unknown playlist name", http.StatusBadRequest)
    return
}

body.ID is always empty, so it matches neither branch and every request returns 400. Settings.jsx rolls back its optimistic update when the save rejects:

saveReplacePlaylist(id, next).catch(() =>
  setReplacePlaylists(prev => ({ ...prev, [id]: !next }))
)

which is what makes the toggle appear to revert.

Fix

Send {id, name, replace}, matching saveSchedule() — whose handler resolves the playlist with the same PlaylistDefs / CustomIDRe logic and already receives both fields. The handler needs id to look up the definition and name to derive the env prefix for custom playlists via util.CustomEnvPrefix(body.Name).

Testing

npm run build in src/web/frontend succeeds. Verified by inspection that s.name is in scope at the call site — it is the same value already passed to saveSchedule(id, s.name, ...) a few lines above, inside the same scheduleProps(id) closure.

Workaround for anyone hitting this before it merges: add --replace-playlist=false to the relevant *_FLAGS variable in .env, which is all the handler does.

The toggle in PlaylistCard reverts immediately and the setting is never
persisted.

saveReplacePlaylist() posted {name, replace}, but HandleSaveReplacePlaylist
reads body.ID to resolve the playlist:

    if def, ok := defs.PlaylistDefs[body.ID]; ok {
    } else if defs.CustomIDRe.MatchString(body.ID) {
    } else {
        http.Error(w, "unknown playlist name", http.StatusBadRequest)

body.ID was always empty, so every request 400'd. Settings.jsx treats a
failed save as a signal to roll back its optimistic update, which is why
the toggle flips back on its own.

Send {id, name, replace} instead, matching saveSchedule() -- whose handler
resolves the playlist the same way and already receives both fields. The
handler needs id to look up the playlist definition and name to derive the
env prefix for custom playlists.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013ZuEbqv1CGbPub9kB3g2s4
@Gabriel-Lewis
Gabriel-Lewis marked this pull request as draft August 19, 2026 06:54
@Gabriel-Lewis
Gabriel-Lewis deleted the fix/replace-playlist-toggle branch August 19, 2026 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant