Commit 33c7b755 authored by Aryan Noshirvnai's avatar Aryan Noshirvnai

Radio tuner restyle + granular snapping dial; Rooms create-as-popup;…

Radio tuner restyle + granular snapping dial; Rooms create-as-popup; live-broadcast playback semantics

- RadioTuner.tsx restyled as a lit console instead of a flat control strip.
- Rooms' always-visible create form is now a button opening CreateRoomModal,
  matching every other modal's chrome in this app.
- PlayableSong gained isLive: seek() is a no-op and resuming from pause
  re-fetches live instead of replaying stale audio frozen at the pause point.
  FullPlayer shows a LIVE badge instead of a scrub bar and disables
  Shuffle/Previous/Repeat for live content.
- Replaced the native tuning <input type="range"> with a custom pointer- and
  keyboard-driven dial: native range sensitivity is fixed to
  element-width/(max-min) with no way to slow it down, so dragging now reads
  raw pixel deltas against a fixed step instead. The dial snaps onto any
  station within the backend's own 0.3 tuning epsilon, with tick marks
  showing where each station sits.
Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
parent 0908e9d2
import { useCallback, useEffect, useRef, useState, type FormEvent } from 'react'
import { X } from 'lucide-react'
import { Button } from './ui/Button'
import { Input } from './ui/Input'
import { LocationPicker } from './LocationPicker'
import { createRoom, type LiveRoom } from '../api/social'
import { useBackButtonClose } from '../hooks/useBackButtonClose'
import { useMountTransition } from '../hooks/useMountTransition'
const ANIMATION_MS = 300
interface CreateRoomModalProps {
onCreated: (room: LiveRoom) => void
onClose: () => void
}
/** Popup for starting a new room - pulled out of Rooms.tsx's always-visible inline form
* (2026-10-12) behind a single "Create a room" button, so the room list reads as the primary
* view and creating one is a deliberate action. Same modal chrome as AddToPlaylistModal/
* SongPicker (mobile bottom sheet, desktop centered card, Escape/backdrop/system-back all
* close it) rather than inventing a new pattern. */
export function CreateRoomModal({ onCreated, onClose }: CreateRoomModalProps) {
const [name, setName] = useState('')
const [pin, setPin] = useState('')
const [tieToLocation, setTieToLocation] = useState(false)
const [latitude, setLatitude] = useState<number | null>(null)
const [longitude, setLongitude] = useState<number | null>(null)
const [submitting, setSubmitting] = useState(false)
const [error, setError] = useState<string | null>(null)
// The caller owns whether this exists in the tree at all, so calling the real onClose prop
// immediately would unmount it before its own exit transition could play - same requestClose
// indirection as every other modal in this app (see AddToPlaylistModal for the full reasoning).
const [closing, setClosing] = useState(false)
const { mounted, visible } = useMountTransition(!closing, ANIMATION_MS)
const closedRef = useRef(false)
const requestClose = useCallback(() => setClosing(true), [])
useEffect(() => {
if (!mounted && !closedRef.current) {
closedRef.current = true
onClose()
}
}, [mounted, onClose])
useEffect(() => {
function onKeyDown(e: KeyboardEvent) {
if (e.key === 'Escape') requestClose()
}
document.addEventListener('keydown', onKeyDown)
return () => document.removeEventListener('keydown', onKeyDown)
}, [requestClose])
useBackButtonClose(true, requestClose)
async function handleSubmit(e: FormEvent) {
e.preventDefault()
if (!name.trim()) return
setSubmitting(true)
setError(null)
try {
const room = await createRoom(name.trim(), {
pin: pin || undefined,
latitude: tieToLocation && latitude !== null ? latitude : undefined,
longitude: tieToLocation && longitude !== null ? longitude : undefined,
})
// Jumping straight into the new room replaces this whole page's content anyway, so the
// modal is dropped immediately rather than playing its own exit animation first.
onCreated(room)
} catch {
setError('Could not create this room. Please try again.')
setSubmitting(false)
}
}
if (!mounted) return null
return (
<div
role="dialog"
aria-modal="true"
aria-label="Create a room"
className={`fixed inset-0 z-40 flex items-end justify-center bg-black/60 transition-opacity duration-300 ease-out motion-reduce:transition-none sm:items-center ${
visible ? 'opacity-100' : 'opacity-0'
}`}
onClick={requestClose}
>
<div
className={`flex max-h-[85vh] w-full max-w-md flex-col overflow-hidden rounded-t-2xl bg-surface-container will-change-transform transition-all duration-300 ease-out motion-reduce:transition-none sm:rounded-2xl ${
visible ? 'translate-y-0 opacity-100' : 'translate-y-full opacity-0 sm:translate-y-4'
}`}
onClick={(e) => e.stopPropagation()}
>
<div className="flex items-center justify-between border-b border-outline-variant px-4 py-3">
<p className="text-sm font-semibold text-white">Create a room</p>
<button
onClick={requestClose}
aria-label="Close"
className="shrink-0 rounded-full p-1.5 text-on-surface-variant transition-colors hover:bg-surface-container-high hover:text-on-surface focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"
>
<X size={18} strokeWidth={2} />
</button>
</div>
<form onSubmit={handleSubmit} className="space-y-3 overflow-y-auto px-4 py-4">
<Input value={name} onChange={(e) => setName(e.target.value)} placeholder="Room name" autoFocus />
<Input
value={pin}
onChange={(e) => setPin(e.target.value.replace(/\D/g, '').slice(0, 4))}
placeholder="PIN (optional)"
inputMode="numeric"
/>
<label className="flex items-center gap-2 text-sm text-on-surface-variant">
<input type="checkbox" checked={tieToLocation} onChange={(e) => setTieToLocation(e.target.checked)} />
Tie to a real-world location (lets others find it on the map)
</label>
{tieToLocation && (
<LocationPicker
latitude={latitude}
longitude={longitude}
onChange={(lat, lon) => {
setLatitude(lat)
setLongitude(lon)
}}
/>
)}
{error && <p className="text-sm text-error">{error}</p>}
<Button type="submit" disabled={submitting || !name.trim()} className="w-full">
{submitting ? 'Starting…' : 'Start'}
</Button>
</form>
</div>
</div>
)
}
...@@ -391,6 +391,20 @@ export function FullPlayer() { ...@@ -391,6 +391,20 @@ export function FullPlayer() {
</p> </p>
</div> </div>
{currentSong.isLive ? (
// Live content (Radio) has no stable timeline - the position behind the stream
// keeps moving in real time whether or not anyone's listening, so a scrub bar
// would only ever be able to lie about "where" playback is. A plain indicator
// replaces it instead of a disabled-looking range input.
<div className="flex items-center justify-center gap-1.5 py-[7px]">
<span className="relative flex h-2 w-2">
<span className="absolute inline-flex h-full w-full animate-ping rounded-full bg-primary opacity-75" />
<span className="relative inline-flex h-2 w-2 rounded-full bg-primary" />
</span>
<span className="text-xs font-bold uppercase tracking-widest text-primary">Live</span>
</div>
) : (
<>
<input <input
type="range" type="range"
min={0} min={0}
...@@ -417,14 +431,17 @@ export function FullPlayer() { ...@@ -417,14 +431,17 @@ export function FullPlayer() {
</> </>
)} )}
</div> </div>
</>
)}
<div className="mt-5 flex items-center justify-between"> <div className="mt-5 flex items-center justify-between">
<button <button
onClick={toggleShuffle} onClick={toggleShuffle}
disabled={currentSong.isLive}
tabIndex={queueOpen || lyricsOpen ? -1 : 0} tabIndex={queueOpen || lyricsOpen ? -1 : 0}
aria-label="Shuffle" aria-label="Shuffle"
aria-pressed={isShuffled} aria-pressed={isShuffled}
className={`rounded-full p-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary ${ className={`rounded-full p-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:opacity-30 ${
isShuffled ? 'text-primary' : 'text-on-surface-variant hover:text-on-surface' isShuffled ? 'text-primary' : 'text-on-surface-variant hover:text-on-surface'
}`} }`}
> >
...@@ -434,9 +451,10 @@ export function FullPlayer() { ...@@ -434,9 +451,10 @@ export function FullPlayer() {
<div className="flex items-center gap-8"> <div className="flex items-center gap-8">
<button <button
onClick={previous} onClick={previous}
disabled={currentSong.isLive}
tabIndex={queueOpen || lyricsOpen ? -1 : 0} tabIndex={queueOpen || lyricsOpen ? -1 : 0}
aria-label="Previous" aria-label="Previous"
className="rounded-full p-1 text-on-surface transition-colors hover:text-on-surface focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary" className="rounded-full p-1 text-on-surface transition-colors hover:text-on-surface focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:opacity-30"
> >
<SkipBack size={26} strokeWidth={2} fill="currentColor" /> <SkipBack size={26} strokeWidth={2} fill="currentColor" />
</button> </button>
...@@ -468,10 +486,11 @@ export function FullPlayer() { ...@@ -468,10 +486,11 @@ export function FullPlayer() {
<button <button
onClick={cycleRepeat} onClick={cycleRepeat}
disabled={currentSong.isLive}
tabIndex={queueOpen || lyricsOpen ? -1 : 0} tabIndex={queueOpen || lyricsOpen ? -1 : 0}
aria-label={`Repeat: ${repeatMode}`} aria-label={`Repeat: ${repeatMode}`}
aria-pressed={repeatMode !== 'off'} aria-pressed={repeatMode !== 'off'}
className={`rounded-full p-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary ${ className={`rounded-full p-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:opacity-30 ${
repeatMode !== 'off' ? 'text-primary' : 'text-on-surface-variant hover:text-on-surface' repeatMode !== 'off' ? 'text-primary' : 'text-on-surface-variant hover:text-on-surface'
}`} }`}
> >
...@@ -591,6 +610,16 @@ export function FullPlayer() { ...@@ -591,6 +610,16 @@ export function FullPlayer() {
className="relative mx-auto w-full max-w-md shrink-0 px-6 pb-4 pt-2" className="relative mx-auto w-full max-w-md shrink-0 px-6 pb-4 pt-2"
style={{ paddingBottom: 'calc(env(safe-area-inset-bottom) + 1rem)' }} style={{ paddingBottom: 'calc(env(safe-area-inset-bottom) + 1rem)' }}
> >
{currentSong.isLive ? (
<div className="mb-2 flex items-center justify-center gap-1.5">
<span className="relative flex h-2 w-2">
<span className="absolute inline-flex h-full w-full animate-ping rounded-full bg-primary opacity-75" />
<span className="relative inline-flex h-2 w-2 rounded-full bg-primary" />
</span>
<span className="text-xs font-bold uppercase tracking-widest text-primary">Live</span>
</div>
) : (
<>
<input <input
type="range" type="range"
min={0} min={0}
...@@ -611,12 +640,15 @@ export function FullPlayer() { ...@@ -611,12 +640,15 @@ export function FullPlayer() {
<span>{formatTime(progress)}</span> <span>{formatTime(progress)}</span>
<span>{formatTime(duration)}</span> <span>{formatTime(duration)}</span>
</div> </div>
</>
)}
<div className="flex items-center justify-center gap-8"> <div className="flex items-center justify-center gap-8">
<button <button
onClick={previous} onClick={previous}
disabled={currentSong.isLive}
tabIndex={lyricsOpen ? 0 : -1} tabIndex={lyricsOpen ? 0 : -1}
aria-label="Previous" aria-label="Previous"
className="rounded-full p-1 text-on-surface transition-colors hover:text-on-surface focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary" className="rounded-full p-1 text-on-surface transition-colors hover:text-on-surface focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:opacity-30"
> >
<SkipBack size={22} strokeWidth={2} fill="currentColor" /> <SkipBack size={22} strokeWidth={2} fill="currentColor" />
</button> </button>
......
import { render, screen, waitFor } from '@testing-library/react' import { fireEvent, render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event' import userEvent from '@testing-library/user-event'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { RadioTuner } from './RadioTuner' import { RadioTuner } from './RadioTuner'
...@@ -79,7 +79,7 @@ describe('RadioTuner', () => { ...@@ -79,7 +79,7 @@ describe('RadioTuner', () => {
renderTuner() renderTuner()
// The default dial (100.0) is already within epsilon of the fixture station's 100.0. // The default dial (100.0) is already within epsilon of the fixture station's 100.0.
expect(await screen.findByText('Night Drive FM')).toBeInTheDocument() expect(await screen.findByText(/Night Drive FM/)).toBeInTheDocument()
expect(await screen.findByText('Midnight Run')).toBeInTheDocument() expect(await screen.findByText('Midnight Run')).toBeInTheDocument()
expect(screen.getByText('The Band')).toBeInTheDocument() expect(screen.getByText('The Band')).toBeInTheDocument()
}) })
...@@ -96,7 +96,7 @@ describe('RadioTuner', () => { ...@@ -96,7 +96,7 @@ describe('RadioTuner', () => {
const browse = vi.spyOn(radioApi, 'browseRadios').mockResolvedValue([STATION]) const browse = vi.spyOn(radioApi, 'browseRadios').mockResolvedValue([STATION])
vi.spyOn(radioApi, 'getNowPlaying').mockResolvedValue(ON_AIR) vi.spyOn(radioApi, 'getNowPlaying').mockResolvedValue(ON_AIR)
renderTuner() renderTuner()
await screen.findByText('Night Drive FM') await screen.findByText(/Night Drive FM/)
browse.mockResolvedValue([]) browse.mockResolvedValue([])
await userEvent.click(screen.getByRole('button', { name: 'SF' })) await userEvent.click(screen.getByRole('button', { name: 'SF' }))
...@@ -131,6 +131,40 @@ describe('RadioTuner', () => { ...@@ -131,6 +131,40 @@ describe('RadioTuner', () => {
await waitFor(() => expect(favorite).toHaveBeenCalledWith(999)) await waitFor(() => expect(favorite).toHaveBeenCalledWith(999))
}) })
it('steps the frequency with arrow keys without overshooting granularity', async () => {
vi.spyOn(radioApi, 'browseRadios').mockResolvedValue([])
renderTuner()
const dial = await screen.findByLabelText('Tuning dial')
dial.focus()
fireEvent.keyDown(dial, { key: 'ArrowRight' })
expect(dial).toHaveAttribute('aria-valuenow', '100.1')
fireEvent.keyDown(dial, { key: 'ArrowLeft' })
fireEvent.keyDown(dial, { key: 'ArrowLeft' })
expect(dial).toHaveAttribute('aria-valuenow', '99.9')
fireEvent.keyDown(dial, { key: 'ArrowRight', shiftKey: true })
expect(dial).toHaveAttribute('aria-valuenow', '100.9')
})
it('snaps onto a nearby station once a drag lands within the tuning epsilon', async () => {
const otherBandStation: Radio = { ...STATION, id: 11, frequency: 120.0 }
vi.spyOn(radioApi, 'browseRadios').mockResolvedValue([otherBandStation])
renderTuner()
const dial = await screen.findByLabelText('Tuning dial')
// Starts at the default 100.0 - not within epsilon of the 120.0 station yet.
expect(dial).toHaveAttribute('aria-valuenow', '100')
fireEvent.pointerDown(dial, { pointerId: 1, clientX: 0 })
// 20.2 frequency units of drag at DIAL_PIXELS_PER_UNIT=14 - lands at 120.2, within the
// 0.3 epsilon of the fixture station's 120.0 but not exactly on it.
fireEvent.pointerMove(dial, { pointerId: 1, clientX: 20.2 * 14 })
fireEvent.pointerUp(dial, { pointerId: 1 })
expect(dial).toHaveAttribute('aria-valuenow', '120')
})
it('opens the add-to-playlist flow for the now-playing song', async () => { it('opens the add-to-playlist flow for the now-playing song', async () => {
vi.spyOn(radioApi, 'browseRadios').mockResolvedValue([STATION]) vi.spyOn(radioApi, 'browseRadios').mockResolvedValue([STATION])
vi.spyOn(radioApi, 'getNowPlaying').mockResolvedValue(ON_AIR) vi.spyOn(radioApi, 'getNowPlaying').mockResolvedValue(ON_AIR)
......
This diff is collapsed.
...@@ -22,6 +22,13 @@ export interface PlayableSong { ...@@ -22,6 +22,13 @@ export interface PlayableSong {
* browser can start playing before the whole file downloads and can seek via Range * browser can start playing before the whole file downloads and can seek via Range
* requests. */ * requests. */
streamUrl?: () => Promise<string> streamUrl?: () => Promise<string>
/** Marks a song as a live broadcast (currently Radio only) rather than an on-demand track -
* there's no stable timeline to rewind to or pause-and-resume-later on, since the position
* behind the same URL keeps moving in real time whether or not anyone is listening. FullPlayer
* hides the seek bar for these, seek() becomes a no-op, and resuming after pause re-fetches a
* fresh stream (rejoining wherever the broadcast actually is now) instead of continuing
* stale, already-played-out audio from the moment it was paused. */
isLive?: boolean
} }
export type RepeatMode = 'off' | 'all' | 'one' export type RepeatMode = 'off' | 'all' | 'one'
...@@ -217,10 +224,13 @@ export function PlayerProvider({ children }: { children: ReactNode }) { ...@@ -217,10 +224,13 @@ export function PlayerProvider({ children }: { children: ReactNode }) {
const seek = useCallback((time: number) => { const seek = useCallback((time: number) => {
const audio = audioRef.current const audio = audioRef.current
if (!audio) return // Live content (see PlayableSong.isLive) has no stable timeline to scrub - the position
// behind the URL keeps moving in real time regardless, so seeking would just land on
// whatever happens to be buffered rather than anything meaningful.
if (!audio || currentSong?.isLive) return
audio.currentTime = time audio.currentTime = time
setProgress(time) setProgress(time)
}, []) }, [currentSong])
const setVolume = useCallback((next: number) => { const setVolume = useCallback((next: number) => {
const clamped = Math.min(1, Math.max(0, next)) const clamped = Math.min(1, Math.max(0, next))
...@@ -263,6 +273,11 @@ export function PlayerProvider({ children }: { children: ReactNode }) { ...@@ -263,6 +273,11 @@ export function PlayerProvider({ children }: { children: ReactNode }) {
if (currentSong?.id === song.id) { if (currentSong?.id === song.id) {
if (isPlaying) { if (isPlaying) {
pause() pause()
} else if (song.isLive) {
// Resuming live content must rejoin wherever the broadcast actually is *now*, not
// continue the stale audio frozen at the moment it was paused - that position has
// already played out in reality whether anyone was listening or not.
playSong(song)
} else { } else {
audio.play() audio.play()
setIsPlaying(true) setIsPlaying(true)
......
...@@ -273,6 +273,59 @@ ...@@ -273,6 +273,59 @@
display: none; display: none;
} }
/* Radio's tuning dial (RadioTuner/RadioCreateForm) - unlike .seek-range above (a scrubber
where the thumb only appears on hover/focus), this is a literal knob the listener drags
continuously, so the thumb stays visible at all times and reads as more tactile: bigger,
with a ringed border rather than a plain dot. The track gets tick marks to read as a real
frequency dial rather than a generic slider. Thumb border color comes from --tuner-accent
(set inline per-band in RadioTuner.tsx) so it changes with the selected band; custom
properties set on the host element are visible to its own ::-webkit-slider-thumb/
::-moz-range-thumb pseudo-elements in every current browser. */
.tuner-dial {
-webkit-appearance: none;
appearance: none;
height: 6px;
border-radius: 9999px;
background-color: transparent;
}
.tuner-dial::-webkit-slider-runnable-track {
height: 6px;
border-radius: 9999px;
background-image: repeating-linear-gradient(to right, color-mix(in srgb, white 20%, transparent) 0 1px, transparent 1px 10px);
}
.tuner-dial::-moz-range-track {
height: 6px;
border-radius: 9999px;
background-color: transparent;
background-image: repeating-linear-gradient(to right, color-mix(in srgb, white 20%, transparent) 0 1px, transparent 1px 10px);
}
.tuner-dial::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 22px;
height: 22px;
margin-top: -8px;
border-radius: 9999px;
background: white;
border: 3px solid var(--tuner-accent, var(--color-primary));
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
cursor: pointer;
}
.tuner-dial::-moz-range-thumb {
width: 22px;
height: 22px;
border: 3px solid var(--tuner-accent, var(--color-primary));
border-radius: 9999px;
background: white;
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
cursor: pointer;
}
.tuner-dial:focus-visible {
outline: 2px solid var(--tuner-accent, var(--color-primary));
outline-offset: 4px;
border-radius: 9999px;
}
:root { :root {
--background: oklch(1 0 0); --background: oklch(1 0 0);
--foreground: oklch(0.148 0.004 228.8); --foreground: oklch(0.148 0.004 228.8);
......
...@@ -83,6 +83,9 @@ const BACKEND_DONE: DoneGroup[] = [ ...@@ -83,6 +83,9 @@ const BACKEND_DONE: DoneGroup[] = [
'Radio (2026-10-12): creator-run stations tuned via a literal band (SM/SF/SR) + frequency (50.0-200.0, 0.1 precision) dial, broadcasting worldwide or to a local radius, looping a queue forever. New Radio/RadioTrack tables; LibrarySong gained duration_seconds (populated at tag/upload/claim/remix time via probe_duration_seconds, pydub - lazily backfilled on first read for pre-existing rows). New /radio router: CRUD with band+frequency validation (rejects two active stations on the same band within 0.6 of each other\'s frequency - floating-point noise in that comparison was a real bug caught by a test expecting two stations exactly 0.6 apart to coexist, fixed by rounding the diff before comparing), /browse (active+on-air+geo-visible, no now-playing info so dialing through it client-side never hits the backend), /queue (owner-only add/remove/reorder), /artwork (new image upload - storage.store_image + /images static mount, the first image-upload precedent in this app).', 'Radio (2026-10-12): creator-run stations tuned via a literal band (SM/SF/SR) + frequency (50.0-200.0, 0.1 precision) dial, broadcasting worldwide or to a local radius, looping a queue forever. New Radio/RadioTrack tables; LibrarySong gained duration_seconds (populated at tag/upload/claim/remix time via probe_duration_seconds, pydub - lazily backfilled on first read for pre-existing rows). New /radio router: CRUD with band+frequency validation (rejects two active stations on the same band within 0.6 of each other\'s frequency - floating-point noise in that comparison was a real bug caught by a test expecting two stations exactly 0.6 apart to coexist, fixed by rounding the diff before comparing), /browse (active+on-air+geo-visible, no now-playing info so dialing through it client-side never hits the backend), /queue (owner-only add/remove/reorder), /artwork (new image upload - storage.store_image + /images static mount, the first image-upload precedent in this app).',
'The core design problem: no scheduler, no background job, no stored "current song" - compute_now_playing() is fully stateless, mapping elapsed_seconds-since-creation modulo the queue\'s total duration to a (song, offset) pair via cumulative-sum arithmetic. Verified live: two now-playing calls 2 real seconds apart advanced the reported offset by ~2s on the same track - any listener, whenever they tune in, lands on the mathematically correct position, no polling job required. Schedule ("on air" 24/7 vs a fixed daily window, including windows that wrap past midnight) is the same kind of stateless check against the current UTC minute-of-day.', 'The core design problem: no scheduler, no background job, no stored "current song" - compute_now_playing() is fully stateless, mapping elapsed_seconds-since-creation modulo the queue\'s total duration to a (song, offset) pair via cumulative-sum arithmetic. Verified live: two now-playing calls 2 real seconds apart advanced the reported offset by ~2s on the same track - any listener, whenever they tune in, lands on the mathematically correct position, no polling job required. Schedule ("on air" 24/7 vs a fixed daily window, including windows that wrap past midnight) is the same kind of stateless check against the current UTC minute-of-day.',
'/soundmarks/geocode and /reverse-geocode relaxed from business-admin-only to any authenticated user - RadioLocationPicker\'s address search needed them too, and there was nothing business-admin-specific about a stateless geocoder proxy in the first place.', '/soundmarks/geocode and /reverse-geocode relaxed from business-admin-only to any authenticated user - RadioLocationPicker\'s address search needed them too, and there was nothing business-admin-specific about a stateless geocoder proxy in the first place.',
'Tuner restyle + Rooms create-as-popup (2026-10-12): RadioTuner.tsx redesigned as a lit console (band-colored glow, LED-style station readout) instead of its original flat layout. Rooms\' always-visible inline create form replaced with a "Create a room" button opening a new CreateRoomModal, matching every other modal\'s chrome (useMountTransition, back-button + Escape + backdrop close) rather than inventing a new pattern.',
'Radio is live broadcast, not a seekable track (2026-10-12): the backend now starts the actual MP3 stream at the live offset itself (stream_audio_from_offset, ffmpeg -ss before -i so it seeks pre-decode and -acodec copy so it never re-encodes) instead of serving from byte 0 and relying on a client-side seek() afterward - that second round trip was the real cause of the reported slow start, confirmed fixed by a regression test asserting the returned stream\'s actual duration matches the expected remaining offset, and by a live check against the running server (10s test track, stream fetched ~4s in, returned ~6-7s of audio). PlayableSong gained isLive: seek() is now a no-op for it and resuming from pause re-fetches live instead of replaying stale paused audio; FullPlayer shows a pulsing LIVE badge instead of a scrub bar, with Shuffle/Previous/Repeat disabled, consistent with there being no stable timeline to control.',
'Tuning dial: granular drag + station snapping (2026-10-12): the native <input type="range"> was replaced with a custom pointer- and keyboard-driven dial (same pointer-capture-after-movement pattern as useSwipeAction) because a native range\'s drag sensitivity is fixed to element-width/(max-min) with no way to slow it down - dragging now reads raw pixel deltas against a fixed DIAL_PIXELS_PER_UNIT instead. The dial also snaps exactly onto any station within the same 0.3 tuning epsilon the backend already locks onto, with tick marks on the track showing where each station sits.',
], ],
}, },
{ {
......
...@@ -117,6 +117,7 @@ describe('Rooms', () => { ...@@ -117,6 +117,7 @@ describe('Rooms', () => {
renderRooms() renderRooms()
await screen.findByText(/No active rooms right now/) await screen.findByText(/No active rooms right now/)
await userEvent.click(screen.getByRole('button', { name: 'Create a room' }))
await userEvent.type(screen.getByPlaceholderText('Room name'), 'New Room') await userEvent.type(screen.getByPlaceholderText('Room name'), 'New Room')
await userEvent.click(screen.getByRole('button', { name: 'Start' })) await userEvent.click(screen.getByRole('button', { name: 'Start' }))
...@@ -130,6 +131,7 @@ describe('Rooms', () => { ...@@ -130,6 +131,7 @@ describe('Rooms', () => {
renderRooms() renderRooms()
await screen.findByText(/No active rooms right now/) await screen.findByText(/No active rooms right now/)
await userEvent.click(screen.getByRole('button', { name: 'Create a room' }))
await userEvent.type(screen.getByPlaceholderText('Room name'), 'Secret Room') await userEvent.type(screen.getByPlaceholderText('Room name'), 'Secret Room')
await userEvent.type(screen.getByPlaceholderText('PIN (optional)'), '1234') await userEvent.type(screen.getByPlaceholderText('PIN (optional)'), '1234')
await userEvent.click(screen.getByRole('button', { name: 'Start' })) await userEvent.click(screen.getByRole('button', { name: 'Start' }))
...@@ -143,6 +145,7 @@ describe('Rooms', () => { ...@@ -143,6 +145,7 @@ describe('Rooms', () => {
renderRooms() renderRooms()
await screen.findByText(/No active rooms right now/) await screen.findByText(/No active rooms right now/)
await userEvent.click(screen.getByRole('button', { name: 'Create a room' }))
await userEvent.type(screen.getByPlaceholderText('Room name'), 'Pinned Room') await userEvent.type(screen.getByPlaceholderText('Room name'), 'Pinned Room')
await userEvent.click(screen.getByText(/Tie to a real-world location/)) await userEvent.click(screen.getByText(/Tie to a real-world location/))
await userEvent.click(screen.getByText('Set location (mock)')) await userEvent.click(screen.getByText('Set location (mock)'))
...@@ -157,8 +160,26 @@ describe('Rooms', () => { ...@@ -157,8 +160,26 @@ describe('Rooms', () => {
renderRooms() renderRooms()
await screen.findByText(/No active rooms right now/) await screen.findByText(/No active rooms right now/)
await userEvent.click(screen.getByRole('button', { name: 'Start' })) await userEvent.click(screen.getByRole('button', { name: 'Create a room' }))
expect(screen.getByRole('button', { name: 'Start' })).toBeDisabled()
expect(create).not.toHaveBeenCalled()
})
it('closes the create-room popup without creating anything', async () => {
vi.spyOn(socialApi, 'getActiveRooms').mockResolvedValue([])
const create = vi.spyOn(socialApi, 'createRoom')
renderRooms()
await screen.findByText(/No active rooms right now/)
await userEvent.click(screen.getByRole('button', { name: 'Create a room' }))
await screen.findByPlaceholderText('Room name')
await userEvent.click(screen.getByLabelText('Close'))
// The modal un-mounts a beat after its exit transition finishes (see useMountTransition),
// not synchronously on click.
await waitFor(() => expect(screen.queryByPlaceholderText('Room name')).not.toBeInTheDocument())
expect(create).not.toHaveBeenCalled() expect(create).not.toHaveBeenCalled()
}) })
......
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { ChevronRight, Lock, MapPin, Radio } from 'lucide-react' import { ChevronRight, Lock, MapPin, Plus, Radio } from 'lucide-react'
import { Button } from '../components/ui/Button' import { Button } from '../components/ui/Button'
import { Input } from '../components/ui/Input' import { Input } from '../components/ui/Input'
import { EmptyState } from '../components/ui/EmptyState' import { EmptyState } from '../components/ui/EmptyState'
import { LocationPicker } from '../components/LocationPicker' import { CreateRoomModal } from '../components/CreateRoomModal'
import { RoomsNearbyMap } from '../components/RoomsNearbyMap' import { RoomsNearbyMap } from '../components/RoomsNearbyMap'
import { ApiError } from '../api/client' import { ApiError } from '../api/client'
import { createRoom, getActiveRooms, getNearbyRooms, joinRoom, type LiveRoom } from '../api/social' import { getActiveRooms, getNearbyRooms, joinRoom, type LiveRoom } from '../api/social'
import { RoomView } from '../components/RoomView' import { RoomView } from '../components/RoomView'
/** Which room (by id or invite code) a PIN prompt is currently being collected for - set /** Which room (by id or invite code) a PIN prompt is currently being collected for - set
...@@ -21,11 +21,7 @@ interface PendingJoin { ...@@ -21,11 +21,7 @@ interface PendingJoin {
export function Rooms() { export function Rooms() {
const [rooms, setRooms] = useState<LiveRoom[]>([]) const [rooms, setRooms] = useState<LiveRoom[]>([])
const [loading, setLoading] = useState(true) const [loading, setLoading] = useState(true)
const [newRoomName, setNewRoomName] = useState('') const [creatingRoom, setCreatingRoom] = useState(false)
const [newRoomPin, setNewRoomPin] = useState('')
const [tieToLocation, setTieToLocation] = useState(false)
const [newLat, setNewLat] = useState<number | null>(null)
const [newLon, setNewLon] = useState<number | null>(null)
const [joinCode, setJoinCode] = useState('') const [joinCode, setJoinCode] = useState('')
const [pendingJoin, setPendingJoin] = useState<PendingJoin | null>(null) const [pendingJoin, setPendingJoin] = useState<PendingJoin | null>(null)
...@@ -47,19 +43,8 @@ export function Rooms() { ...@@ -47,19 +43,8 @@ export function Rooms() {
useEffect(refresh, []) useEffect(refresh, [])
async function handleCreate(e: React.FormEvent) { function handleRoomCreated(room: LiveRoom) {
e.preventDefault() setCreatingRoom(false)
if (!newRoomName.trim()) return
const room = await createRoom(newRoomName.trim(), {
pin: newRoomPin || undefined,
latitude: tieToLocation && newLat !== null ? newLat : undefined,
longitude: tieToLocation && newLon !== null ? newLon : undefined,
})
setNewRoomName('')
setNewRoomPin('')
setTieToLocation(false)
setNewLat(null)
setNewLon(null)
setRooms((r) => [room, ...r]) setRooms((r) => [room, ...r])
// The creator's own invite code/PIN status is shown in RoomView's header once inside - // The creator's own invite code/PIN status is shown in RoomView's header once inside -
// no separate banner needed here. // no separate banner needed here.
...@@ -190,26 +175,10 @@ export function Rooms() { ...@@ -190,26 +175,10 @@ export function Rooms() {
return ( return (
<> <>
<form onSubmit={handleCreate} className="mb-4 space-y-2"> <Button onClick={() => setCreatingRoom(true)} className="mb-4 w-full gap-1.5">
<div className="flex gap-2"> <Plus size={16} strokeWidth={2} />
<Input value={newRoomName} onChange={(e) => setNewRoomName(e.target.value)} placeholder="Room name" /> Create a room
<Input
value={newRoomPin}
onChange={(e) => setNewRoomPin(e.target.value.replace(/\D/g, '').slice(0, 4))}
placeholder="PIN (optional)"
inputMode="numeric"
className="w-32"
/>
</div>
<label className="flex items-center gap-2 text-sm text-on-surface-variant">
<input type="checkbox" checked={tieToLocation} onChange={(e) => setTieToLocation(e.target.checked)} />
Tie to a real-world location (lets others find it on the map)
</label>
{tieToLocation && <LocationPicker latitude={newLat} longitude={newLon} onChange={(lat, lon) => { setNewLat(lat); setNewLon(lon) }} />}
<Button type="submit" className="w-full">
Start
</Button> </Button>
</form>
<form onSubmit={handleJoinByCode} className="mb-4 flex gap-2"> <form onSubmit={handleJoinByCode} className="mb-4 flex gap-2">
<Input <Input
...@@ -277,6 +246,8 @@ export function Rooms() { ...@@ -277,6 +246,8 @@ export function Rooms() {
</li> </li>
))} ))}
</ul> </ul>
{creatingRoom && <CreateRoomModal onCreated={handleRoomCreated} onClose={() => setCreatingRoom(false)} />}
</> </>
) )
} }
...@@ -38,22 +38,22 @@ describe('Social', () => { ...@@ -38,22 +38,22 @@ describe('Social', () => {
it('shows the Rooms panel by default', async () => { it('shows the Rooms panel by default', async () => {
renderSocial() renderSocial()
expect(await screen.findByPlaceholderText('Room name')).toBeInTheDocument() expect(await screen.findByPlaceholderText('Join by invite code')).toBeInTheDocument()
}) })
it('switches to the Radio panel when tapped', async () => { it('switches to the Radio panel when tapped', async () => {
renderSocial() renderSocial()
await screen.findByPlaceholderText('Room name') await screen.findByPlaceholderText('Join by invite code')
await userEvent.click(screen.getByRole('button', { name: 'Radio' })) await userEvent.click(screen.getByRole('button', { name: 'Radio' }))
expect(await screen.findByLabelText('Tuning dial')).toBeInTheDocument() expect(await screen.findByLabelText('Tuning dial')).toBeInTheDocument()
expect(screen.queryByPlaceholderText('Room name')).not.toBeInTheDocument() expect(screen.queryByPlaceholderText('Join by invite code')).not.toBeInTheDocument()
}) })
it('switches to the Posts panel when tapped', async () => { it('switches to the Posts panel when tapped', async () => {
renderSocial() renderSocial()
await screen.findByPlaceholderText('Room name') await screen.findByPlaceholderText('Join by invite code')
await userEvent.click(screen.getByRole('button', { name: 'Posts' })) await userEvent.click(screen.getByRole('button', { name: 'Posts' }))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment