Skip to content

fix(map): five reported defects — camera framing, geolocate, and language - #179

Merged
Ardnived merged 16 commits into
mainfrom
claude/fix-reported-defects
Aug 29, 2026
Merged

Ardnived merged 16 commits into
mainfrom
claude/fix-reported-defects

Conversation

@Ardnived

@Ardnived Ardnived commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Five defects reported by a user, plus what reviewing them turned up.

Try it

Preview: https://claude-fix-reported-defects.sahajatlas.pages.dev — the branch alias, so it survives each push.

⚠ Append ?key=<the published atlas key> to each link until VITE_SAHAJCLOUD_API_KEY is set in the Pages Preview environment. The standalone build reads ?key= and otherwise falls back to that build-time variable (main.tsx), which is why sahajatlas.com needs no key and a preview answers Missing api key. Setting it in Preview to the same value Production already uses makes these links work as-is — and every future PR's too. See .claude/docs/environment.md.

Check Link
Deep-link boot — softly blurred, then arrives; no zoom in from the world a country · a city
Search → tap a class — must never zoom out to the world in between a search
Find my location — the control top-right; opens the list, framed on nearby classes the map
Language menu — the cog; every row in its own language, and ?locale= appears on pick the cog
Back still flies — open a class from the search, then press Back (from the search link above)

The preview was rendering nothing at all, and this fixes it

Worth calling out separately from the five defects, because it affected every PR in this repo. VITE_HOST composes the absolute URL the locale JSON is fetched from; Production sets it in the dashboard and Preview had nothing, so previews shipped .env's localhost:5174 to a pages.dev origin. Every locale fetch then became a blocked private-network request, i18next's init never resolved, and the page rendered blank — no canvas, no content, no readiness marker. PR #178's preview carries the identical bundle string, so this was not introduced here.

vite.config.ts now falls back to CF_PAGES_URL — Cloudflare's own "URL of the current deployment", documented for precisely this. Verified across all three build shapes; an explicit VITE_HOST still wins, so production is untouched and hosts still fetch from sahajatlas.com exactly as docs/embedding.md promises. Confirmed on the deployed preview: /locales/en/common.json now returns 200 from the deployment's own origin.

Also worth a note for the smoke lane's invariants: Smoke passed against a preview that rendered nothing, because those specs are fetch-based over _headers, _redirects and robots.txt and never boot the app. "The specs ran" was true; it just could not mean "the widget works".

What was wrong, and why

1. Searching a city and tapping a pin zoomed out to the whole world first.
DrawerStack renders the active view inside <AnimatePresence mode="popLayout">, which keeps the OUTGOING view mounted for its 150ms exit — and router context still reaches it. So SearchView, whose framing deps are ?center/?bbox, re-rendered under the event's URL, read both as absent, and re-ran its effect into frameSearch({}) → moveMap({ zoom: 0 }). EventView then resolved a cold event read (map pins are never prefetched) and flew back in from zoom 0.

topViewKey names which view the base drawer is actually showing, and useFrameOnTop compares its mount value against the live one. It is derived through baseStackEntry, not compared as a pathname, because a trailing filters over the calendar is a modal overlay whose base view is still the calendar — and DrawerStack now derives top through the same helper so the two cannot drift. The guard is deliberately not "did the location change": a re-search moves ?center and must still re-frame the same view. Both cases are pinned.

frameSearch was also carrying two meanings. With no bbox and no centre nothing was searched, so nothing is framed and the camera stays put; only the root view wants the world, and it now asks by name via reset() — which the seam already declared and nothing called. That branch is why pressing Search from a region used to throw the map to zoom 0 while SearchView was simultaneously snapshotting that camera to rank by.

2. Geolocation zoomed to a street corner and left the list alone. The control was a bare <GeolocateControl />: mapbox's own _updateCamera fits the accuracy circle at zoom 15, and with no handler nothing navigated. It is now a navigation rather than a camera command — /search?center=…&bbox=…, so SearchView's existing frameSearch does the framing (inheriting the REGION_MAX_ZOOM cap), the list re-ranks, and the bottom sheet rises out of its peek. nearbyBounds frames the visitor plus the nearest few classes, floored at NEARBY_RADIUS_KM and capped at NEARBY_MAX_KM — the same radius that already decides whether the IP prompt is offered at all, so a class the app declines to suggest cannot widen the camera either. A browser fix carries no place name and no country, so it is reverse-geocoded for both, after navigating.

