Repository navigation
fix(map): an off-origin atlas canonical renders as an internal link - #237
Conversation
An atlas canonical is owned per-subtree, so `atlasHref` legitimately returns another client's absolute URL. Both consumers rendered it through `Link` with no `external` prop, so a cross-domain link shipped as if it were internal: same tab, and the full referrer handed to a site we do not run. `isSitePath` is the existing exact test — `atlasHref` returns a path for a canonical we serve and an absolute URL otherwise — so each call site classifies with it rather than re-parsing the result, and `Link` keeps sole ownership of the `target`/`rel` pairing. The same-origin branch needs an origin to compare against, which the existing suite has no `pageContext` to supply, so it lives in its own file beside the module-wide mock. Closes #209 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXg1nmypE5GH1XPWhe
…ernal `onlineUrl` and `website` are typed by a coordinator upstream and reached `href` unchanged, so a `javascript:` value would have run in our origin. Nothing upstream validates either field. `isSafeHttpUrl` is the gate this repo already owns for a URL it did not author, and its doc listed only the two callers that had it. The link also hand-rolled half of `Link`'s external pairing: `rel` without `target`, so the referrer was withheld but the visitor still left the class page in the same tab, with no affordance. Routing it through `Link` leaves one owner for that pairing and brings `focus-ring` with it. Behaviour change: this link now opens in a new tab. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXg1nmypE5GH1XPWhe
… link `atlasHref` fell back to the raw upstream `url` when it was not ours to relativize, so the file applied two standards to two untrusted URLs twelve lines apart: the class's own room link was gated and the region canonical was not. One `upstreamUrl` now guards both, and a refused canonical falls through to the `/map` path that keeps the region reachable. The review pass also folded the new origin-aware spec into `AtlasContent.locale.test.tsx`, which already carries the module-wide `pageContext` mock and an origin, rather than standing up a third copy of that harness beside two that exist. `anchorFor` moves to `tests/_helpers/markup.ts` so the two suites share one definition. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXg1nmypE5GH1XPWhe
A `not.toContain` over a whole render passes when nothing matched at all, which is the same silent failure the attribute-casing note already warns about one paragraph down. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXg1nmypE5GH1XPWhe
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
wemeditate-design | cfb446a | Commit Preview URL Branch Preview URL |
Nov 15 2026, 07:27 PM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
wemeditate-web | cfb446a | Commit Preview URL Branch Preview URL |
Nov 15 2026, 07:27 PM |
sydevs-bot
left a comment
There was a problem hiding this comment.
1 question for the reviewer, one per thread.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
The diff matches #209, and the scheme gate it joins sits in the same file on the same path from an atlas value to an href. 199 lines for a two-line defect reads large until it is split: 134 are tests, the behaviour change is nine lines plus a three-line helper. Nothing here is smuggled.
Findings
should-fix— theexternalcontract this PR banks on is documented falsely (AtlasContent.tsx:100).consider—upstreamUrlis the third spelling of one guard (AtlasContent.tsx:39).
Whole-file pass on AtlasContent.tsx. Six components, each with one caller — nothing to fold. Image, Link, formatList and isSitePath are reuse, not reinvention, and the defensive reads earn their place against a hand-mirrored type. One divergence the diff widens: components/atoms/Breadcrumbs/Breadcrumbs.tsx carries neither external nor aria-current="page", so this file's hand-rolled trail is now the better of the two. Worth deciding before either is aligned to the other.
What was checked. Read whole on the branch: AtlasContent.tsx, lib/urls.ts, Link.tsx, the Breadcrumbs atom, server/atlas-types.ts. Ladder on both new pieces — upstreamUrl found three siblings (finding 2); anchorFor found none, LayoutChrome.test.tsx:55 narrows differently, and tests/_helpers/ is where its sibling lives. Contract side: lib/urls.ts's updated caller list is accurate, and no field of SahajCloud's src/endpoints/responseTypes.ts is newly depended on. All three preview links answered 200. /map/gb: 48 of 53 anchors carry target="_blank", the five chrome links do not. Both class pages send their own link off-site, meditate4free.co.uk and meetup.com. The same-origin row is unprovable there, as the body says, and the suite covers it.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
The Link section promised that `external` "adds screen-reader text announcing it opens in a new tab". `Link.tsx:88` sets `target` and `rel` and nothing else, so the doc promised an affordance no visitor gets. This PR adds three `external` links on that assurance, two of them a breadcrumb rung and a heading. Record what the atom does today, and point at #238 for the announcement. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZTKcEfxHFKHDo6gDf
`isSafeHttpUrl`'s caller list named `lib/submissions.ts` for the authored redirect. That module never touches a URL gate. Both the check and the `window.location.href` assignment live in `FormBuilder.tsx`, and the check reaches this predicate through `isSafeNavigationUrl`. A caller list inside a load-bearing warning is only useful while it is true. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZTKcEfxHFKHDo6gDf
|
Adversarial review addressed. Adopted · the Rebutted · lifting Joined · Still open · should a class's own link open in a new tab. It waits on a reviewer. A is built. Lean gate green on the merge: 960 tests, 95 files. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
|
Reviewer answered the one open question. Answered · should a class's own link open in a new tab → A, already built in Merged Lean gate green on the merged result: 970 tests, 97 files. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Seven link and icon call sites still carried `text-teal-700 hover:text-teal-800`, the move the frozen palette forced. The retune makes `teal-600` 4.87:1 on white, so these pay a step of brand for nothing. `SubtleSystem.tsx:253` already read `teal-600`, which is what showed the revert was partial. Found while resolving this branch's merge against `main`, where #237 rewrote one of the seven.
Three resolutions, two of them in files git merged without a conflict. docs/rules/design-system.md — took this branch's text. main (#237) corrected the Link section to say the atom does not announce a new tab, which is part 3 of #238's "correct the docs either way". This branch does part 1, so the claim is true again and the interim correction is the stale side. AtlasContent.tsx — took main's. #237 already routed the join/website link through Link, with `external` and the call-site isSafeHttpUrl gate. This branch's hunk only converted the bare <a>, and passed `rel` without `target` — the half-pairing #237 removed. main's side is this branch's intent, done more completely. MeditationPlayer.locale.test.tsx — main's new assertion pinned `wemeditate.com</a>`, and the upsell link is `external`, so Link now closes that anchor with its sr-only new-tab announcement. Matched as element text instead, which still proves the brand name is not translated. lib/urls.ts — isSafeHttpUrl's ⚠ doc claimed to be the only gate on an unauthored URL. isSafeLinkHref makes that false, so it now says which sink each predicate owns. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZ3PwUpXqAwXEemiP8
Summary
isSafeHttpUrlbefore it reaches anhref. The class's own room link had no gate at all, and the region canonical had none either.externalnever announced the new tab, and the scheme gate's caller list named a module that does not call it.Change outline
atlasHrefresolves a canonical to a path when we serve it and hands back the absolute URL when another owner does. Only the first kind is ours to locale-prefix or to open in the same tab — but both reachedLinkidentically, and one reached it ungated.Behaviour —
pages/map/_components/AtlasContent.tsxThree links then classify what they got, instead of all three assuming it is ours:
What each link renders, by where its canonical lives:
/map/…)target="_blank",rel="noopener noreferrer"relonlytarget="_blank",rel="noopener noreferrer"href/map/…, or to the website, or omittedFlow — the scheme gate
lib/urls.tsalready documentsPreview
⚠ Read the caveat below before judging these. On the preview every rung and card opens in a new tab. That is correct, and it is not what production will do.
/map/gb— the breadcrumb rung and ~40 card titles this changes. Opens on real atlas data.<a>toLink.The preview is served at
*.workers.dev, and every atlas canonical is onwemeditate.com. SositePathFromUrlfinds no origin match there and every rung and card takes the off-origin branch. Onwemeditate.comthose same links are same-origin, relativize to/map/…, and carry neither attribute — the row 1 behaviour above, which no preview on this host can show. The unit suite covers that branch instead (AtlasContent.locale.test.tsx).The Ladle preview is not linked:
AtlasContentis a page component with no story, so it shows nothing of this change.Test results
.claude/skills/pr-prep/check.sh— lint,tsc --noEmit, 960 tests in 95 files, on the branch merged withmainpnpm vitest run pages/map/_components/), 8 new, each watched failing firsttarget="_blank" rel="noopener noreferrer"on the rungs, the card titles and both website linksManual verification
Everything was checked here against the deployed preview and real data, so this is confirmation rather than discovery:
/map/gb— a breadcrumb rung and every card title carrytarget="_blank"andrel="noopener noreferrer". Read the caveat above for why all of them do./map/gb/midlands/birmingham/1487— "Visit the website" points athttp://meditate4free.co.uk/and opens in a new tab. It also now draws a focus ring, which the bare<a>did not.wemeditate.com: the same rungs and cards should be plain internal links again, locale-prefixed. That is the one assertion the preview cannot make.Notes for reviewer
wemeditate.com, so in production today the first behaviour row is dormant and the class-link row is what visitors actually meet. The off-origin path is still real —atlasHref's own doc states a region's canonical can live on another client's domain — and is what every preview and embed host already exercises, as above.Linkdoes not announce a new tab, and the docs no longer say it does.docs/rules/design-system.mdclaimed anexternallink "adds screen-reader text announcing it opens in a new tab";Link.tsx:88setstargetandreland nothing else. This PR adds threeexternallinks on that assurance, two of them a breadcrumb rung and a heading, where a silent new tab is most disorienting. Five pre-existing call sites are in the same position. The doc line is corrected here to state what the atom does. The affordance itself is not added: it belongs in the atom, and thecommon.a11y.opens_in_new_tabstring takes a%{label}thatLinkcannot build from arbitrary children, so it needs a new SahajCloud key first.SocialIcon.tsx:119is the one component that does announce it today. Filed as fix(link): the Link atom enforces neither the affordance nor the scheme gate it is credited with #238.Link.Linklegitimately carries#anchor,mailto:and site paths, whichisSafeHttpUrlandisSafeNavigationUrlboth reject, so an atom-level gate needs a third predicate rather than reusing one. Nine other call sites still pass unvalidated SahajCloud values into anhref. Filed as part 2 of fix(link): the Link atom enforces neither the affordance nor the scheme gate it is credited with #238.components/atoms/Breadcrumbs/Breadcrumbs.tsxexists, andAtlasContenthand-rolls a second breadcrumb trail. This PR addsexternalhandling only to the hand-rolled one, which widens the gap. Worth knowing before either is later "fixed" to match the other.Detail
Why
externalis computed at the call site rather than returned byatlasHref. The ticket chose this, and the review pass agreed on two further grounds:atlasHrefis exported and unit-tested as a purestring | null, so returning{ href, external }would make six assertions destructure for a flag that is meaningless on the/mapfallback branch; andcomponents/organisms/RichText/RichText.tsx:138and:152already computeexternalat two adjacent call sites. One reviewer argued the opposite — that the two call sites re-derive whatatlasHrefalready knew — which is true, and is the cost accepted here.Why
Linkshould not detect off-origin itself.LinkreadsuseLocale()but notuseOrigin(), so outside a request — Ladle, any bare unit render — every absolute href would read as foreign and silently sprouttarget="_blank". Andexternalis an editorial decision in places:RichTextreads the editor's ownnewTabfield, which auto-detection would override.Why
upstreamUrllives inAtlasContent.tsxand notlib/urls.ts. The first draft of this note said the empty-string-means-absent quirk is atlas-specific. It is not —FormBuilder.tsx:231applies the same falsy check to an unrelated contract. The reason that survives is arithmetic. Three call sites, and lifting splits rather than joins them:AtlasContentneeds a value andisSafeHttpUrl,FormBuilderneeds a value and the widerisSafeNavigationUrl, andErrorFallback.tsx:58needs neither — it is a boolean conjunct besideresolvedType === ErrorType.SERVER. Two new exports, one caller each, is not one owner. The predicate they share already lives inlib/urls.tsand all three import it.The join link now opens in a new tab, where before it did not. It had
rel="noopener noreferrer"withouttarget, so the referrer was withheld but the visitor left the class page in place. Routing it throughLinkleaves one owner for that pairing and bringsfocus-ringwith it, which the bare<a>lacked.Review findings dismissed. Hoisting the classification into
atlasHref— declined, reasons above. Wrapping the two identical<Link>elements in a localAtlasLinkcomponent — declined: they sit in different components with different meanings, and the ticket's scope is theexternalflag. LiftingupstreamUrlintolib/urls.ts— declined, reasons above, and the reason itself replaced after review.Test consolidation. The first draft added
AtlasContent.origin.test.tsxfor the origin-known branch.AtlasContent.locale.test.tsxalready carried that module-widepageContextmock, an origin and a mutable locale holder, so the new cases moved there instead of standing up a third copy of the harness beside two that exist.anchorFormoved totests/_helpers/markup.ts, matchingtests/_helpers/page-context.ts.Closes #209
🤖 Generated with Claude Code
https://claude.ai/code/session_01Mg9rjXg1nmypE5GH1XPWhe