Skip to content

fix(widget): render the registration questions the CMS actually has - #192

Merged
sydevs-bot merged 3 commits into
mainfrom
claude/fix-registration-questions-resync
Sep 4, 2026
Merged

sydevs-bot merged 3 commits into
mainfrom
claude/fix-registration-questions-resync

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Registration forms ask the event's questions again. SahajCloud renamed all four registrationQuestions keys ~27 days ago; our zod schema still named the old ones, and z.object strips an undeclared key rather than raising — so {aspirations: true} parsed to {}, every form rendered zero questions, and the build stayed green throughout.
  • The schema is now derived from the synced CMS types, not hand-listed. satisfies Record<RegistrationQuestionName, …> pins the key set to payload-types.ts, so the next rename fails the build instead of emptying the form — once pnpm types:cms has been run, which is the honest limit and is written where the schema is.
  • The four questions are worded as the organiser wrote them, in all ten locales. The form asked "Have you experienced this meditation before?" while the organiser's notification email printed the answer under "Have you practised Sahaja Yoga meditation before?" — two different questions, one answer.
  • Five dead locale strings removed, and the bundles are pinned to the CMS key set in both directions.

Every review thread is answered

Four from the review pass, one from @Ardnived. All five resolved; nothing is waiting on anyone.

Thread State
No CHANGELOG.md entry Done — one ### Fixed bullet under [Unreleased]
The spec re-implements the view's filter Done — enabledQuestions moved to lib/shape/event.ts; the view and the spec now call the same function, watched failing
Eight lines of narrative above the schema Done — four lines, instruction kept, story left in #191
Our question labels vs SahajCloud's Done — realigned on your instruction; the widget is not live, so there was no reader of the old wording to weigh

