Repository navigation
feat(widget): make memory-mode routing linkable where it matters - #142
Merged
Merged
Conversation
On a host page carrying its own anchor (#respond) the widget mounts a MemoryRouter and never writes the URL, so window.location.href names the host's article and nothing about the event. ShareView, the registration confirmation and the ICS export all handed that string out. WidgetMode gains `linkable`, derived once from the mountRoute decision in Widget.tsx and threaded through App. `shareableUrl` (lib/url.ts) resolves the one question both surfaces ask: the canonical webUrl in every mode, the address bar only where the route is in it, undefined otherwise. Closes #115 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
A Share link axis on ShareView's story previews the degraded screen, and a node-lane spec walks the whole chain — WidgetMode context through useShareUrl — including the no-provider default, which is what keeps the axis opt-out. Documents the axis in .claude/rules/components.md, including the one memory-mode consequence still unaddressed (<Link> href resolution). Closes #115 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- export DEFAULT_WIDGET_MODE so the context default has one spelling - ViewHarnessProps.mode is Partial: a story overrides the axis it is about rather than restating the shape. The ShareView story had silently flipped `standalone`, changing what EventSummary renders on the screen it previews. - drop the two hook tests that restated lib/url.test.ts - story for the newly-optional confirmation branch Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
/code-review found the borrowed `unavailable` row answering "there is no link to share" with "see events in Cambridgeshire" — walking the viewer away from the class they were trying to pass on — and the sentence escaping the en-parity test, since `message` is the one override reserved for `unavailable`'s CMS-resolved status table. `share-unavailable` is that row minus `onward`, with its copy in `common` where ERROR_POLICY keys live, so the test pins it word-for-word. The security review's finding is NOT fixed here, deliberately: the host page's query string still rides the address-bar fallback in hash mode. Stripping it would break the share link on a query-routed host, which is WordPress's default permalink shape. Argued in the docblock and pinned by a fixture that now carries a query. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Deploying sahajatlas-design with
|
| Latest commit: |
3587b6d
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://7a880ffb.sahajatlas-design.pages.dev |
| Branch Preview URL: | https://feat-linkable-memory-mode.sahajatlas-design.pages.dev |
Deploying sahajatlas with
|
| Latest commit: |
3587b6d
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://ed587095.sahajatlas.pages.dev |
| Branch Preview URL: | https://feat-linkable-memory-mode.sahajatlas.pages.dev |
This was referenced Aug 18, 2026
Ardnived
added a commit
that referenced
this pull request
Aug 18, 2026
#155) * feat(widget)!: route through a query parameter and remove hash routing The widget's route moves from the URL fragment to a query parameter on the host's own page: before your-site.example/classes#!/gb/london now your-site.example/classes?atlas=/gb/london This is the change the rest of the SEO programme rests on. No search engine has ever treated a fragment as a distinct URL — `#!` was deprecated in 2015 and dropped in 2018 — so every event on every embed was the same URL to a crawler. A query string is indexable and needs no server configuration from the host, which is why it works identically on WordPress, Wix, Weebly and Joomla. It removes a class of bug rather than adding a mode. The widget no longer reads or writes the fragment at all, so the three-way ours/free/foreign decision, the blank-widget failure of #92, the two spellings react-router normalised between, and the whole foreign-anchor branch are simply gone. Engine: a hand-written `History` behind react-router's stable `Router` + `Navigator` (`src/lib/atlas-history.ts`, `src/router.tsx`). `encodeLocation` is deliberately omitted — the obvious implementation returns the host's pathname and poisons every derived route. Two traps the implementation exists to avoid, both silent: `Router` returns null on a basename miss (#92's blank widget), and it defaults `location.key` to a constant, which would collapse every `rememberCamera` snapshot into one bucket with every test green. Also fixed, because the URL is now real: - `<Link>` hrefs are absolute host-origin URLs, so middle-click, "copy link address" and open-in-new-tab work. That is the consequence #92 recorded and #142 left open, closed by `createHref` rather than by a special case. - `useShareUrl` resolves the EVENT's route instead of `window.location.href`, so sharing from the share or registration drawer no longer hands over the drawer. Report 115's finding 3, unfixable while the route was a fragment. - Sentry gains an `atlas.route` tag. The route used to be lost because it lived in the fragment; it now lives in the query, which `hostPageUrl` also strips — so the loss became total. It is ours, not the host's, which is why it may be sent when their query may not. Scope: query + memory only. `routing=path` is accepted, warns through `reportIntegrationWarning` and falls back to query — its prefix comes from the client record, which arrives after the router must exist, so it lands with the canonical work. No back-compat for `#!` links, deliberately: the legacy origins still serve every live client until #148 Part 2, so no real link is at risk. Verified in a browser on a cross-origin host page carrying its own `#respond` anchor and `?p=123`: the fragment is untouched, the host parameter survives, boot writes nothing, and `routing=path` logs its warning by name. The jsdom spec that replaces `hash.router.test.tsx` drives the real router for the ten agreements a pure spec cannot attest. Closes #154 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * docs(widget): correct an overstated risk in the routing history Two fixes, both about accuracy rather than behaviour. The `Router`-returns-null-on-a-basename-miss trap was listed as one the query history exists to avoid. It is not reachable: query routing passes no `basename`, so `stripBasename` is never called. It was a real hazard for the PLANNED path mode, which mounts under a prefix, and it becomes live again if that ships — but claiming it here made the implementation look riskier than it is and pointed a future reader at the wrong thing. The one trap that IS real stays, and is asserted: `Router` defaults `location.key` to a constant, which would collapse every `rememberCamera` snapshot into one bucket. Also reads our history state once on popstate instead of twice. `currentState()` MINTS a key when the entry has none — a host-created entry, or one predating the widget — so calling it twice minted two and used only the first. Harmless today, and exactly the kind of thing that stops being harmless the moment someone trusts `idx`. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#respond,#comment-123— routine on WordPress), fix(widget): survive foreign hashes and harden the mount path #92 mounts aMemoryRouterand never writes the URL.ShareView, the registration confirmation and the.icsexport were all still falling back towindow.location.href, which there is the host page's URL — it names their comment form, not the meditation. All three now offer no URL rather than a wrong one.WidgetModegains alinkableaxis (defaulttrue), derived from the singlemountRoutedecision inWidget.tsxand threaded throughApp. Views ask instead of inferring.shareableUrl(src/lib/url.ts), answers the question for every surface, so the share block and the calendar entry can't disagree about what an event's link is.The judgement, since the ticket asked for it
The canonical wins in every mode — that is a preference, not a fallback order.
event.webUrlis the event's page on the main site: indexable, unfurls with a title/description/image, and outlives the widget session that produced it. A widget URL is none of those even where it works. #105's add-to-calendar and #106's canonicals already lean on it; this makes the rule explicit and shared.When there is no canonical, the address bar is a second-rate stand-in even where it is correct. Worth stating plainly, because it is the argument against investing in making memory mode produce a widget URL: ShareView renders at
<event-path>/shareand RegistrationView at<event-path>/register, so the fallback shares the drawer you are standing in, and the.icsURL:line points at the registration form. Pre-existing, out of scope here, and noted below as the follow-up worth having.So the honest answer with no canonical and no route in the URL is nothing. Not a degraded share block:
CopyField,navigator.shareand everyreact-sharetarget each require a URL, and the only string in reach belongs to somebody else.ShareContent.urltherefore stays required — a share block is a URL plus ways to send it — whileRegistrationForm.eventUrlbecomes optional, because the confirmation screen is a screen with an optional block on it. Each caller then decides what to show instead: ShareView says so, the confirmation just drops the block.Rejected: constructing
origin + pathname + '#!' + routein memory mode. It would work —mountRoutereads that fragment as ours — but it hands every recipient a URL that overrides the host's own anchor, and there is no browser this wave to prove it against.Changes
src/config/mode.ts—linkable+DEFAULT_WIDGET_MODE; documents that the<Link>href consequence of memory mode remains unaddressed, and that this flag is what a fix would consult.src/lib/url.ts—shareableUrl(canonical, currentHref, linkable), reusing the existingvalidateWebUrlhttp(s) guard on both candidates.src/hooks/use-share-url.ts— feeds it the mode axis +window.location.href, so neither view reads the location any more.src/components/molecules/Fallbacks/Fallbacks.tsx— ashare-unavailablepolicy row (outside the ticket's stated file list; see notes)..claude/rules/components.md,.claude/rules/i18n-and-state.md,CLAUDE.md.Verification
pnpm lint)pnpm typecheck)pnpm test:run) —shareableUrlcovered in the node lane across all three modes, incl. the load-bearing no-regression case for standalone + embedded-hash;useShareUrlcovered for the context wiring and the no-provider defaultpnpm ladle:build)Manual verification — NOT run this wave
No dev backend and no browser were available. In rough priority:
demo.htmlwith a#respondanchor, open an event whosewebUrlis null, press Share. Expect the neutral panel and no URL anywhere — not in a copy field, not in the OS share sheet.…#/!/…and the grid.pnpm dev, same check with the pathname URL.webUrl, in all three of the above — the copy field shows the main-site URL, never the address bar.webUrl-less event in memory mode: "Invite a friend" and its grid are absent, add-to-calendar still renders, and the downloaded.icshas noURL:line.none; Molecules → Fallbacks, the twoshare-unavailablecases; Organisms → Registration Form, "Confirmation · nothing to link to".Notes for reviewer
One file outside the ticket's stated ownership:
Fallbacks.tsx. The first pass reusedERROR_POLICY.unavailablewith themessageoverride./code-reviewwas right that this is wrong twice over: that row grantsonward, so with no organiser phone the screen answered "there is no link to share" with "see events in Cambridgeshire" — walking the viewer away from the class they were trying to pass on; andmessageis documented as reserved forunavailable's CMS-resolved status table, so the sentence escaped the en-parity test. The repo's own rule (FallbackValues) is that a state needing a different sentence gets a different row, so it got one. Copy moved fromeventstocommon, whereERROR_POLICYkeys live and the test can see it.Security review finding NOT fixed here — and I'd like a call on it. The address-bar fallback passes the host page's query string through to the clipboard,
navigator.shareand every third-party share intent. The repo has ruled the other way three times for telemetry (hostPageUrl, the refused SentryHttpContext, Fathom'sauto: false), all citing reset tokens and OAuth params. It is pre-existing — this PR narrows the exposure from three modes to two — and it is not a free fix: in hash mode the widget's whole route is in the fragment, so stripping the query is safe for us but breaks the link on a host that routes by query, which is WordPress's default permalink shape (/?p=123) and therefore exactly this feature's audience. Leak a host param, or break the share link on a query-routed host — that is a product call, not a refactor. Argued in theshareableUrldocblock and pinned by a fixture that now carries a query, so the next person sees it rather than rediscovering it.Follow-ups, both out of scope:
shareableUrlshould build the event's route rather than reflect the current one, so a share doesn't hand over the share drawer and the.icsdoesn't point at the registration form. That wants thehrefFor(path)resolver the reviewer proposed, which is also what the<Link>middle-click bug needs — a boolean can't serve it.linkableis now in context and could gate it.Closes #115
🤖 Generated with Claude Code