3. The chosen language now appears in the URL. ?locale= was already half a contract — i18next's detector reads it and docs/embedding.md documents it — but nothing ever wrote it. ⚠ A viewer's ?locale= now outranks the script URL's locale=, which is a deliberate reordering of the documented precedence chain and the point of writing it: deferring to the host would revert the visitor on the next load, on exactly the hosts that pin a language.

4. The language menu listed every language in the wrong language. A French visitor looking for English was offered "anglais" — the one thing the menu exists for was the one thing it could not do. It now reads čeština · Deutsch · English · español · français · magyar · Nederlands · português (Brasil) · русский · українська.

5. Deep links played a long zoom in from the world. <ReactMapGL> is deliberately uncontrolled and takes no initialViewState, so it boots at [0,0] zoom 0 while the region or event query is in flight. useCameraSettled makes the session's first camera command arrive rather than fly, and holds the canvas behind a frosted curtain until it does, so the world frame is never painted. Every later transition flies exactly as before, so drilling in and backing out stay symmetric. The predicate is deliberately not isEntry — that is atlasDepth === 0, true for a structural climb as well as a deep link, so dismissing an event up to its region would have jumped.

Verified in a browser, because three of these could not be tested any other way

Driven with Playwright against stubbed CMS reads.

before after
search → tap a class zoom 11.29 → 0.75 (the world) → back in 11.29 → 15, minimum 11.29
deep link to a region world visible, then a long arc canvas held at opacity: 0 behind blur(12px), then arrives
find my location camera to zoom 15, list unchanged /search at zoom 8.9, list re-ranked, field reads the resolved place
pick Russian nothing in the URL ?atlas=%2F&locale=ru, no new history entry, survives a reload

Going back from a class still flies and still restores the remembered viewport (11.29), which is the asymmetry the first-move jump had to avoid breaking.

The world-reset case was A/B'd by restoring the defect and re-running: it reproduces at 0.75 and disappears with the fix, so the measurement is not vacuous.

What review found afterwards

/code-review high raised five issues, all real and all fixed in fix(map): close four gaps…:

  • A late reverse-geocode could hijack a route the visitor had moved to — it resolves a few hundred ms after the navigation, easily long enough to tap a class, and its replace overwrote whatever entry was current with no Back to undo it.
  • That replace went through useAtlasNavigate, which is for pushes — it stamps atlasDepth and remembers the camera, so an entry that added no history left the drawer stack drawing a peek strip for a back-step that does not exist.
  • useCameraSettled outlived the map it described. A compact embed unmounts the interface when its dialog closes, so the second expansion would have met a stale true — no curtain, and a fly across the planet. Both fixed defects, back on the second view.
  • reset() did not clear the emphasized pin, so the root peek strip left a class's pin drawn over the zoomed-out world.
  • A hidden map was still an interactive one: opacity: 0 hides the canvas but leaves it clickable, and the curtain over it is pointer-events-none.

Earlier, a browser run caught one that no gate could: onGeolocate is bound when Mapbox constructs the control — the same construction-only behaviour the repo already documents for locale — so the handler's captured setSearchParams rewrote the completed search back to the route the widget booted on. It reads live router state through a ref now.

/security-review found no qualifying vulnerabilities. Its one candidate — the device fix landing in the host page's query string — was scored 3/10 by adversarial filtering and is not reported: the coordinates exist only after an explicit press and a browser permission prompt scoped to the host origin, and they land in the visitor's own address bar. It did surface a genuine inconsistency, which is fixed: the same commit coarsened ?q to a town citing "a visitor's doorstep", then wrote that doorstep at full float precision in ?center. Now rounded to ~110m — orders of magnitude below anything the feature resolves.

Tests

+22 specs. Each was seen to fail with its defect reintroduced at the site that caused it, per .claude/rules/tests.md:

  • topViewKey — red when the filter-overlay peel is dropped
  • placeSearchPath — red when built from the previous params, so a stale country leaks
  • nearbyBounds — red when the floor, the cap, the k-nearest slice or the geometry guard goes
  • useCameraSettled — red when markSettled stops being identity-idempotent (a map re-render per camera move), and covers the forget
  • nativeLanguageLabel — red when it falls back to the active locale, reproducing "anglais"
  • localeHref / pageLocaleOverride — red when the supported-language check goes
  • frame-on-top.test.tsx (jsdom) — two mounted views under one router, which is what popLayout actually produces; red when the guard line is deleted

