Skip to content

Fix playlist Crop throwing instead of removing unselected tracks - #1388

Merged
captbaritone merged 1 commit into
masterfrom
fix-playlist-crop
Nov 16, 2026
Merged

captbaritone merged 1 commit into
masterfrom
fix-playlist-crop

Conversation

@captbaritone

Copy link
Copy Markdown
Owner

"Crop" in the playlist's Remove menu throws instead of removing the unselected tracks, and has since 2.2.0. In Sentry this is WEBAMP-1PQ (TypeError: n.has is not a function), 880 events since September 2025 and still arriving daily.

2dee12e ("Avoid non-serializable object in Redux store") changed state.playlist.selectedTracks from a Set to an array and added getSelectedTrackIdsSet for callers that need .has(). cropPlaylist still used getSelectedTrackIds and called .has() on the array. A // @ts-ignore on that line, left over from an older number-keys workaround, hid the type error.

This switches cropPlaylist to getSelectedTrackIdsSet and removes the @ts-ignore, which is no longer needed now that trackOrder is number[]. cropPlaylist was the only remaining caller that treated the selection as a Set.

Steps to reproduce (on webamp.org today)

  1. Open https://webamp.org/.
  2. In the playlist window, click a track to select it.
  3. Click REM at the bottom-left of the playlist, then CROP.
  4. Expected: every other track is removed. Actual: nothing happens, and the console shows TypeError: n.has is not a function.

Test plan

  • New js/actionCreators/playlist.test.ts: with tracks 1, 2 and 3 and track 2 selected, cropPlaylist() dispatches REMOVE_TRACKS with ids [1, 3]; with no selection it dispatches nothing. Before the fix the first test fails with selectedTrackIds.has is not a function, the same error as production.
  • Repeated the steps above against the dev server: CROP now leaves only the selected track, with no console errors.
  • tsc, eslint, prettier --check and vitest run (233 tests) pass.

Not changed here: REMOVE_TRACKS keeps the selected ids that were removed (filter((id) => actionIds.has(id))), which looks inverted. After a crop the kept track ends up deselected. That predates this regression, so I left it for a separate change.

🤖 Generated with Claude Code

2dee12e stored the playlist selection as an array rather than a Set, but
cropPlaylist still called .has() on it. A @ts-ignore on that line hid the
type error, so Crop has thrown "selectedTrackIds.has is not a function"
since 2.2.0. Use the Set selector and drop the stale @ts-ignore.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@netlify

netlify Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for tourmaline-kringle-c98715 ready!

Name Link
🔨 Latest commit 8cfba5d
🔍 Latest deploy log https://app.netlify.com/projects/tourmaline-kringle-c98715/deploys/6afa53609c767027860b0313
😎 Deploy Preview https://deploy-preview-1388--tourmaline-kringle-c98715.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions

Copy link
Copy Markdown

Size Change: +2 B (0%)

Total Size: 491 kB

📦 View Changed
Filename Size Change
packages/webamp/built/webamp.bundle.min.js 298 kB +1 B (0%)
packages/webamp/built/webamp.lazy-bundle.min.js 193 kB +1 B (0%)

compressed-size-action

@captbaritone
captbaritone merged commit 155ffb0 into master Nov 16, 2026
9 checks passed
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