Repository navigation
Description
Summary
"Add to calendar" cannot subscribe anyone to anything. Apple Calendar gets a downloaded file, Google gets a one-off action=TEMPLATE link, and Outlook, Office 365 and Yahoo get only the single session the viewer registered for. SahajCloud will serve a token-addressed .ics feed per class, so this rebuilds the menu over that address: Apple, Google and both Outlooks subscribe, Yahoo keeps its one session, and the download becomes its own last row. It also admits webcal: at the href gate, selects the new field on the event read, and updates the host contract.
Goal context
Consumer child of #368 ("People can add a class to their calendar in one click, whichever calendar they use"). sydevs/SahajCloud#1131 produces the feed, its address and the menu copy; this child builds the menu over all three and merges after it.
Interfaces
Consumed from sydevs/SahajCloud#1131, three things:
- The feed —
GET https://<cloud host>/api/events/calendar/<token>.ics,text/calendar; charset=utf-8, unauthenticated, carrying the full recurrence and no joining link. 404 for an unknown or tampered token and for a finished class;STATUS:CANCELLEDfor 90 days after a takedown. events.calendarFeedUrl— a virtual, read-onlyhttps://string on the single-event read,nullon list reads, the geojson feed, relationship hydration and an unpublished class. It isdefaultPopulate: falseupstream, so an explicitselectis required. It reaches this repo as a generated type throughpnpm types:cms, which the dispatcher's contract sync runs on this PR once the producer merges.- Two
event.actionskeys —calendar_next_session_only("Adds the next session only") andcalendar_keeps_updated("Keeps itself up to date"), reaching this repo throughpnpm sync:translations --writeonce the producer is deployed.
This provides nothing back to the producer. No other repo consumes anything added here.
Approach
A. The addresses (src/lib/ics.ts)
Read the whole file docblock (:7-53) before editing. Its two arguments — why the ICS is hand-rolled (#105, #52) and why schedule.icalRule is unusable — still hold for the download row, which keeps buildEventIcs (:322) unchanged. Keep both, and add which rows now subscribe instead of building a file.
IcsEventInput(:55) gains the feed address as an optional nullish field. The address no longer follows frominput.id, so it is read off the event document, never composed here.- One builder for the
webcal://form of that address (scheme swap on thehttps://string), and the provider wrappers over it. Each returnsundefinedwhen the event carries no address:- Apple — the
webcal://form itself. - Google —
https://calendar.google.com/calendar/r?cid=<the webcal address, percent-encoded>. This replaces today'sbuildGoogleCalendarUrl(:379), whoseaction=TEMPLATE+recur=RRULE:+ctzparams go, per the goal's decision that Google subscribes. ⚠ One source reports thewebcalURL landing in Google's Calendar-Name field rather than its address field, so verify what the dialog actually shows (§ Verification), not merely that it opens. - Outlook.com / Office 365 — two candidate shapes over
OUTLOOK_HOSTS(:408), tried in order, documented by nobody:…/calendar/0/addfromweb?url=…first, then…/calendar/0/deeplink/compose?path=/calendar/action/compose&rru=addsubscription&url=…. Try each with both thewebcal://and thehttps://form ofurl=. - Yahoo —
buildYahooCalendarUrl(:451) unchanged.
- Apple — the
- Keep
buildOutlookCalendarUrl(:425) as the fallback. Itsrru=addeventshape is the sibling ofrru=addsubscriptionand it works today. If no candidate opens a subscribe dialog listing more than one session, the two Outlook rows keep that link and take thecalendar_next_session_onlysub-label — the treatment the goal's decisions already give a service with no subscribe route, so it needs no new answer. It does cost the goal's Outlook success line, so the PR must say which outcome happened. - Correct the docblock's Apple claim (
:14-18). It says Apple resolves IANA TZIDs without aVTIMEZONE, which SahajCloud's own builder docblock contradicts. Apple no longer reads anything this file emits — it subscribes to the feed, which shipsVTIMEZONE— so state which rows each builder serves and drop the Apple-specific claim rather than leave two repos' docblocks disagreeing. - Pin every built URL in
src/lib/ics.test.tsagainst a parsedURL—url.origin + url.pathnameplusurl.searchParams.get(…), as:328-334and:393-404already do. Never a string compare: a percent-encoding difference that a calendar accepts would read as a failure, and one it rejects would not. - ⚠ The host comes from
VITE_SAHAJCLOUD_URL(src/config/api/client.ts:72), by way of the field. Google and Microsoft fetch the feed server-side, so alocalhostor dev host is unreachable to them and no local run can verify those two rows. Verification is on a deployed preview pointed at production SahajCloud.
B. The scheme gate (src/lib/shape/href.ts)
webcal: is refused today, silently: it is not in ALLOWED_SCHEME (:15), so Link reports and degrades the row to a <span> (src/components/atoms/Link/Link.tsx:105) — a row that looks normal and does nothing.
- Add
webcaltoALLOWED_SCHEME, and extendsrc/lib/shape/href.test.ts(which also asserts the JSX-anchor inventory at:131-191, and asserts the allowed set at:111). - ⚠ The docblock's case-insensitivity argument needs the new distinction. It ties the list to two upstream guards over CMS-authored URLs —
SafeUrlSchema(src/types/event.ts:124) andvalidateWebUrl— both/^https?:/i.webcal:is an address we build from a field we select, and it reaches neither guard, so say that rather than let the docblock imply a guard that does not cover it. - Check the same two sentences elsewhere:
isSafeHref's own docblock anddocs/rules/data-layer.md:171§ "isSafeHrefis the sink-level gate" both say "three allowed schemes" and name them. Correct both. - No new JSX anchor: the rows render through the
Linkatom, so the inventory stays at three.
C. The event read
getEventDoc(src/config/api/fetch.ts:668) adds the new field to itsselect. SahajCloud requires an explicitselecton every client read, and the field isdefaultPopulate: falseupstream, so an unlisted field comes back absent.EventDocSchema(src/types/event.ts:197) carries it, shaped likewebUrl(:227) onSafeUrlSchema(:124):https?:only,.nullish().catch(null), so a class with no address parses rather than failing the whole event read.- Thread it to the menu through
calendarExport(src/views/RegistrationView/RegistrationView.tsx:82-99), which is where the form'scalendarprop is built (RegistrationForm.tsx:454). The view holds the full doc;AddToCalendartakes export primitives, never anEvent. - ⚠
src/types/payload/is generated and is acontractSyncpath. Do not runpnpm types:cmswhile the producer is unmerged — it reads SahajCloud'smainand would silently pull the old shape. Copy the producer branch's generated file by hand during the set build; the dispatcher re-syncs it on this PR once the producer merges.
D. The menu (src/components/molecules/AddToCalendar/)
AddToCalendar.tsx, plus AddToCalendar.test.tsx and AddToCalendar.stories.tsx.
- Final order and labels: Apple Calendar, Google Calendar, Outlook.com, Office 365 (each subscribing, each with the
calendar_keeps_updatedsub-label), Yahoo (one session,calendar_next_session_only), then "Download .ics file" last. - The download row carries
event.actions.download_icsas its own label, not a sub-label. The Apple row uses that key as a sub-label today (:92) and no longer downloads anything. calendarLinkTargets(:32-39) gains the sub-label on its target type and returns the five rows in that order; with no feed address it returns none.- The download row stays a
<button>(:90,downloadEventIcsat:41-54) because it synthesises a file. The other five are anchors throughLinkwithtarget="_blank", as:95-101already renders. - No address on the event → render the download row alone. Never render a subscribe row that cannot work.
E. The host contract
Per AGENTS.md, anything a host can observe lands in docs/embedding.md and CHANGELOG.md in the same PR.
allow-popupsnow covers the whole calendar menu, not just the compact card and four link-outs. Extend the notes atdocs/embedding.md:86-87and:602-604and the troubleshooting row at:1360, and add that a sandboxed frame can refuse a protocol handler (webcal:) even withallow-popups.allow-downloadsnow matters for the last row alone.docs/embedding.md:604and:1361andCHANGELOG.md:70-74all tie it to the Apple row. Correct all three.- The CSP and Permissions-Policy tables need nothing, and the PR says so explicitly: every row is a navigation, not a fetch. A reviewer should not have to go looking.
F. The copy
Copy is CMS-owned. This repo may not hand-edit a string, and never src/config/translations.en.json (pnpm sync:translations --write generates it; add_calendar and download_ics sit at :90,93). Once sydevs/SahajCloud#1131 is deployed, run that sync in the build session, then wire the t() calls. src/config/translations.test.ts pins the snapshot against every call site in both directions, so a t() with no key fails the unit lane — the honest consequence is that the rows needing the two new keys cannot ship until the sync lands.
Acceptance criteria
A — the addresses
- A builder reads the feed address off the event document and never composes one from the event id
- The Apple address is the
webcal://form of that address, unchanged otherwise - The Google address is
https://calendar.google.com/calendar/rwithcidcarrying thewebcal://address - No built URL carries
action=TEMPLATE,recur=orctz=any more - Each Outlook row carries whichever subscribe shape verification settled, or
buildOutlookCalendarUrl'srru=addeventlink if neither subscribed - The Yahoo address is byte-identical to today's
- Every built URL is asserted in
src/lib/ics.test.tsthrough a parsedURL, never a string compare - The file docblock keeps its hand-rolled and
icalRulearguments, says which rows each builder serves, and no longer claims Apple reads a TZID withoutVTIMEZONE
B — the scheme gate
-
isSafeHrefandhasAllowedSchemeboth acceptwebcal:andWEBCAL:, andsrc/lib/shape/href.test.tspins both - A
webcal:href renders as a real<a>, not a<span>, and reports nothing - The JSX-anchor inventory is still exactly three components
-
ALLOWED_SCHEME's docblock sayswebcal:is built here and reaches neitherSafeUrlSchemanorvalidateWebUrl -
isSafeHref's docblock anddocs/rules/data-layer.md§ "isSafeHrefis the sink-level gate" both name four schemes
C — the event read
-
getEventDoc'sselectnames the feed field, andEventDocSchemaparses it as a nullishhttp(s)URL - An event document with the field absent,
null, or a non-httpstring still parses, with the address falling tonull - The address reaches
AddToCalendarthroughcalendarExport, not through a second read
D — the menu
- The rows render in order: Apple Calendar, Google Calendar, Outlook.com, Office 365, Yahoo, Download .ics file
- The four subscribing rows carry
event.actions.calendar_keeps_updated; Yahoo carriesevent.actions.calendar_next_session_only - The last row's own label is
event.actions.download_ics, and no row carries that key as a sub-label - The last row is a
<button>; the other five are anchors withtarget="_blank" - An event with no feed address renders the download row and nothing else
E — the host contract
-
docs/embedding.mdtiesallow-popupsto the whole calendar menu and says a sandbox may refuse awebcal:protocol handler even with it -
docs/embedding.mdandCHANGELOG.mdtieallow-downloadsto the download row only, in all three places that name the Apple row today -
CHANGELOG.mdhas an entry describing the menu change in host-facing terms - The PR body states that the CSP and Permissions-Policy tables need no change, and why
F — the copy and the order
- No string is hand-edited, and
src/config/translations.en.jsonchanges only aspnpm sync:translations --writewrote it - The two new keys are present in that snapshot before any
t()call referencing them is pushed - The PR reports which Outlook outcome happened — a subscribe dialog on both hosts, or the single-session fallback
Verification checklist
-
.claude/skills/pr-prep/check.sh— the lean gate (lint, typecheck,test:run) -
pnpm test:run src/lib/ics.test.ts src/lib/shape/href.test.ts src/types/event.test.ts src/config/api/fetch.test.ts src/components/molecules/AddToCalendar/AddToCalendar.test.tsx src/config/translations.test.ts -
pnpm build && pnpm size— the eager-payload budget -
pnpm build && pnpm review:embed, then open the sandboxed host page: every subscribe row opens something or says why, and the download row is the only one that needsallow-downloads. Repeat withallow-popupsremoved and confirm the failure matches whatdocs/embedding.md:1360now says - On a deployed preview pointed at production SahajCloud (⚠ not a local server — Google and Microsoft fetch the feed server-side and cannot reach
localhost), register for a weekly class and click each row signed in:- Apple Calendar (macOS or iOS): a subscribe prompt naming the class, no file in Downloads; after accepting, at least three future sessions appear
- Google Calendar: a subscribe dialog, the class lands under "Other calendars" with all its sessions, and the dialog shows the feed as the address, not as the calendar's name
- Outlook.com (personal account) and Office 365 (work account): a subscribe dialog, not an add-event form, listing more than one session. Try
addfromwebfirst, thenrru=addsubscription, each with thewebcal://and thehttps://form ofurl=, and record which combination worked on which host - Yahoo: one session, and the row says so
- DST, against the subscribed feed in Apple Calendar and Google Calendar: a 6pm Europe/London class still reads 6pm for a session after the next clock change
-
curl -sI "<the address from the event read>"→200andtext/calendar, confirming the field the menu is building from actually answers
Notes
That line orders the merge, not the build: the set is built together, in one session, against the producer's branch. The generated types are provisional until the producer merges and the dispatcher's contract sync refreshes them on this PR.
This PR triggers a security review. .claude/workflow.json's securityReview.triggerPattern covers both src/lib/shape/href and src/config/api/, and this change widens the href allowlist and adds a field to a client read.
The feed is unauthenticated by construction and its token is the whole access control — sydevs/SahajCloud#1131 owns that, and this repo only puts the address it is handed into an href.
The menu redesign this builds on: #366 (merged).
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Hold Until
Projects
- StatusShow more project fieldsDone
Activity
sydevs-bot commentedon Nov 11, 2026
🤖 no session running
approved by Ardnived
Written by the sydevs dispatcher. Sessions never edit this comment.