One change ships deliberately without a spec: the construction-only closure fix. The defect lives in the binding between a library's control construction and a React closure, use-mapbox.ts cannot be imported in the node lane at all, and a spec asserting callback stability would have stayed green through both versions. .claude/rules/tests.md already carries this lesson from #132.

Host-facing

docs/embedding.md and CHANGELOG.md in the same PR, per CLAUDE.md. No CSP change — the reverse geocode reaches api.mapbox.com, which the forward geocoder already requires; the check was made rather than assumed, and the row now says so. .claude/rules/mapbox.md had three statements this branch made stale.

Worth a human eye

  • The locale precedence inversion is the one intentional behaviour change for existing hosts. A host pinning locale=fr will now be overridden by a visitor's own ?locale=nl on a shared link. This was chosen deliberately; say so if you would rather the host always win.
  • The geolocate fit at zoom 8.9 above is fixture-driven — the stub's 4th-nearest class is in Rotterdam, 57km out. Real data is denser and will frame tighter.
  • Overlaps open issue feat(i18n): take the language set from SahajCloud, not from supportedLanguages #167 (take the language set from SahajCloud, not from supportedLanguages). nativeLanguageLabel takes a code and returns its endonym, so it survives that migration unchanged — but whoever picks feat(i18n): take the language set from SahajCloud, not from supportedLanguages #167 up should know the picker now builds per-language Intl.DisplayNames rather than one bound to the current locale.

🤖 Generated with Claude Code

Ardnived and others added 11 commits August 28, 2026 16:16
Searching a city and then tapping a pin zoomed the map out to the whole
world before flying back in to the event.

DrawerStack renders the active view inside `<AnimatePresence mode="popLayout">`,
which keeps the OUTGOING view mounted for its 150ms exit — and router context
still reaches it. So SearchView, whose framing deps are `?center`/`?bbox`,
re-rendered under the event's URL, read both as absent, and re-ran its effect:
`frameSearch({})` fell through to `moveMap({ zoom: 0 })`. EventView then
resolved a cold `['event', id, locale]` (map pins are never prefetched) and flew
in from zoom 0.

`topViewKey` names which view the base drawer is actually showing, and
`useFrameOnTop` compares its mount value against the live one — a view that is
no longer on top does not own the camera. It is derived through `baseStackEntry`
rather than compared as a pathname, because a trailing `filters` over the
calendar is a modal overlay whose base view is still the calendar; DrawerStack
now derives `top` through the same helper, so its AnimatePresence key and this
guard cannot drift.

The guard deliberately is NOT "did the location change": a re-search moves
`?center` and must still re-frame the same SearchView. Both cases are pinned.

Also splits the two meanings `frameSearch` was carrying. With no bbox and no
centre nothing was searched, so there is nothing to frame and the camera stays
put — that branch used to reset to the world, which made pressing Search from a
region throw the map to zoom 0 while SearchView was simultaneously snapshotting
that camera to rank by. Framing the world is something only the root view wants,
and CountriesView now asks for it by name via `reset()`, which the seam already
declared and nothing called.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…nmount

EventView cleared the map's selection from an effect cleanup. Two things were
wrong with that, and neither is reachable by the exiting-view guard, because an
unmount cleanup is never the active view.

It ran 150ms after the incoming view had already framed — the length of the
drawer's exit animation — so on a back navigation it wiped the `selection` and
`boundary` that `restore()` had just reinstated from the camera snapshot, and on
a push to a region it wiped the boundary `frameRegion` had just set.

And its dependency was `clearSelection`, whose identity changes whenever the
controller memo re-creates. That memo depends on the mapbox callbacks, which
depend on the camera padding — so a resize or an orientation change while an
event was open cleared the pin with no navigation involved at all.

The emphasized point belongs to whatever framed the camera last, so
`frameRegion` and `frameSearch` now clear it themselves, beside the boundary
they already cleared. `restore` and `frameEvent` already set both. With no
caller left, `clearSelection` is dropped from the seam rather than kept as an
unused member — an unused seam member is an invitation to write this bug again.

One accepted consequence: opening the calendar over an event no longer clears
the pin, since CalendarView never frames. The calendar is full-width and the pin
is behind it, and `restore` reinstates it on the way back.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…om the world

Loading straight into a region or an event played a long, disorienting zoom:
the map appeared showing the whole planet and then flew across it to wherever
the link pointed.

