Repository navigation
feat(widget): classify errors, and make every empty screen recoverable - #90
Merged
Merged
Conversation
Ardnived
added a commit
that referenced
this pull request
Aug 6, 2026
Seven new keys for the per-entity not-found copy and its recovery ladder, across all ten locales. Two rewords of copy #90 shipped: - `not_found` said "We couldn't find that page." The widget has no pages, and embedded in someone else's site "that page" reads as the HOST's — misassigning the fault and naming nothing the viewer can act on. It becomes the generic line, used only where no view context exists; EventView and RegionView now say "that event" / "that place". - `config` said "This Atlas embed isn't set up correctly." "embed" is developer jargon, and every locale had localized it as jargon. Refs #89 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Ardnived
added a commit
that referenced
this pull request
Aug 6, 2026
Both fallbacks centred their content in a DrawerBody that fills an h-dvh sheet (vaul computes snap translates off the window height), while the mobile sheet only shows its top 300px. So `items-center` placed them at roughly 1.5x viewport minus 300 from the top — below the fold. On every phone, loading rendered a blank sheet and an error rendered a blank sheet. That is the "nothing happened when I tapped" report, and it also meant the error copy #90 added was invisible on the surface where most viewers meet it. Both are top-aligned now, matching EmptyResults and EmptyEventList. Also gives MapSearch two defaulted props ahead of the not-found body that needs them: `syncToUrl`, so the field can stop mirroring into a URL we've just told the viewer is broken (embedded, that URL is the host page's fragment and rides along in anything copied), and `label`, since the default placeholder promises nearby events — wrong in an error state. Refs #89 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Deploying sahajatlas with
|
| Latest commit: |
fb5ea97
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://ecf80db2.sahajatlas.pages.dev |
| Branch Preview URL: | https://feat-classify-errors.sahajatlas.pages.dev |
Deploying sahajatlas-design with
|
| Latest commit: |
fb5ea97
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://863d8b93.sahajatlas-design.pages.dev |
| Branch Preview URL: | https://feat-classify-errors.sahajatlas-design.pages.dev |
Both fallbacks render a fixed button list today, so most of what a viewer sees on an error is noise or a dead end — "Try again" for a region that doesn't exist, "See nearby events" for a dropped connection, "Report an issue" for their own offline state. `classifyError` narrows a thrown value to one of six kinds, and ERROR_POLICY holds what each kind may say and offer, as data — so neither fallback has to hard-code a button list. Order matters: an HTTP status is checked first (it proves a server answered, which outranks anything navigator.onLine claims), and navigator.onLine last, as the weakest signal. It never throws — it runs inside an error fallback, where a throw would blank the widget on the host page. Refs #89 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`errorMessage(error)` renders the raw thrown developer string — "Region has no events: pune", "SahajCloud request returned no data: /events/geojson" — untranslated, to a viewer, inside someone else's host page. Each kind gets a sentence instead. Added across all ten locales rather than en-only: short common.json labels in this repo have a habit of shipping en and leaning on the fallback. Refs #89 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Each fallback hard-coded its own button list — the drawer always three, the app level always one — so neither asked whether the action could help, and the two could drift on what the same failure offers. Both now read `errorPolicy(error)` and render the shared ErrorActions, differing only in chrome. The app-level fallback gains a retry it never had (it takes `resetErrorBoundary` now), gated on the policy rather than on availability. The raw thrown string stops being the headline everywhere; it still reaches openReport / ReportContext.error unchanged. Refs #89 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
getRegion threw "Region has no events" so the boundary rendered an error page — the one case where no button makes sense: a retry fails identically, and an empty region isn't a wrong turn to report. It resolves now and RegionView renders EmptyEventList, which the code already noted was unreachable precisely because of that throw. Framing is already null-safe: no located events means bounds/center are null and frameRegion clears its boundary rather than fitting a degenerate bbox. getCountries still hides 0-event countries from the home list, so this stays reachable only by a direct link or a region whose events have all ended. Refs #89 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Neither boundary was wrapped in QueryErrorResetBoundary, so
`resetErrorBoundary` handed the reset subtree a query still parked in its
error state, which threw again on the spot — a retry button that visibly
does nothing is worse than no button at all.
Both boundaries now take `onReset={reset}`, which clears those errors
first. The app-level one had no reset path at all.
Refs #89
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The view harness wrapped stories in the app-level ErrorFallback while the real drawer stack wraps its views in DrawerErrorFallback — so the stories previewed a screen the drawer never renders. It now mirrors DrawerStack's nesting, drawer-shaped fallbacks included. A `throws` escape drives any view story into its error state: the harness seeds its QueryClient synchronously and React Query has no public API for seeding a REJECTED query, so a thrower inside the boundary is the honest route. The thrown values are the real ones (mocks/errors.ts, shared by both stories), so a story exercises classifyError rather than being handed a kind. Each view gets the failure it actually reaches: EventView a dead link, SearchView a dropped connection, RegionView the empty region that no longer 404s. Refs #89 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Tag our own throws with their kind instead of regexing English back out of them. Six one-line `throw` sites become `atlasError(kind, message)`, and the SENTINELS table goes: a reworded message used to silently reclassify a failure — a dead region link degrading from "See nearby events" to "Try again + Report" — with lint, typecheck and the unit lane all still green. Same reasoning as RegistrationRefusedError, which carries a code rather than trusting prose. A `kind` from a host page's own rejection is rejected against the known set. Move ERROR_POLICY out of src/lib (declared React-free and i18n-free) into Fallbacks.tsx: an i18next key and three button flags are UI policy, not domain logic. The pure half — which KIND a failure is — stays in lib. Collapse the derivation both fallbacks were repeating into one `useErrorDisplay`, so the "localized copy on screen, thrown string in the report" rule is stated once. That also fixes DrawerErrorFallback missing the `useSuspense: false` its twin had. Also: pass Thrower as children rather than adding a `throws` prop to the shared harness; hold the per-kind rationale once in mocks/errors.ts; assert every fixture classifies as its own key, so the stories stay honest without a browser; searchPath() over a hardcoded '/search'; and drop a stale App.tsx comment claiming a lazy-load the code doesn't do. Refs #89 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- data-layer: throw `atlasError(kind, message)` rather than `new Error`, and why (a message is not a contract); a 0-event region resolves now - CLAUDE.md: what report.ts owns, and the pure/UI line the policy sits on - DESIGN_SYSTEM: the Fallbacks folder's new exports - i18n-and-state: the report CTA is the policy's call, not the fallback's Refs #89 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Three of these could strand a viewer on a third-party page:
- A fetch TypeError was read as "you appear to be offline", but `fetch`
rejects identically for a DNS failure, SahajCloud being down, a
rejected CORS preflight, and a host CSP that omits `connect-src`. Since
`offline` suppresses the report CTA, the failures that are OURS or the
host's were the ones with no way to report them. Only the browser can
say the viewer is offline, so an ambiguous network failure is now
`server` — which keeps both the retry and the report.
- The app-level fallback offered "See nearby events", but that boundary
has no resetKeys and the drawer stack isn't mounted when the app failed
to boot: the button changed the URL and left the same error on top.
It no longer navigates there, and `visibleActions` guarantees the
narrowing can never leave a screen with zero buttons.
- Every sentence and label now carries English via `defaultValue`.
Nothing is bundled — i18next fetches each namespace over HTTP — so a
failure that beat the locale JSON rendered the raw key ("error.offline")
at the viewer, and for a network failure it never recovered, since the
JSON travels the link that just broke.
Also: match the tag with an own-property check, since `'toString' in
ERROR_KINDS` is true and would have returned a kind with no policy.
Refs #89
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`ERROR_POLICY[classifyError(error)]` was dereferenced unguarded on the next line. classifyError is total by construction, but its own-property check resolves hasOwnProperty at call time, and we render inside host pages free to patch Object.prototype. That is the one dereference that could break the promise both fallbacks are built on: a throw from there escapes the only boundary in the tree and unmounts the whole widget on someone else's page. Found by /security-review, which otherwise reported no critical, high or medium findings. Refs #89 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Two pure pieces the graceful error views need, ahead of anything that renders them. `nearestKnownRegion` answers "where do I send someone whose link 404'd": it drops the failing terminal entry (that entry IS what threw), then walks back for the first ancestor the region tree still carries. One rule steps over a register/share segment, a dead event id, and a renamed venue. Deliberately not `parentOf` — the parent of <event>/register is the event path, which 404s identically, so a parent-based recovery would hand the viewer a second dead link. `reportInternalError` is the seam for a failure that happens *while rendering an error state*. Callers degrade gracefully and the cause still gets recorded, rather than being swallowed where nobody sees it for months. There is no error reporter in this repo, so it logs to the console today and is the single call site one wires into later. Its own body is guarded: a host page may replace console.error, and logging must never be what takes the widget down. Refs #89 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Seven new keys for the per-entity not-found copy and its recovery ladder, across all ten locales. Two rewords of copy #90 shipped: - `not_found` said "We couldn't find that page." The widget has no pages, and embedded in someone else's site "that page" reads as the HOST's — misassigning the fault and naming nothing the viewer can act on. It becomes the generic line, used only where no view context exists; EventView and RegionView now say "that event" / "that place". - `config` said "This Atlas embed isn't set up correctly." "embed" is developer jargon, and every locale had localized it as jargon. Refs #89 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Both fallbacks centred their content in a DrawerBody that fills an h-dvh sheet (vaul computes snap translates off the window height), while the mobile sheet only shows its top 300px. So `items-center` placed them at roughly 1.5x viewport minus 300 from the top — below the fold. On every phone, loading rendered a blank sheet and an error rendered a blank sheet. That is the "nothing happened when I tapped" report, and it also meant the error copy #90 added was invisible on the surface where most viewers meet it. Both are top-aligned now, matching EmptyResults and EmptyEventList. Also gives MapSearch two defaulted props ahead of the not-found body that needs them: `syncToUrl`, so the field can stop mirroring into a URL we've just told the viewer is broken (embedded, that URL is the host page's fragment and rides along in anything copied), and `label`, since the default placeholder promises nearby events — wrong in an error state. Refs #89 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Every view renders its DrawerHeader inside the boundary and below its useSuspenseQuery, so a throw or a suspend erased the header and its close button along with the content. An error left the viewer with no way out of the drawer — and in the configurations with no peek strips (desktop, map-less) no swipe and no Esc either. `DrawerChrome` renders that header from the URL plus already-cached data, so it survives the query that's failing or pending. The title comes from the wholesale region tree (warmed at boot) for a region, the titles sliver for an event, and the view's own static string for the rest — which is what makes it worth showing instead of "Loading…". `canDismiss` on DrawerControl is the same expression `dismiss()` already evaluated internally, hoisted so the chrome can tell whether pressing X would go anywhere. At the root it wouldn't — there is no parent to climb to and navigate(-1) would take the HOST page back — so the chrome offers the collapse instead of a close that silently no-ops. `DrawerErrorBody` splits out for the boundaries landing next, which sit below a view's own working header and must not draw a second one. Verified in the browser: /atlantis now shows a close control that returns to the root. Refs #89 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Adds the three body-level boundaries — the only places a seam already exists, i.e. a child that owns its own suspense read below the view's header. No view is split to manufacture one: a split buys a header whose only still-working control is Close, which the shared chrome already provides everywhere. - CalendarGrid: the month nav, view picker, filters, close and the active pills read nothing from ['calendar', …], so a failed grid no longer takes them down. - DynamicEventsList: the geocoder stays live, so the escape from a failed search is to run a different one. - The lazy EventDetails chunk: the title, close and sticky Register CTA survive, so an event stays bookable when its description doesn't load. And closes the one drawer with no fence at all: a throw in the filter overlay escaped to the app boundary and blanked the whole widget. Safe today only because FilterView reads exclusively through non-suspense useQuery, which nothing structural was preserving. `resetKeys` is load-bearing rather than decorative. The drawer boundary is keyed on the PATHNAME, but a re-search or a filter change moves only the query string — so without it one failed fetch would pin its error over every later attempt, turning a transient failure into the permanent dead end this work exists to remove. Search deliberately excludes `?q` from its key: the geocoder rewrites it per keystroke, and keying on it would retry a failing query once per character. ErrorPanel splits from DrawerErrorBody because two of the three sites sit INSIDE an existing DrawerBody, where a second one would nest scroll containers. Refs #89 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The body-level boundaries reset on the query string while the drawer boundary keys on the pathname, so `resetKeys` is what stops a single failed fetch pinning its error over every later attempt. That is a re-render behaviour, and the lane's SSR-markup approach cannot express it. Split in two, cheapest part first: - `listResetKey` lifts the actual logic — which URL params change WHAT is queried — into a pure helper in lib/shape, tested in the node lane with no DOM. It covers the case that motivated it: `?q` is excluded because the geocoder rewrites it per keystroke, and keying on it would retry a failing query once per character typed. - `reset-boundary.test.tsx` covers the part that genuinely needs a DOM, opting into jsdom with a per-file `@vitest-environment` docblock so the lane stays node-only by default. `createRoot` + React 18.3's exported `act`; no Testing Library. tests.md said to add jsdom only as its own decision rather than sneak it in, so the rule now records the decision, the opt-in mechanism, and the bar for reaching for it again. Lane is 523 tests in ~1.6s. Refs #89 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
"See nearby events" navigated to a bare /search, which ranks from the
view-state default (0,0) — fifty events nearest Null Island, no distance
cap, no empty state, map zoomed to the world. On a fresh deep link there
is no map centre to fall back on, so that was the common case, not the
edge one.
A dead link now gets the empty-state register — neutral, role="status",
because a wrong turn is not a malfunction — naming what was missing and
offering one place to go, from the first rung that resolves:
1. the nearest ancestor in the URL the region tree still knows
2. the host's configured home region
3. a cached IP guess, read passively — never firing a lookup from an
error screen, since a blocked CSP is a plausible cause of the
failure being displayed
4. the country list, which always exists and so is the floor
Plus the prompted geocoder, which is the only option that reaches a place
none of the rungs would guess. It runs with syncToUrl={false}: this URL
is the dead one, and embedded it lives in the host page's fragment.
The copy names the noun the URL implies — "that event" / "that place" —
rather than "that page", which the widget doesn't have.
Per the never-fail rule, the offer is layer 2: it reads three caches and
mounts a geocoder, so it sits behind its own boundary that degrades to
the static floor rung and reports why. useRecoveryOffer is total
independently, so the boundary is the second line of defence.
ErrorPolicy.nearby retires with it — the flag was false for five kinds
and the sixth now owns its own ladder.
Verified against the seeded backend: /be/antwerpen/999999 offers
Antwerpen; /be/antwerpen/999999/register offers Antwerpen rather than the
dead event `parentOf` would have given; /999999 offers the country list
and lands there; /be/atlantis says "that place" and offers Belgium.
Refs #89
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
When a boundary trips mid-session, focus was on the card that was just activated — and that element has now unmounted, so focus falls to <body> and the next Tab starts at the top of the HOST page. A keyboard user was silently ejected from the widget they were using. The error region takes focus instead, which also gets the message announced: a live region doesn't do that reliably here, because both fallbacks mount already containing their text and a live region only announces content that changes after it exists. It only steals focus from <body> (or nothing). A background refetch can throw while the viewer is typing in the host page's own form, and moving their caret would be worse than a missed announcement — while costing nothing in the case this exists for, where an unmounted card leaves focus exactly there. Also pins a drift this turned up: the ERROR_POLICY fallbackText strings still carried the pre-reword wording, so a viewer whose locale fetch lost the race would have read different words than everyone else. They now match the shipped en copy, and a test keeps them that way — the failure mode is invisible precisely because those defaults only render when the network is already misbehaving. Refs #89 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Two of nine view stories had an error case. All nine are now accounted for, each previewing the failure a real viewer meets there rather than a generic one — and the dead-link cases exist to be COMPARED: - EventView: an ancestor the tree knows vs a flat legacy link, so the two recovery rungs sit side by side. - RegionView: under a region vs top level; the first proves the ladder drops the failing terminal instead of offering `atlantis` back. - RegistrationView: not-an-event vs dead-event — the load-bearing pair, since `parentOf` would answer the second with the very link that just 404'd. - ShareView: the same body as Registration's, proving the sibling routes share one recovery rather than two copies. - OnlineView inherits the region wording; Countries and Calendar preview what they can actually reach (no dead link exists for either). - FilterView gets no case and a comment saying why: every read there is non-suspense, so it cannot reach a boundary at all. ViewHarness gains `path`, without which every dead-link case would preview the floor rung and none would show what the app really offers. It gates children until the location lands rather than accepting SeedSearchParams' one-render-late behaviour — here the first render resolves a DIFFERENT rung, so the story would visibly flip from "Browse all countries" to "See events in Cambridgeshire": the exact layout shift these previews exist to catch. It also provides a DrawerControlContext, so the close control the fallbacks render is exercisable instead of inert. Verified in Ladle: the Registration dead-event case offers Cambridgeshire, and the calendar's grid failure leaves the month nav, view picker, Filters (2), Close and both filter pills working. Refs #89 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The rule a future change most needs: where a boundary sits decides how far a failure propagates, ERROR_POLICY decides what it says — two axes, kept separate, and an inner fallback never re-throws to escalate. Plus the four things that are non-obvious from the code: never split a view to manufacture a seam (the header is below the suspense read, so it wouldn't survive anyway); body-level boundaries need resetKeys because the drawer boundary keys on the pathname; each needs its own QueryErrorResetBoundary or Try again re-throws; and a dead link renders the empty-state register, so red chrome there means the two have drifted. Refs #89 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Three dedupes, all of them things that had been written out by hand several times: - `ResetErrorBoundary` replaces the QueryErrorResetBoundary render-prop triple at five call sites. Its real value isn't the ~45 lines: forgetting `onReset` silently produces a dead "Try again", which is precisely the bug this branch fixed in App.tsx, and now a new boundary cannot be added without it. It deliberately does not bundle a Suspense — the five sites nest one differently, and normalizing that would move loading states nobody asked to move. - `ErrorRegion` replaces a focus hook implemented twice and a ref/aria-label/tabIndex triple written four times. The "only steal focus from <body>" rule is now stated and implemented once. - The error surfaces move out of views/shared.tsx into views/fallbacks.tsx (714 → 437 lines). The cluster's governing rule — the fallback must never throw, in three degradation layers — was restated across four docstrings; a file header states it once. Also trims four comments that restated code or docstrings elsewhere, and fixes a stale story note still describing the retired "See nearby events" button. Considered and rejected: a helper for the six story files. The repeated shape is ~8 lines each and carries the case-specific fixture, path and commentary that are the point of a story — a helper would hide the Ladle argTypes wiring, which is the one thing a reader opens the file to check. Re-verified in the browser after the move: the register-over-a-dead-event case still offers Antwerpen, and focus lands on the error region named by its own message. Refs #89 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
No critical, high or medium findings; three lows, two worth fixing.
`regionRoute` guarded only `webPath`, not its `/${slug}` fallback — and
`slug` is an unconstrained server string, so `/evil.com` yielded
`//evil.com`. react-router renders a foreign-origin `to` verbatim as a
plain anchor with the click handler detached, making that a same-tab
redirect in the HOST page's origin. It pre-dates this issue (every region
card routes through it) but #89 puts the route on the error screen — the
one screen a lost viewer is scanning for something to click. `safePath`
now also rejects a leading backslash, which browsers normalise to a
slash: the standalone build would render `<a href="/\evil.com">` and
Chrome resolves that on a middle-click.
The recovery hook and the drawer chrome documented their reads as
cache-only but carried real queryFns, so a cold cache fetched from inside
the fallback. On a server or offline failure that re-issues a read to the
backend that just broke, and on a 401 re-sends the rejected API key. Both
are `enabled: false` now, which is what the comments already promised —
a miss costs a rung or the title, which is what the ladder's floor and
the untitled header are for.
Also pins jsdom to 27.x: 28+ raise their engine floor above this repo's
declared `engines.node`, so a contributor on Node 20 could not install it.
Not fixed here, noted for #80: a hand-typed slug rides into
ReportContext.error via the thrown message. Capped at 500 chars and only
alerted today, but when #80 emails these the template must encode it
rather than interpolate.
Refs #89
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Four mediums, four lows. The first is a regression this branch itself introduced. - DrawerLoading gained chrome, but CalendarView uses it as a NESTED Suspense fallback below its own header — so a loading grid drew a second header with a second close button. The error path had been split for exactly this reason (DrawerErrorBody is chrome-less); the loading path now has the same split. - EventView's new boundary offered a "Try again" that could never work: React caches a lazy component's rejected payload forever, so resetting re-threw it instantly. The lazy is minted per attempt now. That in turn exposed a trap in ResetErrorBoundary — it assigned `onReset` after the prop spread, silently swallowing a caller's own handler. It composes both now; overriding was the same class of dead-retry bug the component exists to prevent. - ErrorRegion focused without `preventScroll`, so a boot failure on a page where the widget sits below the fold yanked the HOST page down to it. - The recovery ladder claimed the offered ancestor "still lists live classes" while only checking that it exists. Rather than build the O(feed) ancestry index the data layer keeps private, the claim is corrected: a barren region is a real place with navigation and a search field, not the dead end this ladder removes. Lows: the chrome's own `t()` calls were suspend-free but CloseButton and CollapseToggle weren't, so a language switch mid-error could blank the widget instead of showing it; the chrome ignored the filter-overlay peel and titled the base drawer "Filters"; the floor-rung story previewed the IP rung, because the harness seeds a guess for every story; and `aria-label` on a role-less div is ignored by screen readers. Refs #89 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Ardnived
force-pushed
the
feat/classify-errors
branch
from
August 6, 2026 00:45
78ac6f4 to
c49d98b
Compare
Contributor
Author
|
Rebased onto Worth knowing: the PR had gone Four files needed hand-merging where #88 and this branch overlapped:
Re-verified against the seeded backend after the rebase: |
Five refinements, all in the direction of leaving less on the table. - Empty lists get the same onward offer a dead link gets. A region whose events have all ended was one sentence with nothing to press — the same dead end as a wrong URL, differing only in why. `NotFoundOffer` becomes `OnwardOffer`, since the two states share it. Search's filtered empty state keeps "Clear all" alone: filters are both the explanation and the escape, and a second link would compete with the one action that restores results. - The fallback chrome now renders the view's REAL header, not a generic one: the geocoder and Filters on search and at the root, Calendar and Search on a region. Nothing is disabled, because nothing needs to be — every one of those controls is a navigation, not a read of the data that failed, so on an offline search the field is the most useful thing on screen (a new URL remounts the boundary). - The actions are one wrappable row rather than a column; two short peers stacked read as a sequence of steps rather than a choice. - "Report an issue" is `neutral`/`flat`. Beside a filled retry, a ghost button read as disabled. - The bodies are centred again — but within the sheet's VISIBLE height, via `--sy-sheet-top`, not the body's own. Plain centring is what put them off screen on mobile (measured at 643px in a 667px viewport). The rAF loop that maintains that var now runs for every bottom-sheet view rather than only stacked ones, since the root can fail too. Refs #89 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Verifying the centring on a real bottom sheet turned up the flaw in it: `100dvh - var(--sy-sheet-top)` measures from the SHEET's top edge, but the body starts below the header — so the box ran to 735px in a 667px viewport, 68px past the fold. Short content happened to fit; taller content would have been clipped, and `justify-center` clips the TOP of an overflowing flex container, which would have hidden the sentence and left only the buttons. A fix for invisible content, failing the same way. Auto margins instead: they centre when there is slack and collapse to nothing when there isn't, so tall content starts at the top and scrolls in the body as normal. The cap stays, since it still keeps the box from extending far past the fold. Measured on the running widget: desktop 329px above and below (exactly centred); mobile 375x667 fully on screen; and with content forced taller than the box, the margin collapses to 0 and nothing is clipped above. Refs #89 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
A dead link, a broken query and an empty list all leave a viewer looking at nothing, and they were three components agreeing by hand about what to do about it. They are now one `FallbackPanel` reading one `ERROR_POLICY` row. The table gained the axes the callers were hard-coding: - `color` — the register. `danger` (red, role="alert") for a malfunction, `neutral` (role="status") for a dead end or an empty list. A test pins which kinds get which, since drift here is invisible in review. - `onward` / `search` / `clearFilters` — the CTAs that used to live inside the retired `OnwardOffer` and `CountrySiteOffer`, or as a bare button in `EmptyResults`. `FallbackKind` therefore spans more than `ErrorKind`: `empty`, `no-results`, `no-nearby` and `country-site` are data states, not throws, but they share the screen so they share the table. `not-found` and `empty` are asserted identical but for their sentence — if they ever diverge, one has quietly become the worse dead end. The controls also move OUT of the alert banner into the same wrappable row the error states already used. Inside it they inherited its tint and read as part of the sentence; the onward rung in particular looked like more red text on a danger alert. `visibleActions` now narrows on three surface facts rather than one, and its never-strand rule is stated honestly: report comes back when the policy promised a way out and the surface removed all of them. A row that promised nothing is left alone — `no-nearby` is a note about the list below it, whose own "Show distant events" control is the way out, and a report CTA there would invite reports of a working feature. Verified against the seeded backend: /be/atlantis (dead link -> "See events in Belgium" + field), /lu (empty region -> the IP-guess rung), and a filtered search (-> "Clear all", which clears). Every row's controls and computed alert colour checked in Ladle. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…tence Five refinements to the unified panel, plus an answer to two questions. **The rung goes back inside the banner.** Splitting every control out was one step too far: `retry` / `clearFilters` / `report` act on the screen you're looking at, but the onward rung CONTINUES the sentence — "we couldn't find that place… see events in Belgium" — and as a filled button beside the banner it read as an action competing with a retry that wasn't there. `OnwardLink` now renders in the Alert's children; `FallbackActions` keeps the buttons and returns null when the row would be empty, so a dead end doesn't carry a stray flex gap. **One column, one width.** Banner, action row and geocoder are all `w-full` inside a single `max-w-xs` box. Left to shrink-wrap they came out three widths stacked on a centre line — measured 302/302 in the drawer and 320/320 in Ladle, where before the banner shrank to its sentence. **The field prompts itself.** "Or search for a place:" above a field labelled "Search for a place" said the same thing twice. The label — which is also the placeholder — becomes "Enter your city or post code", and the line goes. Reworded across all 10 locales; `error.search_prompt` dropped from all 10. **`LoadingFallback` + `ErrorFallback` share a frame, not a component.** They now fill the same `APP_SURFACE`, which is what they actually had in common. Merging them further would mean one component with an optional `error` branching at runtime on a distinction React already makes at the mount point — `Suspense` takes an element, `ErrorBoundary` a component type — and would drag the policy table, the recovery ladder and the report modal into rendering a spinner. **Naming.** The folder stays `Fallbacks` — every export is literally what a React boundary renders as its `fallback`, and `EmptyStates` would be wrong for the loading and error halves. But three exports said "Error" while serving non-errors: `ErrorActions` → `FallbackActions`, `ErrorRegion` → `FallbackRegion`, `ErrorActionsProps` → `FallbackActionsProps`. `ErrorFallback` and `useErrorDisplay` keep their names — they are error-only. **Stories.** Every policy flag now has a visible case: the two dead-end rows pass the real `SearchField` (so `search` renders at all), `no-results` shows `clearFilters`, and each title names the actions it exercises. `error-states` keeps its place — its doc now states what it uniquely covers: `config`, `contract` and `unknown` have no drawer-width case anywhere else, and those are precisely the rows whose only control is "Report an issue". Verified: /be/atlantis at 1280x900 (both children left=41 width=302) and at 375x667 (column 524-646, fully on screen); every Ladle row measured sameWidth=true at 320px, with `no-nearby` rendering the banner alone. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
**Alert gains `textAlign`** (`left` default, `center`). Not a synonym for the
existing `align`, which is the icon's cross-axis position within the row: this
one changes the LAYOUT — `center` stacks the icon above the content, because an
icon pinned to the left of centred text reads as a misaligned banner rather than
a centred one. `left` emits `text-start` rather than nothing, so it survives a
container that centres its own text — which is exactly the case the fallback
panel presents.
**The fallback banners are left-aligned internally** in both postures, and the
panel gains a posture: `align="start"` for the four LIST views (Countries,
Region, Online, Search), where it stands in for content that begins at the
top-left and centring it moved the sentence away from where the reader already
was. `fallbackAlign` derives it from the URL, because the view boundary's
fallback is mounted by DrawerStack and the failing view never gets to say.
**The prompt line is gone.** "Or search for a place:" above a field labelled
"Search for a place" said it twice; the label — which is also the placeholder —
is now "Or search for a place", across all 10 locales.
**The focus ring is gone.** `FallbackRegion` focuses itself so a screen reader
announces the message and a keyboard user isn't ejected to the host page, but the
ring drew a box around the whole panel the moment it mounted, which reads as a
selected element. Safe to suppress: at `tabIndex={-1}` nothing can Tab there.
**View stories now have two axes.** `ViewStory` + `errorControl` (story-harness)
give every view an Error control beside its Example control, so any failure can
be seen against any example — merged, most combinations were unreachable. Each
view lists the not-found flavours its ROUTES can produce; the fetch failures
every data-reading view shares are appended by the helper.
And the not-found variant now falls out of the example, with no per-error stub:
each story passes its example's own canonical path, so the ladder answers from
where that example actually lives. Verified in Ladle — RegionView's City offers
"See events in Cambridgeshire", City with Centers offers "Greater London", and
Country (no ancestor) drops to the IP guess, "See events near Cambridge".
That makes `views/error-states.stories.tsx` genuinely redundant and it is
deleted: its one unique contribution was config/contract/unknown at drawer width,
which every view story now carries.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
**`contract` is gone.** A zod parse failure — SahajCloud's shape drifting from ours — had its own kind, differing from `unknown` only in withholding the retry. It named a CAUSE the viewer can do nothing with, and the cause already travels in the report, which carries the thrown message. So the ZodError branch goes and the shape falls through to the catch-all; the fixture is now a ZodError precisely so the fall-through stays covered. Five kinds, not six. **Empty joins the failures on one control.** It is the same screen — FallbackPanel on the `empty` row of the same table — so it belongs on the same axis. It is the one option that is DATA rather than a throw, so `ViewStory` renders the view and the story seeds an emptied version of whichever example is selected. That makes it a real axis: "City · Empty" keeps the Cambridge header and shows the barren list, where the old fixed "Empty" example was one region standing in for all of them. `mockMinimalRegion` retires with it. **The control is a select, and it sorts last.** With the shared failures appended the list runs to seven, and a radio column that tall pushed the Example control off the panel. Ladle orders the controls panel alphabetically by arg KEY, ignoring declaration order — which is why the axis is now keyed `state`: `error` sorted above both `example` and `region`, putting the failure control first on every story. Only Ladle's own global "Brand palette" outranks a story's controls, so ShareView now reads Region → State. **"Not found · not an event" is gone.** Asked why it existed: it is a second throw site (`useEventFromPath` bailing on a `/register` whose parent is a region) but it reaches the boundary as the same kind, at the same path, and renders the same screen — a reviewer flipping between the two saw nothing change. What actually differs is which branch of `classifyError` runs, and `report.test.ts` covers both directly. Verified in Ladle: Region reads Example → Brand palette → Fallback with options None / Empty / Not found · place / Offline / Server / Config / Unknown; Share reads Brand palette → Region → Fallback; "City · Empty" renders the Cambridge header over "No events found." + "See events in Cambridgeshire" + the field. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Four review angles over `origin/main...HEAD`. The findings clustered on the
edges of the change rather than its shape, and split into work that runs at
runtime and work that only reads badly.
## Runtime
**The sheet mirror parks when the sheet is still.** Relaxing its gate so the ROOT's
fallback bodies could read `--sy-sheet-top` left a `requestAnimationFrame` loop
running for the whole session on every mobile-with-map view — a forced layout
flush per frame, spent in the map's own budget, while the sheet is stationary for
almost all of it. It now parks after half a second of stillness and wakes on the
three things that move the sheet: a pointer down, a snap transition, a resize.
Measured in the browser: 0 sheet measurements per second when idle (was ~60),
~60/s again the frame after a pointerdown, and the var still tracks a real snap
exactly (367→384→521→…→587, matching the rect at every sample).
**No live geocoder in the loading chrome.** `SearchField` mounts a Mapbox Geocoder
— a shadow-DOM custom element bound to the live map — and `DrawerChrome` renders
it for the root and search headers. As a Suspense fallback, freshly mounted per
path, that instantiated one during a cold start while the map was still
initialising, then tore it down when CountriesView mounted its own. The loading
chrome gets the field's shape (`interactive={false}`); the ERROR chrome keeps the
real field, where it is the escape hatch.
**The recovery ladder only runs where a rung can render.** Six of the eleven policy
rows never show one — including the two empty-list rows and the country-site
offer, which render in normal operation, not just on failure. Also memoizes
`DrawerChrome`'s scan of the unbounded region tree, which sat in a render body
re-running on every location and drawer-control change.
**The calendar's inner Suspense drew a second header.** It used the chrome-ful
`DrawerLoading` below its own header — the exact regression `DrawerLoadingBody`
was written for and then never wired to.
## Drift
**One definition each** for three rules that had two: the filter-overlay peel
(`isFilterOverlay`, which DrawerStack hand-rolled and had already drifted on its
`hasMap` gate), the `['event-titles']` key (`eventTitlesQuery` — a cache-only read
under a divergent key doesn't error, it silently misses), and "which entry am I
on" inside `views/fallbacks.tsx`, where the chrome peeled and the body didn't.
**One guard for clear-filters.** `canClearFilters` defaulted to `true`, so
`visibleActions` reported an action the row then had to un-report.
**The message override went.** `FallbackMessage.key`/`.text` had no caller —
per-entity sentences are policy ROWS, which is what keeps them under the test
pinning `fallbackText` to the shipped en copy. Only interpolation remains.
**The barrel is five values and two types.** It exported 21; fourteen had no
consumer outside the folder. Publishing the policy table and its narrowing
function invites the next view to hand-roll a panel from them.
Also: `EventView` holds the lazy component in state rather than a counter a memo
keys off; `DrawerStack` resolves `dismissAction` once instead of twice (the
comment already claimed it did); a doc block that had drifted onto the wrong
declaration moved back.
**One test was vacuous** — the StrictMode reset spec rendered a child that never
threw, so it asserted only that a working component works. It now throws, changes
the key under StrictMode, and asserts recovery.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
No criticals; one medium and two lows, all fixed. **`safePath` let a tab/LF/CR through** (medium). The guard rejected `//evil.com` and `/\evil.com`, but the WHATWG URL parser STRIPS ASCII tab, LF and CR before parsing — so `/<TAB>/evil.com` was read as `//evil.com` and resolved off-origin while walking straight through a check that only looked at the character after the leading slash. This branch widened the blast radius: `regionRoute`'s fallback now routes through `safePath` too, and the recovery ladder feeds a server `webPath` directly into a new href sink. Inert under the embedded HashRouter, but the standalone build renders the raw string as the anchor's href, where middle-click, ctrl-click and "copy link address" all hand the browser the off-origin URL. Six new cases pin it, with the parser rule written down — it is not guessable from the code. **The wake listeners fired on the host page's own activity** (low). The rAF park I added an hour ago listens on `document` in the capture phase, so any click anywhere on the embedding page — and any CSS transition it runs — restarted the loop. On a transition-heavy host it would never park at all, which both defeats the optimisation and spends a third party's main-thread budget on a problem of ours. `wake` now ignores events whose target isn't inside our sheet. **`Link` had no guard for a non-relative, non-allowed scheme** (low, not reachable). Its internal branch hands an absolute `to` to react-router, which renders it verbatim on a plain anchor — so a `javascript:` string arriving there would execute in the HOST page's realm. Every caller today passes a `/…` route or an `https:`/`mailto:`/`tel:` URL, but this atom is the last gate before a data-driven string becomes an href, and the whole guarantee otherwise rests on `safePath` never regressing. It now renders the text without the link and reports why. Deferred, with reason: the sheet lookup (`document.querySelector`) is unscoped and could match a host page's own vaul drawer. Pre-existing, and scoping it needs a reference to the portal root — worth doing, but not inside a security fix whose other changes are one-liners. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
No critical or high findings. One medium, plus lows worth taking. **Two geocoders on a root/search error** (medium). `hasSearchChrome` existed and was documented as the thing that stops it — "`visibleActions` narrows by surface … a geocoder already in the chrome" — but only `EmptyResults` ever passed it. `ErrorPanel` didn't, so a `not-found` at `/` or `/search` drew the chrome's field AND the body's, since every dead-end row asks for one. Both sides now read the same `leadsWithGeocoder` predicate, so they can't disagree about which routes those are. **The peel ignored `hasMap`.** `baseStackEntry` defaulted it true, so the map-less build — which renders no overlay, and where the trailing entry IS the view — titled a failing Filters drawer "Calendar". Threaded through from both callers. **The sheet cache could go stale.** Dropping the depth dep widened its lifetime to the whole session, and two elements carry `[data-vaul-drawer]`. A resize across the md breakpoint while the filter overlay is open can leave it holding the overlay; once that closes, a detached node measures `top: 0` and would write `--sy-sheet-top: 0px` onto the LIVE strips, pinning every peek to the viewport top. Revalidated with `isConnected`. The loop also never parked when no sheet resolved (`still` only advanced inside the `if`), so it re-queried the DOM every frame forever — the exact cost the parking removes. **`transitionrun` now only wakes on the sheet's own transition.** Target-filtering alone still let every `transition-colors` hover on a button inside the sheet re-arm 30 frames of layout reads for a colour change. **The error chrome's geocoder wrote to the dead URL** the body's field is forbidden to write to — the same `#!` fragment a visitor might copy. **The ladder could offer the page you are on**: a France-scoped embed whose France listing has emptied answered "nothing here" with a link back to itself. **`DrawerChrome`'s "never suspends" claim was false** — four of its children still used a suspending `useTranslation`. The three header controls now pass `useSuspense: false` like `CloseButton`; the remaining one is `useLocale`, and the comment now says so rather than claiming an invariant the code doesn't hold. Two comments corrected rather than code changed, both flagged as overclaiming: the fresh-`lazy` retry doesn't beat the browser's failed-module-fetch record (it recovers a render throw, not a 404'd chunk), and the layer-2 floor covers a data failure but not a missing Router — its own rung is an internal `Link`, and the alternative would navigate the host page away. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The `safePath` guard now rejects tab/LF/CR alongside the slash and backslash, and the reason is not guessable from the code: the WHATWG URL parser strips those three characters BEFORE parsing, so `/<TAB>/evil.com` is read as `//evil.com`. Written down in the data-layer rule beside the rest of the untrusted-`webPath` contract, with the standalone-vs-HashRouter distinction that makes it live, and a pointer to the `Link` atom as the backstop. The other doc updates for this branch (the Fallbacks barrel now being five values and two types, the `eventTitlesQuery` factory, the loading chrome's inert field) rode along with the commits that made them. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
RegistrationView's blocked state — full, ended, or registration closed — was two bare paragraphs: the reason, and a line of prose saying "contact the host to join". It is the same shape as every other screen with nothing to act on, so it now renders through the shared `FallbackPanel`, and the prose becomes something to press. **A new row, `unavailable`, and a new axis, `contact`.** It is the only row whose best next step is a PERSON: an organiser can still let somebody into a full class where no button of ours can. So the number leads whenever the event carries one, and `visibleActions` stands `onward` down while it does — offering "see events nearby" beside a number that can get you into THIS class would present a consolation prize as an equal. With no contact on the event the recovery ladder takes over, so a viewer is pointed at another class in the area rather than left holding the reason. **The sentence comes from the caller**, and this is the one row where that's right: `useEventDisplay` already owns the status→copy table (full / ended / closed / hidden) and `event.test.ts` asserts every row of it. Copying those four sentences into `ERROR_POLICY` would be exactly the hand-agreement the table exists to remove. The row keeps a generic behind it, and everything the table itself defines still takes its copy from the table, where the en-parity test can see it. (This is why `message` returns as a prop — it was dropped last round for having no caller, which was true then.) The CTA labels itself with the NUMBER rather than the word "Contact": on touch it dials, and on desktop a bare `tel:` is a dead end, so the thing a desktop viewer actually needs — a number to read and copy — has to be on screen rather than behind the press. Whitespace is stripped from the URI (RFC 3966 has no room for it) and kept in the label. The accessible name says what it does, with the organiser's name when the event has one. Verified in Ladle, both branches: with a contact → "This event is full" + `tel:+442012345678` labelled "+44 20 1234 5678", aria "Contact — Anna"; without → the same sentence + "See events in Cambridge" → `/united-kingdom/cambridge`. Both are story cases now, on RegistrationView and on the Fallbacks gallery. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A failure that reached an error boundary used to say "Something went wrong" and offer
buttons that couldn't help — a retry on a URL that doesn't exist, a report CTA for the
visitor's own dropped connection — and it erased the drawer's header, so on desktop or
map-less there was no way out of the error screen at all.
offline | server | not-found | config | unknown) and renders only the controls that could help. The thrown developerstring never reaches the screen; it rides along as report context.
broken query and a legitimately-empty list leave a viewer in the same position, so
ERROR_POLICY+FallbackPanelreplaced three sets of components that agreed by hand.failure and a load — and a dead link is offered somewhere real to go, chosen by a
four-rung recovery ladder, plus a field to name somewhere else.
Changes
src/lib/report.ts—classifyError/atlasError/reportInternalError. The kind isa field we throw, never our English regexed back out of a message.
src/components/molecules/Fallbacks/— the policy table,visibleActions(which narrowsby surface: no boundary to reset, nowhere to navigate, a geocoder already in the
chrome), and the one shared panel.
OnwardOfferandCountrySiteOfferfolded in.src/views/fallbacks.tsx(new) — what a drawer adds: chrome rebuilt from the URL andalready-cached data, and the routing knowledge only a drawer has.
src/hooks/use-recovery-offer.ts(new) — nearest known URL ancestor → host home region →cached IP guess → "Browse all countries". Cache-only reads: an error screen never
re-issues the request that just failed.
with its own
QueryErrorResetBoundaryand load-bearingresetKeys.Verification
ladle:build✓/simplify(4 angles) → applied;/code-review→ 1 medium + lows, applied;/security-review→ no criticals, 1 medium + 2 lows, applied.Manual / visual verification
Against the seeded local backend, and measured rather than eyeballed:
/be/atlantis→ "We couldn't find that place." + See events in Belgium + the field;header keeps Calendar / Search / Close.
/lu(0-event country) → the empty state, same panel, one policy row apart.the fold), banner and field the same width and axis.
no-nearbyrenders zerocontrols;
country-siterenderstarget="_blank"+ the flag.Notes for reviewer
not-foundand the empty rows are neutral/status; only real failures are red/alert.A test pins which kinds get which — drift there is invisible in a diff.
no-nearbyoffers nothing, on purpose. It's a note about the list below it, whose own"Show distant events" control is the way out.
visibleActions' never-strand rule fires ona broken promise, not on emptiness, so it leaves that row alone.
requestAnimationFrame+ forced layoutper frame for the whole session on mobile. Measured: 0 reads/second idle (was ~60), ~60/s
again on interaction, still tracking a real snap exactly.
safePathrejects tab/LF/CR because the WHATWG URL parser strips them before parsing,so
/<TAB>/evil.comresolves off-origin. Not guessable from the code; written down in.claude/rules/data-layer.mdand pinned by tests.React's rejected-payload cache but not the browser's failed-module-fetch record, so a
404'd chunk still won't recover on "Try again".
Closes #89
🤖 Generated with Claude Code