Play state syncing + some nicities #15
Open
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.
To message Nick about this (UNTESTED currently)
Here is an AI slop description in case it's helpful to get up to speed fast:
Overview
This PR implements real-time synchronized playback for Jukebox, allowing multiple users to listen to music together in perfect sync. The feature includes democratic voting, personal volume control, and comprehensive error handling.
Key Features
🎧 Synchronized Playback
🗳️ Democratic Voting System
🔊 Enhanced Playback Controls
🛡️ Error Handling & Polish
Technical Implementation
Architecture Decisions
Database Changes
box_playback_statetable for sync stateskip_votestable for vote trackingAPI Endpoints Added
GET /api/boxes/:boxId/events- SSE endpointGET/PUT /api/boxes/:boxId/playback-state- Sync state managementDELETE /api/boxes/:boxId/playback-state/leader- Leader releasePOST /api/boxes/:boxId/vote-skip- Cast skip voteGET /api/boxes/:boxId/songs/:songId/votes- Get vote countFrontend Components
SyncContext- Manages sync state and SSE connectionVoteSkip- Voting UI with real-time updatesVolumeSlider- Volume control with visual feedbackConnectionStatus- Sync connection indicatorErrorBoundary- App-wide error handlingFiles Changed
Backend
server/migrations/010_add_playback_state.js- Sync state tableserver/migrations/011_add_skip_votes.js- Voting tableserver/src/index.ts- SSE endpoints and voting logicserver/src/types/db.ts- TypeScript interfacesFrontend
frontend/src/contexts/SyncContext.tsx- Sync state managementfrontend/src/components/YouTubePlayer.tsx- Integration pointfrontend/src/components/VoteSkip.tsx- Voting UIfrontend/src/components/VolumeSlider.tsx- Volume controlfrontend/src/components/ConnectionStatus.tsx- Connection indicatorfrontend/src/components/ErrorBoundary.tsx- Error handlingfrontend/src/App.tsx- Provider setup