`<ReactMapGL>` is deliberately uncontrolled and takes no `initialViewState`, so
it boots at [0, 0] zoom 0 while the region or event query is still in flight.
The framing that follows was an ordinary `flyTo`, and a fly from zoom 0 to zoom
15 arcs over half the world.

`useCameraSettled` records whether the camera has arrived anywhere yet. Until it
has, `flyTo` jumps and `fitBounds` fits without animating; everything after
flies exactly as before, so drilling in and backing out stay symmetric.

The predicate is deliberately NOT `isEntry`. That is `atlasDepth(location) === 0`,
which is true for a fresh deep link AND for a structural climb — so dismissing an
event up to its region an hour into a session would have jumped. "Has the camera
moved yet" is a fact about the map, and it is exactly the condition under which a
fly is disorienting.

The canvas is also held until then, so the world frame is never painted at all:
it fades in on the same flag behind `MapCurtain`, a backdrop-blurred overlay with
the Spinner atom. The spinner fades in on a 200ms CSS delay so a warm boot reads
as a clean frost-then-reveal rather than flashing a spinner nobody registers, and
a timeout armed on style load reveals the map anyway after 1.5s — CalendarView
never frames the camera, so a /calendar deep link would otherwise stay hidden for
the session.

Two library mechanics were measured against mapbox-gl 3.9.2 rather than assumed,
and both are recorded in the hook: the instant point move is `jumpTo` (what
flyTo's own reduced-motion branch delegates to, keeping padding through the
`pick`), and an instant bounds fit needs BOTH `linear: true` and `animate: false`,
because `_fitInternal` only reaches the `easeTo` that honours `animate` when
`linear` is set.

This is not a reduced-motion branch and must not become one: it reads no media
query and passes no `essential: true`. Under the preference mapbox already jumps,
so the first move is a no-op difference and every later one is untouched.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Pressing the geolocate control zoomed to street level and did nothing else:
mapbox's own `_updateCamera` fits the accuracy circle at zoom 15, so every class
was off-screen, and with no `onGeolocate` handler the results list never
re-ranked from where the visitor actually is.

It now navigates to `/search?center=…&bbox=…`, which makes it a navigation
rather than a camera command — SearchView's existing `frameSearch` does the
framing (capped at REGION_MAX_ZOOM for free), the list re-ranks by distance from
the fix, and the bottom sheet rises out of its peek.

`nearbyBounds` computes the frame: the visitor's point unioned with the nearest
few classes, floored at NEARBY_RADIUS_KM so standing on top of a venue gives a
neighbourhood rather than the degenerate box `fitBounds` answers with maximum
zoom, and capped at NEARBY_MAX_KM. Both bounds are reused rather than invented —
the cap is already this module's definition of "genuinely near", the thing that
decides whether the IP prompt is offered at all, so a class the app declines to
suggest cannot widen the camera either.

`followUserLocation={false}` stops mapbox moving the camera itself. The flag
gates only `_updateCamera` in `_onSuccess`, so the blue dot, the accuracy circle,
the permission flow and the localized labels all stay. (Mapbox's own .d.ts claims
otherwise; its source disagrees, and the source is right.)

A browser GeolocationPosition carries no place name and no country, so the fix is
reverse-geocoded for both — but AFTER navigating, never before: getting here has
already cost up to six seconds of `positionOptions.timeout`. `?q` then labels the
field and `?cc` turns on the country-site offer and the foreign-distance rule.
It resolves null on any failure, which costs a label rather than the feature.

Supporting changes, each of which removes a way to get this wrong:

- `preserveSearchState` moves to `lib/shape/path.ts` and gains `placeSearchPath`,
  one builder for the three things that name a searched place. Each previously
  hand-rolled the same four params, one forgotten call away from silently
  clearing somebody's filters. It was also module-private and untested.
- `geocodeBounds` narrows the geocoder's `LngLatBoundsLike` to the four numbers
  `?bbox` carries. The previous inline `.toString()` would have written
  `[object Object]` for a LngLatBounds instance, which `parseBounds` discards in
  silence — degrading the fit to a pinpoint with nothing to show for it.
- MapSearch adopts a `?q` written by anyone else. It seeded from the URL only in
  its state initializer, which was right while typing was the only writer; the
  field would otherwise keep naming a place the results are no longer about.
- The bottom sheet lifts out of its peek on a new `?center`. The geolocate
  control lives on the map, so "drag the sheet down, then press locate" is the
  likely gesture — and it re-searches without changing `top.kind`, which is all
  the existing snap effect watched.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The language menu labelled every option through the ACTIVE locale's
