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)
......
This diff is collapsed.
...@@ -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