Skip to content

Media remote controls#298

Open
anoying-kid wants to merge 14 commits into
sozercan:mainfrom
anoying-kid:media-remote-controls
Open

Media remote controls#298
anoying-kid wants to merge 14 commits into
sozercan:mainfrom
anoying-kid:media-remote-controls

Conversation

@anoying-kid

@anoying-kid anoying-kid commented Jun 10, 2026

Copy link
Copy Markdown

Description

This PR implements a robust Media Remote Control Interface that allows users to remotely control playback, manage queue items, and execute search queries on their Mac's Kaset app from a mobile browser or remote device.

AI Prompt (Optional)

🤖 AI Prompt Used
1. Implement a local control server in LocalControlServer.swift that replaces token-based URL parameters with static URLs and PIN-based authorization.
2. Build a remote control web player UI with standard controls (Play, Pause, Next, Previous, Volume), queue list display, and share/forward button.
3. Enhance the search bar UI to include category filter tabs: All, Songs, Albums, Playlists. Make clicking a song play it.
4. Implement a clear (cross) button to reset search input, and add an auto-select-all text focus behavior.
5. Upgrade SearchResponseParser.swift to navigate and parse search results nested under itemSectionRenderer blocks, restoring full search capabilities under the 'All' filter.
6. Add unit tests for itemSectionRenderer parsing to SearchResponseParserTests.swift.
7. Implement TCP chunk accumulation in LocalControlServer to ensure full HTTP POST bodies are read before processing, resolving PIN validation failures over fragmented USB-tethered links.
8. Select a single case-insensitive `.local` hostname URL as the primary QR code target in settings to prevent cluttering the interface with multiple codes, and provide simple text copy actions for alternative raw IP addresses.
9. Implement a fallback in YTMusicClient.getPlaylistAllTracks to call getPlaylist when get_queue returns no tracks, enabling the remote control Play/Play Next/Add Queue detail actions to function correctly on Albums.
10. Build a local toast notification system in the remote web control page to confirm play-next, clear-queue, and add-to-queue actions.
11. Add a 'Clear' queue button to the remote web control's queue panel, communicating with a new POST /clear_queue endpoint to purge Kaset's active queue.

AI Tool: Antigravity CLI

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 📚 Documentation update
  • 🎨 UI/UX improvement
  • ♻️ Refactoring (no functional changes)
  • 🧪 Test update
  • 🔧 Build/CI configuration

Related Issues

Fixes #199

Changes Made

  • Local Control Server & PIN Security: Replaced token URL security with an interactive PIN-approval gateway, saving device IDs to an authorized database. Implemented a recursive TCP buffer reader to correctly accumulate the full request payload before PIN validation over cable/USB-tethered links.
  • Settings View & Dynamic QR Code: Added a dynamic QR code selector allowing users to choose their active host URL. Includes warning notices for Android users when .local (mDNS) fails, prompting them to select a raw IP address.
  • Remote Web UI: Built a responsive player page with artwork rendering, playback states, volume adjustment, and full queue browsing.
  • Search & Filters: Added autocomplete search matching with filters (All, Songs, Albums, Playlists). Tapping a result triggers play/queue actions.
  • UI Enhancements: Added a clear search input cross button and an input focus handler that highlights/selects all text on tap.
  • Search Parser Upgrade: Expanded SearchResponseParser to extract search items nested within itemSectionRenderer containers, restoring "All" tab results.
  • Album Actions & Client Fallback: Implemented a fallback in getPlaylistAllTracks that falls back to getPlaylist when the queue API returns empty, restoring Play, Play Next, and Add Queue actions on Albums.
  • Action Confirmation (Toasts): Integrated a lightweight, responsive toast notification overlay on the remote web player page, rendering immediate feedback when queue actions or transport items are modified.
  • Queue Purging: Added a "Clear" button to the remote web player's Queue panel linking to a new POST /clear_queue endpoint on the server, allowing users to wipe the active playback queue.
  • Unit Tests: Added parseItemSectionRendererResults in SearchResponseParserTests ensuring 100% correct parsing behavior.

Testing

  • Unit tests pass (swift test --skip KasetUITests)
  • Manual testing performed
  • UI tested on macOS 26+

Checklist

  • My code follows the project's style guidelines
  • I have run swiftlint --strict && swiftformat .
  • I have added tests that prove my fix/feature works
  • New and existing unit tests pass locally
  • I have updated documentation if needed
  • I have checked for any performance implications
  • My changes generate no new warnings

Screenshots

Player UI

Click to expand (4 images)

Search UI

Click to expand (4 images)

Desktop UI

Click to expand (4 images)

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.

[Feature]: Local Web API / Remote Control Support

1 participant