`Intl.DisplayNames`, so the one thing it exists for was the one thing it could
not do: a French visitor looking for English was offered "anglais", a Russian one
"английский", and someone who could not read the current language had no way to
find their own.

`nativeLanguageLabel` builds the label with the code as both the display locale
and the subject, which is what makes it an endonym — čeština, Deutsch, English,
español, français, magyar, Nederlands, português (Brasil), русский, українська.
It reuses the module-level DisplayNames cache, so offering ten languages costs
ten ICU objects for the widget's lifetime rather than ten per render.

The submenu trigger showing the CURRENT language was already an endonym by
construction, since its DisplayNames was built in the locale it was naming. It
now says so outright, so the row and the list it opens cannot drift apart.

`languageLabel` is deliberately untouched: it names an event's language inside a
filter, where the reader is reading the current UI language and "Russian" is the
right word. Each row also carries `lang`, so a screen reader pronounces the
endonym in the language it belongs to rather than through the page's.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Picking a language from the settings menu changed the widget and left the
address bar describing the page as it was before — nothing to copy, nothing to
reload into, and no way to hand somebody the atlas in the language you were
reading it in.

`?locale=` was already half a contract: i18next's detector reads it and
docs/embedding.md documents it to integrators. Nothing ever wrote it. The
settings menu now publishes the pick with a `history.replaceState`.

`replaceState` rather than a push, because a language is a preference and not a
place — pushing would leave an entry in the host's history whose only effect on
Back is to change the language again. `history.state` is passed through verbatim,
which keeps the atlas history's own slice: drop it and the drawer's next X climbs
to the structural parent instead of going back, and the camera snapshot taken
against that entry key is stranded. It does not go through AtlasRouter, which
would mint a route entry; writing behind the history's back is safe precisely
because `?atlas=` is untouched, and that is the only parameter it re-reads.
Skipped entirely in memory routing, where the route deliberately isn't in a URL.

The write lives in SettingsMenu rather than in `useLocale().setLocale`. That hook
is called by every card in a list that pages to hundreds of rows, and this is the
one place a viewer picks a language — a context read and a URL write on that path
would serve one menu at the cost of the app's hottest one.

**A viewer's `?locale=` now outranks the script URL's `locale=`**, which is a
deliberate reordering of the documented precedence chain and the point of writing
the parameter at all: deferring to the host would revert the visitor on the very
next load, on exactly the hosts that pin a language, and the link they shared
would carry a language it does not honour.

`pageLocaleOverride` insists the parameter names a language we actually ship
rather than merely being present — a junk `?locale=zz` resolves to English
through `supportedLngs`, and letting that suppress a host's `locale=fr` would be
a worse answer than either party asked for. It takes the supported set as an
argument rather than importing it: `config/i18n-options.ts` imports LOCALE_PARAM
from this module, so reaching back would close a cycle that typecheck cannot see
and that surfaces as a TDZ ReferenceError at boot, in whichever load order the
bundler happens to pick.

docs/embedding.md carries the inverted precedence, a section on the write, and
the parameter in the list of what the widget touches on a host's page.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Everything a host or their visitors can observe from the five fixes, per the
rule that the integrator guide and the changelog change in the same PR as the
behaviour they describe.

embedding.md: the Permissions Policy row now says what the geolocate control
actually does (it opens the nearby class list, not just a camera move), so a host
reading the table knows what breaks when `geolocation` is denied. The
`connect-src` row for api.mapbox.com names the reverse lookup alongside the
forward geocoder — the check was made rather than assumed, and the answer is that
this adds no CSP row, because the place-search geocoder already reaches the same
origin. The list of what the widget touches on a host's page gains the query
string, naming both parameters it claims.

CHANGELOG: entries for the two visible additions and the three fixes, written for
somebody who embeds the widget rather than somebody who works on it. The existing
`locale` precedence line is corrected in place — it stated the old order, which
this branch inverts.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…e closure

Found in a browser, and invisible to every gate: pressing "find my location"
navigated to `/search?center=…&bbox=…` correctly and then immediately rewrote the
URL back to `/?q=…&cc=…`, dropping the search it had just performed.

`onGeolocate` is bound ONCE, when Mapbox constructs the control — the same
construction-only behaviour `Map.tsx` already documents for the `locale` prop.
The handler therefore closed over the `searchParams`, `setSearchParams` and
`location` of the render in which the map mounted, and the reverse-geocode phase's
`setSearchParams(…, { replace: true })` replaced the wrong entry with a merge onto
the wrong base.