Changes

  • src/types/event.ts — RegistrationQuestionName derived from CmsEvent['registrationQuestions']; the schema's four keys renamed and pinned by satisfies.
  • src/lib/shape/event.ts — enabledQuestions, moved out of RegistrationView. It is a pure per-event derivation with no React and no i18n, which is this file's remit (it sits beside isOnline and eventTimeZone, which the same view already imports).
  • src/views/RegistrationView/RegistrationView.tsx — calls it rather than owning a private copy.
  • public/locales/*/events.json — the five unreachable question strings dropped, and the surviving four realigned to EVENT_REGISTRATION_QUESTIONS' labels in every one of the ten bundles.
  • src/types/payload/ — regenerated by pnpm types:cms, not hand-edited.
  • CHANGELOG.md — the visitor-visible entries.
  • Specs: event.test.ts, registration.test.ts, i18n-options.test.ts, src/mocks/events.ts.

Test results

  • Lean gate on 0e98027: ✓ pnpm lint, ✓ pnpm typecheck (app + tsconfig.test.json), ✓ pnpm test:run — 114 files / 1518 specs, all exit 0.
  • CI was green on all five checks at 1bed420 (Lint/Typecheck/Build, Smoke, Dependency Audit, both Cloudflare Pages); the two pushes since re-run them.

Manual verification

Not done, and it needs a preview plus a key: open an event whose CMS record enables two questions and confirm both render on the form, then submit and confirm the answers reach the manager email. The unit lane covers the parse and the derivation; it cannot cover a live CMS payload.

Every new assertion was watched FAILING, including the one that was vacuous first

Per docs/testing.md, at the site that would really cause it. Replacing the filter body in lib/shape/event.ts with [...REGISTRATION_QUESTION_NAMES]:

Assertion What goes red
resolves the questions a CMS payload enables, in schema order expected [ 'experience', 'referral', …(2) ] to deeply equal [ 'referral', 'questions' ]
resolves nothing when the schema and the CMS payload disagree expected [ 'experience', 'referral', …(2) ] to deeply equal []
keeps an enabled CMS question through the parse naming the pre-rename keys in the schema — expected undefined to be true

The first of these was vacuous in the version this PR opened with, which is the finding worth carrying: it re-implemented RegistrationView's filter inline instead of calling it, so it stayed green with the real filter broken, while its own comment claimed to walk "the whole chain RegistrationView walks". That is the docs/testing.md #103 shape — a spec that can only reach a state through the door the story uses is not covering the state, it is covering the door — and it is why the function moved rather than the comment being softened.

The copy realignment adds no assertion of its own, so instead the gate it relies on was confirmed live: blanking de's questions.referral reddens de: answers every event key but the known gaps with expected [ 'questions.referral' ] to deeply equal []. Restored after.

The retranslation, and two things it swept up
key was now
experience Have you experienced this meditation before? Have you practised Sahaja Yoga meditation before?
referral How did you hear about us? How did you hear about this event?
aspirations What are you looking for from meditation? What are you hoping to get out of this?
questions Do you have any questions? Do you have any questions for us?

experience is the one where the two genuinely asked different things rather than saying the same thing differently.

  • hu was carrying the four English strings verbatim and is now actually Hungarian. The parity gate could not see it: untranslated() tests for a blank or missing value, not for one identical to English. Left alone here — it is a gate question, not this PR's.
  • Two Cyrillic typos in ru — a Latin Y in "У вас есть вопросы?" and a Latin o in "Как вы узнали о нас?" — were in strings being replaced anyway.
  • Register made consistent per language where the old four disagreed with themselves: es and nl each mixed formal and informal across the four. Now tú throughout in es, je throughout in nl.
What is still not covered, and the guard's real limit

The second hop is uncovered: questions[] → t('questions.<name>') in RegistrationForm. That component takes questions as a prop, so an SSR spec there would pass the array in by hand — the door again. The bundle-key half is pinned in both directions by gives every locale bundle exactly the CMS question keys, so what remains is React rendering a label from a key that is known to exist.

The satisfies guard does not fire on its own. src/types/payload/ is a checked-in copy, so between resyncs the schema is compared against a snapshot of its own past agreement. The detector that actually caught this was the Thursday survey-contracts run, 27 days after the fact.

And the labels are now a second copy of an upstream constant, checked by nobody — the same shape as the key drift this PR fixes, one field over. A CI step diffing the two types:cms sources, extended to the question labels, would close both. Worth a follow-up ticket; deliberately not smuggled in here.

Closes #191

🤖 Written by the sydevs autonomous loop — see what this is


🤖 Generated with Claude Code

https://claude.ai/code/session_01SswRq8ZsEtxify2x9rXUkg

Closes #191.

No optional registration question has rendered on any event since
2026-08-07. SahajCloud's four questions are `experience`, `referral`,
`aspirations`, `questions`; the widget looked for `priorExperience`,
`referralSource`, `healthInfo`, `accessibility`, `guests`. Zero overlap,
so `enabledQuestions()` returned `[]` for every event whatever a manager
had switched on.

Nothing failed, and that is the part worth carrying. `RegistrationQuestionsSchema`
is a plain `z.object`, so zod STRIPPED the CMS keys rather than raising:
`{aspirations: true}` parsed to `{}`, and an empty form is
indistinguishable from an event with no questions enabled.

The guard written for exactly this — `satisfies Record<RegistrationQuestionName, …>`
— could not fire, because `RegistrationQuestionName` derives from
`src/types/payload/`, a CHECKED-IN copy of the upstream types. Between
resyncs it compares the schema against a snapshot of its own past
agreement. Running `pnpm types:cms` is what arms it, and it had not been
run for 27 days and five upstream schema commits. The resync fails the
build immediately, which is the guard working; the comment above the
schema now says so, because "it can't drift from the backend" was read as
unconditional and is not.

- `src/types/payload/payload-types.ts` — resynced (generated, do not hand-edit)
- `src/types/event.ts` — the four current keys, plus the caveat above
- `src/mocks/events.ts`, `RegistrationForm.stories.tsx` — fixtures follow
- `public/locales/en/events.json` — drop the five dead keys. Only `en` carried
  them; the other nine locales already held exactly the four live ones, which is
  why the rename looked half-adopted
- `src/config/i18n-options.test.ts` — those five leave the untranslated-debt
  baseline, since the keys no longer exist to be translated

Four new assertions in `src/types/event.test.ts`, and all four were watched
FAILING against the schema reverted to the five stale keys, per
`docs/testing.md`. The one that matters reads
`expected [] to deeply equal [ 'referral', 'questions' ]` — that `[]` is the
production defect, reproduced. A locale-parity assertion covers both
directions over every bundle, so an unreachable key or a missing label
reddens the lane rather than shipping.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01W3bncHkCBKywbTiJSniKh8
@sydevs-bot
sydevs-bot requested a review from Ardnived September 3, 2026 16:34
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Deploying sahajatlas with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0e98027
Status: ✅  Deploy successful!
Preview URL: https://122f21ed.sahajatlas.pages.dev
Branch Preview URL: https://claude-fix-registration-ques.sahajatlas.pages.dev

View logs

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 Adversarial review

Holistic: the diff is the size of the problem and no larger — four schema keys, the fixtures and specs that follow them, five dead locale strings, and a generated file the author did not hand-edit. I verified the generated half rather than taking the claim: applying strip-payload-augmentation.mjs to SahajCloud main's src/payload-types.ts today produces this file byte for byte, and response-types.ts is already identical, so both halves of types:cms are genuinely fresh. I also diffed the whole five-commit drift field by field against the widget's read schemas: registrationQuestions is the only moved field the widget consumes (contactName, address, schedule, images, webPath/webUrl, registrationsFull all survive; the notificationLog→activityLog, verificationStage, quality/confidence and Client.canonical changes are inert here) — so the other ~600 generated lines carry no second silent-strip hiding behind them. That check is what makes the narrow fix the right shape.

Two things the ticket asked for are not in the diff. The user-visible half of the fix is undocumented: CHANGELOG.md is the file for "visible behaviour" a host observes and gets no entry, though this restores questions to every registration form on every embed. And acceptance criterion 3 — renders in RegistrationView — is stood in for by a spec that re-implements the view's own filter rather than calling it, so the claim in the comment and the PR body outruns the assertion. Neither is a reason to hold the PR; both are cheap now and expensive to notice later.

One shape-level note with no line to hang it on: nothing in this PR makes the guard fire any earlier next time. The only new defence is a comment, and the detector that caught this remains the Thursday survey-contracts run — 27 days after the fact. A CI step that curls the two types:cms sources and diffs them would turn "the guard is armed" into something checkable, but that is a follow-up ticket rather than this PR's job (and per the repo's own rule, not a second behaviour to smuggle into a fix).

Findings

  • should-fix — no CHANGELOG.md entry for a change the file's own scope explicitly covers (thread, src/types/event.ts:97).
  • consider — resolves the questions a CMS payload enables copies RegistrationView.tsx:27 instead of calling it, and is the only cover for the "renders" criterion (src/types/event.test.ts:164-174).
  • consider — the surviving question labels diverge from upstream EVENT_REGISTRATION_QUESTIONS, whose labels the manager email forwards; the two strings that matched verbatim are the two deleted here (public/locales/en/events.json:69-73).
  • consider — eight lines of #191 narrative above the schema where one imperative sentence does the work (src/types/event.ts:89-96).
What was checked

Ticket vs diff. Read #191 (all five acceptance criteria and the verification checklist) before the diff. Criteria 1, 2, 4 and 5 are covered and asserted; criterion 3 is covered only by the re-implemented filter above; the two "live" checks the PR body lists as unverified genuinely need a preview and a key.

Generated half, verified not trusted. curl of raw.githubusercontent.com/sydevs/SahajCloud/refs/heads/main/src/payload-types.ts, then applied scripts/strip-payload-augmentation.mjs's own regex → diff against src/types/payload/payload-types.ts on this branch: identical. Same for src/collections/Events/endpoints/responseTypes.ts → response-types.ts: identical. So acceptance criterion 1 holds today.

The rest of the drift, consumer side. Extracted the Event and Client interfaces from both revisions and diffed them, then checked every changed field against EventDocSchema / AgnosticFeedEventSchema (src/types/event.ts) and ClientSchema (src/types/client.ts, whose only load-bearing read is canonical.embed for routing=path). No other consumed field moved.

Producer side. Read SahajCloud's src/lib/registrations/questions.ts — EVENT_REGISTRATION_QUESTIONS, the additionalProperties: false jsonSchema, and the label-forwarding contract. Confirmed the four names, their order (which REGISTRATION_QUESTION_NAMES and therefore the form's field order now match), and read the labels against public/locales/en/events.json.

Local blast radius. Grepped the repo for all five retired names outside src/types/payload/: every remaining hit is in the files this diff changes. Read RegistrationView.tsx (enabledQuestions, module-private), RegistrationForm.tsx:464-469 (t('questions.<name>'), so a bundle key really is the label sink), src/config/i18n-options.test.ts (the untranslated helper and the baseline the diff shrinks — the five keys cannot recur now that en no longer declares them), and .claude/workflow.json's contractStep. Checked docs/embedding.md's scope: no origin, attribute, CSP or sizing change here, so it needs nothing.

Gates. All five checks green on 1bed420 (Lint/Typecheck/Build, Smoke, Dependency Audit, both Cloudflare Pages). Nothing was run locally — node_modules is absent in this checkout, so every claim above comes from source, the diff, and the upstream files named.

Reviewer profile: read (workflow/skills/adversarial-review/reviewer-profile.md).

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread src/types/event.ts Resolved
Comment thread src/types/event.test.ts Resolved
Comment thread public/locales/en/events.json Resolved
Comment thread src/types/event.ts Resolved
…t changed

Three of the four threads from the review pass on this PR.

**The spec re-implemented the filter it claimed to cover.** `event.test.ts`
copied `RegistrationView`'s private `enabledQuestions` body rather than calling
it, so the only assertion standing in for #191's third acceptance criterion —
that an enabled question *renders* — stayed green with the real filter broken.
Move the function to `lib/shape/event.ts`, where the repo puts pure per-event
derivations (`isOnline`, `eventTimeZone`) and where the spec can reach it; the
view now calls it instead of owning it.

Watched failing at the site that would really cause it, per docs/testing.md:
replacing the filter body with `[...REGISTRATION_QUESTION_NAMES]` reds both
assertions (`expected [ 'experience', 'referral', …(2) ] to deeply equal
[ 'referral', 'questions' ]`), where the copied version could not. The second
assertion is the stale-schema case end to end — the CMS enables a name the
schema does not declare, zod strips it, the view resolves an empty form — which
is what #191 actually looked like from a visitor's seat.

**CHANGELOG.md gets the entry it exists for.** The file's own preamble scopes it
to "visible behaviour", and CLAUDE.md makes it same-PR. Putting up to four
questions back on every registration form on every embed, after four weeks of
showing none, is a larger visitor-visible change than several entries already
under `### Fixed`. Written in that file's register — what a visitor and an
organiser see now versus before, no schema names.

**The schema docblock keeps its instruction and loses the incident report.**
Eight lines of #191 narrative above a four-line schema, where the rule is one
sentence: the `satisfies` guard only fires once `pnpm types:cms` has been run,
because it compares against a checked-in copy. #191 already holds the story.

The fourth thread — whether our on-screen question labels should adopt
SahajCloud's `EVENT_REGISTRATION_QUESTIONS` wording — is a copy decision across
nine locales and stays open for @Ardnived.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013BsMzL3hwyPdNpMLR3yEfY
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Three of the four review threads are done and resolved; one copy decision is back with you. Pushed as 8e3538e, PR body refreshed.

The one that mattered was the second: the spec standing in for #191's "renders" criterion copied RegistrationView's question filter instead of calling it, so it would have stayed green with the real filter broken. enabledQuestions now lives in src/lib/shape/event.ts — beside isOnline and eventTimeZone, which the same view already imports — and both the view and the spec call it. Watched failing at that site before restoring, plus one new assertion for the #191 shape end to end (CMS enables a name the schema does not declare → zod strips it → empty form).

The open thread is the question labels: ours and SahajCloud's have drifted, and experience is the one where they genuinely differ — an organiser's notification email says "Have you practised Sahaja Yoga meditation before?" beside an answer to our "Have you experienced this meditation before?". My recommendation is to keep our wording and fix it upstream, since ours is the only version a visitor reads and realigning costs nine locales. One word from you and I will take either.

Lean gate green on the new head: lint, typecheck (app + tests), 114 files / 1518 specs.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

The four question labels on the registration form were the widget's own
wording; SahajCloud's `EVENT_REGISTRATION_QUESTIONS` labels are what the
organiser configures and what the manager notification email prints beside
each answer. So the visitor answered one question and the organiser read the
answer under another:

  experience   "Have you experienced this meditation before?"
            -> "Have you practised Sahaja Yoga meditation before?"
  referral     "How did you hear about us?"
            -> "How did you hear about this event?"
  aspirations  "What are you looking for from meditation?"
            -> "What are you hoping to get out of this?"
  questions    "Do you have any questions?"
            -> "Do you have any questions for us?"

`experience` is the one where the two genuinely asked different things, not
merely differently-worded versions of the same thing.

Realigned on @Ardnived's instruction on #192: the widget is not live yet, so
no visitor has read the old wording and there is no migration to weigh. All
ten locale bundles are retranslated to the new source strings rather than
left to fall back to English — `hu` was carrying the English strings verbatim
and is now actually Hungarian, and two Cyrillic typos in `ru` (Latin `Y` in
"У вас", Latin `o` in "о нас") went with the rewrite.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SswRq8ZsEtxify2x9rXUkg
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Realigned and retranslated — every thread on this PR is now answered and resolved. 0e98027.

Your call on the copy is done: the four questions are worded as EVENT_REGISTRATION_QUESTIONS has them, so a visitor and the organiser reading the notification email see the same sentence. All ten locale bundles are rewritten to the new source strings rather than left to fall back to English — the detail, and two things the pass swept up, are on the thread and in the PR body.

Lean gate green on this head: lint, typecheck (app + tests), 114 files / 1518 specs. CI re-runs on the push.

One thing left open deliberately: the en labels are now a copy of an upstream constant that nothing checks — structurally the same defect as the key drift this PR fixes, one field over. I'd file it rather than widen this PR; say the word.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@Ardnived Ardnived left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with the en labels should be resolved when we move the whole translation schema to be being provided from the CMS instead of being defined in files on this repo. Go ahead and merge this PR

@Ardnived Ardnived removed the awaiting label Sep 4, 2026
@sydevs-bot
sydevs-bot merged commit 69b6078 into main Sep 4, 2026
5 checks passed
@sydevs-bot
sydevs-bot deleted the claude/fix-registration-questions-resync branch September 4, 2026 17:05
@github-project-automation github-project-automation Bot moved this from Approved to Done in SYDevelopers Technical Roadmap Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

fix(widget): no registration question ever renders — the CMS renamed all of them

3 participants