Skip to content

Complete Theme System + AI-Powered Smart Playlist Sorting#86

Merged
vas2000-emu merged 124 commits into
mainfrom
playlist-order-ai
Dec 1, 2025
Merged

Complete Theme System + AI-Powered Smart Playlist Sorting#86
vas2000-emu merged 124 commits into
mainfrom
playlist-order-ai

Conversation

@vas2000-emu

Copy link
Copy Markdown
Contributor

Overview

This PR introduces two major features: a complete theme system with dark/light/system/custom modes, and AI-powered smart playlist sorting using OpenAI.


🎨 Theme System

Features:

  • Dark, light, system, and custom color themes
  • Theme-aware styling across 25+ components
  • CSS variables for consistent theming
  • Persistent theme preferences (cookies + localStorage)
  • Custom color picker for personalized themes

Key Changes:

  • Replaced all hardcoded colors with CSS variables (var(--foreground), var(--background), etc.)
  • Added [data-theme='light'] variants for all components
  • Fixed input/textarea, buttons, cards, modals to be fully theme-aware
  • Maintains "liquid glass" aesthetic in all themes

Files: app/globals.css, components/providers/ThemeProvider.jsx, components/ThemeToggle.jsx, 25+ component/page files


🎵 AI-Powered Smart Sorting

Features:

  • Automatic playlist/song reordering on import using OpenAI GPT-4o-mini
  • Multi-source metadata: Spotify, Last.fm, MusicBrainz
  • Intelligent ordering based on genres, artists, popularity, audio features
  • Rate limiting with exponential backoff retry logic

Database:

  • Migration 007_add_smart_sorting.sql adds smart_sorted_order columns
  • New indexes for efficient sorted queries

New Files:

  • lib/services/musicMetadata.js - Fetches metadata from 3 APIs
  • lib/services/openaiSorting.js - AI analysis with retry logic
  • lib/db/smartSorting.js - Database functions
  • app/api/groups/[groupId]/smart-sort/route.js - API endpoint

Modified:

  • app/api/import-playlist/route.js - Auto-triggers sorting
  • app/groups/[id]/page.jsx - Displays sorted order

Env Vars: OPENAI_API_KEY (required), LASTFM_API_KEY, MUSICBRAINZ_USER_AGENT (optional)

Rate Limiting: Last.fm (5 req/s), MusicBrainz (1 req/s), OpenAI retry with 2s/4s/8s backoff

vas2000-emu and others added 30 commits September 13, 2025 23:13
- Remove Privacy and Notifications tabs from settings navigation
- Delete privacy and notifications page files
- Improve mobile responsiveness with better padding and layouts
- Enhance SettingsNav mobile menu (slides from right, better touch targets)
- Add notification bell icon to Navbar (desktop and mobile)
- Create NotificationBell and NotificationDropdown components
- Create useNotifications hook with placeholder data
- Optimize form inputs for mobile (better touch handling, responsive text)
- Update conflict resolution handlers to remove privacy/notifications cases
- Add old-pbi/ and pbi-77/ to .gitignore

All settings now focus on essential features: Profile and Account only.
- Add Privacy section between Profile and Account in settings
- Implement toggle for 'Allow others to find me when searching for friends' (searchable)
- Implement radio group for Song of the Day visibility (Public/Friends Only/Private)
- Update users search API to respect searchable privacy setting
- Filter out non-searchable users from friend search results
- Add 'Export to YouTube' button to group playlist view
  - Button only visible for users with YouTube/Google accounts
  - Works for both individual and 'All Playlists' views
  - Uses Youtube icon from lucide-react

- Create /api/export/youtube POST endpoint
  - Authenticates user via Supabase session
  - Validates playlistId and groupId parameters
  - Fetches songs from playlist_songs table (ordered by position/created_at)
  - Creates YouTube playlist using YouTube Data API v3
  - Returns playlist URL and metadata

- Fix middleware to allow API routes to handle their own auth
  - API routes can now return proper JSON error responses (401, etc.)
  - Prevents unwanted redirects to sign-in page for API endpoints

Note: Requires Supabase configuration:
- Google OAuth scope: youtube.force-ssl
- RLS policy fix for youtube_tokens table
See pbi-72/SUPABASE-YOUTUBE-SETUP-REQUIRED.md for setup guide
- Added youtube.force-ssl scope to Google OAuth sign-in
- This enables playlist creation/management permissions
- Users will see a new consent screen requesting YouTube permissions
…& add

- Implemented search-and-add loop for songs using YouTube Search API
- Added sequential processing with 100ms rate limiting between requests
- Implemented robust error handling for search failures and quota limits
- Added detailed result tracking (successful/failed songs with reasons)
- Returns comprehensive response with song counts and error details
- Gracefully handles quota exceeded errors (testing pending quota reset)

Testing Notes:
- Feature implementation complete and validated in logs
- Hit YouTube API quota limit during testing (resets midnight PT)
- Will validate full success with smaller playlist tomorrow

Related Files:
- apps/web/app/api/export/youtube/route.js
- memory-bank/progress.md
- memory-bank/architecture.md
- memory-bank/code-review-notes.md
- Connected frontend UI to API using React Query useMutation
- Added loading states and user feedback with toast notifications
- Removed temporary console.log debugging statements (kept console.error for error handling)
- Updated progress.md to mark feature as COMPLETE
- Rewrote code-review-notes.md into cohesive presentation script
- Updated architecture.md with frontend integration details
Comment thread apps/web/app/api/spotify/create-playlist/route.js Fixed
@vercel vercel Bot temporarily deployed to Preview – vybe December 1, 2025 14:56 Inactive
@vas2000-emu vas2000-emu merged commit 55f3fb8 into main Dec 1, 2025
6 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.

8 participants