Skip to content

feat(ui): de-brand the widget and keep host CSS out of it - #158

Merged
Ardnived merged 3 commits into
mainfrom
feat/white-label
Aug 19, 2026
Merged

Ardnived merged 3 commits into
mainfrom
feat/white-label

Conversation

@Ardnived

@Ardnived Ardnived commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Closes #156. Stage B of the white-label programme — the one that states the goal literally.
#150 made the embed cheap, #155 made it indexable; this is the part a visitor sees.

Nothing names the product any more

The landmark's accessible name, the "on Sahaj Atlas" link on the share and registration cards, the
app-level error title, the ICS PRODID, the page title and the typeface family — all neutral,
across all ten locales.

A ratchet spec (src/lib/brand.test.ts) walks the locale bundles and a named list of
copy-carrying source files and fails if a brand string returns. It also asserts the pattern leaves
sahaj-atlas, sy-atlas and the origins alone — those are DOM identifiers hosts key off, not
copy — and that the pattern would actually catch a reintroduction, so it can't quietly match
nothing.

The calendar UID moves to @cloud.sydevelopers.com. I first left it alone on the grounds
that changing a dedupe key makes previously-exported events reappear as duplicates — that
constraint does not apply, since the export is not live yet.

Removing it does not make the UID free, though, and the rule that survives is the stronger one:
it must stay tenant-independent. The same class can be exported from several client embeds — a
visitor might reach it from the national site and again from a city one — and those have to land in
a calendar as ONE entry, so nothing client-derived may enter the string. It is now namespaced to
the CMS the id actually comes from, rather than to a widget origin that #148 is consolidating and
a canonical that is moving to per-owner domains. Neither should be able to change an identifier
whose whole job is to stay put. The dedupe rule is asserted now, not just described.

PRODID identifies the producing software, which is a different field with different rules, and is
neutral rather than tenant-named.

Two things dropped from the plan, on evidence

  • widget.label_named was added and then removed. The plan split the landmark's name into a
    plain and a tenant-named variant. But the name lives on the client record (you removed the name
    script parameter for exactly that reason), and the client is fetched at App.tsx:179 — below
    the landmark at Widget.tsx:160, inside Suspense. A named landmark would therefore have to change
    its accessible name after load, which is worse for a screen-reader user than omitting a name that
    is redundant on the tenant's own site.
  • EventSummary is deleted, carrying over the one Atlas-side piece of the blocked Stage C. It
    rendered both the brand label and an outbound link to event.webUrl — never correct, and once
    canonicals point at the owning client it becomes a link from the host's page back to the host's
    page. Without it the component was a two-call-site alias over EventFacts.

Structured data no longer credits the wrong organisation

The JSON-LD hardcoded We Meditate as the organizer of every event in the world. It now derives
from the client record and is omitted entirely when unknown — an absent optional property being
better structured data than a confidently false one, and schema.org/Event does not require it.

Host CSS is kept out — with one honest exception

An unlayered all: revert over the scope subtree, plus an inherited-property baseline. Three
things were verified in a browser rather than assumed, and two of them were wrong on the first
attempt
:

  • The baseline was written inside @layer base and lost to the unlayered reset directly above
    it
    — the widget rendered in the host's font, with the host's letter-spacing. That is precisely
    the @layer trap the rule's own comment warns about, fired at ourselves. It is unlayered now,
    and the comment records the symptom because it is subtle enough to ship unnoticed.
  • Against a deliberately hostile stylesheet (global button, a, div, letter-spacing,
    line-height, box-sizing), non-!important rules are fully blocked. !important rules
    are not, and cannot be: outranking them needs all: revert !important, which would beat our
    own styles and leave the widget unstyled — strictly worse than the problem. Documented for hosts
    in the integrator guide, and the reason chore(ui): evaluate shadow DOM now that the CSS reset has a measured gap #157 exists.
  • Cost measured, not guessed: a forced style recalc over 3,200 nodes inside the scope is ~2×
    one outside it (41ms vs 20ms across five recalcs, Chrome 151). Accepted — full recalcs are rare
    (a theme toggle, not a scroll) and the results list is bounded by MAX_REVEAL.

And one fix that isn't branding

The theme localStorage key was the bare string theme, so a host page storing its own
light/dark preference under that name had it read and overwritten by the widget — a collision
docs/embedding.md has admitted in a table for months. Now atlas.theme, with a one-time read of
the old key (never a write) so nobody loses a choice they already made. Framed in the changelog as
a fix rather than a feature.

Explicitly not done

  • Removing sahajatlas.com as a runtime dependency. Assets are served from there whichever way the widget loads, so bundling the locale JSON would move which requests hit that origin, not remove it.
  • Renaming the DOM identifiers. docs/embedding.md invites hosts to key off the style ids and promises stability; no visitor sees any of them.

Verification

lint, typecheck, test:run (1196 passing, 31 new), build, size, ladle:build green,
including a credentialed build (loader 3.4 KiB against 3.8). Locale key parity checked across
all ten bundles. Browser-verified against a hostile host stylesheet, both with and without
!important, with the host's own elements as a control to prove the CSS was actually applying
outside the widget.

🤖 Generated with Claude Code

