Skip to content

Remove uid from playback#14193

Merged
dylanjeffers merged 2 commits into
mainfrom
claude/remove-uid-references-YHDqv
Apr 30, 2026
Merged

Remove uid from playback#14193
dylanjeffers merged 2 commits into
mainfrom
claude/remove-uid-references-YHDqv

Conversation

@dylanjeffers
Copy link
Copy Markdown
Contributor

Summary

Strips the per-queue-entry UID concept from the playback module entirely, replacing it with (queue index, trackId). Duplicates in the queue are disambiguated by index; tile-highlight comparisons fall back to trackId-only, with collectionId / source as the disambiguator for the same track in different rendering contexts.

This is the foundation pass. About half the consumer fixups are also in this PR — the rest (~15 files, mechanical rewrites) are listed under Remaining Work below. The build will not typecheck until those are done.

What changed (foundation — complete)

Playback module (packages/common/src/store/playback/)

  • types.ts — drop uid?: UID from PlaybackTrack and Queueable; add collectionId?: ID for analytics.
  • slice.ts — replace playingUid state with playingIndex; drop removeByUid reducer; change reorder to take an index array (orderedIndices) instead of a uid array; drop uid from play / set / playSucceeded payloads; set now requires index.
  • selectors.ts — drop getUid, getCurrentEntryUid, getUidInQueue, getOrder; add getPlayingIndex; getCollectionId now reads PlaybackTrack.collectionId instead of parsing it out of a uid string; makeGetCurrent() returns { trackId, index, source }.

Web saga (packages/web/src/common/store/playback/sagas.ts)

  • Drop makeUid import + usage in playCurrent and queueAutoplay.
  • Plumb index (from getPlaybackIndex) through playSucceeded instead of uid.
  • Drop getUid from the reset-after-autoplay branch — only getTrackId is needed.

Mobile AudioPlayer (packages/mobile/src/components/audio/AudioPlayer.tsx)

  • Switch the RNTrackPlayer diffing loop from queueTrackUids: string[] (compared with isEqual) to queueTrackIds: ID[] — duplicates are still distinguished position-by-position.
  • Replace previousUid && !uid stop-detection with previousPlayingTrackId && !playingTrackId.
  • updatePlayerInfo({ trackId, uid })updatePlayerInfo({ trackId, index }).

