Skip to content

fix(map): an off-origin atlas canonical renders as an internal link - #237

Merged
sydevs-bot merged 7 commits into
mainfrom
claude/fix-209-atlas-external-link
Nov 17, 2026
Merged

sydevs-bot merged 7 commits into
mainfrom
claude/fix-209-atlas-external-link

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • An atlas link to another owner's domain now renders as one: new tab, and the referrer withheld.
  • Joined: every URL the atlas sends passes isSafeHttpUrl before it reaches an href. The class's own room link had no gate at all, and the region canonical had none either.
  • Joined: two docs lines this change leans on were false. external never announced the new tab, and the scheme gate's caller list named a module that does not call it.

Change outline

atlasHref resolves 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 reached Link identically, and one reached it ungated.

Behaviour — pages/map/_components/AtlasContent.tsx

+upstreamUrl(url)                                 # absent or not http(s) → null
+  nothing upstream validates either field it guards
+
 atlasHref(link, origin)
-  link.url → sitePathFromUrl(link.url, origin) ?? link.url
+  canonical = upstreamUrl(link.url)              # a refused scheme falls through
+  canonical → sitePathFromUrl(canonical, origin) ?? canonical
   else     → link.route && `/map<route>`         # unchanged

Three links then classify what they got, instead of all three assuming it is ours:

 Breadcrumbs → rung
-  <Link href variant="unstyled">
+  <Link external={!isSitePath(href)} href variant="unstyled">
 EventCard → title
-  <Link href variant="unstyled">
+  <Link external={!isSitePath(href)} href variant="unstyled">
 EventContent → join online / visit website
-  joinUrl = content.onlineUrl || null            # ungated
-  <a href rel="noopener noreferrer">             # rel without target
+  joinUrl = upstreamUrl(content.onlineUrl)
+  <Link external href variant="unstyled">        # Link owns the pairing

What each link renders, by where its canonical lives:

Link's destination Before After
a path we serve (/map/…) internal internal, unchanged
another owner's domain internal — same tab, full referrer target="_blank", rel="noopener noreferrer"
a class's room or website same tab, rel only target="_blank", rel="noopener noreferrer"
a non-http(s) scheme rendered into the href refused — falls back to /map/…, or to the website, or omitted

Flow — the scheme gate lib/urls.ts already documents

 isSafeHttpUrl — "any URL the site did not author itself passes one of them"
   ErrorFallback           status-page link
   FormBuilder             an authored form's redirect, via isSafeNavigationUrl
+  AtlasContent            a region's canonical
+  AtlasContent            a class's room or website link

Preview

⚠ 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.

The preview is served at *.workers.dev, and every atlas canonical is on wemeditate.com. So sitePathFromUrl finds no origin match there and every rung and card takes the off-origin branch. On wemeditate.com those 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: AtlasContent is a page component with no story, so it shows nothing of this change.

Test results

  • Lean gate: ✓ .claude/skills/pr-prep/check.sh — lint, tsc --noEmit, 960 tests in 95 files, on the branch merged with main
  • Targeted specs: 38 passed (pnpm vitest run pages/map/_components/), 8 new, each watched failing first
  • Build: N/A — no build, Worker or server path in the diff
  • Preview: ✓ verified against real atlas data on the links above — target="_blank" rel="noopener noreferrer" on the rungs, the card titles and both website links

Manual verification

Everything was checked here against the deployed preview and real data, so this is confirmation rather than discovery:

  1. /map/gb — a breadcrumb rung and every card title carry target="_blank" and rel="noopener noreferrer". Read the caveat above for why all of them do.
  2. /map/gb/midlands/birmingham/1487 — "Visit the website" points at http://meditate4free.co.uk/ and opens in a new tab. It also now draws a focus ring, which the bare <a> did not.
  3. After merge, on 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

  • Measured, and it changes the ticket's premise. The ticket recorded as unknown whether live atlas data returns a foreign-origin canonical. It does not, in the GB subtree: every canonical is on 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.
  • Link does not announce a new tab, and the docs no longer say it does. docs/rules/design-system.md claimed an external link "adds screen-reader text announcing it opens in a new tab"; Link.tsx:88 sets target and rel and nothing else. This PR adds three external links 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 the common.a11y.opens_in_new_tab string takes a %{label} that Link cannot build from arbitrary children, so it needs a new SahajCloud key first. SocialIcon.tsx:119 is 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.
  • The scheme gate is at the call site, not in Link. Link legitimately carries #anchor, mailto: and site paths, which isSafeHttpUrl and isSafeNavigationUrl both reject, so an atom-level gate needs a third predicate rather than reusing one. Nine other call sites still pass unvalidated SahajCloud values into an href. 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.tsx exists, and AtlasContent hand-rolls a second breadcrumb trail. This PR adds external handling only to the hand-rolled one, which widens the gap. Worth knowing before either is later "fixed" to match the other.
Detail

Why external is computed at the call site rather than returned by atlasHref. The ticket chose this, and the review pass agreed on two further grounds: atlasHref is exported and unit-tested as a pure string | null, so returning { href, external } would make six assertions destructure for a flag that is meaningless on the /map fallback branch; and components/organisms/RichText/RichText.tsx:138 and :152 already compute external at two adjacent call sites. One reviewer argued the opposite — that the two call sites re-derive what atlasHref already knew — which is true, and is the cost accepted here.