The handler now reads `navigate` and `searchParams` from a ref refreshed on every
render, and the naming phase rebuilds the whole destination from the same base and
place rather than merging onto whatever the URL says by the time it resolves. So
the label cannot disturb the search it is labelling.

Verified end to end in a browser, which is the only thing that could see it:

  pushState    -> /search?center=4.9003,52.3791&bbox=4.4777,51.9244,5.2686,52.6039
  replaceState -> /search?q=Amsterdam, North Holland, Netherlands&center=…&bbox=…&cc=NL

with the fit settling at zoom 8.9 rather than mapbox's 15, the search field reading
the resolved place, and `followUserLocation={false}` confirmed to suppress mapbox's
own camera move (the map did not budge from zoom 0.75 before our framing ran).

No unit spec accompanies this one deliberately. The defect is in the binding
between a library's control construction and a React closure — `use-mapbox.ts`
cannot even be imported in the node lane, and a spec asserting callback stability
would have stayed green through both the broken and the fixed version. The repo
already carries this lesson from #132: when a helper's output feeds a caller,
something has to exercise the caller.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
All four are cases where a change earlier in this branch was right about the
common path and silent about an edge.

**A late reverse-geocode could hijack a route the visitor had moved to.** The
naming phase fires a few hundred ms after the navigation — easily long enough to
tap a class — and its `replace` overwrote whatever entry was current by then,
with no Back to undo it. It now labels the search only while the visitor is still
on the route it pushed, compared exactly, since both sides come from
`placeSearchPath` over the same inputs.

**That replace also went through `useAtlasNavigate`, which is for pushes.** It
stamps an incrementing `atlasDepth` and remembers the outgoing camera, so an entry
that added no history left the drawer stack drawing a peek strip for a back-step
that does not exist. It uses the raw navigate now, carrying `state` explicitly the
way MapSearch does.

**`useCameraSettled` outlived the map it described.** The store is module-global
and the map is not: a compact embed unmounts the whole interface when its dialog
closes. On the second expansion a stale `true` would have met a fresh map at [0,0]
zoom 0 — no curtain, and a fly across the planet. Both of the defects the store
exists to fix, back on the second view. It is now forgotten from the map's own
unmount, and `store.test.ts` pins that.

**`reset()` did not clear the emphasized pin.** Moving selection ownership into
the framing calls covered `frameRegion` and `frameSearch` but missed the one the
root view actually calls, so pressing the root peek strip out of an event left its
pin drawn over the zoomed-out world.

**And a hidden map was still an interactive one.** The curtain hides the canvas
with `opacity: 0` and is itself `pointer-events-none`, so a click landed on pins
nobody could see — reachable on any route that never frames the camera, where the
reveal waits out the 1.5s backstop. The canvas is inert while hidden.

Re-verified in a browser: geolocate still lands on /search with the fit at zoom
8.9, the resolved place in the field, and both history writes in the right order.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The geolocate feature was internally inconsistent about the same question.
`reverseGeocode` deliberately asks Mapbox for a `place` rather than a street
address, on the stated grounds that "a visitor's doorstep is not something to
write into a shareable URL" — and then `?center` beside that label carried the
doorstep at full float precision.

Rounding to ~110m closes it. Nothing the feature can see changes: the frame is a
neighbourhood (NEARBY_RADIUS_KM is 25km) and the list ranks over hundreds of km,
both orders of magnitude coarser. What it buys is that the coordinates a visitor
might copy into a link, or that their host page's analytics scrape off the query
string, are a neighbourhood rather than an address.

In the hook rather than in `placeSearchPath`, because the other two callers pass
a typed geocode or an IP guess — already public and already coarse — and blurring
those would cost accuracy for nothing.

Raised by the branch security review and deliberately NOT recorded as a
vulnerability: the coordinates exist only after an explicit press and a browser
permission prompt scoped to the host origin, and they land in the visitor's own
address bar. Adversarial filtering scored it 3/10 as a security finding. It is a
privacy-consistency tidy-up, and it is worth making because the same commit was
already arguing for it one field over.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`.claude/rules/mapbox.md` is path-scoped to the map subsystem and auto-loads when
those files are edited, so a stale claim there is read as current by whoever
touches this next. Three of its statements are no longer true, and two things this
branch learned belong in it.