Chat playback (packages/common/src/hooks/chats/useTrackPlayer.ts)

  • useToggleTrack and usePlayTrack no longer take a uid; the "is this tile playing" check is now (currentQueueItem.trackId === id && currentQueueItem.source === source).
  • Behavior change: if the same trackId appears in two messages of the same chat thread, both tiles will highlight together when that track plays. (Today they're disambiguated by uid.) Acceptable for chat UX.

Data layer

  • useCollectionTracksWithUiduseOrderedCollectionTracks; CollectionTrackWithUid → plain TrackMetadata re-exported as CollectionTrack. The hook no longer rebuilds per-collection uids; it just returns the tracks in playlist order.

Consumers also fixed up

  • TrackListItem (desktop), TrackTile (desktop), components/track/types.tstogglePlay(uid, trackId)togglePlay(trackId, index?); isActive = uid === playingUidisActive = id === playingTrackId.
  • PlayBarProvider, PlayBar (desktop + mobile), SocialActions — drop uid selectors and props.
  • CookieBanner, usePlaylistPlayingStatus — switch to getHasTrack / collectionId === id.
  • feed-page/types.ts, trending-page/types.ts — drop UID from prop signatures.

Remaining Work (not in this PR — build will not typecheck until done)

These files still reference removed selectors (getUid, getOrder, getCurrentEntryUid, getUidInQueue), removed types (CollectionTrackWithUid), or build queue entries with .uid fields. Each needs the same shape of rewrite — replace uid comparisons with (trackId, source, collectionId) and pass (trackId, index) through togglePlay chains. The legacy queue removal (#14186) is the model.

Web:

  • packages/web/src/pages/library-page/hooks/useLibraryPage.ts (~887 lines, deeply uid-integrated)
  • packages/web/src/pages/library-page/components/mobile/LibraryPage.tsx
  • packages/web/src/pages/collection-page/useCollectionPage.ts
  • packages/web/src/pages/collection-page/components/mobile/CollectionPage.tsx
  • packages/web/src/pages/pick-winners-page/PickWinnersPage.tsx
  • packages/web/src/pages/fan-club-detail-page/components/FanClubFeedSection.tsx
  • packages/web/src/pages/visualizer/VisualizerProvider.tsx
  • packages/web/src/pages/search-explore-page/components/desktop/TileHelpers.tsx
  • packages/web/src/components/now-playing/NowPlaying.tsx
  • packages/web/src/components/lineup/TrackLineup.tsx
  • packages/web/src/components/track/{desktop,mobile}/CollectionTile.tsx
  • packages/web/src/components/track/mobile/{TrackTile,TrackListItem,TrackList}.tsx

Mobile:

  • packages/mobile/src/components/lineup-tile/{TrackTile,CollectionTile,CollectionTileTrackList}.tsx
  • packages/mobile/src/components/track-list/{TrackList,TrackListItem}.tsx
  • packages/mobile/src/components/now-playing-drawer/NowPlayingDrawer.tsx
  • packages/mobile/src/components/lineup/TrackLineup.tsx
  • packages/mobile/src/screens/chat-screen/ChatMessagePlaylist.tsx
  • packages/mobile/src/screens/track-screen/TrackScreenDetailsTile.tsx
  • packages/mobile/src/screens/explore-screen/components/TrackTileCarousel.tsx

Test plan

  • npm run verify clean once consumer fixups land
  • Click-to-play on trending / feed / profile / collection / library / search pages
  • Queue reorder via NowPlaying drawer (reorder now takes index array)
  • Same-track-in-two-messages chat playback (acceptable highlight behavior change)
  • Mobile RNTrackPlayer queue diffing on rapid next/prev presses
  • PlaylistLibrary "currently playing" indicator
  • Listen analytics + recommendation autoplay near end of queue

https://claude.ai/code/session_01GMw8KhWviP9LhvCMKB4nFu


Generated by Claude Code

Strips the per-queue-entry UID concept from the playback module entirely.
Identity is now (queue index, trackId) — duplicates in the queue are
disambiguated by index, and tile-highlight comparisons fall back to
trackId-only (with collectionId/source as the disambiguator for the same
track in different contexts).

Foundation changes (complete):
- packages/common/src/store/playback/types.ts: drop `uid?: UID` from
  PlaybackTrack and Queueable, add `collectionId?: ID` for analytics
- packages/common/src/store/playback/slice.ts: replace `playingUid` state
  with `playingIndex`, drop `removeByUid` reducer, change `reorder` to
  use index arrays, drop uid from play/set/playSucceeded payloads
- packages/common/src/store/playback/selectors.ts: drop getUid,
  getCurrentEntryUid, getUidInQueue, getOrder; add getPlayingIndex; route
  getCollectionId through the new entry field; rewrite makeGetCurrent to
  return {trackId, index, source}
- packages/web/src/common/store/playback/sagas.ts: drop makeUid usage and
  the uid plumbing through play/playSucceeded; getCollectionId now sources
  from PlaybackTrack.collectionId
- packages/mobile/src/components/audio/AudioPlayer.tsx: switch
  queueTrackUids -> queueTrackIds for RNTrackPlayer diffing; replace
  previousUid stop-detection with previousPlayingTrackId; drop uid from
  set() payloads
- packages/common/src/hooks/chats/useTrackPlayer.ts: drop uid identity,
  compare playing-tile by (trackId, source); accept the minor edge case
  where the same trackId in two messages of the same chat highlight
  together
- packages/common/src/api/tan-query/collection/useCollectionTracksWithUid.ts:
  rename hook to useOrderedCollectionTracks, drop CollectionTrackWithUid
  in favor of plain TrackMetadata (re-exported as CollectionTrack)

Consumer fixups (partial — see Remaining):
- TrackListItem desktop, TrackTile desktop, types.ts: togglePlay sigs and
  isActive comparisons updated to (trackId, index)
- PlayBarProvider, PlayBar desktop+mobile, SocialActions: dropped uid
  selectors and props
- CookieBanner, usePlaylistPlayingStatus: switched to getHasTrack /
  collectionId comparisons
- feed-page/types, trending-page/types: dropped UID from prop signatures

Remaining (not yet wired up — build will not typecheck until done):
- packages/web/src/pages/library-page (useLibraryPage, mobile LibraryPage)
- packages/web/src/pages/collection-page (useCollectionPage, mobile)
- packages/web/src/pages/pick-winners-page/PickWinnersPage.tsx
- packages/web/src/pages/fan-club-detail-page/components/FanClubFeedSection.tsx
- packages/web/src/pages/visualizer/VisualizerProvider.tsx
- packages/web/src/components/now-playing/NowPlaying.tsx
- packages/web/src/components/lineup/TrackLineup.tsx
- packages/web/src/components/track/{desktop,mobile}/CollectionTile.tsx
- packages/web/src/components/track/mobile/{TrackTile,TrackListItem,TrackList}.tsx
- packages/mobile/src/components/lineup-tile/* (TrackTile, CollectionTile, CollectionTileTrackList)
- packages/mobile/src/components/track-list/{TrackList,TrackListItem}.tsx
- packages/mobile/src/components/now-playing-drawer/NowPlayingDrawer.tsx
- packages/mobile/src/components/lineup/TrackLineup.tsx
- packages/mobile/src/screens/{chat-screen/ChatMessagePlaylist,track-screen/TrackScreenDetailsTile,explore-screen/components/TrackTileCarousel}.tsx
- packages/web/src/pages/search-explore-page/components/desktop/TileHelpers.tsx

These remaining files reference removed selectors (getUid, getOrder,
getCurrentEntryUid), removed types (CollectionTrackWithUid), or build
queueables with .uid fields. Each needs a small rewrite to compare by
trackId/source/collectionId and pass (trackId, index) through togglePlay
chains. The legacy queue removal PR pattern (#14186) is the model.

https://claude.ai/code/session_01GMw8KhWviP9LhvCMKB4nFu
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 29, 2026

⚠️ No Changeset found

Latest commit: 4220ef2

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

@dylanjeffers dylanjeffers changed the title Remove uid from playback (foundation; consumers WIP) Remove uid from playback Apr 30, 2026
@dylanjeffers dylanjeffers merged commit a47293c into main Apr 30, 2026
13 of 14 checks passed
@dylanjeffers dylanjeffers deleted the claude/remove-uid-references-YHDqv branch April 30, 2026 19:11
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.

2 participants