Remove uid from playback#14193
Merged
Merged
Conversation
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
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, withcollectionId/sourceas 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— dropuid?: UIDfromPlaybackTrackandQueueable; addcollectionId?: IDfor analytics.slice.ts— replaceplayingUidstate withplayingIndex; dropremoveByUidreducer; changereorderto take an index array (orderedIndices) instead of a uid array; dropuidfromplay/set/playSucceededpayloads;setnow requiresindex.selectors.ts— dropgetUid,getCurrentEntryUid,getUidInQueue,getOrder; addgetPlayingIndex;getCollectionIdnow readsPlaybackTrack.collectionIdinstead of parsing it out of a uid string;makeGetCurrent()returns{ trackId, index, source }.Web saga (
packages/web/src/common/store/playback/sagas.ts)makeUidimport + usage inplayCurrentandqueueAutoplay.index(fromgetPlaybackIndex) throughplaySucceededinstead ofuid.getUidfrom the reset-after-autoplay branch — onlygetTrackIdis needed.Mobile AudioPlayer (
packages/mobile/src/components/audio/AudioPlayer.tsx)queueTrackUids: string[](compared withisEqual) toqueueTrackIds: ID[]— duplicates are still distinguished position-by-position.previousUid && !uidstop-detection withpreviousPlayingTrackId && !playingTrackId.updatePlayerInfo({ trackId, uid })→updatePlayerInfo({ trackId, index }).Chat playback (
packages/common/src/hooks/chats/useTrackPlayer.ts)useToggleTrackandusePlayTrackno longer take a uid; the "is this tile playing" check is now(currentQueueItem.trackId === id && currentQueueItem.source === source).Data layer
useCollectionTracksWithUid→useOrderedCollectionTracks;CollectionTrackWithUid→ plainTrackMetadatare-exported asCollectionTrack. 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.ts—togglePlay(uid, trackId)→togglePlay(trackId, index?);isActive = uid === playingUid→isActive = id === playingTrackId.PlayBarProvider,PlayBar(desktop + mobile),SocialActions— drop uid selectors and props.CookieBanner,usePlaylistPlayingStatus— switch togetHasTrack/collectionId === id.feed-page/types.ts,trending-page/types.ts— dropUIDfrom 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.uidfields. Each needs the same shape of rewrite — replace uid comparisons with(trackId, source, collectionId)and pass(trackId, index)throughtogglePlaychains. 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.tsxpackages/web/src/pages/collection-page/useCollectionPage.tspackages/web/src/pages/collection-page/components/mobile/CollectionPage.tsxpackages/web/src/pages/pick-winners-page/PickWinnersPage.tsxpackages/web/src/pages/fan-club-detail-page/components/FanClubFeedSection.tsxpackages/web/src/pages/visualizer/VisualizerProvider.tsxpackages/web/src/pages/search-explore-page/components/desktop/TileHelpers.tsxpackages/web/src/components/now-playing/NowPlaying.tsxpackages/web/src/components/lineup/TrackLineup.tsxpackages/web/src/components/track/{desktop,mobile}/CollectionTile.tsxpackages/web/src/components/track/mobile/{TrackTile,TrackListItem,TrackList}.tsxMobile:
packages/mobile/src/components/lineup-tile/{TrackTile,CollectionTile,CollectionTileTrackList}.tsxpackages/mobile/src/components/track-list/{TrackList,TrackListItem}.tsxpackages/mobile/src/components/now-playing-drawer/NowPlayingDrawer.tsxpackages/mobile/src/components/lineup/TrackLineup.tsxpackages/mobile/src/screens/chat-screen/ChatMessagePlaylist.tsxpackages/mobile/src/screens/track-screen/TrackScreenDetailsTile.tsxpackages/mobile/src/screens/explore-screen/components/TrackTileCarousel.tsxTest plan
npm run verifyclean once consumer fixups landreordernow takes index array)https://claude.ai/code/session_01GMw8KhWviP9LhvCMKB4nFu
Generated by Claude Code