Corrected: the seam member list still named `clearSelection`, which is gone;
`frameSearch({})` no longer resets to the world, and the rule now says which call
does and why the two were split.

Added, both because they cost real time to find and neither is visible from the
source alone: that a Mapbox control's HANDLERS are construction-only just as its
`locale` is — the trap that let a stale closure rewrite a completed search, which
every gate passed — and that the first camera command of a session arrives rather
than flying, with the three mechanics that make it work (`jumpTo`; `linear` AND
`animate: false` together; the flag being forgotten on unmount, without which a
compact embed's second expansion brings both defects back).

Also a short section on the geolocate control now being a navigation rather than a
camera move, carrying the `followUserLocation` finding — where mapbox's own types
contradict its source — and the coordinate rounding.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Deploying sahajatlas with  Cloudflare Pages  Cloudflare Pages

Latest commit: eba3d6e
Status: ✅  Deploy successful!
Preview URL: https://e41d56c1.sahajatlas.pages.dev
Branch Preview URL: https://claude-fix-reported-defects.sahajatlas.pages.dev

View logs

Every preview deploy of this repo rendered nothing at all, and had done for a
long time — this branch's preview, and PR #178's before it, both ship
`http://localhost:5174/locales/` in the bundle.

`VITE_HOST` composes the absolute URL the locale JSON is fetched from, and it has
to be absolute: embedded, the widget runs on the host's page while its
translations live wherever the bundle came from. Production sets it in the Pages
dashboard. **Preview deploys had nothing**, so they inherited `.env`'s
`localhost:5174` and shipped it to a `pages.dev` origin — every locale fetch then
a cross-origin request to the reviewer's own machine, blocked as private-network
access.

That does not degrade into missing strings, which is what makes it easy to miss.
i18next's `init` never resolves, every component reading a translation suspends
forever, and the page renders blank: no canvas, no content, no readiness marker.

`CF_PAGES_URL` is Cloudflare's own answer — the URL of the current deployment,
documented for exactly this ("allowing build tools to know the URL the page will
be deployed at"). Taking it in `vite.config.ts` rather than adding a dashboard
variable is deliberate: a preview host is per-deployment, so no static value could
work, and this way forks get it too.

Verified against real builds, all three cases:

  pnpm build                            → http://localhost:5174/locales/   (unchanged)
  CF_PAGES_URL=… pnpm build             → https://abc12345.…pages.dev/locales/
  VITE_HOST=… CF_PAGES_URL=… pnpm build → https://sahajatlas.com/locales/  (unchanged)

The third is the one that matters for safety: an explicit value still wins, so
production is untouched and `docs/embedding.md`'s promise to hosts — that UI
strings come from `sahajatlas.com` — stays true. No host-facing change, so that
guide and CHANGELOG.md are deliberately not touched.

Worth noting for whoever reads the smoke lane's invariants: the Smoke job passed
against a preview that rendered nothing, because those specs are fetch-based over
`_headers`, `_redirects` and `robots.txt` and never boot the app. "The specs ran"
was true; it just could not mean "the widget works".

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

Ardnived and others added 4 commits August 28, 2026 17:54
…mes from

The `VITE_SAHAJCLOUD_API_KEY` row read "the key the widget uses in dev", which is
what made a keyless preview look inexplicable next to a keyless production site.

It is not dev-only. `main.tsx` falls back to it whenever the URL carries no
`?key=` — `searchParams.get('key') || import.meta.env.VITE_SAHAJCLOUD_API_KEY` —
so it is inlined into every deploy that has it set, which is why sahajatlas.com
renders keyless and a preview answers `Missing api key`.

Both mentions now say so, and the row carries the consequence: set it in the Pages
**Preview** environment as well as Production, or every preview needs `?key=`
appended by hand. Noted there too is why this one cannot be defaulted in
`vite.config.ts` the way `VITE_HOST` now is — there is no Cloudflare-provided
value to fall back to, and the key must stay out of the committed `.env` or it
would ship to every fork and every `pnpm dev`.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Every existing smoke spec asks whether a file was deployed. None asks whether
what was deployed points anywhere real — which is why every preview in this repo
could render a completely blank page while the whole lane stayed green.

`boot-origins.smoke.test.ts` reads the eager graph back off the deploy and checks
the two origins the app will actually request from, `${VITE_HOST}/locales/` and
`${VITE_SAHAJCLOUD_URL}/api`, naming the variable rather than just the string —
"which env var produced this" being the only useful next question.

Proven against both real artifacts rather than a simulation. The broken
deployment is still live, so the A/B is exact:

  c6e49822 (broken)  → FAIL: locale JSON (VITE_HOST) → http://localhost:5174
                             (/assets/api-d6S0tmYy.js)
  branch alias (fixed) → 4 passed, whole lane 19 passed

Three properties are load-bearing, and two of them are corrections to my own
first draft:

- **Targeted, not a sweep.** Scanning for any private host anywhere flagged a
  healthy deploy: react-router carries its own literal `http://localhost` as the
  `createURL` base for when there is no `window.location`.
- **Reading the string is the deterministic half; dialling the origin is not.**
  The companion test fetches whatever origin was baked in, and it cannot own the
  localhost case — anyone running `pnpm dev` has something answering on 5174, so
  against the very deploy that shipped this bug it passed on my machine and would
  only have failed on a runner. Measured, not assumed; each docblock now says
  which half it owns.
- **A missing match fails rather than passing empty.** If an origin stops
  matching, the assertions would go vacuously green — the failure this lane's own
  history says is hardest to notice.

⚠ It still does not prove the widget RENDERS, and no fetch-based spec can. That
is acceptable here only because this defect is a string in the bundle, so reading
it back is a direct observation rather than an inference. A runtime-only failure
still needs a browser, which stays local per the note atop `embed.smoke.test.ts`.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…en the spinner

Two things wrong with the loading state, both visible the moment you actually look
at it — which I had not done: I verified the mechanism (canvas held, curtain up,
reveal fires) and never once photographed the result.

**The frost showed nothing at all.** The canvas was held at `opacity: 0` AND
frosted, and the two cancel out: `backdrop-filter` filters what is BEHIND the
element, so with a transparent canvas there was nothing to blur and the tint
painted onto the page's own white. A blank screen where a soft map should be —
the opposite of the point, since a frost works by letting you see that something
is there. The canvas now stays opaque and the overlay blurs it for real, at a
much lighter `sm`/4px over a 20% tint rather than `md`/12px over 60%.

It stays non-interactive while blurred, which is now the honest reason rather
than a workaround: a map nobody can read clearly should not take clicks.

**The drawer spinner carried a redundant caption.** `DrawerLoadingBody` passed
`label`, which draws "Loading…" under the glyph — a word a spinner already says —
and that caption is also what pushed the glyph itself off centre, since the column
centres as a unit and the label's height sits half of it below the middle. It
passes `srLabel` now: announced, not drawn. Measured after: the glyph's centre and
its container's centre are both at y=451.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The first thing a visitor sees — the app-level fallback, before the interface or
even the map exists — sat 140px tall at the TOP of the window with its spinner
centred in that 140px rather than on screen. Measured at an 800px viewport: the
surface ran 0→140, the glyph's centre was y=70.

`APP_SURFACE` sizes with `h-full`, and a percentage height against a parent with
no definite height resolves to `auto`. An unboxed map embed has exactly that by
design — it measures zero height, because everything the interface draws is
`position: fixed` and the element takes no room in the host's layout — and the
standalone shell's `<html>` is no different. So the surface shrink-wrapped to its
own content, every time, in the most common form.

It now mirrors what it stands in for: that interface is `fixed; inset: 0`, so in
that form the fallback is too. Measured after: the surface runs 0→800 and the
glyph sits at exactly (600, 400).

**The caller decides, rather than the component guessing.** A contained map, a
map-less embed and the compact card all have a real box where `h-full` is already
correct, and taking the viewport there would paint over the host's page — or, in
the compact form, over the very margin the expanded dialog keeps so the page shows
through and can be clicked to close. `App` and `AppShell` both have `hasMap`,
`contained` and `compact` in scope at the mount point, so neither has to infer it.
Verified that `?map=0` still renders `position: static` and in flow.

It also drops the visible "Loading…" to `srLabel`, the same call `DrawerLoadingBody`
now makes — announced, not drawn, and its height was a second reason the glyph sat
below centre.

⚠ `ErrorFallback` shares `APP_SURFACE` and so has the same collapse in the same
form. Left alone here because it takes `FallbackProps` from the error boundary
rather than props from the call site, so giving it the same switch is a different
change — worth doing, but not silently inside this one.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@Ardnived
Ardnived merged commit 7bdbd04 into main Aug 29, 2026
5 checks passed
@Ardnived
Ardnived deleted the claude/fix-reported-defects branch August 29, 2026 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant