Skip to content

fix(collection): stage playlist track removals until Apply#14418

Merged
dylanjeffers merged 1 commit into
mainfrom
feat/playlist-staged-track-removal
May 28, 2026
Merged

fix(collection): stage playlist track removals until Apply#14418
dylanjeffers merged 1 commit into
mainfrom
feat/playlist-staged-track-removal

Conversation

@dylanjeffers
Copy link
Copy Markdown
Contributor

Summary

  • The bulk Remove button on the playlist edit view dispatched removeTrackFromPlaylist per selected id, which persisted each deletion to the backend immediately — bypassing the Apply/Discard gate. Because selection is keyed by track id, a track that repeats in a playlist expanded one selection into multiple removals, so Remove could wipe more than intended.
  • Track removals are now staged in the edit-mode draft and only persisted when Apply is pressed (Undo/Discard restores them).

Changes

  • PlaylistEditModeContext now owns removedTrackIds plus a batched undo/redo stack (stageRemoval/undoRemoval/redoRemoval, canUndoRemoval/canRedoRemoval). Staged removals count toward hasChanges and are persisted in apply() by filtering playlist_contents.track_ids. They reset atomically on enter/exit/discard/apply/conflict.
  • TrackBulkActionsBar Remove stages only the selected ids (no saga, no backend write); Undo/Redo and Select-all exclude already-staged ids.
  • EditAwareTracksTable hides staged-removed rows so they disappear immediately; Undo/Discard restores them in their original position.
  • Removed the standalone TrackHistoryContext (its separate undo/redo stack could desync from the staged set across Discard/re-enter) and its provider.

Test plan

  • Enter playlist edit mode, select one track, click Remove → only that track disappears; nothing is persisted yet.
  • Press Apply → removal persists to the backend; toast reflects "Saved tracks".
  • Press Discard (or Undo) → removed tracks reappear in their original positions; no backend write occurred.
  • Remove several batches, then Undo/Redo repeatedly → staged set and table stay consistent.
  • Re-enter edit mode after applying → Undo/Redo are disabled (no stale history).
  • Select-all / Cmd-A excludes tracks already staged for removal.

🤖 Generated with Claude Code

Bulk Remove previously dispatched removeTrackFromPlaylist per selected id,
which persisted each deletion to the backend immediately. Combined with
id-based selection (a track repeated in a playlist expanded one selection
into multiple removals), this could wipe more than the user intended and
ignored the Apply/Discard gate entirely.

Removals are now staged in the edit-mode draft and only persisted when Apply
is pressed:
- PlaylistEditModeContext owns removedTrackIds plus a batched undo/redo stack;
  staged removals count toward hasChanges and are persisted in apply() by
  filtering playlist_contents.track_ids. They reset atomically on
  enter/exit/discard/apply/conflict.
- TrackBulkActionsBar's Remove stages only the selected ids (no saga, no
  backend write); Undo/Redo/Select-all exclude already-staged ids.
- EditAwareTracksTable hides staged-removed rows so they disappear
  immediately; Undo/Discard restores them in place.
- Removed the standalone TrackHistoryContext (it could desync from the staged
  set across Discard/re-enter) and its provider.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 28, 2026

⚠️ No Changeset found

Latest commit: 9eab815

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

🌐 Web preview ready

Preview URL: https://audius-web-preview-pr-14418.audius.workers.dev

Unique preview for this PR (deployed from this branch).
Workflow run

@dylanjeffers dylanjeffers merged commit c85b503 into main May 28, 2026
13 checks passed
@dylanjeffers dylanjeffers deleted the feat/playlist-staged-track-removal branch May 28, 2026 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant