Repository navigation
feat(event): add-to-calendar on the registration confirmation - #127
Conversation
Restores src/lib/ics.ts and its spec byte-for-byte from 4f6b397^ — the commit that dropped the Add to calendar action end to end (PR #83). That removal was an action-row rebalance to a four-action maximum, not a technical defect, and nothing it depended on has moved: scheduleStart, scheduleTimeZone and withEndTime are all still exported from lib/shape/event.ts, and EventSchedule still carries every field the builder reads. All 25 original tests pass unchanged. Committed as a pure revert so the extensions for issue #105 (the four additional providers, the recurrence-less anchor rule, the DTEND fallback) are reviewable as a diff against the known-good original. Closes #105 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Extends the revived builder to the five providers issue #105 asks for. Google and the .ics download already carried the real recurrence; the three added here take no recurrence parameter, so each gets a single occurrence and the whole question is WHICH one. Never the series start. A weekly class running since 2019 would otherwise drop a 2019 date into the viewer's calendar — so `occurrenceStart` anchors them on the session the viewer registered for (`from`, new on the input), falling back to the next upcoming occurrence. `exportStart` deliberately ignores `from` for a recurring event: DTSTART is the instance the RRULE counts from, so re-anchoring an 8-session course on session five would hand the importer eight MORE sessions starting there. Also gives an occurrence with no `endTime` a one-hour default rather than omitting DTEND. A bare DTSTART is RFC-legal but means a zero-length event (RFC 5545 §3.6.1) that calendars draw as a hairline, and the three new provider APIs require an end anyway. The hour matches SahajCloud's own ICS builder, so the download and the confirmation email agree. The module docblock now records WHY this is hand-rolled, measured rather than asserted: datebook (3.3 KiB gz) and calendar-link (4.9 KiB gz, pulls dayjs beside our luxon) both emit a bare `DTSTART:...Z` with no TZID, which drifts a weekly 19:00 London class to 18:00 after the October DST change. It also records why the CMS's own `icalRule` is unusable — it emits FREQ=DAILY;COUNT=1 for one-offs, and its UTC EXDATE does not match its TZID-local DTSTART. SahajCloud's own builder rejects it for the same reasons. Closes #105 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Puts calendar export at the moment it is most wanted — right after a successful registration — rather than back in the event action row the four-action rebalance cut it from (PR #83). The block renders five targets: Apple (an .ics Blob download, which is also the escape hatch for Thunderbird/Proton/desktop Outlook), plus link-outs to Google, Outlook.com, Office 365 and Yahoo. The four link-outs are real anchors, so middle-click and long-press behave; only the .ics path is a button, because it synthesises a file rather than navigating. RegistrationForm stays event-decoupled. It takes a `calendar` prop of export PRIMITIVES, never an Event, and renders nothing when absent. RegistrationView builds that prop because it holds the FULL event doc — `getEventDoc` selects the whole schedule group, so it has the exclusions / untilDate / monthDay / weekdayOfMonth the trimmed feed deliberately omits. Exporting from a feed event would silently ship a series missing its cancelled sessions and its end date. Two details worth the reviewer's eye: - The anchor is the session the viewer actually registered for, read from `mutation.variables` so it needs no extra state. It only moves the recurrence-less providers; Google and the .ics keep the series anchor. - LOCATION is omitted for ONLINE events. `whereLine` there reads "hosted from <somewhere>" — where the class originates, not anywhere the viewer goes — and as a calendar location it would send them to a city they have no business in. AddToCalendar is not re-exported from the molecules barrel: that barrel is imported by eager views, and the re-export edge alone would pull this and its luxon-backed builder into every host page's first-load payload. Same rule the barrel already states for ShareContent and ImageCarousel. Restores `actions.add_calendar` / `actions.download_ics` across all ten locales, recovered from 4f6b397^ rather than retranslated. Closes #105 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Four cleanup agents over the branch diff; the findings two of them raised
independently were the real ones.
- `DEFAULT_DURATION` was defined twice — `shape/calendar.ts` already had it
for the grid, and the ICS export added a second with a DIFFERENT
condition (`?? null` vs `end > start`). So an `endTime` equal to the
start time drew an hour-long block in the grid and exported a
zero-length VEVENT. Lifted to `shape/event.ts` beside `withEndTime` (its
stated home as the one parser of the wire format) and both now apply the
same test.
- `exportStart` and `occurrenceStart` each carried a full copy of the
anchor resolution, and `occurrenceStart`'s fallback re-entered
`exportStart` — a branch reachable only when both were provably falsy,
so it always resolved to `seriesStart`. `exportStart` is now the one line
it always was: recurring → series anchor, else the occurrence rule.
- `AddToCalendar` was not in `molecules/index.test.ts`'s `LEAF_PATH_ONLY`.
Its own index.ts asserts that rule in prose while nothing enforced it —
and `pnpm size` is a weaker net here than for the Swiper/react-share
cases, because luxon is already eager, so the leak would be `ics.ts`
alone and would land inside the budget's slack.
- The `.ics` and share blocks disagreed about the event URL:
`eventUrl={event.webUrl ?? window.location.href}` beside a raw
`url: event.webUrl`. `webUrl` is `SafeUrlSchema` (`.catch(null)`), so
events with a missing or non-http CMS url got a share link and no
calendar link. One fallback now.
- The export anchors on the FILTERED upcoming dates, so it can't land on a
session that already finished — the guard the date picker above it
already needed, and the one thing `lib/ics.ts` can't re-derive alone.
- Dropped a redundant `rel` the Button atom already derives, matched
ShareContent's `gap-3` (the two rows stack on one screen), derived the
list key from the brand label, and added the missing molecule story.
Deliberately NOT taken: routing the confirmation through a render-prop
slot instead of the `calendar` prop (a larger change to a file a sibling
a11y ticket owns), and collapsing the four provider builders behind a
config table (the simplification pass argued against it — they vary on
anchor, stamp format and parameter names, and `grep startdt` landing in
the Outlook builder is worth more than the deduplication).
Also kept, against one finding: the export's LOCATION still comes from
`whereLine`. The concern was display copy leaking into export data, but
that branch is only reached for PHYSICAL events, where `whereLine` is
`street, city` falling back to the region name — address data, no
translated prose. The translated form is the online one, which is already
excluded.
Closes #105
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Deploying sahajatlas-design with
|
| Latest commit: |
452502b
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://4ab20c3a.sahajatlas-design.pages.dev |
| Branch Preview URL: | https://feat-add-to-calendar.sahajatlas-design.pages.dev |
Deploying sahajatlas with
|
| Latest commit: |
420ec20
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://afba37b4.sahajatlas.pages.dev |
| Branch Preview URL: | https://feat-add-to-calendar.sahajatlas.pages.dev |
CI statusGreen: Lint/Typecheck/Build · Smoke · Cloudflare Pages (app + design). Red — This branch changes no dependency files — Four newly-published high advisories:
It's the advisory database that moved, not the code — #124's CI ran at 18:01Z and passed; #125, #126 and this PR ran between 23:48Z and 23:53Z and all three fail on exactly these four IDs. Deliberately not fixed here. Worth one ticket that owns all four, landing once — then #125/#126/#127 pick it up on rebase. |
Four high advisories published 2026-08-07 against the existing lockfile (image-size x2, nanoid x2) turned the audit gate red on every open PR, none of which touch either package. Both are verified absent from the shipped bundle by build + grep — payload is types-only so image-size never ships, postcss is build-time, and the one 'nanoid' string in dist/ is zod's .nanoid() validator name. image-size has no published fix; nanoid's is held back by postcss's own pin and arrives free under #101. Baselined against #101 with per-entry reasoning. Unblocks #123, #125, #126, #127.
Closes #105
Reintroduces calendar export at the moment it is most wanted — right after a successful
registration — rather than back in the event action row PR #83 cut it from.
The two decisions worth your attention
1. No external library, decided on correctness rather than size
I measured every candidate by actually bundling it (esbuild, minified + gzipped), not by
dist.unpackedSize:add-to-calendar-buttontimezones-ical-libraryicsyup,nanoidcalendar-linkdayjsdatebookSize is the least interesting column. I probed the two real contenders with a weekly
19:00 Europe/London class and both emit
DTSTART:20260907T180000Z— a bare UTCinstant with no
TZID. That preserves the instant, not the wall-clock time, so everyoccurrence after the October DST change lands at 18:00 for a class that still meets at
19:00. It is the precise defect SahajCloud's own
icsBuilder.tswas rewritten to avoid.calendar-linkalso emitsLOCATION:Community Hall, Londonwith the comma unescaped —an RFC 5545 violation.
A library that can't express recurrence in the event's own timezone isn't a smaller
version of this module, it's a wrong one.
2.
icalRuleis unusable — checked upstream rather than assumedIt's
rrule-temporal'stoString()(computeIcalRule, SahajCloudsrc/lib/schedule/scheduleHooks.ts). Four disqualifiers:FREQ=DAILY;COUNT=1,so a single class would import as a series;
EXDATEis UTC-stamped while itsDTSTARTis TZID-local, and a UTC EXDATEfrequently fails to match a TZID-local instance, so the cancelled session still shows;
DTEND(endTimeis absent from it entirely);SahajCloud's own builder rejects it for the same reasons. We rebuild from the structured
fields, which the full event doc carries (
getEventDocselectsschedule: true) andthe trimmed feed deliberately does not.
Revived, not rewritten
The first commit restores
src/lib/ics.ts+ its spec byte-for-byte from4f6b397^.All 25 original tests passed unchanged — which is the evidence that #83's removal was
a four-action-maximum rebalance, not a technical defect. Extensions land in later commits
so they're reviewable as a diff against the known-good original.
Added on top:
buildOutlookCalendarUrl(live + office hosts),buildYahooCalendarUrl,icsFileName, and:.icscarry a realRRULE, so they stay on theseries start — DTSTART is the instance
COUNT/BYDAYare reckoned from, andre-anchoring an 8-session course on session five would hand the importer eight more
sessions from there. Outlook, Office 365 and Yahoo have no recurrence parameter, so
each gets one occurrence: the session the viewer registered for, else the next upcoming
one. Never the series start — a class running since 2019 would otherwise put a 2019 date
in someone's calendar.
DTENDfallback. A bare DTSTART is RFC-legal but zero-length (§3.6.1),which calendars draw as a hairline. Matches SahajCloud's builder so the download and the
confirmation email agree.
Bundle cost — eager payload unchanged
standaloneembedBUDGET_KIBuntouched. The feature costs +2.1 KiB gz on theRegistrationViewchunk, which #96 already put behind a lazy seam. Verified mechanically:
VCALENDARappears in exactly one built chunk, and that chunk is absent from
dist/index.html'sentry + modulepreload list.
One deliberate deviation: I did not add a third
import()hop insideRegistrationView. It's already a second hop contributing zero to first load, and achunk fetched after a successful registration POST is a network request at the worst
possible moment — a failed fetch would replace "you're registered" with an error, for
2 KiB. Happy to add the seam if you'd rather.
Design notes
RegistrationFormstays event-decoupled — it takes acalendarprop of exportprimitives, never an
Event, and renders nothing when absent.RegistrationViewbuilds it, because it holds the full doc.
mutation.variables, so the session the viewer actuallyregistered for needs no extra state.
LOCATIONis omitted for online events.whereLinethere means "hosted from<city>" — where the class originates, not anywhere the viewer goes.
in
index.test.ts'sLEAF_PATH_ONLYso the rule is enforced rather than just stated.One review finding I pushed back on: an altitude pass flagged the export's
LOCATIONcoming from
whereLine, a display string. Sound in general, but that branch is reachedonly for physical events, where
whereLineis[street, city].join(', ')fallingback to
region.name— pure address data, no translated prose. The translated form isthe online one, already excluded.
Review passes completed
/simplify— 4 agents. Caught a real duplicateDEFAULT_DURATIONwith a differentcondition (grid drew an hour, export emitted zero-length, for the same event), a dead
recursive branch in the anchor helpers, the missing barrel guard, and a
webUrldisagreement where the share block had a fallback and the calendar link didn't.
/code-reviewand/security-review— not run. The session hit an account quotamid-run and the coordinator directed no further review subagents. Per
finalize-pr'spath filter the security review was skippable anyway (no match on the api/auth layer,
Widget.tsx, HTML sinks, deps, or env), but note this branch does add outbound URLconstruction from CMS-authored strings and a
blob:download — worth a human eye.No CSP change
Provider links are top-level
target="_blank"navigations and the.icsis ablob:download. The AC excludes both, and neither is a fetched cross-origin subresource — no
new origin is contacted.
Verify manually (the node lane can't)
.icsand import it into Apple Calendar and Google Calendar. Highestvalue check: a file that parses in a test and is rejected by a real client is the
failure mode.
Browser verification was not authorised this wave (a sibling ticket owns the shared
browser).
Full write-up:
.claude/reports/105-add-to-calendar.md.🤖 Generated with Claude Code