Commit b6cd0b29 authored by Aryan Noshirvnai's avatar Aryan Noshirvnai

Fix the actual reason the broadcast circle never looked like a circle

The previous pass only strengthened the circle's styling (stronger fill,
dashed border) - that wasn't the real bug. The radius is computed as a
fraction of the map's current visible viewport. Search and "use my location"
already jump+zoom the map on pin placement, but a plain click never did, so
clicking to place a pin left the map at its whole-world starting zoom -
where a small picker map's viewport spans roughly a third of the planet's
longitude. At that zoom the "radius" came out to literally thousands of
kilometers. A circle that large has no edge anywhere inside a small map:
every visible pixel is inside it, so it reads as a flat color wash, not a
circle - "the circle isn't there" was a completely accurate description.

ClickToPlacePin now zooms in to the same level search/locate already use,
but only on a station's very first placement (checked via whether a pin
already exists, not the current zoom, so a user who deliberately zooms back
out later never gets yanked back in). The computed radius is also clamped
to a 200m-100km sane range as a defensive backstop against the same
degenerate math at any other extreme zoom level.
Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
parent df189218
...@@ -12,6 +12,15 @@ const ZOOM_ON_JUMP = 12 ...@@ -12,6 +12,15 @@ const ZOOM_ON_JUMP = 12
// The broadcast circle covers this fraction of the visible viewport's east-west span - leaves // The broadcast circle covers this fraction of the visible viewport's east-west span - leaves
// breathing room on both sides rather than touching the map edges exactly. // breathing room on both sides rather than touching the map edges exactly.
const VIEWPORT_RADIUS_FRACTION = 0.35 const VIEWPORT_RADIUS_FRACTION = 0.35
// At the whole-world starting zoom (ZOOM_NO_PIN), a plain map click placed a pin without ever
// zooming in first - the viewport at that zoom is a huge fraction of the globe, so the "35% of
// the viewport" radius above came out to literally thousands of kilometers. A circle that big
// doesn't render as a circle at all on a small picker map - every visible pixel is inside it,
// so it just looks like a flat color wash, which is what "the circle isn't there" actually was.
// Clamping to a sane broadcast-radius range is a defensive backstop; the real fix is below
// (ClickToPlacePin now zooms in on first placement, same as search/locate already did).
const MIN_RADIUS_METERS = 200
const MAX_RADIUS_METERS = 100_000
interface RadioLocationPickerProps { interface RadioLocationPickerProps {
latitude: number | null latitude: number | null
...@@ -31,9 +40,17 @@ function FlyToOnJump({ jumpTo }: { jumpTo: { lat: number; lon: number } | null } ...@@ -31,9 +40,17 @@ function FlyToOnJump({ jumpTo }: { jumpTo: { lat: number; lon: number } | null }
return null return null
} }
function ClickToPlacePin({ onClick }: { onClick: (lat: number, lon: number) => void }) { function ClickToPlacePin({ hasPin, onClick }: { hasPin: boolean; onClick: (lat: number, lon: number) => void }) {
useMapEvents({ const map = useMapEvents({
click(e: LeafletMouseEvent) { click(e: LeafletMouseEvent) {
// Zooms in on the very first placement only (a click with no pin yet) - search and
// "use my location" already jump+zoom via FlyToOnJump, but a plain first click left the
// map at its whole-world starting zoom, where the broadcast circle's radius (computed
// from the current viewport) came out to thousands of kilometers. Re-clicking to move an
// already-placed pin intentionally does NOT re-zoom, preserving whatever view the user
// has already framed - checking hasPin rather than the current zoom level so a user who
// deliberately zoomed back out afterward doesn't get yanked back in against their will.
if (!hasPin) map.setView(e.latlng, ZOOM_ON_JUMP)
onClick(e.latlng.lat, e.latlng.lng) onClick(e.latlng.lat, e.latlng.lng)
}, },
}) })
...@@ -57,7 +74,8 @@ function RadiusFromViewport({ centerLat, onRadiusChange }: { centerLat: number; ...@@ -57,7 +74,8 @@ function RadiusFromViewport({ centerLat, onRadiusChange }: { centerLat: number;
function recompute() { function recompute() {
const bounds = map.getBounds() const bounds = map.getBounds()
const widthMeters = map.distance([centerLat, bounds.getWest()], [centerLat, bounds.getEast()]) const widthMeters = map.distance([centerLat, bounds.getWest()], [centerLat, bounds.getEast()])
onRadiusChange(Math.round((widthMeters / 2) * VIEWPORT_RADIUS_FRACTION)) const raw = Math.round((widthMeters / 2) * VIEWPORT_RADIUS_FRACTION)
onRadiusChange(Math.min(MAX_RADIUS_METERS, Math.max(MIN_RADIUS_METERS, raw)))
} }
useEffect(recompute, [centerLat]) // eslint-disable-line react-hooks/exhaustive-deps useEffect(recompute, [centerLat]) // eslint-disable-line react-hooks/exhaustive-deps
...@@ -178,7 +196,7 @@ export function RadioLocationPicker({ latitude, longitude, radiusMeters, onChang ...@@ -178,7 +196,7 @@ export function RadioLocationPicker({ latitude, longitude, radiusMeters, onChang
<MapContainer center={initialCenter} zoom={initialZoom} className="h-full w-full" scrollWheelZoom> <MapContainer center={initialCenter} zoom={initialZoom} className="h-full w-full" scrollWheelZoom>
<TileLayer attribution={DARK_TILE_ATTRIBUTION} url={DARK_TILE_URL} /> <TileLayer attribution={DARK_TILE_ATTRIBUTION} url={DARK_TILE_URL} />
<FlyToOnJump jumpTo={jumpTo} /> <FlyToOnJump jumpTo={jumpTo} />
<ClickToPlacePin onClick={onChange} /> <ClickToPlacePin hasPin={hasPin} onClick={onChange} />
{hasPin && ( {hasPin && (
<> <>
<RadiusFromViewport centerLat={latitude} onRadiusChange={onRadiusChange} /> <RadiusFromViewport centerLat={latitude} onRadiusChange={onRadiusChange} />
......
...@@ -90,6 +90,7 @@ const BACKEND_DONE: DoneGroup[] = [ ...@@ -90,6 +90,7 @@ const BACKEND_DONE: DoneGroup[] = [
'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.', '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.',
'Fixed: global library search in Radio\'s queue manager (2026-10-13) - RadioManageTab\'s "Add song" reuses SongPicker, whose "Public Library" tab calls GET /soundmarks/song-library, which was still gated get_current_business_admin even though Radio hands this same picker to any station owner, admin or not. A plain user got a silent 403 (SongPicker swallows the error into an empty "No songs found" state, so nothing looked broken, it just never returned results). Relaxed to get_current_user, same reasoning as the geocode endpoints above - a plain title/artist search has nothing business-admin-specific about it. Confirmed live with a real plain-role account: 403 before the fix, real results after.', 'Fixed: global library search in Radio\'s queue manager (2026-10-13) - RadioManageTab\'s "Add song" reuses SongPicker, whose "Public Library" tab calls GET /soundmarks/song-library, which was still gated get_current_business_admin even though Radio hands this same picker to any station owner, admin or not. A plain user got a silent 403 (SongPicker swallows the error into an empty "No songs found" state, so nothing looked broken, it just never returned results). Relaxed to get_current_user, same reasoning as the geocode endpoints above - a plain title/artist search has nothing business-admin-specific about it. Confirmed live with a real plain-role account: 403 before the fix, real results after.',
'Local-scope UX pass (2026-10-14): the "Reach: Worldwide/Local" pill pair in RadioCreateForm read as two unrelated buttons rather than one feature being switched on, so it was rebuilt as a single ToggleRow ("Tie to a real-world location") - the same shared switch component Settings/Onboarding already use, and the same wording Rooms\' own location toggle uses, instead of each feature inventing its own phrasing. Fixed a real latent bug surfaced by that change: ToggleRow\'s switch <button> had no explicit type, so clicking it inside an actual <form> (its first use inside one) defaulted to type="submit" and silently submitted the surrounding form with stale state instead of just flipping the toggle - fixed in the shared component itself (type="button"), not worked around locally, since any future form usage would hit the same bug. The broadcast-radius circle on the map was real but easy to miss - fillOpacity 0.12 on a dark basemap - strengthened to a dashed, higher-contrast outline, skipped entirely for the one frame before a real radius exists (previously flashed as a literal zero-radius circle), and paired with an explicit "~Xkm radius" badge on the map itself rather than only a caption line below it. The location+circle picker was also only ever reachable once, during station creation - RadioManageTab gained the same ToggleRow + RadioLocationPicker + a "Save broadcast area" action so an existing station\'s broadcast area is visible and editable after creation too, not just in the one-time create flow (PATCH /radio/{id} already supported this; only the frontend was missing the wiring).', 'Local-scope UX pass (2026-10-14): the "Reach: Worldwide/Local" pill pair in RadioCreateForm read as two unrelated buttons rather than one feature being switched on, so it was rebuilt as a single ToggleRow ("Tie to a real-world location") - the same shared switch component Settings/Onboarding already use, and the same wording Rooms\' own location toggle uses, instead of each feature inventing its own phrasing. Fixed a real latent bug surfaced by that change: ToggleRow\'s switch <button> had no explicit type, so clicking it inside an actual <form> (its first use inside one) defaulted to type="submit" and silently submitted the surrounding form with stale state instead of just flipping the toggle - fixed in the shared component itself (type="button"), not worked around locally, since any future form usage would hit the same bug. The broadcast-radius circle on the map was real but easy to miss - fillOpacity 0.12 on a dark basemap - strengthened to a dashed, higher-contrast outline, skipped entirely for the one frame before a real radius exists (previously flashed as a literal zero-radius circle), and paired with an explicit "~Xkm radius" badge on the map itself rather than only a caption line below it. The location+circle picker was also only ever reachable once, during station creation - RadioManageTab gained the same ToggleRow + RadioLocationPicker + a "Save broadcast area" action so an existing station\'s broadcast area is visible and editable after creation too, not just in the one-time create flow (PATCH /radio/{id} already supported this; only the frontend was missing the wiring).',
'Fixed the actual reason the broadcast circle never looked like a circle (2026-10-14) - the previous pass only strengthened its styling, which turned out not to be the real bug. The radius is computed as a fraction of the map\'s current visible viewport, but a first pin placed by a plain click (search and "use my location" already jumped+zoomed in; a bare click never did) left the map at its whole-world starting zoom - at that zoom a small picker map\'s viewport spans roughly a third of the planet\'s longitude, so the "radius" came out to literally thousands of kilometers. A circle that large has no edge anywhere inside a small map: every visible pixel is inside it, so it reads as a flat color wash, not a circle. ClickToPlacePin now zooms in to the same level search/locate already use on a station\'s very first placement only (checked via whether a pin already exists, not the current zoom, so a user who deliberately zoomed back out later is never yanked back in); the computed radius is also now clamped to a 200m-100km sane range as a defensive backstop against the same degenerate math at any other extreme zoom.',
], ],
}, },
{ {
......
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