Why Link should not detect off-origin itself. Link reads useLocale() but not useOrigin(), so outside a request — Ladle, any bare unit render — every absolute href would read as foreign and silently sprout target="_blank". And external is an editorial decision in places: RichText reads the editor's own newTab field, which auto-detection would override.

Why upstreamUrl lives in AtlasContent.tsx and not lib/urls.ts. The first draft of this note said the empty-string-means-absent quirk is atlas-specific. It is not — FormBuilder.tsx:231 applies the same falsy check to an unrelated contract. The reason that survives is arithmetic. Three call sites, and lifting splits rather than joins them: AtlasContent needs a value and isSafeHttpUrl, FormBuilder needs a value and the wider isSafeNavigationUrl, and ErrorFallback.tsx:58 needs neither — it is a boolean conjunct beside resolvedType === ErrorType.SERVER. Two new exports, one caller each, is not one owner. The predicate they share already lives in lib/urls.ts and all three import it.

The join link now opens in a new tab, where before it did not. It had rel="noopener noreferrer" without target, so the referrer was withheld but the visitor left the class page in place. Routing it through Link leaves one owner for that pairing and brings focus-ring with 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 local AtlasLink component — declined: they sit in different components with different meanings, and the ticket's scope is the external flag. Lifting upstreamUrl into lib/urls.ts — declined, reasons above, and the reason itself replaced after review.

Test consolidation. The first draft added AtlasContent.origin.test.tsx for the origin-known branch. AtlasContent.locale.test.tsx already carried that module-wide pageContext mock, 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. anchorFor moved to tests/_helpers/markup.ts, matching tests/_helpers/page-context.ts.

Closes #209

🤖 Generated with Claude Code

https://claude.ai/code/session_01Mg9rjXg1nmypE5GH1XPWhe

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
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

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

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

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 sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 question for the reviewer, one per thread.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread pages/map/_components/AtlasContent.tsx Resolved
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 15, 2026
@sydevs-bot

sydevs-bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 23:31Z address-review · attempt 1 · session · done
  • 23:31Z address-review · attempt 1 · session
  • 19:22Z address-review · attempt 1 · session · done
  • 19:22Z address-review · attempt 1 · session
  • 19:15Z review-pr · attempt 1 · session · done

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 15, 2026

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 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 — the external contract this PR banks on is documented falsely (AtlasContent.tsx:100).
  • consider — upstreamUrl is 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

Comment thread pages/map/_components/AtlasContent.tsx Resolved
Comment thread pages/map/_components/AtlasContent.tsx Resolved
@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 15, 2026
@sydevs-bot sydevs-bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 15, 2026
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 15, 2026
@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 15, 2026
sydevs-bot and others added 3 commits November 15, 2026 19:23
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
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Adversarial review addressed. cf6c926..cfb446a. Merged origin/main, clean.

Adopted · the external doc claim · 89bf938. docs/rules/design-system.md promised screen-reader text that Link.tsx:88 never emits. The line now states what the atom sets, and names #238.

Rebutted · lifting upstreamUrl into lib/urls.ts. Three call sites, two predicates, three shapes. It does land on the body's stated reason, which was wrong; the body now gives the count.

Joined · cfb446a. isSafeHttpUrl's caller list named lib/submissions.ts for the form redirect. That module gates no URL — FormBuilder.tsx:231 does.

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

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 15, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review November 15, 2026 19:30
@sydevs-bot
sydevs-bot requested a review from Ardnived November 15, 2026 19:30
@sydevs-bot
sydevs-bot enabled auto-merge November 15, 2026 19:30
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 15, 2026
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 17, 2026
@sydevs-bot sydevs-bot moved this from Awaiting to Working in SYDevelopers Technical Roadmap Nov 17, 2026
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Reviewer answered the one open question. cfb446a stands, and nothing is pushed.

Answered · should a class's own link open in a new tab → A, already built in 0d7084b. The join and website link goes through <Link external>, so the target/rel pairing has one owner. Thread resolved.

Merged origin/main (13317c9..556a4eb) locally, clean. It stays local: a merge with no work beside it only re-runs CI. Checked one coupling it could have broken — main's #231 touched lib/submissions.ts, and that module still gates no URL, so this branch's isSafeHttpUrl caller-list correction is still true.

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

@sydevs-bot
sydevs-bot added this pull request to the merge queue Nov 17, 2026
@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 17, 2026
@sydevs-bot sydevs-bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 17, 2026
Merged via the queue into main with commit e8c2000 Nov 17, 2026
81 of 90 checks passed
@sydevs-bot
sydevs-bot deleted the claude/fix-209-atlas-external-link branch November 17, 2026 23:36
@sydevs-bot sydevs-bot moved this from Pending to Done in SYDevelopers Technical Roadmap Nov 17, 2026
sydevs-bot pushed a commit that referenced this pull request Nov 17, 2026
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.
sydevs-bot pushed a commit that referenced this pull request Nov 18, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

fix(map): an off-origin atlas canonical renders as an internal link

3 participants