Repository navigation
Description
Summary
#92 stopped the widget rendering blank on a host page whose fragment it declined to take. On
such a page (#respond, #comment-123 — routine on WordPress) mountRoute returns
{ router: 'memory' } (src/lib/shape/hash.ts:69) and Widget.tsx:171 mounts a
MemoryRouter, so the widget never writes the URL. That was the right call, and it left two
consequences the implementing agent deliberately deferred — both already written down in
.claude/rules/components.md → "Widget / embedding constraints", and neither addressed:
ShareViewandRegistrationViewfall back towindow.location.href. In memory mode
that string is the host page URL — it identifies nothing about the event, so the copy
field, the native share sheet and the registration confirmation all hand out a link that
lands on the host page's article, not the meditation.<Link>hrefs resolve against the host origin. A route string like/gb/londonis not
a widget location in memory mode; nothing in the code says so, so components can't ask.
The fix is to give WidgetMode a linkable axis, so a view asks whether its route can be
put in front of a human rather than inferring it. Today WidgetMode carries standalone and
hasMap (src/config/mode.ts:13-16) — this is a third runtime axis of exactly the same kind.
Current behavior
src/config/mode.ts:13-16—WidgetMode = { standalone: boolean; hasMap: boolean }; context
default{ standalone: false, hasMap: true }.src/Widget.tsx:168-171—mount.current.router === 'hash' ? <HashRouter…> : <MemoryRouter initialEntries={[mount.current.path]}>. The router choice is made once at mount and is not
surfaced to the tree.src/views/ShareView/ShareView.tsx:40—url={event.webUrl ?? window.location.href}src/views/RegistrationView/RegistrationView.tsx:91—eventUrl={event.webUrl ?? window.location.href}
The fallback is not hypothetical: event.webUrl is null for an unpublished or
publication-gated event, which is exactly when the fallback fires. Note the fallback is correct
in the other two modes — standalone (BrowserRouter) and embedded-hash both put an identifying
route in window.location.href — so this is specifically a memory-mode defect, and the fix must
not regress the two working cases.
Proposed changes
- Add
linkable: booleantoWidgetMode(src/config/mode.ts), documented in the same
comment block asstandalone/hasMap: whether the current route can be handed to someone
else — true for the standalone build and for embedded hash routing, false in memory mode.
Default it totruein the context default (the standalone/dev path), so the falsy case is
opt-in and a component that forgets the axis behaves as it does today. - Thread it from
Widget.tsx, derived from the single existing decision
(mount.current.router === 'hash'). Do not re-derive it fromwindow.locationanywhere else —
mountRouteis the one place that answers this, and a second reading is how the two drift. ShareViewandRegistrationViewconsult it instead of reaching forwindow.location.href:event.webUrlwhen present — unchanged, and still preferred in every mode.linkable→window.location.href, as today.!linkable→ decide one documented behaviour and apply it to both views. The preferred
shape is to omit the URL rather than ship a wrong one (ShareContent/RegistrationForm
degrade to label-only sharing and a confirmation with no link), because a host-page URL is
actively misleading in a share sheet. If a URL is genuinely required by a downstream prop
contract, say so in the report and make the prop optional instead of passing a lie.
- Document the
<Link>consequence on the mode axis (a comment inmode.tsand the
existing bullet in.claude/rules/components.md), so the next component that needs it has
something to read. Do not change theLinkatom in this ticket — that file is owned by the
sibling anchor-predicate ticket in this batch.
Acceptance criteria
-
WidgetModecarrieslinkable, defaulting totrue, documented alongsidestandalone
andhasMap -
Widget.tsxderives it from themountRouteresult only; grep finds no second
window.location.hashreading introduced for this - Neither
ShareView.tsxnorRegistrationView.tsxreferenceswindow.location.href
unconditionally; both branch onlinkable - On a host page with a foreign anchor, opening Share for an event with a null
webUrl
produces no host-page URL in the copy field or the native share payload - No regression in the two working modes: standalone and embedded-hash still produce the
identifying URL they do today (this is the load-bearing check — cover both) - Unit coverage in the node lane for the mode-to-URL decision (a pure helper preferred over a
component test, per.claude/rules/tests.md);ShareView.stories.tsxstill renders -
.claude/rules/components.md→ "Widget / embedding constraints" updated: the consequences
bullet now points atlinkableas the way to ask, and states which consequence remains
unaddressed (<Link>href resolution) - Lint + typecheck +
pnpm test:runpass - Verified in the running widget against a page carrying a
#respond-style anchor - Implementation report written to
.claude/reports/<this-issue-number>-linkable-mode-axis.mdin the main checkout at
/Users/devindra/Documents/Projects/SahajAtlasWeb(.claude/reports/.gitignoreis*, so a
worktree copy would be discarded)
Parallel implementation
This ticket owns these files; no other ticket in this batch touches them:
src/config/mode.tssrc/Widget.tsxsrc/views/ShareView/ShareView.tsx(+ its stories)src/views/RegistrationView/RegistrationView.tsx.claude/rules/components.md- whatever molecule prop contracts the URL decision requires (
ShareContent,RegistrationForm)
— if that reaches beyond these files, note it in the report
Do not edit src/lib/shape/hash.ts (its decision is correct and pinned by hash.test.ts /
hash.router.test.tsx), src/components/atoms/Link/, src/components/atoms/Button/, or
src/lib/shape/href.ts — those belong to the sibling anchor-predicate ticket.
Files affected
src/config/mode.ts(:13-16)src/Widget.tsx(:168-171)src/views/ShareView/ShareView.tsx(:40)src/views/RegistrationView/RegistrationView.tsx(:91).claude/rules/components.md
References
- fix(widget): survive foreign hashes and harden the mount path #92 / PR fix(widget): survive foreign hashes and harden the mount path #112 — the memory-mode mount decision this builds on
.claude/reports/92-widget-mount-hardening.mdsrc/lib/shape/hash.ts:1-26— the three-way ours/free/foreign decision, in full.claude/rules/components.md→ "Widget / embedding constraints" — already documents both
consequences as known and unaddressed
Metadata
Metadata
Assignees
Labels
Type
Fields
Hold Until
Activity
feat(widget): make memory-mode routing linkable where it matters (#142)
feat(ui): share, directions and contact open from the event's action …