Commit 0362b75c authored by Aryan Noshirvnai's avatar Aryan Noshirvnai

Fix radio artwork proxy gap; redesign tuning dial as a scrolling tape

Custom station artwork wasn't rendering: storage.store_image returns a
backend-relative path ("/images/7/x.png") meant to load same-origin, but
neither the dev vite proxy nor prod's nginx config had a rule for anything
besides /api, so the browser 404'd requesting it against its own origin.
Added a mirroring /images proxy rule to both.

The tuning dial's previous drag-based redesign still felt disconnected: the
thumb was positioned by percent-of-the-full-150-unit-range while drag
sensitivity was a separate, decoupled pixel constant, so the thumb visibly
lagged behind the finger - confirming the range itself wasn't really the
problem, the position/sensitivity mismatch was. Replaced it with a
scrolling-tape dial: a fixed center needle never moves, and a tape of
whole-MHz ticks (plus taller station ticks) scrolls underneath it at exactly
the same px-per-MHz rate the drag reads at, so it tracks the finger 1:1
regardless of the band's width. Added whole-MHz snapping during a drag (with
one haptic tick per newly-entered detent, Vibration API feature-detected) and
new +/- buttons for an exact 0.1 nudge - routed through a separate step path
that skips the whole-number magnet, since a magnet strong enough to feel
good on a drag would otherwise trap a single button press at the same value.
Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
parent 33c7b755
...@@ -98,6 +98,14 @@ server { ...@@ -98,6 +98,14 @@ server {
proxy_set_header Upgrade \$http_upgrade; proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection "upgrade"; proxy_set_header Connection "upgrade";
} }
# The backend's /images static mount (radio station artwork - storage.store_image) lives at
# the backend's own root, not under /api, and the paths it hands back ("/images/7/x.png")
# are relative - same same-origin reasoning as /api/ above, just with no prefix to strip.
location /images/ {
proxy_pass http://127.0.0.1:8000/images/;
proxy_set_header Host \$host;
}
} }
EOF EOF
ln -sf "$SITE_CONF" /etc/nginx/sites-enabled/stax_webapp ln -sf "$SITE_CONF" /etc/nginx/sites-enabled/stax_webapp
......
...@@ -157,14 +157,44 @@ describe('RadioTuner', () => { ...@@ -157,14 +157,44 @@ describe('RadioTuner', () => {
expect(dial).toHaveAttribute('aria-valuenow', '100') expect(dial).toHaveAttribute('aria-valuenow', '100')
fireEvent.pointerDown(dial, { pointerId: 1, clientX: 0 }) 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 // 20.2 frequency units of drag at DIAL_PIXELS_PER_UNIT=22 - lands at 120.2, within the
// 0.3 epsilon of the fixture station's 120.0 but not exactly on it. // 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.pointerMove(dial, { pointerId: 1, clientX: 20.2 * 22 })
fireEvent.pointerUp(dial, { pointerId: 1 }) fireEvent.pointerUp(dial, { pointerId: 1 })
expect(dial).toHaveAttribute('aria-valuenow', '120') expect(dial).toHaveAttribute('aria-valuenow', '120')
}) })
it('snaps onto the nearest whole MHz while dragging through empty band space', async () => {
vi.spyOn(radioApi, 'browseRadios').mockResolvedValue([])
renderTuner()
const dial = await screen.findByLabelText('Tuning dial')
fireEvent.pointerDown(dial, { pointerId: 1, clientX: 0 })
// 5.05 units of drag at DIAL_PIXELS_PER_UNIT=22 lands at 105.05 - within the dial's own
// 0.12 whole-number epsilon of 105, so it should snap exactly onto it mid-drag.
fireEvent.pointerMove(dial, { pointerId: 1, clientX: 5.05 * 22 })
fireEvent.pointerUp(dial, { pointerId: 1 })
expect(dial).toHaveAttribute('aria-valuenow', '105')
})
it('nudges the frequency by exactly 0.1 per tap of the increase/decrease buttons', async () => {
vi.spyOn(radioApi, 'browseRadios').mockResolvedValue([])
renderTuner()
await screen.findByLabelText('Tuning dial')
// From the default 100.0 - a plain +0.1 button tap must land on 100.1 and stay there, not
// get pulled back onto the whole number it started from (the dial's own drag-only magnet
// would do that, but a deliberate button tap is the one path that must always escape it).
await userEvent.click(screen.getByRole('button', { name: 'Increase frequency by 0.1' }))
expect(screen.getByLabelText('Tuning dial')).toHaveAttribute('aria-valuenow', '100.1')
await userEvent.click(screen.getByRole('button', { name: 'Decrease frequency by 0.1' }))
await userEvent.click(screen.getByRole('button', { name: 'Decrease frequency by 0.1' }))
expect(screen.getByLabelText('Tuning dial')).toHaveAttribute('aria-valuenow', '99.9')
})
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)
......
import { useEffect, useRef, useState, type KeyboardEvent as ReactKeyboardEvent, type PointerEvent as ReactPointerEvent } from 'react' import { useEffect, useRef, useState, type KeyboardEvent as ReactKeyboardEvent, type PointerEvent as ReactPointerEvent } from 'react'
import { Heart, ListPlus, Music2, Pause, Play, RadioTower } from 'lucide-react' import { Heart, ListPlus, Minus, Music2, Pause, Play, Plus, RadioTower } from 'lucide-react'
import { Button } from './ui/Button' import { Button } from './ui/Button'
import { browseRadios, fetchRadioStreamUrl, getNowPlaying, type NowPlaying, type Radio, type RadioBand } from '../api/radio' import { browseRadios, fetchRadioStreamUrl, getNowPlaying, type NowPlaying, type Radio, type RadioBand } from '../api/radio'
import { usePlayer, type PlayableSong } from '../context/PlayerContext' import { usePlayer, type PlayableSong } from '../context/PlayerContext'
...@@ -8,14 +8,14 @@ import { useClaimThenAct, type ClaimableSong } from '../hooks/useClaimThenAct' ...@@ -8,14 +8,14 @@ import { useClaimThenAct, type ClaimableSong } from '../hooks/useClaimThenAct'
const BANDS: RadioBand[] = ['SM', 'SF', 'SR'] const BANDS: RadioBand[] = ['SM', 'SF', 'SR']
const FREQUENCY_MIN = 50.0 const FREQUENCY_MIN = 50.0
const FREQUENCY_MAX = 200.0 const FREQUENCY_MAX = 200.0
// Pixels of horizontal drag needed per 1.0 frequency unit. A plain native range input maps const FREQUENCY_STEP = 0.1
// its full rendered width to the whole 150-unit span - on a ~400px-wide card that's roughly // Pixels of horizontal drag per 1.0 frequency unit. This is also the tape's own tick spacing
// 0.4 units per pixel, so overshooting a station by a hair on a real touch drag was nearly // (see the scrolling-tape dial below), so a drag genuinely moves the tape 1:1 under the
// unavoidable. This custom dial reads raw pointer-movement pixels instead of relying on the // finger - the previous version mapped the thumb's position to percent-of-the-full-150-unit-
// browser's width-based mapping, so sensitivity is independent of layout and can be tuned // range while sensitivity was a separate, decoupled constant, so the thumb visibly lagged far
// directly - deliberately coarser (dragging the full visible width now only covers a few // behind the finger (the real cause of "the dial is just bad"). Tying both to the same number
// units, not the whole band) in exchange for being able to nudge onto a specific frequency. // fixes that, independent of what this constant's actual value is.
const DIAL_PIXELS_PER_UNIT = 14 const DIAL_PIXELS_PER_UNIT = 22
// One accent hue per band, so the console actually reads as "tuned to something" rather than // One accent hue per band, so the console actually reads as "tuned to something" rather than
// every band looking identical - reuses the same accent hues mapTheme.ts already established // every band looking identical - reuses the same accent hues mapTheme.ts already established
// for soundmark tiers (indigo/amber), plus a new emerald for the third band. // for soundmark tiers (indigo/amber), plus a new emerald for the third band.
...@@ -27,6 +27,11 @@ const BAND_COLORS: Record<RadioBand, string> = { ...@@ -27,6 +27,11 @@ const BAND_COLORS: Record<RadioBand, string> = {
// Mirrors the backend's own TUNING_LOCK_EPSILON (radio.py) exactly - this is the client-side // Mirrors the backend's own TUNING_LOCK_EPSILON (radio.py) exactly - this is the client-side
// half of the same "close enough to count as tuned in" tolerance, not an independent choice. // half of the same "close enough to count as tuned in" tolerance, not an independent choice.
const TUNING_LOCK_EPSILON = 0.3 const TUNING_LOCK_EPSILON = 0.3
// A tighter window than the station epsilon above, purely for the dial's own whole-MHz detents
// (50, 51, 52...) - gives the "snaps into place on whole numbers" feel the tuner needs on top
// of station snapping, without swallowing so much travel that it fights precision near a real
// station sitting at a non-whole frequency.
const WHOLE_NUMBER_SNAP_EPSILON = 0.12
const NOW_PLAYING_POLL_MS = 10_000 const NOW_PLAYING_POLL_MS = 10_000
// Clear of Rooms' (-roomId) and Soundmarks' (-soundmarkId) own negative-id ranges - see // Clear of Rooms' (-roomId) and Soundmarks' (-soundmarkId) own negative-id ranges - see
// PlayableSong's own docstring in PlayerContext.tsx for why these ids just need to be unique // PlayableSong's own docstring in PlayerContext.tsx for why these ids just need to be unique
...@@ -53,6 +58,10 @@ export function RadioTuner({ onAddToPlaylist }: RadioTunerProps) { ...@@ -53,6 +58,10 @@ export function RadioTuner({ onAddToPlaylist }: RadioTunerProps) {
// Not state, same reasoning as useSwipeAction - only exists to reject a second simultaneous // Not state, same reasoning as useSwipeAction - only exists to reject a second simultaneous
// pointer and to remember where this particular drag started. // pointer and to remember where this particular drag started.
const dragRef = useRef<{ pointerId: number; startX: number; startFrequency: number } | null>(null) const dragRef = useRef<{ pointerId: number; startX: number; startFrequency: number } | null>(null)
// Identifies whichever detent (a specific station, or a specific whole MHz) the dial is
// currently resting in, or null if it's between detents. Only used to fire exactly one
// haptic tick per newly-entered detent, rather than once per pixel of movement.
const lastDetentRef = useRef<string | null>(null)
// Best-effort geolocation so local-scope stations show up in browse - silently skipped if // Best-effort geolocation so local-scope stations show up in browse - silently skipped if
// denied/unavailable/insecure, same posture as every other optional-location feature here. // denied/unavailable/insecure, same posture as every other optional-location feature here.
...@@ -140,18 +149,74 @@ export function RadioTuner({ onAddToPlaylist }: RadioTunerProps) { ...@@ -140,18 +149,74 @@ export function RadioTuner({ onAddToPlaylist }: RadioTunerProps) {
return Math.min(FREQUENCY_MAX, Math.max(FREQUENCY_MIN, value)) return Math.min(FREQUENCY_MAX, Math.max(FREQUENCY_MIN, value))
} }
/** Once a dragged or keyboard-stepped value lands within TUNING_LOCK_EPSILON of a station // Real vibration motors only exist on touch devices, and not every one of those exposes the
* actually on this band, snaps exactly onto that station's frequency - the "index that snaps // Vibration API (notably iOS Safari) - feature-detected and silently a no-op otherwise, same
* to places" the dial's tick marks (below) visually promise, so landing precisely on a // posture as every other best-effort browser capability in this app (geolocation, etc).
* station doesn't require a pixel-perfect drag. */ function vibrateTick() {
function snapToStation(value: number): number { if (typeof navigator !== 'undefined' && typeof navigator.vibrate === 'function') {
const nearby = stations.find((s) => Math.abs(s.frequency - value) < TUNING_LOCK_EPSILON) navigator.vibrate(10)
return nearby ? nearby.frequency : Math.round(value * 10) / 10 }
}
/** Locks onto a real station (TUNING_LOCK_EPSILON, matching the backend's own lock-in) if one
* is close enough; otherwise just rounds to the dial's 0.1 precision. Shared by every path -
* drag, keyboard, and the +/- buttons all need station lock-on, but only the drag path (below)
* also gets pulled onto whole-MHz detents, since that pull would otherwise fight a deliberate
* single 0.1 nudge from the stepper buttons (the whole point of adding them) and make it
* impossible to ever leave a whole number one step at a time. */
function snapToStationOnly(value: number): number {
const station = stations.find((s) => Math.abs(s.frequency - value) < TUNING_LOCK_EPSILON)
return station ? station.frequency : Math.round(value * 10) / 10
}
/** Discrete, exact moves - one keypress or button tap, one step. Always vibrates once per
* actual change, since every tap here is a deliberate action, not a continuous sweep. */
function stepFrequency(delta: number) {
const next = snapToStationOnly(clampFrequency(frequency + delta))
if (next !== frequency) vibrateTick()
setFrequency(next)
}
function jumpFrequency(value: number) {
const next = clampFrequency(value)
if (next !== frequency) vibrateTick()
setFrequency(next)
}
/** The drag-only path: snaps onto a station first, then falls back to the dial's own
* whole-MHz detents (WHOLE_NUMBER_SNAP_EPSILON) so sweeping through empty band space still has
* somewhere to rest. Fires exactly one haptic tick the moment a *different* detent is entered
* - not on every pixel of movement, and not again while still sitting in the same one - so a
* drag feels like real clicks, not a buzz. */
function applyDragFrequency(raw: number) {
const clamped = clampFrequency(raw)
const station = stations.find((s) => Math.abs(s.frequency - clamped) < TUNING_LOCK_EPSILON)
let detentKey: string | null = null
let snapped: number
if (station) {
detentKey = `station:${station.id}`
snapped = station.frequency
} else {
const rounded = Math.round(clamped * 10) / 10
const nearestWhole = Math.round(rounded)
if (Math.abs(rounded - nearestWhole) < WHOLE_NUMBER_SNAP_EPSILON && nearestWhole >= FREQUENCY_MIN && nearestWhole <= FREQUENCY_MAX) {
detentKey = `whole:${nearestWhole}`
snapped = nearestWhole
} else {
snapped = rounded
}
}
if (detentKey !== null && detentKey !== lastDetentRef.current) {
vibrateTick()
}
lastDetentRef.current = detentKey
setFrequency(snapped)
} }
function handleDialPointerDown(e: ReactPointerEvent<HTMLDivElement>) { function handleDialPointerDown(e: ReactPointerEvent<HTMLDivElement>) {
if (e.pointerType === 'mouse' && e.button !== 0) return if (e.pointerType === 'mouse' && e.button !== 0) return
dragRef.current = { pointerId: e.pointerId, startX: e.clientX, startFrequency: frequency } dragRef.current = { pointerId: e.pointerId, startX: e.clientX, startFrequency: frequency }
lastDetentRef.current = null
} }
function handleDialPointerMove(e: ReactPointerEvent<HTMLDivElement>) { function handleDialPointerMove(e: ReactPointerEvent<HTMLDivElement>) {
...@@ -164,8 +229,7 @@ export function RadioTuner({ onAddToPlaylist }: RadioTunerProps) { ...@@ -164,8 +229,7 @@ export function RadioTuner({ onAddToPlaylist }: RadioTunerProps) {
if (Math.abs(deltaX) > 4 && !e.currentTarget.hasPointerCapture(e.pointerId)) { if (Math.abs(deltaX) > 4 && !e.currentTarget.hasPointerCapture(e.pointerId)) {
e.currentTarget.setPointerCapture(e.pointerId) e.currentTarget.setPointerCapture(e.pointerId)
} }
const raw = clampFrequency(drag.startFrequency + deltaX / DIAL_PIXELS_PER_UNIT) applyDragFrequency(drag.startFrequency + deltaX / DIAL_PIXELS_PER_UNIT)
setFrequency(snapToStation(raw))
} }
function handleDialPointerUp(e: ReactPointerEvent<HTMLDivElement>) { function handleDialPointerUp(e: ReactPointerEvent<HTMLDivElement>) {
...@@ -175,24 +239,33 @@ export function RadioTuner({ onAddToPlaylist }: RadioTunerProps) { ...@@ -175,24 +239,33 @@ export function RadioTuner({ onAddToPlaylist }: RadioTunerProps) {
} }
function handleDialKeyDown(e: ReactKeyboardEvent<HTMLDivElement>) { function handleDialKeyDown(e: ReactKeyboardEvent<HTMLDivElement>) {
const step = e.shiftKey ? 1.0 : 0.1 const step = e.shiftKey ? 1.0 : FREQUENCY_STEP
if (e.key === 'ArrowRight' || e.key === 'ArrowUp') { if (e.key === 'ArrowRight' || e.key === 'ArrowUp') {
e.preventDefault() e.preventDefault()
setFrequency((f) => snapToStation(clampFrequency(f + step))) stepFrequency(step)
} else if (e.key === 'ArrowLeft' || e.key === 'ArrowDown') { } else if (e.key === 'ArrowLeft' || e.key === 'ArrowDown') {
e.preventDefault() e.preventDefault()
setFrequency((f) => snapToStation(clampFrequency(f - step))) stepFrequency(-step)
} else if (e.key === 'Home') { } else if (e.key === 'Home') {
e.preventDefault() e.preventDefault()
setFrequency(FREQUENCY_MIN) jumpFrequency(FREQUENCY_MIN)
} else if (e.key === 'End') { } else if (e.key === 'End') {
e.preventDefault() e.preventDefault()
setFrequency(FREQUENCY_MAX) jumpFrequency(FREQUENCY_MAX)
} }
} }
function handleStepButton(direction: 1 | -1) {
stepFrequency(direction * FREQUENCY_STEP)
}
const accent = BAND_COLORS[band] const accent = BAND_COLORS[band]
const dialPercent = ((frequency - FREQUENCY_MIN) / (FREQUENCY_MAX - FREQUENCY_MIN)) * 100 // How far along the full band the current frequency sits, in px - this is the tape's own
// internal offset, not a percent-of-container like the old dial used. The tape is translated
// so this point always sits at the viewport's horizontal center (see the dial JSX below).
const tapeOffsetPx = (frequency - FREQUENCY_MIN) * DIAL_PIXELS_PER_UNIT
const wholeTicks: number[] = []
for (let v = Math.ceil(FREQUENCY_MIN); v <= Math.floor(FREQUENCY_MAX); v++) wholeTicks.push(v)
return ( return (
<div> <div>
...@@ -227,22 +300,40 @@ export function RadioTuner({ onAddToPlaylist }: RadioTunerProps) { ...@@ -227,22 +300,40 @@ export function RadioTuner({ onAddToPlaylist }: RadioTunerProps) {
})} })}
</div> </div>
<div className="mb-4 flex items-center justify-center gap-3 rounded-xl bg-black/30 py-5"> <div className="mb-4 flex items-center justify-center gap-1 rounded-xl bg-black/30 py-5">
<span <span
className="rounded-md px-2 py-0.5 text-xs font-bold tracking-widest transition-colors duration-500" className="mr-2 shrink-0 rounded-md px-2 py-0.5 text-xs font-bold tracking-widest transition-colors duration-500"
style={{ backgroundColor: `${accent}33`, color: accent }} style={{ backgroundColor: `${accent}33`, color: accent }}
> >
{band} {band}
</span> </span>
<button
onClick={() => handleStepButton(-1)}
aria-label="Decrease frequency by 0.1"
className="shrink-0 rounded-full p-2 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 active:scale-90"
>
<Minus size={16} strokeWidth={2.5} />
</button>
<span <span
className="font-mono text-4xl font-bold tabular-nums tracking-tight text-on-surface transition-[text-shadow] duration-500" className="w-[5.5ch] shrink-0 text-center font-mono text-4xl font-bold tabular-nums tracking-tight text-on-surface transition-[text-shadow] duration-500"
style={{ textShadow: `0 0 18px ${accent}66` }} style={{ textShadow: `0 0 18px ${accent}66` }}
> >
{frequency.toFixed(1)} {frequency.toFixed(1)}
</span> </span>
<span className="text-xs font-medium text-on-surface-variant">MHz</span> <button
onClick={() => handleStepButton(1)}
aria-label="Increase frequency by 0.1"
className="shrink-0 rounded-full p-2 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 active:scale-90"
>
<Plus size={16} strokeWidth={2.5} />
</button>
<span className="ml-1 shrink-0 text-xs font-medium text-on-surface-variant">MHz</span>
</div> </div>
{/* A scrolling tape, not an absolute-position bar: the needle in the middle never
moves, and the tape underneath it slides at exactly DIAL_PIXELS_PER_UNIT per MHz -
the same rate the drag gesture itself reads at, so the marks genuinely track the
finger 1:1 instead of visually lagging behind a much larger logical range. */}
<div <div
role="slider" role="slider"
tabIndex={0} tabIndex={0}
...@@ -256,31 +347,42 @@ export function RadioTuner({ onAddToPlaylist }: RadioTunerProps) { ...@@ -256,31 +347,42 @@ export function RadioTuner({ onAddToPlaylist }: RadioTunerProps) {
onPointerUp={handleDialPointerUp} onPointerUp={handleDialPointerUp}
onPointerCancel={handleDialPointerUp} onPointerCancel={handleDialPointerUp}
onKeyDown={handleDialKeyDown} onKeyDown={handleDialKeyDown}
className="relative h-7 w-full cursor-grab touch-none select-none rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary active:cursor-grabbing" className="relative h-16 w-full cursor-grab touch-none select-none overflow-hidden rounded-xl bg-black/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary active:cursor-grabbing"
> >
<div <div
className="pointer-events-none absolute left-0 top-1/2 h-1.5 w-full -translate-y-1/2 rounded-full bg-surface-container-high" className="absolute left-1/2 top-0 h-full"
style={{ style={{ transform: `translateX(${-tapeOffsetPx}px)` }}
backgroundImage: `linear-gradient(to right, ${accent}aa ${dialPercent}%, transparent ${dialPercent}%), repeating-linear-gradient(to right, color-mix(in srgb, white 20%, transparent) 0 1px, transparent 1px 10px)`, >
}} {wholeTicks.map((v) => (
/> <div
{/* Station tick marks - shows exactly where a station sits on the dial, and is key={v}
what dragging/keyboard-stepping above snaps onto once close enough. */} className="pointer-events-none absolute top-0 flex h-full flex-col items-center justify-end pb-1.5"
{stations.map((s) => ( style={{ left: `${(v - FREQUENCY_MIN) * DIAL_PIXELS_PER_UNIT}px` }}
>
<div className={`w-px ${v % 10 === 0 ? 'h-5 bg-white/50' : 'h-2.5 bg-white/25'}`} />
{v % 10 === 0 && (
<span className="absolute bottom-6 -translate-x-1/2 text-[10px] font-medium text-outline">{v}</span>
)}
</div>
))}
{/* Station tick marks - taller, colored, and above the plain whole-MHz ticks so a
real station always reads as the more significant landmark on the tape. */}
{stations.map((s) => (
<div
key={s.id}
className="pointer-events-none absolute top-1.5 h-9 w-1 -translate-x-1/2 rounded-full"
style={{ left: `${(s.frequency - FREQUENCY_MIN) * DIAL_PIXELS_PER_UNIT}px`, backgroundColor: accent, boxShadow: `0 0 8px ${accent}99` }}
/>
))}
</div>
{/* The fixed needle - this is the only thing that visually represents "where you
are," and it never moves; everything else scrolls underneath it. */}
<div className="pointer-events-none absolute inset-y-0 left-1/2 w-0.5 -translate-x-1/2" style={{ backgroundColor: accent, boxShadow: `0 0 10px ${accent}` }}>
<div <div
key={s.id} className="absolute -top-0.5 left-1/2 h-0 w-0 -translate-x-1/2 border-x-[5px] border-t-[6px] border-x-transparent"
className="pointer-events-none absolute top-1/2 h-3 w-0.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-white/70" style={{ borderTopColor: accent }}
style={{ left: `${((s.frequency - FREQUENCY_MIN) / (FREQUENCY_MAX - FREQUENCY_MIN)) * 100}%` }}
/> />
))} </div>
<div
className="pointer-events-none absolute top-1/2 h-6 w-6 -translate-x-1/2 -translate-y-1/2 rounded-full border-[3px] bg-white shadow-md"
style={{ left: `${dialPercent}%`, borderColor: accent }}
/>
</div>
<div className="mt-1.5 flex justify-between text-[10px] font-medium text-outline">
<span>{FREQUENCY_MIN.toFixed(0)}</span>
<span>{FREQUENCY_MAX.toFixed(0)}</span>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -86,6 +86,7 @@ const BACKEND_DONE: DoneGroup[] = [ ...@@ -86,6 +86,7 @@ const BACKEND_DONE: DoneGroup[] = [
'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.', '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.', '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.', '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.',
'Radio artwork fix + dial redesign v2 (2026-10-13): custom station artwork wasn\'t rendering - storage.store_image returns a backend-relative path ("/images/7/x.png") meant to be loaded same-origin, but neither the dev vite proxy nor prod\'s nginx config had a rule for anything besides /api, so the browser requested it against its own origin and 404\'d. Both gained an /images proxy rule mirroring /api\'s (vite.config.ts; deploy/scripts/deploy.sh\'s generated nginx site config). Separately, the v1 dial (above) turned out to still feel disconnected: its thumb was positioned by percent-of-the-full-150-unit-range while drag sensitivity was a decoupled pixel constant, so the thumb visibly lagged far behind the finger - a real mismatch, not just "the range is big." Replaced with a scrolling-tape dial: a fixed center needle never moves, and a tape of whole-MHz ticks (plus taller, colored station ticks) scrolls underneath it at exactly the same px-per-MHz rate the drag itself reads at, so the marks track the finger 1:1 regardless of how wide the 50-200 range is. The dial now also snaps onto whole MHz values during a drag (WHOLE_NUMBER_SNAP_EPSILON, tighter than the station epsilon so it doesn\'t fight precision near a real station), each landed-on detent firing a single Vibration-API tick (feature-detected, silently a no-op where unsupported) rather than buzzing continuously through a sweep. New +/- buttons flank the frequency readout for an exact 0.1 nudge - deliberately routed through a separate step path that skips the whole-number magnet entirely, since a magnet strong enough to feel satisfying on a drag would otherwise make it impossible to ever press-step one tick away from a whole number.',
], ],
}, },
{ {
......
...@@ -87,6 +87,14 @@ export default defineConfig(({ mode }) => { ...@@ -87,6 +87,14 @@ export default defineConfig(({ mode }) => {
ws: true, ws: true,
rewrite: (path) => path.replace(/^\/api/, ''), rewrite: (path) => path.replace(/^\/api/, ''),
}, },
// The backend's /images static mount (radio station artwork uploads - see
// storage.store_image) lives at the backend's own root, not under /api, and returns
// relative paths like "/images/7/abc.png" for the frontend to use directly - those need
// the exact same same-origin proxy treatment as /api, just with no prefix to strip.
'/images': {
target: backendProxyTarget,
changeOrigin: true,
},
}, },
}, },
test: { test: {
......
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