Repository navigation
fix(link): the Link atom enforces neither the affordance nor the scheme gate it is credited with - #257
Conversation
…atom Two rules this repo writes down were enforced nowhere, and both read as the atom's behaviour to anyone checking the docs rather than the code (#238). `isSafeLinkHref` is the third predicate in `lib/urls.ts`, and the only one an editor's own link survives: a site path, a bare `#anchor`, `mailto:` and `tel:` all fail `isSafeHttpUrl` and `isSafeNavigationUrl`. `Link` applies it itself, which is what covers the nine call sites handing it an unvalidated SahajCloud value — five already reached an `href` through `Link` or `Button href`, and `MusicLibrary`, `AudioPlayer` and `Author` now do too. A refused href renders no `href` at all, so the words stay on the page and nothing navigates. `//cdn.example.com` and `''` stop rendering as hrefs. Neither is in the allowlist: the first borrows our scheme to name another origin, when `https://` spells the same destination, and the second reloads the page the visitor is on. The announcement needed a label-free key, because `Link`'s children are arbitrary nodes and `opens_in_new_tab` interpolates `%{label}`. Where a caller does supply an `aria-label`, that label replaces the accessible name and an `sr-only` child inside the anchor is never read — so the warning folds into the label through the existing key instead. `SocialIcon` lost the whole announcement that way for every `SocialShare` button, which spreads its own label over the one the atom had just built. `server/payload-types.ts` and `lib/translations.en.json` carry the new key by hand, from the producer branch. Both are generated files, and neither generator can reach a key that has not merged and deployed upstream yet. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjYEmWtAv98DwgGDTFt
`new URL` answers `''`, `//host` and a bare relative href by throwing, and V8 captures a stack trace for the `TypeError` — about 3µs, some twenty times the cost of rendering a whole link. Two comparisons ahead of the parse take the first two to a few nanoseconds each, with every verdict unchanged. This is not hypothetical input. `creditURL` is typed a bare `string` and is `''` for a track with no credit, and the `Link` gate is what newly puts it on this path, once per track in a playlist. The function's own comment already singled out these two spellings as deliberate refusals, so the fast path and the prose now say the same thing. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjYEmWtAv98DwgGDTFt
… more anchors Three review lenses independently found the same thing: `SocialIcon` had been given its own copy of the scheme gate, the `target`/`rel` pair and the `aria-label` fold, in the very commit that exists to make those one copy. It renders a `Link` now, as `Button`, `Breadcrumbs` and `Logo` already do, and loses its own `isSafeLinkHref` call, its `useT` and its duplicate comment. Dropping its `transition-all` costs nothing: the hover classes it was meant to animate sit on the `<svg>`, which carries no transition utility, and `transition-property` does not inherit from the anchor. Measured, not assumed — `transition-colors` compiles after `transition-all`, so a className override would not have won that collision either way. Two bare anchors the ticket did not list were still handing an unauthored URL to an `href`, which made the rule in `AGENTS.md` false as written: - `Splash` renders an editor's `actionURL`. It keeps its anchor, because its hover is a transform `Link`'s `transition-colors` would override, so it gates at the call site and renders no call to action for a refused URL. - `AtlasContent` renders `onlineUrl` or `website` from the atlas contract, a third party's. It becomes a `Link`, keeping its `rel` and same-tab navigation. `AudioPlayer`'s credit link was spelling `variant="primary"` by hand in `teal-600`/`teal-700`, which does not resolve against a surface. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjYEmWtAv98DwgGDTFt
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
wemeditate-web | 197177b | Commit Preview URL Branch Preview URL |
Nov 18 2026, 01:32 AM |
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
wemeditate-design | 197177b | Commit Preview URL Branch Preview URL |
Nov 18 2026, 01:32 AM |
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
|
Merged
Also reconciled Lean gate green: 988 tests. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
This PR is the size of #238. All nine listed call sites now pass a gated href, both halves of the atom land, and both docs the ticket named are corrected rather than deleted. Splash is joined by the rule it broke, so it is not smuggled scope. The two findings worth your time are that the atom's own baseStyles is the only reason a second gate had to exist outside it, and that the rule this PR writes into AGENTS.md is already false at one call site.
The body credits work the diff does not contain. ## Summary and the flow diagram both say AtlasContent is closed here. The merged diff has no AtlasContent change — #237 did it, as your own 01:16Z comment says. Correct both. (should-fix; no inline, the file is outside the diff.)
Findings
- should-fix —
Link.tsx:87:transition-colorson every variant forcesSplashto stay a bare<a>. - should-fix —
AGENTS.md:117: the new rule says aLinkcall site adds nothing, but two gate deliberately. - should-fix — the PR body, above.
- consider —
lib/urls.ts:136: three overlapping predicate names now need a map in two docs. - consider —
lib/urls.ts:111:isSitePathat line 181 already refuses//host. This does not.
What was checked
Read whole on the branch: lib/urls.ts, Link.tsx, SocialIcon.tsx, Splash.tsx, the four converted call sites, the three doc hunks. Ladder walk on the one new piece, isSafeLinkHref: isSitePath and isSafeHttpUrl already exist here, which is finding 5. Verified SocialIcon keeps the platform name through Link's label fold, and that {...props} now precedes aria-label, closing the SocialShare drop. git grep confirmed every predicate caller and all nine table rows. Track.creditURL is non-optional, so the '' path is real. No preview link, and no fixture block.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
`isSafeNavigationUrl` read `//host` as a path through a raw
`startsWith('/')`, while `isSafeLinkHref` refused the same string. So one
module held two views of it, and a form's redirect field reached
`window.location.href` with an origin that borrowed our scheme.
`isSitePath` already draws the line, and now both predicates call it.
An editor reaching another site spells it `https://`, which still passes.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjUu2HTqoZYj8CvZtco
`transition-colors` in `baseStyles` applied to `unstyled` too, so a caller painting a transform hover could not escape it: at equal specificity the atom's `transition-property` wins on source order. That is the whole reason `Splash`'s call to action stayed a bare `<a>` with a second copy of the scheme gate. Each coloured variant now carries the transition and `unstyled` carries none, so `Splash` renders a `Link`. Its call-site gate stays, for the reason that was always the real one: a refused URL must render no call to action, where the atom renders the leaves and the words inert. Four `unstyled` call sites did rely on the inherited transition — `MusicLibrary`, `Playlist`'s current track and three `AtlasContent` links. Each brings its own now, as `ContentCard` and `Column` already did. Splash's CTA is locale-prefixed from here, which a bare anchor never was. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjUu2HTqoZYj8CvZtco
The new rule said an href reaching an anchor through `Link` is gated and the call site adds nothing. Two call sites gate on purpose, so the rule was false at the moment it was written — the shape #238 was filed for. The exception is about what renders, not about safety: a refused URL must render nothing where inert words would invite a click. `isSafeHttpUrl`'s two callers are named too, since the rule gives no reason to reach for the strictest predicate and both have one. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjUu2HTqoZYj8CvZtco
|
Four threads answered, three adopted. Pushed as 197177b.
Corrected — the body and the flow diagram credit #237 now. Splash's CTA href is locale-prefixed from here, and a form redirect spelled Gate green, 995 tests. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
…st-index Conflict: AudioPlayer.tsx's import block. #257 added the `Link` atom beside `Button, Image`; this branch replaced the `usePlaylistAudioPlayer` and `Track` imports with the state and controls types it now takes as props. Both sides kept: `Link` is imported, and the hook is not. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXhW5G1HAiwwRZ3U7L
…ontrast Six conflicts, from #257 (the Link atom becomes the scheme gate), #201 (the carousel dots take their own line) and #201's own preview-discovery fix. SocialIcon.tsx, AudioPlayer.tsx — main's side. Both raw `<a>` elements became `Link`, whose `variant="primary"` resolves to the retuned `teal-600`, so the colours this branch set on them are what the atom now paints. SocialIcon keeps this branch's `secondary: coral-600`, which sits outside the conflict. ColumnCarousel.tsx — main's side. `CarouselNavButton` became the `Button` atom at `variant="ghost"`, which draws `text-fg-muted`, the token this branch retunes to `gray-700`. The branch's `text-gray-600` → `text-gray-700` had no other effect here. Link.stories.tsx — main's structure, this branch's sweep. main rewrote the External Links section and added Refused Schemes; every `text-gray-500` and `text-gray-600` it brought with it moves to `text-gray-700`, the step the rest of the file already reads. Playlist.tsx — both sides. The credit keeps this branch's `text-teal-50` (4.92:1 on `teal-700`) and main's `transition-colors duration-200`. scripts/get-cloudflare-preview-url.mjs, docs/cloudflare-previews-ci.md — main's side, and this branch's `RETIRED_HOST_RE` goes with it. #201 fixed the same red check by narrowing `PREVIEW_URL_RE` to `workers.dev`, so no candidate can carry a `pages.dev` host and the branch's later filter can never fire. main also derives the Worker's branch host when no comment names one, which this branch's version does not. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjV73qfNDBaWPzRpeBE
Summary
Linknow does the two things the docs already credited it with: it announces a new tab to a screen reader, and it gates the href scheme for every URL the site did not author.href—Splash(an editor'sactionURL). It is closed here, because the rule this PR writes intoAGENTS.mdwas false while it stood.AtlasContentwas the same shape and is not this PR's work: fix(map): an off-origin atlas canonical renders as an internal link #237 routed it throughLinkbefore this branch mergedmainin.Change outline
Components — the atom gains two behaviours
Link({ href, external, 'aria-label': ariaLabel, …props }) components/atoms/Link/Link.tsx - baseStyles = 'transition-colors duration-200 focus-ring' + baseStyles = 'focus-ring' + variantStyles.default/primary/secondary/neutral += transition-colors duration-200 + variantStyles.unstyled = '' # so `unstyled` carries no transition + safe = isSafeLinkHref(href) + !safe && DEV → console.warn, naming the refused value + opensNewTab = external && safe # a refused href opens nothing <a - href={localeHref(locale, href)} + href={safe ? localeHref(locale, href) : undefined} # React omits it + aria-label={opensNewTab && ariaLabel + ? t('common.a11y.opens_in_new_tab', { label: ariaLabel }) # folded in + : ariaLabel} {…opensNewTab && { target: '_blank', rel: 'noopener noreferrer' }} > {children} + {opensNewTab && !ariaLabel + && <span className="sr-only">{t('…opens_in_new_tab_suffix')}</span>}Two announcement shapes, because an
aria-labelreplaces the accessible name — ansr-onlychild inside the anchor would never be read. Each takes the translation key written for its shape; composing one from the other would build an English sentence in code.transition-colorssat inbaseStyles, sounstyledcarried atransition-propertyno caller asked for, and at equal specificity it beat a className override on source order. That is the whole reason a second gate had to exist outside the atom. Only a variant that paints a colour carries the transition now, and the fourunstyledcall sites that relied on inheriting it bring their own:MusicLibrary,Playlist's current track, and threeAtlasContentlinks.Contract — a third predicate, and which one is whose
lib/urls.tshad no predicate an editor's own link survives:isSafeHttpUrlrejects every path, andisSafeNavigationUrlrejectsmailto:,tel:and#anchor.lib/urls.ts isSafeHttpUrl(url) # http(s) only → window.location, and # wherever a URL must be absolute - isSafeNavigationUrl(url) # + url.startsWith('/') + isSafeNavigationUrl(url) # + isSitePath(url) → window.location + isSafeLinkHref(href) # + #anchor, mailto:, tel: → every hrefRefused:
javascript:,data:and every other scheme, plus a protocol-relative//hostand the empty string.//cdn.example.comand''stop rendering as hrefs — the first borrows our scheme to name another origin whenhttps://spells the same destination, and the second reloads the page the visitor is on.isSafeNavigationUrlanswered//hostthe opposite way, through a rawstartsWith('/'), so one module held two views of one string and a form's redirect reachedwindow.location.hrefwith a borrowed scheme. It callsisSitePathnow, and a spec pins the two predicates to the same answer.Flow — where an unauthored href converges
SocialIconhad been given its own copy of the gate, thetarget/relpair and the label fold — in the commit meant to make those one copy. It renders aLinknow, asButton,BreadcrumbsandLogoalready do.Splashkeeps its ownisSafeLinkHrefcall on top of the atom's, andAtlasContentkeepsisSafeHttpUrl. Neither is a second gate: each decides whether to render its element at all, where the atom renders inert words.AGENTS.mdnames that exception, since the rule as first written said a call site overLinkadds nothing.Preview
Both Workers previews build on the branch slug, so each link below always serves this branch's newest green build:
/map/<a region with a website>External Linksand newRefused Schemessections demonstrate both halves directlyContract impact
server/payload-types.tsandlib/translations.en.jsoncarrycommon.a11y.opens_in_new_tab_suffixby hand, copied from the producer branch. Both are generated, and neither generator can reach a key that has not merged and deployed upstream:pnpm types:cmsreads SahajCloudmain, andpnpm sync:translationsreads the deployed English locale. The dispatcher re-syncs the types once the producer closes;pnpm sync:translationsstill needs one run after SahajCloud deploys, and will produce the identical line (the generator sorts keys, and this was inserted in sorted position).Test results
.claude/skills/pr-prep/check.sh— lint 0 errors,tsc --noEmit, 995 tests in 100 fileslib/urls.test.ts,components/atoms/Link,components/organisms/Splash,components/molecules/Playlist,components/organisms/MusicLibrary,pages/mappnpm ladle:build(the story changed); the app build is the Cloudflare preview'sAll 8 new specs were watched failing against the pre-change components before being kept. The seven added while addressing the review pin behaviour those same commits introduced, and were not watched failing first.
Manual verification
javascript:link and confirm the anchor carries nohrefwhile the words still render.Notes for reviewer
href— focusable-but-inert rather than a dead link. The alternative was dropping the element, which would have removed the editor's words from the page too.Splashtakes the other choice on purpose: its CTA is leaves plus a word, meaningless without its link, so a refused URL renders nothing.Splashrenders aLinknow, after the review pointed at the real cause:transition-colorsdid not belong inbaseStyles. It is on the four variants that paint a colour,unstyledcarries none, and the transform hover needs no exception. The measurement that made this necessary stands — at equal specificity a className override does not win on source order — and it is also why droppingSocialIcon'stransition-allcosts nothing: its hover classes sit on the<svg>, which carries no transition utility, andtransition-propertydoes not inherit.Splash's CTA href is locale-prefixed from here, which a bare anchor never was, so a/meditationsaction on a French splash now reaches/fr/meditations. And a form redirect spelled//hostis now dropped rather than followed;https://hostis unaffected./simplify(four lenses) and/code-review highfound one duplication, flagged by three lenses independently —SocialIcon's second copy of the gate — now collapsed into the atom./security-reviewran (theserver/path triggers it) and returned no finding at confidence ≥8, having tested 57 bypass strings./\evil.comstill passesisSitePathand folds to//evil.comin a browser — an off-site navigation, never script execution, andhttps://evil.comis equally available to an editor. It isisSitePath's limit, so it now applies to bothwindow.locationpredicates equally rather than to one of them. A spec pins it so the next reader does not take it for an oversight.SubtleSystem's bare anchor, and givingBadge/DropdownItemanhref→Linkbranch. Neither is fed an unauthored URL (the first takes a generated path; the latter two have no production caller), and both change URLs or atom behaviour. Filed instead — see below.Detail
Why
externalstays a prop.LinkreadsuseLocale()but notuseOrigin(), so off a request every absolute href would read as foreign and sprouttarget="_blank"; andRichTexthonours the editor's ownnewTabfield, which auto-detection would override. The JSDoc now says so.The dev-only warning. A refused href is otherwise invisible — the page just renders words.
console.warnbehindimport.meta.env?.DEVmatcheslib/i18n.ts's missing-key warning, and the efficiency lens confirmed vite eliminates the whole block from both the client and SSR bundles, so the Worker pays nothing. Sentry was the alternative and is wrong here: a per-render capture on an atom this hot bills the quota per page view, andserver/AGENTS.mdkeepscaptureMessageto reads.Measured cost, since
Linkrenders many times per page: +11% on the atom's own render for the common case (a site path, not external), attributed as the gate +23–55 ns,useT+131–162 ns, the extra child slot +90–129 ns, label plumbing +104–127 ns.getTmemoises per(translations, locale), so no closure is allocated per card and noIntlconstructor runs. Theperf(urls)commit removes the one real cliff:new URLanswers'',//hostand a bare relative href by throwing, and a captured stack trace cost ~3 µs — about twenty times a whole link render — which mattered becausecreditURLis''for a track with no credit and this PR is what put it on that path.A docs claim corrected rather than kept.
docs/rules/design-system.mdandAGENTS.mdboth described behaviour the atom did not have. Both now describe it, andAGENTS.mdsays which predicate guards which sink, so the next reader does not have to work it out from three similar names. Both also name the one exception the first draft denied — a call site overLinkthat must render nothing — andAGENTS.mdnamesisSafeHttpUrl's two callers, since nothing there otherwise said why the strictest predicate is the right one for them.The three predicates stay three. The review asked whether
isSafeHttpUrlcould become module-private, leaving one public name per sink. Both its callers need absolute-only:ErrorFallbackputs the status page in a bare<a target="_blank">, where a site path, amailto:or a#anchorwould all be wrong, andAtlasContent'supstreamUrlfeeds a region's canonical tositePathFromUrl, which parses it and compares origins. So the name→sink map earns its place rather than papering over an avoidable overlap.Closes #238
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code