Stage B of the white-label programme, and the one that states the goal
literally. The loader made the embed cheap (#150) and query routing made it
indexable (#155); this is the part a visitor sees.

**Nothing names the product any more.** The landmark's accessible name, the
"on Sahaj Atlas" link on the share and registration cards, the app-level error
title, the ICS `PRODID`, the page title and the typeface family — all neutral,
across all ten locales. A ratchet spec walks the locale bundles and a named list
of copy-carrying source files and fails if a brand string returns; it also
asserts the pattern leaves `sahaj-atlas`, `sy-atlas` and the origins alone,
because those are DOM identifiers hosts key off rather than copy.

⚠ `UID:event-<id>@atlas.sydevelopers.com` is deliberately unchanged and now says
so at the line: it is the calendar dedupe key, and moving it would make every
previously-exported event reappear as a second entry in somebody's calendar.

**`EventSummary` is deleted**, carrying over the one Atlas-side piece of the
blocked Stage C. It rendered both the brand label and an outbound link to
`event.webUrl` — a link that was never correct, and that becomes a link from the
host's page back to the host's page once canonicals point at the owning client.
Without it the component was a two-call-site alias over `EventFacts`.

**JSON-LD no longer credits We Meditate for every event in the world.** The
organizer comes from the client record and is omitted entirely when unknown: an
absent optional property is better structured data than a confidently false one.

**Host CSS is kept out**, via an unlayered `all: revert` over the scope subtree
plus an inherited-property baseline. Three things about it were verified in a
browser rather than assumed, and two were wrong on the first attempt:

- The baseline was written inside `@layer base` and therefore LOST to the
  unlayered reset directly above it — the widget rendered in the host's font
  with the host's letter-spacing. That is the `@layer` trap the rule's own
  comment warns about, fired at ourselves; it is unlayered now.
- Against a deliberately hostile stylesheet, non-`!important` host rules are
  fully blocked. **`!important` rules are not**, and cannot be: outranking them
  needs `all: revert !important`, which would beat our own styles and leave the
  widget unstyled. Documented for hosts, and the reason #157 exists.
- Cost measured rather than guessed: a forced recalc over 3,200 nodes inside the
  scope is ~2x one outside (41ms vs 20ms over five recalcs). Accepted — full
  recalcs are rare and the list is bounded by MAX_REVEAL.

**And one bug fix that is not branding**: the `theme` localStorage key was the
bare string `theme`, so a host page storing its own preference under that name
had it read and overwritten. Namespaced to `atlas.theme`, with a one-time read
of the old key so nobody loses a choice they already made.

Closes #156
Refs #157

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

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

Copy link
Copy Markdown

Deploying sahajatlas-design with  Cloudflare Pages  Cloudflare Pages

Latest commit: d5cd944
Status: ✅  Deploy successful!
Preview URL: https://259f163c.sahajatlas-design.pages.dev
Branch Preview URL: https://feat-white-label.sahajatlas-design.pages.dev

View logs

@cloudflare-workers-and-pages

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

Copy link
Copy Markdown

Deploying sahajatlas with  Cloudflare Pages  Cloudflare Pages

Latest commit: d5cd944
Status: ✅  Deploy successful!
Preview URL: https://7942b1b2.sahajatlas.pages.dev
Branch Preview URL: https://feat-white-label.sahajatlas.pages.dev

View logs

Ardnived and others added 2 commits August 18, 2026 11:46
The root smoke spec asserted `<title>Sahaj Atlas`, so de-branding the page title
failed it. The spec was only ever trying to prove "this is our shell rather than
an error page or the SPA fallback" — and a brand string is the wrong anchor for
that, in the worst way: it breaks precisely when the product does what this
programme set out to make it do.

Re-anchored on two structural markers that are actually load-bearing — the
`#syatlas` mount point and the `sy-atlas` scope class on <html> — plus a
non-empty title, which is the part that genuinely distinguishes a rendered shell
from a stray response.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…t host

The back-compat constraint I stated does not apply — the calendar export is not
live, so there are no already-exported entries to keep matching.

Removing it does not make the UID free, though. A different rule survives and is
the stronger one: **it must stay tenant-independent.** The same class can be
exported from several client embeds — a visitor might reach it from the national
site and again from a city one — and those must land in a calendar as ONE entry.
Anything client-derived in this string turns each embed into a separate event
for the same class.

So it moves from `@atlas.sydevelopers.com` to `@cloud.sydevelopers.com`: the
host part is an opaque namespace rather than a link, and the CMS is where the id
actually comes from. The old value pointed at an origin that is being
consolidated (#148) while the canonical moves to per-owner domains — neither of
which should be able to change an identifier whose whole job is to stay put.

The dedupe rule is now asserted rather than only described.

Refs #156

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@Ardnived
Ardnived merged commit 5d6caad into main Aug 19, 2026
5 checks passed
@Ardnived
Ardnived deleted the feat/white-label branch August 19, 2026 00:19
Ardnived added a commit that referenced this pull request Aug 20, 2026
The ticket's reference case — sahajayoga.nl at 400x600 — is an IFRAME
client, and the compact card was unreachable there twice over: main.tsx
never measured anything, and even if it had, the slot IS the viewport in a
frame so an in-page overlay would gain nothing.

A frame cannot expand, so a framed embed too small for the interface gets an
anchor to a page that fits, opened in a new tab. Rendered through the Button
atom's href form rather than a new JSX anchor, so it inherits the isSafeHref
gate that href.test.ts pins to three components.

"Is a new tab bigger?" is answered against min(outerWidth, screen.avail*).
screen alone reports the DISPLAY, so a small frame in a small window on a
large monitor would be told a new tab gains far more than it does.

main.tsx also gains two things it should have had already. It mounted a bare
BrowserRouter, so a sandboxed frame threw SecurityError on the visitor's
FIRST navigation rather than at boot — a live failure the frame delivery
walks straight into. And it composed share links against
window.location.origin, handing out sahajatlas.com URLs from inside a frame
whenever an event had no canonical of its own: a dead end for the visitor
and the branding leak #158 exists to close.

A page-URL ?atlas= now mounts the widget eagerly and opens onto that route.
Eager-loading is not an optimisation — the loader lazy-mounts behind an
IntersectionObserver, so auto-opening without it would slam a modal over the
page MID-SCROLL. One provenance signal drives both, so they cannot disagree,
and a script-URL default view does neither.

Documents the browser permissions a host must grant. geolocation,
clipboard-write and web-share are denied to a cross-origin frame by default
and all three fail silently. Our own source does not enumerate them:
<GeolocateControl /> is our JSX but the call is inside mapbox-gl, so a grep
of src/ finds nothing and concludes wrongly.

Closes #161

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Ardnived added a commit that referenced this pull request Aug 20, 2026
Three rows off the already-cached feed — nearest when the session's IP guess is
there, soonest otherwise, since a card promising "near you" with no location
would be picking three classes at random from the world. No fetcher of its own;
`toSlim` is exported so the route guard on a CMS `webPath` keeps one definition.

The one control is named for the task, not the product, and the file joins the
#158 ratchet's list so it stays that way.

Closes #161

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Ardnived added a commit that referenced this pull request Aug 20, 2026
The ticket's reference case — sahajayoga.nl at 400x600 — is an IFRAME
client, and the compact card was unreachable there twice over: main.tsx
never measured anything, and even if it had, the slot IS the viewport in a
frame so an in-page overlay would gain nothing.

A frame cannot expand, so a framed embed too small for the interface gets an
anchor to a page that fits, opened in a new tab. Rendered through the Button
atom's href form rather than a new JSX anchor, so it inherits the isSafeHref
gate that href.test.ts pins to three components.

"Is a new tab bigger?" is answered against min(outerWidth, screen.avail*).
screen alone reports the DISPLAY, so a small frame in a small window on a
large monitor would be told a new tab gains far more than it does.

main.tsx also gains two things it should have had already. It mounted a bare
BrowserRouter, so a sandboxed frame threw SecurityError on the visitor's
FIRST navigation rather than at boot — a live failure the frame delivery
walks straight into. And it composed share links against
window.location.origin, handing out sahajatlas.com URLs from inside a frame
whenever an event had no canonical of its own: a dead end for the visitor
and the branding leak #158 exists to close.

A page-URL ?atlas= now mounts the widget eagerly and opens onto that route.
Eager-loading is not an optimisation — the loader lazy-mounts behind an
IntersectionObserver, so auto-opening without it would slam a modal over the
page MID-SCROLL. One provenance signal drives both, so they cannot disagree,
and a script-URL default view does neither.

Documents the browser permissions a host must grant. geolocation,
clipboard-write and web-share are denied to a cross-origin frame by default
and all three fail silently. Our own source does not enumerate them:
<GeolocateControl /> is our JSX but the call is inside mapbox-gl, so a grep
of src/ finds nothing and concludes wrongly.

Closes #161

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Ardnived added a commit that referenced this pull request Aug 20, 2026
Three rows off the already-cached feed — nearest when the session's IP guess is
there, soonest otherwise, since a card promising "near you" with no location
would be picking three classes at random from the world. No fetcher of its own;
`toSlim` is exported so the route guard on a CMS `webPath` keeps one definition.

The one control is named for the task, not the product, and the file joins the
#158 ratchet's list so it stays that way.

Closes #161

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Ardnived added a commit that referenced this pull request Aug 20, 2026
The ticket's reference case — sahajayoga.nl at 400x600 — is an IFRAME
client, and the compact card was unreachable there twice over: main.tsx
never measured anything, and even if it had, the slot IS the viewport in a
frame so an in-page overlay would gain nothing.

A frame cannot expand, so a framed embed too small for the interface gets an
anchor to a page that fits, opened in a new tab. Rendered through the Button
atom's href form rather than a new JSX anchor, so it inherits the isSafeHref
gate that href.test.ts pins to three components.

"Is a new tab bigger?" is answered against min(outerWidth, screen.avail*).
screen alone reports the DISPLAY, so a small frame in a small window on a
large monitor would be told a new tab gains far more than it does.

main.tsx also gains two things it should have had already. It mounted a bare
BrowserRouter, so a sandboxed frame threw SecurityError on the visitor's
FIRST navigation rather than at boot — a live failure the frame delivery
walks straight into. And it composed share links against
window.location.origin, handing out sahajatlas.com URLs from inside a frame
whenever an event had no canonical of its own: a dead end for the visitor
and the branding leak #158 exists to close.

A page-URL ?atlas= now mounts the widget eagerly and opens onto that route.
Eager-loading is not an optimisation — the loader lazy-mounts behind an
IntersectionObserver, so auto-opening without it would slam a modal over the
page MID-SCROLL. One provenance signal drives both, so they cannot disagree,
and a script-URL default view does neither.

Documents the browser permissions a host must grant. geolocation,
clipboard-write and web-share are denied to a cross-origin frame by default
and all three fail silently. Our own source does not enumerate them:
<GeolocateControl /> is our JSX but the call is inside mapbox-gl, so a grep
of src/ finds nothing and concludes wrongly.

Closes #161

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Ardnived added a commit that referenced this pull request Aug 20, 2026
Three rows off the already-cached feed — nearest when the session's IP guess is
there, soonest otherwise, since a card promising "near you" with no location
would be picking three classes at random from the world. No fetcher of its own;
`toSlim` is exported so the route guard on a CMS `webPath` keeps one definition.

The one control is named for the task, not the product, and the file joins the
#158 ratchet's list so it stays that way.

Closes #161

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Ardnived added a commit that referenced this pull request Aug 20, 2026
The ticket's reference case — sahajayoga.nl at 400x600 — is an IFRAME
client, and the compact card was unreachable there twice over: main.tsx
never measured anything, and even if it had, the slot IS the viewport in a
frame so an in-page overlay would gain nothing.

A frame cannot expand, so a framed embed too small for the interface gets an
anchor to a page that fits, opened in a new tab. Rendered through the Button
atom's href form rather than a new JSX anchor, so it inherits the isSafeHref
gate that href.test.ts pins to three components.

"Is a new tab bigger?" is answered against min(outerWidth, screen.avail*).
screen alone reports the DISPLAY, so a small frame in a small window on a
large monitor would be told a new tab gains far more than it does.

main.tsx also gains two things it should have had already. It mounted a bare
BrowserRouter, so a sandboxed frame threw SecurityError on the visitor's
FIRST navigation rather than at boot — a live failure the frame delivery
walks straight into. And it composed share links against
window.location.origin, handing out sahajatlas.com URLs from inside a frame
whenever an event had no canonical of its own: a dead end for the visitor
and the branding leak #158 exists to close.

A page-URL ?atlas= now mounts the widget eagerly and opens onto that route.
Eager-loading is not an optimisation — the loader lazy-mounts behind an
IntersectionObserver, so auto-opening without it would slam a modal over the
page MID-SCROLL. One provenance signal drives both, so they cannot disagree,
and a script-URL default view does neither.

Documents the browser permissions a host must grant. geolocation,
clipboard-write and web-share are denied to a cross-origin frame by default
and all three fail silently. Our own source does not enumerate them:
<GeolocateControl /> is our JSX but the call is inside mapbox-gl, so a grep
of src/ finds nothing and concludes wrongly.

Closes #161

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Ardnived added a commit that referenced this pull request Aug 24, 2026
…iframe (#162)

* feat(widget): decide whether the interface fits its slot

`embedForm` beside `mapSlotWarning`: absolute pixel floors, because "does the
interface fit?" is a question about the interface rather than about the host's
intent — and a false positive changes what renders instead of costing a console
line. `MIN_EXPANSION_GAIN` is what stops those floors mistaking a phone for a
cramped slot: a compact card is only worth offering when the overlay it expands
into would be bigger than the slot.

Nothing reads it yet.

Closes #161

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

* feat(widget): add the expansion seam and its viewport surface

`useExpansion` is the same seam shape as `MapController`: nothing branches on
whether expansion is possible, and the framed provider E1/E2 needs slots in
beside the two here.

The surface is Radix Dialog directly rather than the Modal atom — the whole
viewport, no chrome — because expansion is map mode's layout made explicit and
reversible, which is what makes vaul's window-height arithmetic correct inside
it. Every portal in the app is redirected into it while it is open, since a
modal dialog would otherwise leave the drawer stack unreachable by keyboard.

Closes #161

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

* feat(ui): add the compact card and the rows it previews

Three rows off the already-cached feed — nearest when the session's IP guess is
there, soonest otherwise, since a card promising "near you" with no location
would be picking three classes at random from the world. No fetcher of its own;
`toSlim` is exported so the route guard on a CMS `webPath` keeps one definition.

The one control is named for the task, not the product, and the file joins the
#158 ratchet's list so it stays that way.

Closes #161

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

* feat(widget): render the compact form in a slot that cannot hold the interface

AppShell picks the form, and it has to be AppShell: it is the only component
above MapProvider, so it is the only place from which the map subtree can be
left unmounted — which is what keeps mapbox-gl unfetched. The interface is
passed as children, so React never renders it until the surface opens.

Widget.tsx measures once, on the first render, from the element itself. One
pass answers both questions and emits at most one line: where the widget now
renders compact, the map-slot warning has nothing left to warn about.

Closes #161

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

* fix(ui): keep focus and the overlay where a browser says they go

Three findings from driving the real drawer stack inside the surface, none of
which a node spec could have reached.

Focus on open landed on the settings cog — the first tabbable — announced with
no word about what had opened; it now lands on the dialog. Focus on close landed
on <body>, because Radix restores to a `Dialog.Trigger` and expansion is
requested through the seam instead: the surface remembers the opener itself,
skipping anything inside its own subtree, since the dialog's own mount focus
fires while that listener is still attached.

And a host ancestor with transform / filter / contain confines the overlay to
its box — re-measured here, `container-type` does not — so a compact embed under
one now says so rather than expanding into the slot it was degrading out of.

Closes #161

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

* docs(embedding): describe the compact form and what a host must avoid

`compact` has been documented and inert since #149; the guide now says what the
three values actually do, what the floors are, that the decision is taken once,
and that an ancestor with transform/filter/contain confines the overlay.

The card's list scrolls rather than clips — a row cut in half by the slot reads
as a broken card, where a scrollbar reads as more to see.

Closes #161

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

* docs(ui): correct what the surface claims Radix gives it

Escape does not reach this dialog and never will: the drawer stack inside it is
vaul, which is Radix Dialog underneath, so its dismissable layer is the topmost
one and Radix delivers the key there. That is the right behaviour — Escape
dismisses the drawer the viewer is looking at — but it makes the collapse
control the only way out, so the docblock had better say so.

Closes #161

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

* refactor(widget): fix three findings from the review pass

The ancestor walk's docblock claimed it names the outermost offender; it walks
outward and stops at the first, so it names the innermost — which is the better
one to name anyway, and now the comment says what the loop does.

`forEach(reportIntegrationWarning)` handed the callback an index and the array
as well; wrapped, so a second parameter on that function can never be fed a
number. And the surface's `onOpenChange` returned a discarded boolean.

Closes #161

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

* docs: record the compact form where the repo's rules live

`.claude/rules/components.md` gains the form decision (and a row in the
responsive table saying it is NOT one of the three signals), the portal
redirect, the two browser-only findings and the containing-block hazard;
tests.md's enumerated jsdom list grows a fifth entry rather than going stale.
CLAUDE.md and DESIGN_SYSTEM.md pick up the two new components and the seam.

The overlay's `aria-hidden` over the host page is host-observable, so the
integrator guide and the changelog say so alongside the scroll lock.

Closes #161

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

* fix(widget): stop the overlay locking a visitor out of the host page

A modal that covers nothing is worse than no modal. The surface locks the host's
scroll, hides their page from assistive technology and — because vaul's layer
swallows Escape — leaves its collapse control as the only exit. A host who hides
the slot, confines it with a transform or scrolls it out of view therefore gets
a page nobody can scroll, read or click, recoverable only by reload. No attacker
required.

Two exits. `DrawerStack` finishes the Escape ladder: once the stack can neither
dismiss nor collapse further, the key belongs to whatever contains the widget,
so it calls `useExpansion().collapse()` — a no-op with no surface, which is the
seam doing its job. And the surface watches its own box while open, closing
itself with a warning rather than trapping anyone when it turns out not to cover
the page.

Closes #161

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

* fix(widget): tell the host the true thing about a slot that cannot fit

Two wiring bugs, both invisible under `auto` and both wrong in the one mode that
still paints over somebody's page.

The map-mode takeover warning was suppressed whenever the compact decline had
already spoken — which is exactly `compact=never`, the case `embed-slot.ts`
promises it survives. A map embed in a 300px sidebar was told the interface
would be "cramped" when it was about to cover the whole page.

And the measurement named an axis it had not measured. `<sahaj-atlas>` is still
empty when this runs, so a bare element reports 0 tall — the headline case for
the whole feature reading as "300×0px", pointing at the opposite of the fix.

The composition is now `slotDecision`, a pure function with a spec: every part
was already covered and the join was where the fault lived, exactly as
`tests.md` records for `timeoutStatus`.

Closes #161

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

* fix(ui): honour the geolocation dismissal, and survive a feed the card cannot parse

The IP lookup was ungated where every other call site gates it, so a visitor who
had dismissed the nearby prompt was pinged again and `docs/embedding.md`'s
promise that it is skipped when no feature needs it stopped being true.

The card also rendered before its titles arrived — nameless rows — and ran the
only `toSlim` in the repo that sits in a render body, so a schema drift React
Query would have handled threw past it and replaced the whole embed with an
error panel in a 300px box. No rows is a state this card already has.

`ReportIssueModal` portals through `overlayContainer()`, so collapsing with it
open would strand it in a detached node with its scroll lock still on the host
page; it is closed first.

Closes #161

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

* docs: Escape works now, and say what the floors actually measure

The guide, the changelog and the components rule all recorded "Escape does not
close the overlay" as an accepted limitation. It is closed, so they said the
wrong thing.

Three other corrections a review caught: the height floor has no column
fallback, so an element with no height of its own is never called too short; the
IP lookup has a third consumer and honours the session dismissal; and a deep
link into a compact embed opens the card rather than the route, which is a
decision worth stating rather than leaving a host to discover.

Closes #161

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

* feat(ui): size the compact card to what the host's box can hold

The card assumed it had a box to fill. `h-full` resolves against nothing when the
host gave the element no height — the common way a bare <sahaj-atlas> lands in a
column, and one the guide already says is never called too short — so the embed
collapsed to invisible in exactly that case.

A third question, beside the two already here: `mapSlotWarning` asks whether
somebody intended a box, `embedForm` whether the interface fits, and `compactFit`
whether anything beyond the button fits. All three come off the one measurement
taken at mount. The button is irreducible — a 200px box still gets it, centred —
and rows appear above it only with room to spare.

A card with no rows now reads nothing at all: no feed, no titles, and no IP
lookup. That is a better answer to the review's gating finding than honouring the
dismissal alone, because a button-only card has nowhere to put the answer.

Closes #161

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

* refactor(widget): ask one question about the slot instead of three

`mapSlotWarning`, `embedForm`/`resolveEmbedForm` and `compactFit` were three
predicates over one measurement, which is three places the answers can
disagree — and they did, in the wiring bug this branch already fixed once.

What survives is the question underneath all three: is the space we have
meaningfully smaller than the space the button would take the visitor to?
That needs two boxes rather than one, because "too small" is meaningless
alone — 360px is cramped in a 1440px page and is simply the screen on a
phone. `resolveDestination` answers where the button goes, and `embedLayout`
answers what to render, from the same numbers.

Three constants become one. 0.8 is not a midpoint: it preserves the old
`boxed` boundary to the pixel, converts a 1000px map takeover that was
silent, and fixes a live false positive where a normally padded phone layout
degraded a working map-less embed.

Map mode that does not own its viewport now renders the card rather than
warning and then painting over the host's page — so `mapSlotWarning` has no
remaining job. `containingBlockProperty`'s ancestor walk goes too: it cost
~80 lines to name at mount what `SURFACE_CONFINED_MESSAGE` already says at
the first press, and only for causes it enumerated.

The card is now the button. Preview rows were sized by a per-row pixel
estimate that a wrapped title or a larger default font made wrong, and cost
a feed read, a titles read and a third-party IP lookup on every page view of
a sidebar embed nobody scrolls to. A compact card now makes no data requests
at all.

`compact` is removed from the loader. A documented knob for a measurement we
can get right is a permanent edge case traded for a misconfiguration we would
rather fix.

Closes #161

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

* feat(widget): make the compact card work in an iframe

The ticket's reference case — sahajayoga.nl at 400x600 — is an IFRAME
client, and the compact card was unreachable there twice over: main.tsx
never measured anything, and even if it had, the slot IS the viewport in a
frame so an in-page overlay would gain nothing.

A frame cannot expand, so a framed embed too small for the interface gets an
anchor to a page that fits, opened in a new tab. Rendered through the Button
atom's href form rather than a new JSX anchor, so it inherits the isSafeHref
gate that href.test.ts pins to three components.

"Is a new tab bigger?" is answered against min(outerWidth, screen.avail*).
screen alone reports the DISPLAY, so a small frame in a small window on a
large monitor would be told a new tab gains far more than it does.

main.tsx also gains two things it should have had already. It mounted a bare
BrowserRouter, so a sandboxed frame threw SecurityError on the visitor's
FIRST navigation rather than at boot — a live failure the frame delivery
walks straight into. And it composed share links against
window.location.origin, handing out sahajatlas.com URLs from inside a frame
whenever an event had no canonical of its own: a dead end for the visitor
and the branding leak #158 exists to close.

A page-URL ?atlas= now mounts the widget eagerly and opens onto that route.
Eager-loading is not an optimisation — the loader lazy-mounts behind an
IntersectionObserver, so auto-opening without it would slam a modal over the
page MID-SCROLL. One provenance signal drives both, so they cannot disagree,
and a script-URL default view does neither.

Documents the browser permissions a host must grant. geolocation,
clipboard-write and web-share are denied to a cross-origin frame by default
and all three fail silently. Our own source does not enumerate them:
<GeolocateControl /> is our JSX but the call is inside mapbox-gl, so a grep
of src/ finds nothing and concludes wrongly.

Closes #161

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

* docs(embedding): correct what a sandboxed iframe actually blocks

Measured in Chrome 151 against a real `sandbox="allow-scripts"` frame,
because this branch was about to ship a claim built on the old one.

The guide has said since #154 that "in a sandboxed iframe the browser
refuses to let us write the URL at all", and I repeated it in this branch's
own comments as the justification for the MemoryRouter fallback. It is
wrong. The frame IS opaque — `localStorage` throws SecurityError — and
`replaceState`, `pushState` and a replaceState to a different URL all still
succeed. So `urlWritable` does not detect a sandbox, and the fallback is
insurance for `file://` and stricter engines rather than the fix it was
introduced as.

What a sandbox does block is `window.open`, which returns null without
`allow-popups` — so the compact card's link, which is the one thing in this
branch that depends on opening a tab, is the real casualty. That was the
documented host requirement already; it is now a verified one, and the
troubleshooting table names the symptom, since the browser blocks it in
silence.

Also verified in a real cross-origin frame, since the framed path rests on
it: `window.outerWidth` reads 1200 where `screen.availWidth` reads 1440, so
taking the smaller of the two is load-bearing rather than defensive.

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

* refactor(widget): drop the file:// fallback rather than carry it

The MemoryRouter branch this branch added to main.tsx was justified as
insurance for a sandboxed iframe. Measuring that turned out to be wrong —
Chrome 151 permits replaceState and pushState in a real
`sandbox="allow-scripts"` frame — which left `file://` as the branch's only
remaining trigger.

`file://` is not a supported way to run this build: it has no origin the API
will accept and no CORS, so the widget fails long before its router does. A
branch whose only case is a configuration we do not support is never
exercised and never right, so it is gone along with `lib/url-writable.ts`
and the cross-seam pin it needed.

The loader keeps its own probe, privately, because it answers a different
question: whether a page can carry a shareable route, which is what decides
canonical viability in the embed report.

Recorded in `.claude/rules/components.md` so the next reader does not
re-add it.

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

* fix(ui): stop the compact card's fill class welding itself to its neighbour

`h-full` was joined onto the class list with a template literal, and
prettier-plugin-tailwindcss re-sorts the static half and eats the leading
space — so a filling card shipped `text-foregroundh-full`: a class present in
the DOM, matching no rule, with lint, typecheck, the unit lane and the
production build all green. The card sat 91px tall at the top of a 600px slot
instead of centred in it.

This is the silent-Tailwind failure `.claude/rules/code-style.md` warns
about, and it survived a computed-style check because that check read the
inner column rather than the root. A screenshot of the deployed preview is
what caught it.

`clsx` for the conditional half, which is what the rules already prescribe
for conditional joins. The spec now splits the class attribute into tokens
and asserts membership rather than substring containment — the old
`toContain('h-full')` passes happily on `text-foregroundh-full`, which is
precisely why it missed. Verified by reverting the fix and watching it fail.

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

* fix(story): make the compact card's button actually open the surface

Every overlay story passed `onOpen: () => {}`, so the buttons did nothing —
which made the one interaction worth reviewing the one thing a reviewer
could not see. Only the framed fallback worked, because an anchor needs no
handler.

The overlay stories now compose the real `useExpansion` seam with a real
`ExpandedSurface`, the way `AppShell` does, so pressing a button opens the
surface, Esc steps out, the collapse control works and focus returns to the
button. The framed story stays an anchor, and its docblock now says why that
difference is the feature rather than an inconsistency.

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

* fix(ui): stop the defensive reset erasing every icon in the widget

`all: revert` over a bare `*` was applied to SVG internals too, and in SVG 2
the geometry IS css: `d`, `fill`, `cx`, `r`, `x`, `y` are properties, and a
presentation attribute is only an author rule of zero specificity. So the
reset beat every `d="…"` in the app and rolled it to `none`.

The failure is total and silent. The `<path>` stays in the DOM at its full
28x28 with a computed fill; `getBBox()` reports 0x0; nothing paints. Measured
at 53/53 paths in a PRODUCTION build, so this is shipping — every icon in the
embedded widget renders as nothing, and lint, typecheck, the unit lane and
assert:css are all green while it does.

The reset exists to keep a host's CSS out of our HTML. SVG internals are not
a surface a host styles, so excluding them costs nothing it was there to buy.

Pinned in postcss-scope-widget.test.ts as a string check, which is the honest
limit of the node lane: whether a browser paints a glyph is not something it
can answer, but it can stop the exclusion being simplified away — which is
exactly how this would come back.

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

* refactor(story): show CompactCard's props, not the places it appears

Five named exports, each a context the card turns up in, against a repo
where every other story is one `Default` with sections and a `storyName` —
and contexts are a view's concern, not an organism's.

Now one story whose sections are the component's two actual props: `action`
(overlay vs link) and `fill`. Which one an embed gets is `decideSlot`'s
answer, which is measurement rather than configuration, and is specced in
the node lane rather than previewed here.

Includes the `storyName` convention applied to ReportIssueForm.

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

* refactor(ui): ExpandedSurface becomes a generic Dialog with a margin

Renamed and re-scoped. The old name described one caller; what the component
is, is a large chrome-less dialog — the widget's own interface over the page
rather than in it. `Modal` remains the small `max-w-md` panel with a
title/description header; the difference is size and whether the content is
a panel or an application.

It now keeps a margin, and the margin is the point: a full-bleed `inset: 0`
layer reads as a navigation, with the host's page simply gone and no way for
a visitor to judge that they are still on it. A visible frame plus
click-outside-to-close makes it legibly a layer over their site.

⚠ `contain: layout` on the content is what makes the margin possible, not an
optimisation. Everything inside is `position: fixed` — the map canvas, every
drawer, the peek strips, the cog — and a fixed descendant resolves against
the VIEWPORT unless an ancestor establishes a containing block. Measured in
Chrome 151: a `fixed; inset: 0` child of a `fixed; inset: 16px` parent lands
at 0,0,1440,900 plain and at 16,16,1408,868 under `contain: layout`. Without
it the interface escapes the margin and paints to the screen edge. That is
the same property the rules forbid on the SCOPE ROOT, for the same mechanism
pointed the other way.

Custom code removed rather than moved: the `ResizeObserver` that watched the
surface's own box and closed it when it stopped covering the viewport, plus
`surfaceCoversPage`, `SURFACE_MIN_COVERAGE` and `SURFACE_CONFINED_MESSAGE`.
That machinery existed because the × was the only exit and a host could hide
it. Radix maintains two more exits for free — click-outside and Escape — so
a confined dialog is now a cosmetic problem rather than a trap, and there is
nothing left for it to guard.

Verified in a browser: opens inset on all four sides, `contain: layout`
active, clicking the margin closes it, focus returns to the opening button.

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

* refactor(views): CompactCard becomes CompactView, and never fills its slot

**A view rather than an organism, because it is a whole screen.** It is what
the widget IS in a slot too small for the interface — the alternative to
`DrawerStack`, chosen by `decideSlot` at mount — not a piece something else
composes. Its stories were already describing contexts rather than props,
which is the symptom of a view filed under components.

**`fill` is gone.** It takes the height its content needs and no more, in
the host's own flow, whatever box they gave. Filling was wrong in both
directions: against an element with no height `h-full` resolved to nothing
and the card collapsed to invisible, and against a tall one it stretched a
two-line card down 600px of empty background. A card the size of a card is
right in every slot, and removing the prop removes the whole class of bug
that produced `text-foregroundh-full`.

That deletes `fill` from `CompactState` and `decideSlot` too — the element's
own height was measured only to feed it.

The story now opens the REAL `CountriesView` inside the dialog, seeded
through `ViewHarness`, so the whole path is reviewable end to end without a
backend rather than mocked at the last step.

⚠ It does NOT settle the vaul question. `ViewHarness` substitutes a flex
panel for the vaul sheet, so no `position: fixed` drawer is in play — there
were zero fixed descendants inside the dialog when measured. Whether a real
snap-point sheet computes its travel correctly against a dialog 32px shorter
than the window still needs the app with a live key.

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

* fix(ladle): keep the style scope inside the viewport iframe

Setting a viewport in Ladle stripped every component in every story back to
UA defaults — unstyled buttons, Times body text, no tokens.

The scope class was added at module scope to `document.documentElement`, and
Ladle's viewport control re-renders the story inside an iframe. The side
effect ran against the document that loaded the module, not the one the
story lands in, so the iframe received the stylesheet and no `.sy-atlas` —
and since the PostCSS pass scopes every emitted rule to `:where(.sy-atlas)`,
the whole sheet matched nothing.

The wrapper `<main>` now carries the class as well, which is the only form
that travels with the story into whatever document renders it. Harmless
where both apply: `:where()` contributes no specificity and the
inherited-property block sets the same values at either level.

Measured before and after in the iframe: button background
rgb(239,239,239) (UA) → rgb(26,92,97) (brand), content font Times → Atlas
Raleway.

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

* refactor(views): fold the Dialog atom into CompactView, its only caller

Two components called Modal and Dialog sat side by side in atoms/ appearing
to do the same job, and the one that looked generic was not. It published
itself as the app's portal target, it needed `contain: layout` because THIS
app's interface is fixed-positioned throughout, and it had exactly one
caller. That is domain knowledge in an atom and a single-use composition
exported as a primitive — `.claude/rules/components.md` rules against both,
in the same section.

So it moves into `CompactView`, module-private, and `Modal` becomes
unambiguously the dialog atom: small, centred, chrome-ful, generic.

`CompactView` now owns the whole compact screen — the card, the dialog, the
expansion providers and the report-modal handoff — which also deletes
`CompactShell` and `CompactForm` from App.tsx. App's branch is one line: the
compact view, or the interface.

Also collapses the duplicated `autoOpen`, which was stored both on the
action and hoisted beside it.

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

* feat(story): one CompactEmbedView story, with a real map in the dialog

Renamed from CompactView throughout — "embed" is the word that says which
slot this is about.

The story collapses to a single example with controls, matching every other
view story: an Interface select (Countries / Search / Region / Event /
Calendar), an "In context" toggle that renders it in a mock host page, and a
Map toggle, on by default. No fixed viewport, so the embed gets the whole
canvas and how it sizes itself in an unconstrained slot is what is on screen.

**The map was missing because the harness never rendered one.** `ViewHarness`
hard-coded `hasMap: false` and `NoopMapControllerProvider`, so every view
story — not just this one — previewed the map-less arm. It now takes `map`,
which moves all three together: the mode flag, `MapProvider` + a real
`<Mapbox/>`, and `RealMapControllerProvider`. A flag on `WidgetMode` alone
would tell the tree a map exists without rendering one and without a real
controller, which is a state the app never has. Falls back to the map-less
arm without a token rather than previewing a broken canvas.

⚠ Then the view floated transparently over the map, and the cause is worth
recording: the map wrapper is `position: absolute` and the drawer column was
static, and **a positioned element paints above a static sibling whatever the
DOM order**. The column is now positioned, and with a map behind it is an
anchored panel rather than a full-bleed column — which is what map mode
actually renders.

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

* fix(story): stop the harness sizing off the viewport inside the dialog

The expanded dialog appeared unscrollable. It was not — the scroll range was
94px and worked programmatically — but the harness column is `h-screen`
(900px) inside a dialog that is 868px with `overflow-hidden`, so the bottom
32px of the scroll area, scrollbar included, was clipped. Scrolling you
cannot see is indistinguishable from scrolling that does not work.

32px is exactly the dialog's margin, which makes this the first concrete
instance of the tension that margin introduces: anything inside the dialog
that sizes off the VIEWPORT is wrong by the margin. `ViewHarness` now takes
`height`, and the compact story passes `container`.

⚠ We own that arithmetic. We do not own vaul's: it computes a snap-point
sheet's travel from `window.innerHeight`, so a real bottom sheet inside the
dialog has the same exposure and cannot be fixed the same way.

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

* fix(story): one position class on the harness column, not two

The countries list still would not scroll with the map on — the default, and
the branch my previous fix did not check.

The column carried `relative` in the shared half and `absolute` in the map
arm. Tailwind emits `.relative` after `.absolute`, so `relative` won,
`inset-y-0` did nothing, and the column grew to its content: 994px inside an
868px dialog, clipped, with no height bound for the body to scroll within.
Nothing was scrollable at all — `scrollables: []`.

Now exactly one position class per branch. Verified in BOTH map states with
a real trusted wheel rather than a synthetic event (synthetic wheels do not
scroll in Chrome, which is what made the first check read as inconclusive):
0 → 126 of 126 either way.

Checking one branch and shipping the other is what produced the bug; the
comment says so where the next person will be tempted to merge the strings
again.

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

* refactor: simplify per /simplify pass

`compactState()` had exactly one caller and lived in its own 43-line module.
Its result type now sits with the function that returns it, which is one
fewer module and one fewer import hop for a feature that was spread over
four.

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

* docs: retire the claims this branch made false

Two rule/reference files described machinery the branch deleted:

`.claude/rules/components.md` said the surface "watches its own box while
open (`surfaceCoversPage`)". That observer is gone — the dialog's margin and
click-outside are what replaced it, and the passage now says so rather than
describing a guard that no longer exists.

`DESIGN_SYSTEM.md` still listed a `Dialog/` atom. It was folded into
`CompactEmbedView`, so `Modal` is now named as the dialog atom outright.

Also records the margin's one real cost while it is fresh: anything inside
the dialog sizing off the viewport is wrong by the margin — ours is fixed,
vaul's is not ours to fix and is unverified against a live drawer stack.

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

* fix: triage the review pass — three verified bugs and the claims that were false

**autoOpen never fired in a dev build.** The once-per-document latch was
written inside a `useState` initialiser. React double-invokes initialisers
under StrictMode — which `providers.tsx` mounts unconditionally — and keeps
the SECOND result, so pass 1 set the flag and pass 2 returned false. Three
reviewers reproduced it independently: committed state false, flag true.
Production strips the double-invoke, so the shipped path works today — but
only while nothing below the provider suspends before it commits, which is
not a property anything holds. The latch is now an effect, which runs only
for a commit that survived.

**An unmeasurable screen degraded every framed embed.** `newTabBox` `||`-ed a
zero reading up to Infinity, making "is a new tab bigger?" unconditionally
true — so a browser reporting 0 for both `outerWidth` and `screen.avail*`
(WebViews, prerender, hardened privacy modes) sent every framed embed,
however large, to the card and then off-site. Zero now means "no evidence",
which is the bias every other predicate in the file takes.

**Focus fell to the host page's body on two real paths.** `preventDefault()`
ran unconditionally, suppressing Radix's own restore, while `opener` is empty
both on the auto-open path (the recorder effect never runs for a dialog open
on its first render) and on Safari/Firefox, which fire no focusin from a
button click. It now pre-empts Radix only when it has somewhere to send focus.

Also fixed: the framed `hrefFor` composed routes against the fallback base and
fabricated `wemeditate.com/<route>` 404s, where the contract already models
"no link" as `undefined`; `fromPage` was read twice from `location.search`
either side of a dynamic import, so a host SPA adding `?atlas=` after boot
could lazy-mount and still auto-open mid-scroll; the story seeded the Search
key at [0, 20] against a store default of [0, 0], so that arm hit the absent
backend; and the scrim had drifted to /40 against the Modal atom's /50.

Docs corrected rather than defended: both host-facing files promised an
overlay self-close this branch deleted, and claimed the collapsed card makes
"no data requests at all" when the client read, the cache warm-up and the
embed report all still run. The guide now names `wemeditate.com` as the
framed fallback destination — a host can observe it and nothing told them.

Housekeeping: `toSlim` re-privatised, `canExpand` removed (declared, set by
both providers, read by nothing), four stale comments fixed, the `+`
continuation markers a blanket Prettier run flipped in three governance files
restored, tests.md's jsdom list corrected to six, and `responsive.test.ts`
extended to police raw `window.inner*` / `screen.avail*` reads — the
closed-list gate could not see the one this branch added.

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

* perf(widget): actually keep mapbox-gl out of a compact embed

The claim was false, and I made it in five places. `react-map-gl`'s
`exports-mapbox.js` runs `const mapLib = import('mapbox-gl')` at MODULE
scope, so importing it anywhere in the eager graph fetches 485 KiB gz
whether or not a map renders. A 300px sidebar embed — a heading and one
button — downloaded the entire map library on every page view.

Three eager edges had to go, not one:

- `FullInterface` is now its own module behind `lazy`, carrying `MapProvider`,
  `Mapbox` and the real camera provider.
- `use-map-controller.tsx` keeps only the seam — context, `NOOP`,
  `useMapController`, `NoopMapControllerProvider` — and can no longer import
  `react-map-gl`, directly or transitively. The real provider moved to
  `use-map-controller-real.tsx`. While they shared a module, even `map=false`
  pulled the library in.
- `App.tsx` imports `ReportIssueModal` from its own path rather than the
  `@/components/organisms` barrel, which re-exports `Mapbox`.

That last one is why measuring mattered: after the lazy split, static
analysis said mapbox-gl was no longer reachable from `embed.js`, and a
browser said it was still fetched — through the one remaining barrel import.

Measured in a production build, real page, real network log: mapbox requests
went 1 → 0, and the eager payload 375 KiB → 301 KiB (embed) and 373 → 299
(standalone), a 74 KiB drop on top of the 485 KiB that left the critical path
entirely.

`check-bundle-size.mjs`'s docblock said dynamic-import targets are "a second
hop, not the first-load cost" — the sentence that let this hide for a whole
PR. It now says a dynamic import is only a second hop when the module holding
it is itself lazy.

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

* fix(ui): stop the widget sizing off the viewport inside the dialog

The dialog keeps a margin, so it is 16-32px shorter than the window — and
every drawer, peek strip and sheet inside it is `position: fixed`, which
means `100dvh` was only ever correct while nothing had taken the containing
block. The dialog takes it, via `contain: layout`. Four consumers were wrong
by exactly the margin: the sheet overran the clip edge, the peek strips sat
below the sheet they cap, the sticky Register bar was offset, and the
fallback bodies mis-measured their max height.

One token fixes three of them. `--sy-frame-h` is `100dvh` on `.sy-atlas` and
`100%` on `[data-sy-expanded]`; `100%` on a fixed child resolves against its
containing block, which is the dialog there and the viewport everywhere else,
so a single value is correct in both places without anything branching.

`--sy-sheet-top` needed the matching correction: it is written from
`getBoundingClientRect().top`, a viewport coordinate, and consumed as `top:`
on fixed peek strips and `bottom:` on the sticky bar. The dialog's own top is
now subtracted — zero offset everywhere else, so it is the same number it
always was outside one.

vaul turned out not to need a patch. It measures `container` when given one
and `window.innerHeight` otherwise, so the Drawer atom forwards `container`
to `Vaul.Root` — the same element it portals into, so the box vaul measures
can never differ from the box it renders in.

Verified with a REAL snap-point sheet in a contained 768px box at an 800px
viewport, which nothing had tested before: the sheet computes 768px rather
than 800, and its peek is exactly the 80px snap. The story harness could not
answer this — it substitutes a flex panel for the vaul sheet — so the
measurement was taken against a throwaway probe story.

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

* fix(widget): stop a collapsed compact card writing the host's URL

`AppShell`'s home-region redirect ran whenever the shell mounted, including
when a compact card was the only thing on screen — and `navigate` pushes
`?atlas=/nl` onto the HOST page's URL. A visitor who then reloaded,
bookmarked or shared that address got a full-screen dialog over the host's
page on load, having never asked for one: auto-open fired by our own
bookkeeping rather than by a link anybody followed.

The redirect moves into `FullInterface`, which renders only when the
interface is actually on screen — always in the full form, and only once the
dialog opens in the compact one. That is a structural guarantee rather than a
condition somebody has to remember: there is no longer a state in which the
redirect can run while nothing but the card is rendered.

Note the Ladle story cannot demonstrate this — it runs on a MemoryRouter, so
no URL write would reach an address bar there either way.

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

* perf(build): ratchet the eager-payload budget onto what this branch ships

`pnpm size` failed UNDER budget, which is the gate working: 395 KiB was set
against a 383 KiB payload and this branch put both graphs at ~300, so the
budget had quietly stopped being able to detect anything.

Lowering it to 310 locks the win in, per the rule the script's own header
states — ratchet down in the commit that won the space. The ~3% headroom is
the same margin the previous line carried, and clears the ~2.1 KiB a
credentialed build adds that CI cannot measure.

  standalone  382.1 → 299.3 KiB
  embed       383.6 → 301.3 KiB

The space comes from `FullInterface`: the map-bearing interface now sits
behind a lazy seam, so a slot too small to hold it mounts a card and a dialog
and never fetches mapbox-gl.

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

* fix(ui): stop vaul measuring a box that has no box

The branch forwarded `container` to `Vaul.Root` as well as to its portal, on the
reasoning that measuring the box we render in cannot be the wrong box. It is.

vaul computes every snap offset as `containerSize.height - height`
(`snapPointsOffset`, vaul dist), and the element we portal into is not always
something with a height. Embedded, it is the theme root, which is
`display: contents` and measures **0×0** — verified in Chrome 151. Standalone it
is `<html>`, which in map mode holds nothing but `position: fixed` children and
measured **195px against an 844px viewport**. At zero, the ladder
`['80px','300px',0.97]` becomes `[-80,-300,0]` instead of `[764,544,25]`: the
bottom sheet translates UP and covers the top of the screen, with the map in a
strip beneath it. That is the default phone experience of a map embed.

Passing a container also sets vaul's `data-vaul-custom-container`, which disables
the `::after` background extension — so over-dragging the sheet revealed the map
behind it.

The portal target and the measurement box are different questions, so they are
now different props. Only the expanded dialog supplies a measurement box, which
is the one case that genuinely needs one: it keeps a margin, so it is 16–32px
shorter than the window and a fractional snap measured against the window
overruns its clip. Everything else falls back to `window.innerHeight`, which is
what shipped before this branch.

Lint, typecheck and all 1263 unit specs were green with this live, so the fix
comes with a jsdom spec that fails against it — asserted by restoring the defect
and watching two of its three cases go red.

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

* fix: triage the second review pass

A collapsed compact card was still fetching the world. `warmCaches()` ran from
`App`'s mount effect regardless of layout, so every host page view of a sidebar
embed nobody presses pulled the whole events feed and the wholesale region tree
— the exact cost #161 removed by deleting the card's preview rows, arriving back
through a component two levels above the one whose spec asserts those rows are
absent. Verified in a browser: three data requests before, one after
(`clients/me`, which the card legitimately needs). `FullInterface` warms them
instead, so pressing the button still does; the full form keeps `App`'s call,
where the point is overlapping the client bootstrap rather than following it.

`fallbackUrl` validated a parsed URL and returned the unparsed string. The
WHATWG parser strips leading and embedded ASCII whitespace before parsing, so
` https://…` — the likeliest .env typo there is — passed the https check here
and was then refused by `isSafeHref` at the sink, whose scheme test is anchored,
producing precisely the dead unlabelled card this module exists to prevent. It
now returns the parsed URL, with the whitespace cases in its spec.

`--sy-sheet-top`'s offset came from `document.querySelector('[data-sy-expanded]')`
— the HOST's whole document, where an element of theirs carrying the attribute
would win on document order and offset every peek strip by its box — re-run on
every animation frame, sixteen lines below a comment explaining why the sibling
lookup is cached. It reads the node `lib/overlay` already tracks.

Also: `toSlim` was exported for preview rows that no longer exist; the
`react-map-gl` invariant that `use-map-controller-real.tsx` cross-references was
never actually written down, leaving the branch's headline perf claim defended by
a pointer to nothing; `Modal` was the one viewport-unit consumer the
`--sy-frame-h` sweep missed; and the mangled comment in `EventsList/index.ts` was
collateral from an earlier agent's stray edit, reverted to origin/main.

Docs: `CHANGELOG.md` promised a self-closing overlay this branch deleted,
`.claude/rules/components.md` justified a deletion by citing a message that no
longer exists, `docs/embedding.md`'s privacy section credited the IP lookup with
ranking card rows that were removed, and both host docs said the card is "centred
both ways" when it is centred across and sits at the top.

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

* fix(analytics): only record a pageview once the interface is on screen

The Fathom effects lived in `AppShell`, which renders for every embed — including
one whose entire appearance is a collapsed card. So every host page view of a
sidebar nobody pressed recorded a pageview of `/` for an interface nobody opened,
and injected our tracker into the host's page to do it.

They move into an `Analytics` component rendered from `interfaceElement`, so they
cannot run before the interface does: immediately in the full form, and only on
opening in the compact one. Same reasoning that moved the home-region redirect
into `FullInterface` and the cache warm out of a collapsed card — a collapsed
card should do nothing a visitor did not ask for. The tracker script is no longer
loaded at all while the card is closed, which is the better half of the fix.

Pinned with a jsdom spec, and the route to it is worth recording. I wrote the
assertion first in the SSR sibling, where it passed — and kept passing with the
regression deliberately reintroduced, because the dialog's content is a Radix
portal and `renderToStaticMarkup` renders no portals. That is a spec covering the
door rather than the state. The jsdom version fails when the interface is mounted
alongside the card, which is the shape the regression would actually take.

It pins one property that three fixes on this branch all rest on — unfetched
mapbox-gl, unwarmed caches, and now this — each of which has its own spec that
would keep passing if the collapsed card started rendering its children.

Verified in a browser that a collapsed embed makes one request (`clients/me`) and
no others. The Fathom half is NOT browser-verified: `VITE_FATHOM_ID` is commented
out locally, so no probe could observe a tracker request either way.

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

* docs: record what the #161 session learned, and make the browser check one command

Seven changes from the session reflection, each traceable to a specific way this
branch cost time or nearly shipped something wrong.

Two go to `.claude/rules/tests.md`, both from the same afternoon. First:
`renderToStaticMarkup` renders NO portals, so an SSR assertion about what is
inside a drawer or dialog passes whether the content rendered or not — asserting
ABSENCE is the trap, and this app is portal-dense enough that it will recur.
Second: a regression spec is not finished until it has failed. Two freshly written
specs here passed against the very bug they were written for, the second because
the simulated regression flipped a gate Radix already made unreachable.

`.claude/rules/components.md` gains the invariant behind four separate bugs: an
effect in `AppShell` runs for a collapsed card too, so anything that writes the
host's URL, fetches, injects a script or reports must mount with the interface.
The redirect, `warmCaches`, and both Fathom effects were each fixed in isolation
before the pattern had a name.

`.claude/rules/code-style.md` records that `react/jsx-sort-props`' autofix moves
props but leaves comments where they sat, so a commented prop added out of order
ends up documenting its neighbour — silently, with lint green afterwards.

`finalize-pr` gets two: dispatch review subagents READ-ONLY (one with write access
edited 17 files on an earlier pass, including a file the branch never touched), and
run `pnpm build && pnpm size` before pushing when the import graph moved, since the
budget fails UNDER as well as over and the lean gate cannot see it.

And `pnpm review:embed` (`scripts/serve-embed-review.mjs`) serves `dist/` as real
host pages — full map, narrow sidebars, hostile host CSS, iframes, a page-URL deep
link. Hand-rolling this cost a dozen turns and has four traps, all hit: the element
observes no attributes so config must ride on the script URL; locales come from
`VITE_HOST` and their absence renders NOTHING with no error; python's http.server
sends no CORS; and `_redirects` makes a leftover server answer 200 with the app
shell for a page it does not have. It refuses to start on an occupied port for that
last reason.

Verified by running it: locales resolve same-origin, zero mapbox requests on the
sidebar page, one data request, and the documented backend caveat reproduces
exactly.

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

* fix: triage the third review pass

**The analytics move I made last commit was broken, and its own reviewer caught
it.** `Analytics` mounts inside the interface, which the compact dialog unmounts
on close — so `ownsTracker`, a ref, reset on the next open, while
`'fathom' in window` was by then TRUE because our own script had put it there.
The load effect returned early, never re-set the flag, and the pageview effect
short-circuited for the rest of the document's life: analytics silently dead
after the first collapse, in exactly the compact form the move existed to serve.
Both latches are module scope now, like `autoOpened` in `use-expansion` — and
`lastTracked` too, since the contract is one pageview per real NAVIGATION and
closing and reopening on the same route is not one.

It also moves into `FullInterface`, which is the module whose documented purpose
is being the interface, alongside the redirect and the cache warm. Verified with
`VITE_FATHOM_ID` set: `fathom-client` lands in the `FullInterface` chunk and
`dist/index.html` does not preload it. The eager payload is unchanged at
299.3/301.3 — no size claim, since without the ID the module is eliminated
either way.

A comment in `App.tsx` still told readers that `analytics="false"` on the element
keeps the tracker out. It does not: the element observes no attributes and the
loader parses no such parameter, so that was the last surviving claim of a
host-side opt-out that no longer exists.

The review server gets four fixes, three of them real failure modes: an unguarded
`decodeURIComponent` made `curl 'http://localhost:5173/%'` an uncaughtException
that killed the process — leaving a dead port and no message, which is trap 4
wearing a different hat; `listen(port)` bound 0.0.0.0, handing every page (each
with the client API key substituted in) to the whole subnet on shared Wi-Fi; and
the port probe was a TOCTOU proxy for a question `listen` answers exactly. It
also stops writing its index into `dist/`, and reads env through vite's own
`loadEnv` rather than a hand-rolled parser that mis-handled quotes and inline
comments.

Verified each: malformed escape now 400s with the server still up, the LAN
address refuses the connection, no file is left in `dist/`, and the key still
substitutes.

Also: `main.tsx` shares `framed()` rather than keeping an inverted copy of a
predicate whose `catch` arm is the subtle part (with a note that the loader's
third copy must stay duplicated — importing across that seam fails `pnpm size`);
`parseConfig` drops an object built only to be spread; and two orphaned comments
now sit above what they describe.

Dismissed: excluding `?atlas=/` from auto-open. `fromPage` is a boolean and the
route is not in scope, so it would mean threading a value through a function
whose design point is asking one question — and `/` opens the countries view,
which is what the button opens anyway, so it removes a spelling rather than any
impact.

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

* fix: triage the code-review pass, including a false claim in my own rule

**The tests.md section I added two commits ago was wrong, and it was wrong in the
way that section is about.** It said `renderToStaticMarkup` "renders NO portals",
inferred rather than measured. React 18.3.1 THROWS on one — "Portals are not
currently supported by the server renderer" — which I have now actually run. So
the broad conclusion it drew ("the node lane can never assert a portal's
subtree") was backwards in the direction that matters: an eagerly-mounted portal
fails loudly.

What genuinely made the #161 spec vacuous is a Radix property, not a renderer
one: `Dialog.Portal` wraps its child in `<Presence present={open}>`, so a CLOSED
dialog never calls `createPortal` and there is nothing to serialize or throw
about. The section now states both halves as a table, with the asymmetry — blind
to a closed portal, deafening about an open one — as the useful part.

**The auto-open spec did not catch the bug it was written for**, twice over.
First it went in `CompactEmbedView.mount.test.tsx`, where a sibling test's click
had already latched the module-scope `autoOpened`, so it observed a closed
surface for the wrong reason; `vi.resetModules()` does not rescue that, since it
governs future imports rather than the instance the file already resolved. It
now has its own file, where vitest gives it a clean registry. Then it passed
against the restored defect anyway, because a bare `createRoot` render does not
double-invoke — the whole StrictMode bug is invisible outside `<StrictMode>`,
which `providers.tsx` mounts and the spec now does too. Confirmed failing against
the initialiser version.

The review server had a second crash path beside the malformed escape:
`existsSync` is true for a directory, so `/assets` or `/locales` passed the
guard, sent a 200, and then died on an unhandled EISDIR from
`createReadStream`. Both are 404s now, with a stream error handler as backstop.

And `full-map.html` — the one page whose note says "map mode, full page" —
showed the compact card on any display wider than ~1455px. The shared shell caps
content at 1100px, so the element's parent measured 1164, which IS the slot,
which is meaningfully smaller than a 1512px viewport. Verified with a control:
the map page no longer warns at 1512 and the sidebar page still does.

Also: the `probeUrlWritable` docblock claimed `canonicalViable` is "the only
thing that reads" `urlWritable` — it also decides the router in `mountDecision`
and rides in the readiness marker, and a reader trusting "only" would delete a
load-bearing field with the report. `docs/embedding.md` blamed a blocked
`window.open` for the framed card; it renders an anchor. And the `review:embed`
insert had orphaned the map rule's fallback instruction.

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

---------

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
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.

feat(widget): de-brand the widget and keep host CSS out of it

1 participant