Skip to content

feat(forms): render contact & subscribe forms via unified intake - #112

Merged
sydevs-bot merged 26 commits into
mainfrom
claude/feat-78-forms-intake
Sep 18, 2026
Merged

sydevs-bot merged 26 commits into
mainfrom
claude/feat-78-forms-intake

Conversation

@sydevs-bot

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

Copy link
Copy Markdown
Contributor

Summary

  • A forms node embedded in page rich text now renders the form and submits it, where it used to render its title as plain text.
  • Submissions go to the CMS's unified user-submissions intake through a same-origin proxy, with a Cloudflare Turnstile captcha — both net-new here.
  • CMS types are synced past SahajCloud#801, so registrations / user-messages / form-submissions are gone from this repo.

Changes

  • components/organisms/FormBuilder/ — the whole feature. It takes the authored forms document itself and owns the captcha, the submit and the refusal handling. It server-renders: index.tsx re-exports FormBuilder.tsx, which renders @marsidev/react-turnstile with execution: 'render' so the widget survives a client-side navigation.
  • lib/submissions.ts — the user-submissions create body, and where every wire-contract decision lives. Pure.
  • server/api-routes.ts — POST /api/submissions, forwarding one create with SAHAJCLOUD_API_KEY and the captcha header.
  • server/cms-client.ts — EMBEDDED_FORM_SELECT in PAGE_POPULATE, tied to EmbeddedForm so the select and its renderer cannot drift.
  • layouts/tailwind.css — @source inline("sm:col-span-{1..12}"), so the runtime-built span class is emitted.

Preview

The feature has no fixed route of its own, so the pages worth opening are any CMS page whose rich text embeds a form, plus the Ladle story Organisms → Form Builder.

Contract impact

  • Generated Payload types re-synced (pnpm types:cms against SahajCloud main, post-#801). registrations, user-messages and event-submissions no longer exist in this repo's types; nothing referenced them.
  • New build-time variable PUBLIC__TURNSTILE_SITE_KEY. Deliberately absent from .env.production — see Manual verification.
  • New dependency @marsidev/react-turnstile 1.6.1. It renders a plain container and touches the DOM only from effects, so it server-renders. It is in the Worker bundle and in every route's client chunk — see the SSR decision below.
  • Filed fix(api): Turnstile sees the proxying client's IP, not the visitor's SahajCloud#808: the CMS reads cf-connecting-ip off its own request for Turnstile's remoteip, so a proxied submission presents this Worker's address, not the visitor's. Cloudflare validates remoteip against the address that solved the challenge, so this may refuse every proxied submission. Recorded in server/AGENTS.md.
  • An author must call the sender's name field exactly name. prepareUserSubmission matches it on that literal key, not on a block type, and upsertUserByEmail writes the users row once and never revisits it. A field called fullName names the row off the email's local part, permanently. Documented in the FormBuilder README.

Test results

  • Lean gate: ✓ pnpm lint (0 errors), tsc --noEmit, pnpm test:run — 682 passed, 72 files
  • Build: ✓ pnpm build. dist/server is 2.63 MB raw and 564 kB gzipped, against Cloudflare's 3 MB gzipped Worker ceiling. react-hook-form and Turnstile are in it deliberately.

Manual verification

Two operational prerequisites gate everything below, and neither is code. Until both are met, every submission is refused captcha_failed — the CMS requires a token on every public write.

  1. Provision a Turnstile widget covering this site's domains, and confirm SahajCloud's TURNSTILE_SECRET_KEY is the matching half of that same pair. Set PUBLIC__TURNSTILE_SITE_KEY in .env.production or the Cloudflare build variables.
  2. Then submit a contact form end to end and confirm a type: contact row reaches the CMS and is delivered to the form's recipient.
  3. Submit a subscribe form and confirm a type: subscribe row reaches the configured provider (activityLog or the provider dashboard).
  4. Confirm the remoteip question above (SahajCloud#808) on that first real submission — check the CMS logs for errorCodes on a refusal. This is the one thing that could make the whole path fail with nothing wrong at either end.
  5. In the admin, author a form with two 50% fields and confirm they pair up from the sm breakpoint and stack on a phone.
  6. Confirm an embedded form still renders after a client-side navigation to the page (not just a full load) — that is what explicit captcha rendering is for.
  7. Author a message block containing a link, and confirm it renders as a link. It used to be flattened to plain text.
  8. View a page's source (not the inspector) and confirm the <form> and its inputs are in the delivered HTML.

Notes for reviewer

  • One organism, not two. FormBuilder takes the CMS document directly. The parallel FormBuilderConfig type had one producer and one consumer, and FormBuilder had no caller but CmsForm, so the conversion layer only bridged two shapes of the same thing. See the review round below.
  • The form server-renders, and that was priced before it was chosen. RichText renders on every page, so react-hook-form and @marsidev/react-turnstile are in the Worker (dist/server 2.53 MB → 2.63 MB, 564 kB gzipped against a 3 MB ceiling) and in a 495 kB client chunk the route entries import statically, against a 42 kB lazy chunk before. The reviewer took SSR at that price. AGENTS.md and the FormBuilder README now carry the decision, since both previously said the opposite.
  • video: true in WEB_TRANSLATIONS_SELECT is not a drive-by. WebTranslations makes every group required, so the new upstream tab has to be selected or getWebTranslations stops compiling. It is in its own chore(types) commit. Nothing reads video.* yet, and lib/translations.en.json has no video group — pnpm sync:translations still needs running by someone with the key (it is not run in CI). I checked that no existing media.* key moved upstream, so nothing regresses meanwhile.
  • Every refusal shows one message. The intake distinguishes a failed captcha from a disposable address, but the only CMS-owned string for a failed send is forms.general.submit_error, and a translation key cannot be invented here. Richer copy needs the keys added upstream first.
  • country and state render as text inputs — the plugin's option lists are neither mirrored here nor returned by the read. A typed answer still submits the pair the collection expects.
  • Reviewed by /simplify and /code-review high; /security-review ran because server/** and .env* changed. One anomaly: /pr-review-toolkit:review-pr is not installed in this environment, so /code-review high stood in for it, and comment-rule-sync.mjs cannot resolve its canonical path from a worktree (no rule copy was touched).
Detail

The human review round.

  • Four threads were one change (3b99c91), confirmed before it was made. FormBuilder now takes the forms document. lib/cms-forms.ts becomes lib/submissions.ts holding only the wire contract; cmsFormConfig, formFields, FormBuilderConfig, lib/lexical-text.ts and the whole CmsForm/ directory are gone, as are the onSubmit, schema and captcha props. getNodeText returns to lexical-helpers.ts, where the heading converter reads it, and a message block and the confirmation render through RichText instead of being flattened — so an authored link or bold survives. Net −671 lines.
  • Turnstile is the published React package now (7193bd9). @marsidev/react-turnstile 1.6.1 replaces the hand-rolled explicit render: the module-scoped script-load promise, the widget-id ref and the cache-clearing rejection path are all the library's. execution: 'render' keeps the behaviour that mattered — a widget tied to the component's lifecycle rather than to Cloudflare's once-per-document scan, which a Vike client-side navigation never re-runs.
  • And then the wrapper went too (1fa39b3). Once the library landed, components/molecules/Turnstile/ mapped five props onto it and passed them through, for a single importer. FormBuilder renders the library itself; execution: 'render' and the page-locale language keep their reasoning at the call site, and the x-turnstile-token contract stays where it is owned, in lib/submissions.ts. Net −111 lines.
  • And the client-only barrel went with it (ca28108, 7766380). The ClientOnly + React.lazy wrapper and its skeleton fallback are gone, so RichText renders the real form on the server. Measured after: dist/server 2.63 MB raw / 564 kB gzipped, and a 495 kB (161 kB gzipped) client chunk that pages_slug_, entry-client-routing and both _embed routes import statically. Neither library touches the DOM while rendering. RichText.test.tsx now asserts the <form> and its inputs are in the server output, so putting the component back behind ClientOnly fails a test rather than passing quietly.
  • The "CMS Form" label is gone (77d4e38). The Ladle story kept the name of the organism that was folded into FormBuilder, so it read as a second component. It is "Form Builder" now, like every other organism story. The same label sat in the story and component JSDoc, types/vike.d.ts, .env.example, the README heading and docs/rules/zod-validation.md; all say "authored form". Two stale pointers from the same removal went too: the README's redirect warning named the deleted cmsFormConfig, and the story JSDoc pointed at a FormBuilder story that is itself.
  • URL safety stays hand-written, rebutted with evidence. The check is new URL(url) plus a scheme comparison, so a library would wrap the same platform parser; validator.isURL matches by regex, which is weaker for scheme allowlisting and far larger.

The adversarial review round (six threads, all adopted).

  • isSafeNavigationUrl carried two meanings at once (1e7c174). It excluded //host as if the rule were "stay on this site", while the http(s) arm permitted https://host — the same destination, plainly spelled. The exclusion bought nothing, and /\host, which browsers fold into //host, walked past it anyway. The rule is now the scheme alone: an authored redirect may leave the site, but it may not be javascript: or data:.
  • submitDisabled could dead-end the form (29489fd). Turnstile reports a blocked challenges.cloudflare.com by calling onToken(null), so the button greyed out permanently with nothing saying why. The refusal path already covers the case, so the prop is gone.
  • The body ceiling was opt-out (6b75e11). A chunked POST carries no content-length, Number(undefined ?? 0) is 0, and the body was read regardless. It refused honest large submissions and not unfriendly ones. submissionSchema's 40-pair bound is what stays.
  • Twelve literal span classes became one CSS directive (b0a2454). @source inline("sm:col-span-{1..12}") is Tailwind v4's answer to exactly this scanner problem, and scanner configuration belongs in the CSS. Confirmed against a real build: all twelve .sm\:col-span-N rules reach dist/client.
  • The isSafeHttpUrl re-export shim is gone (8154521). Its two importers now read from lib/urls, which owns the rule, and the tests moved with it.
  • The sender's name is matched by literal key (eaec47a) — see Contract impact. Verified against SahajCloud main.

What the earlier review passes caught, since the commits are where the reasoning lives:

  • A quoted form id would have silently refused every authored field. SahajCloud resolves the relationship with relationId(), which answers null for a string, leaving the intake unable to load the form and so with an empty authored-field allow-list. Base context keys would still pass, which is what would have made it look like it worked.
  • An authored width rendered nothing: the buckets were emitted from lib/, which layouts/tailwind.css does not @source, so sm:w-2/3 existed nowhere in the repo — and the container was flex flex-col, so no width could have paired two fields anyway.
  • The authored redirect.url reaches window.location.href. That line was unreachable before this branch, so making the form live makes the sink live. isSafeNavigationUrl gates it at the CMS boundary.
  • Turnstile cached a rejected script load forever: one blocked request would have left every later form in the visit unsubmittable, since Vike never reloads the document.
  • A repeated submissionData key is a 400 upstream, so an author naming a field locale or path had a form nobody could submit.

Rejected suggestions. Branching the form on the refusal code — whether the token was spent depends on where upstream refused, so re-challenging always is the only rule that cannot be wrong. Sharing the satisfies EmbeddedForm fixtures — they differ in what each test needs, and per-file Lexical fixtures are the existing house style.

Closes #78

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

🤖 Generated with Claude Code

https://claude.ai/code/session_01WzXYaXtdds4VRxr9NjdFPF

`pnpm types:cms` against SahajCloud main after #695 Phase 3 (#801):
`registrations`, `user-messages` and `form-submissions` are gone, replaced
by `user-submissions` with a `type` discriminator, and `forms` gains
`actionType` plus its conditional `recipient` / `client`.

The same sync brought a new `video` translations tab. `WebTranslations`
makes every group required, so the read has to select it or the cast in
`getWebTranslations` stops compiling.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WCGod1mebic2xdXWUP8fgE
`lib/cms-forms.ts` turns a `forms` document into the render config and the
create body for `POST /api/user-submissions`. Both shapes are fixed from
opposite ends, so the translation is pure and tested on its own.

Three choices worth stating:

- The plugin's percentage `width` is bucketed into Tailwind classes.
  Tailwind scans source, so an interpolated `w-[NN%]` produces no class at
  all.
- `country` and `state` render as text inputs. Their option lists live in the
  plugin and are not mirrored here; rendering nothing would drop a required
  field and fail the submission at the collection.
- The email answer is lifted to the `senderEmail` column and its pair
  dropped, so the address screening and delivery read cannot disagree with a
  copy in the blob.

FormBuilder gains a `captcha` slot and `submitDisabled`, both provider-
agnostic, and its example no longer names the retired
`/api/form-submissions` path.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WCGod1mebic2xdXWUP8fgE
`POST /api/submissions` forwards one submission to the CMS's
`POST /api/user-submissions`. The browser cannot make that call itself: the
create is authenticated with `SAHAJCLOUD_API_KEY`, and SahajCloud answers a
wildcard CORS origin with no credentials — the same pairing the live-preview
populate proxy already works around.

Three properties the tests pin, because the route attaches our API key:

- The body is re-validated (`submissionSchema`) before the CMS is called, and
  `type` is narrowed to the two form-backed intakes.
- Exactly one browser header crosses over, the captcha token. Forwarding
  `Origin` or `Referer` would put this site's host through the client's
  `allowedDomains` allowlist, which a server-to-server call is exempt from.
- A refusal forwards the intake's `errors[].data.code` and never its message,
  which is English written for a log. A CMS fault reads as 502, never as the
  browser's bad request.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WCGod1mebic2xdXWUP8fgE
A `forms` relationship node is the one reference in rich text that is
content rather than a link: the editor embedded it to be filled in, and it
has no page of its own. `CmsForm` composes FormBuilder, the Turnstile
widget and the submit call; the RichText `relationship` converter renders it
and leaves every other collection to the route mapper.

`Turnstile` renders **explicitly**, not through Cloudflare's automatic
document scan. Vike swaps the page under `<main>` on a client-side
navigation and that scan runs once per document load, so an auto-rendered
widget would appear on a full load and never again.

⚠ `PAGE_POPULATE` gains a narrow `forms` select, and it is not about
payload size. A collection absent from `populate` comes back fully
populated, and a form's `recipient` is a relationship to `managers` — so
without this entry a manager's record is serialized into the page's
hydration payload.

A refusal shows one message whatever its code. The intake distinguishes a
failed captcha from a disposable address, but this site has one CMS-owned
string for a failed send and a translation key cannot be invented here, so
the code decides only whether to re-challenge.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WCGod1mebic2xdXWUP8fgE
`server/AGENTS.md` covered reads only, which left the four load-bearing
facts about a public submission — why the browser cannot make the call, the
captcha header, the `errors[].data.code` envelope, and that `select` gates
reads alone — stated nowhere.

The FormBuilder README's `/api/form-submissions` example predates both auth
and the captcha, and its `getFormById` pointer names a function that does
not exist. Both now point at what is real.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WCGod1mebic2xdXWUP8fgE
The /simplify pass found two defects and several cleanups.

**Every page was paying for the form.** `RichText` renders on every route, so
importing `CmsForm` statically put `react-hook-form` and the resolver
(~38 kB minified) into the eager client chunk of every entry — the lean
embed routes included — and into the Worker bundle, for a component almost
no page contains. `CmsForm/index.tsx` is now a `ClientOnly` + `React.lazy`
barrel, the repo's documented pattern. Measured after: `dist/server` carries
only the wrapper, and react-hook-form sits in a 40 kB chunk no entry imports
statically. Nothing is lost by not server-rendering a form that submits
through `fetch`; the fallback still renders its heading.

**An authored width rendered nothing.** The percentage was bucketed into
three Tailwind classes emitted from `lib/`, which `layouts/tailwind.css` does
not `@source` — so `sm:w-2/3` existed nowhere in the repo and the other two
worked only by inheriting CSS from unrelated files. And the field container
was `flex flex-col`, so no width could have paired two fields anyway. Fields
now sit in a 12-column grid, single-column below `sm`, and the span classes
are written out one per column in a scanned file. `FormBuilderField.width` is
the percentage the editor authored, not a class name.

Also from the pass:

- `EmbeddedForm` replaces `Form` at every consumer, tied to
  `EMBEDDED_FORM_SELECT` through `EmbeddedFormSelect`, so the select and its
  renderer cannot drift. The old `as unknown as Form` asserted columns the
  select does not return.
- One Lexical text walker in `lib/lexical-text.ts`, with the separator as an
  argument — `getNodeText` was a second copy of it.
- `CmsFormSpec` collapses into `cmsFormConfig` plus a `submissionBody` that
  derives what it needs, removing a non-null assertion at every call site.
- `siteKey` is a prop defaulting to the env var, as `LocationSearch` does, so
  the story can show the captcha with Cloudflare's test key.
- `path` comes from `pageContext.urlPathname`, beside the locale, instead of
  `window.location`.
- The refusal `code` is no longer parsed by the form. Whether the captcha
  token was spent depends on where upstream refused, so re-challenging on
  every refusal is the only rule that cannot be wrong. The route still
  forwards the code, and `SubmissionResult` now types its responses.
- Turnstile's existing-script branch is gone: unreachable, and its live path
  would have hung the promise forever.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WCGod1mebic2xdXWUP8fgE
Findings from the review pass, the first one a break rather than a nit.

**A quoted form id would have refused every authored field.** SahajCloud
resolves the relationship with `relationId()`, which answers `null` for a
string — so `form: "12"` is accepted, the intake cannot load the form, and
the authored-field allow-list comes back empty: every field the editor named
is then refused as unknown while the base context keys still pass. It also
skips the `actionType`-versus-`type` guard and blanks the admin subject.
`submissionBody` now sends the form's own numeric id and `submissionSchema`
refuses a string, so this cannot ship again.

The rest:

- A repeated `submissionData` key is a 400 at the collection, so an author
  who names a field `locale` or `path` had a form nobody could submit. The
  author's answer wins; the context pair is skipped.
- `path` goes through `normalizeContentPath`, so the home page reports `/`
  rather than `+onBeforeRoute`'s `/index` spelling.
- A thrown `fetch` now re-challenges like any other failure. It could have
  reached the CMS and spent the token, so leaving the token in place let the
  retry send a spent one.
- Turnstile no longer caches a rejected script load. One blocked request
  would have left every later form in the visit captcha-less and
  permanently unsubmittable, since Vike never reloads the document.
- The challenge takes the page locale. Cloudflare's default follows the
  *browser's* language, so a Spanish page could serve an English challenge.
- The route refuses an oversized body on its declared length, before reading
  it.
- The unconfigured-captcha test stubs the env var instead of assuming it is
  unset — `.env.example` tells developers to set it.

Filed sydevs/SahajCloud#808: the CMS reads `cf-connecting-ip` off its own
request for Turnstile's `remoteip`, so a proxied submission presents this
Worker's address rather than the visitor's. Recorded in `server/AGENTS.md`
as the one thing needing an end-to-end test before anyone trusts it.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WCGod1mebic2xdXWUP8fgE
`forms.redirect.url` is a plain CMS text field with no upstream validation,
and `FormBuilder` assigns it to `window.location.href` on a successful
submission. That line was unreachable before this branch — FormBuilder had
no call site with real data — so making the form live from page content also
makes the sink live. An authored `javascript:` URL would run in this origin
for every visitor who submits the form.

`cmsFormConfig` now drops a redirect the browser must not be sent to, which
leaves the form showing its confirmation message instead. The guard sits
where the CMS value enters rather than at the sink, so there is one
enforcement point; `FormBuilderConfig.redirect` states that a caller owns
the scheme.

`isSafeHttpUrl` moves from `server/error-utils.ts` to `lib/urls.ts`, which
owns how a URL is spelled, and is re-exported so its existing importers do
not change. It is too strict alone here: `/thank-you` is the redirect an
editor is most likely to write and `new URL` cannot parse it. So
`isSafeNavigationUrl` accepts a root-relative path as well — excluding
`//host`, the one spelling that reads like a path and behaves like an
absolute URL.

Reaching the sink needs CMS write on `forms`, which no manager role grants,
so this is defence in depth rather than an open door.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WCGod1mebic2xdXWUP8fgE
The repo-wide `lib/urls.ts` convention listed the path and locale rules but
not the scheme guard, which is what stops a configured `javascript:` value
reaching an `href` — so the next person to plumb an external URL had nothing
pointing them at it. FormBuilder's redirect section says the same at the one
sink that navigates.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WCGod1mebic2xdXWUP8fgE
@cloudflare-workers-and-pages

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

Copy link
Copy Markdown

Deploying wemeditate-design with  Cloudflare Pages  Cloudflare Pages

Latest commit: 75180e4
Status: ✅  Deploy successful!
Preview URL: https://4032d424.wm-design.pages.dev
Branch Preview URL: https://claude-feat-78-forms-intake.wm-design.pages.dev

View logs

@cloudflare-workers-and-pages

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

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
wemeditate-web 75180e4 Commit Preview URL

Branch Preview URL
Sep 18 2026, 07:17 PM

@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Sep 17, 2026
@sydevs-bot

sydevs-bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 19:11Z resolve-conflicts · attempt 1 · session · done
  • 19:11Z resolve-conflicts · attempt 1 · session
  • 17:02Z address-review · attempt 1 · session · done
  • 17:02Z address-review · attempt 1 · session
  • 16:34Z address-review · attempt 1 · session · done

Written by the sydevs dispatcher. Sessions never edit this comment.

@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

The PR is the size of its ticket. #78 asked for five things — render the embedded form, submit to the unified intake, add Turnstile, re-sync types, retire the dead example path — and all five are here with nothing smuggled in beside them. The two heaviest calls are right: every wire-contract decision in a pure lib/cms-forms.ts, and the ClientOnly + React.lazy barrel that keeps react-hook-form out of the Worker and out of every route's eager chunk.

The cross-repo contract holds. I checked the producer side rather than taking the body's word for it, and the numeric form id, the x-turnstile-token header and the locale/path scan exemption are all as claimed.

Nothing blocking. Six findings; the two worth reading are both "does this need to exist" — a redirect guard whose one special case protects nothing while a different spelling gets past it, and a submitDisabled prop that turns a blocked captcha script into a permanently dead submit button.

Findings

  • should-fix lib/urls.ts:54 — the // exclusion blocks nothing isSafeHttpUrl already allows, and /\evil.com navigates off-site straight through it.
  • should-fix FormBuilder.tsx:165 — submitDisabled dead-ends the form when Turnstile fails to load, to save a round trip on an already-failing submission.
  • consider server/api-routes.ts:232 — the content-length ceiling is skipped by omitting the header.
  • consider FormBuilder.tsx:181 — @source inline("sm:col-span-{1..12}") replaces the twelve literals.
  • consider server/error-utils.ts:104 — one importer; repoint it and delete the shim.
  • consider lib/cms-forms.ts:169 — upstream matches the name field by the literal key name, which is an authoring constraint nothing documents.

What was checked

  • Ticket against diff: #78's five bullets and five acceptance criteria against git diff origin/main...c8fc598 — 35 files, ~1370 lines once regenerated payload-types.ts is set aside.
  • Read whole: lib/cms-forms.ts, lib/lexical-text.ts, lib/urls.ts, server/api-routes.ts, server/validation.ts, server/cms-types.ts, Turnstile.tsx, both CmsForm files, and the FormBuilder, RichText, cms-client, lexical-helpers and .env* diffs.
  • Consumer side, at SahajCloud 07e3e40: relationId does return null for a string, so the numeric-id fix is load-bearing rather than cosmetic. writeGuardPlugin requires x-turnstile-token on every client-originated user-submissions create and screens senderEmail for disposable domains. URL_EXEMPT_KEYS holds locale and path. allowedSubmissionKeys reads authored names off the live form, which is what makes the collision rule in submissionBody necessary.
  • Ran: new URL('/\\evil.com', 'https://site.com') to confirm the bypass; git grep isSafeHttpUrl to count the shim's importers; checked @source usage in layouts/tailwind.css.
  • Not checked: everything behind the two operational prerequisites. No Turnstile widget exists yet, so no real submission has been made, and SahajCloud#808's remoteip question stays open — it is still the one thing that could refuse every proxied submission with nothing wrong in this diff.

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


Generated by Claude Code

Comment thread lib/urls.ts Resolved
Comment thread server/api-routes.ts Resolved
Comment thread server/error-utils.ts Resolved
Comment thread lib/cms-forms.ts Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Sep 17, 2026
isSafeNavigationUrl carried two meanings at once. It excluded `//host` as
if the rule were "stay on this site", while the http(s) arm permitted
`https://host` — the same destination, spelled plainly. The exclusion
bought nothing, and `/\host`, which browsers fold into `//host`, walked
past it regardless.

The rule is the scheme: an authored redirect may leave the site, but it
may not be `javascript:` or `data:`. The branch and its test go.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RMWA5UmUx1tpsAZj6YbXjY
Turnstile reports a blocked or unreachable challenges.cloudflare.com by
calling onToken(null), and its script-load catch does the same. With
submitDisabled wired to `token == null`, CmsForm then held null forever:
a greyed button, an empty widget container, and nothing telling the
visitor why. Ad blockers and corporate proxies reach that state often.

Submitting without a token already refuses with captcha_failed, shows
forms.general.submit_error and remounts the widget. That path covers the
case, so the prop and its one caller go.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RMWA5UmUx1tpsAZj6YbXjY
The branch read content-length, which a chunked or streamed POST simply
omits: `Number(undefined ?? 0)` is 0, the check passes, and the next line
reads the whole body regardless. It refused an honest large submission
and not an unfriendly one.

submissionSchema on the following line bounds what can get through — 40
pairs, 5000 characters each — and that is the bound the CMS enforces too.
Bounding request size on a public route belongs in front of the Worker,
where it cannot be skipped.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RMWA5UmUx1tpsAZj6YbXjY
Tailwind v4 has `@source inline()` for exactly the scanner problem the
twelve literals worked around, and layouts/tailwind.css is already where
this repo configures scanning. fieldSpanClass interpolates again.

Confirmed against a real build: all twelve `.sm\:col-span-N` rules are in
dist/client, emitted by the directive alone.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RMWA5UmUx1tpsAZj6YbXjY
Two importers found the function in server/error-utils before it moved,
and a re-export kept them working. Repointing them at lib/urls, which
owns the rule, leaves it one home. The tests move with it.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RMWA5UmUx1tpsAZj6YbXjY
The email field is matched here by blockType, but prepareUserSubmission
matches the name field by the literal key `name` — the plugin has no name
block to match on instead. An author who calls it `fullName` gets a users
row named off the address, written on first contact and reused after.

Verified against SahajCloud main: upsertUserByEmail returns early on an
existing row, so the name is never revisited.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RMWA5UmUx1tpsAZj6YbXjY
`//evil.example` moves from the refused list to the accepted one:
isSafeNavigationUrl now gates the scheme, and an off-site redirect is an
editor's to make.

The oversized-body case drops its content-length header and exceeds
submissionSchema's 40-pair bound instead, which is the bound that is
still enforced.

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

Copy link
Copy Markdown
Contributor Author

Six adversarial-review threads, all adopted, replied to and resolved. Nothing rebutted, nothing left open.

Thread Commit
one rule for a navigable URL 1e7c174
submitDisabled dropped 29489fd
body ceiling deleted 6b75e11
@source inline for the spans b0a2454
isSafeHttpUrl shim deleted 8154521
the name key constraint eaec47a

Gate green: lint, tsc --noEmit, 683 tests, pnpm build. Span classes and an empty dist/server both checked against a real build.

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


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Sep 17, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review September 17, 2026 01:45
AGENTS.md told the next reader to keep `FormBuilder` out of the Worker,
and the README told them to import it through the barrel. Both are now
the opposite of the rule the PR ships.

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

Copy link
Copy Markdown
Contributor Author

Pushed at 7766380. No threads left open.

Adopted — server-rendered fields (ca28108). The ClientOnly + React.lazy barrel and its skeleton fallback are gone, so RichText renders the real form on the server.

Measured after: dist/server 2.63 MB raw, 564 kB gzipped, under Cloudflare's 3 MB gzipped ceiling. react-hook-form and Turnstile join a 495 kB (161 kB gzipped) client chunk that pages_slug_, entry-client-routing and both _embed routes import statically. Neither library touches the DOM while rendering.

AGENTS.md and the FormBuilder README both told the next reader to keep this out of the Worker. They carry the decision now (7766380). RichText.test.tsx asserts the <form> and its inputs are in the server output, so a revert fails a test.

Gate: lint 0 errors, tsc, 682 tests, pnpm build.

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


Generated by Claude Code

@sydevs-bot sydevs-bot added awaiting and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Sep 18, 2026

@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.

Ensure that there are no other remaining references to "CMS Form" - this labelling is quite unclear and unhelpful

@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed awaiting labels Sep 18, 2026
The Ladle story was still named "CMS Form", after the component it named
was folded into `FormBuilder`. It reads as a second organism that no
longer exists. Renamed to "Form Builder", matching every other organism
story.

The same label sat in six more places — the story and component JSDoc,
`types/vike.d.ts`, `.env.example`, the FormBuilder README heading and
`docs/rules/zod-validation.md`. All of them mean the form a content
editor authors, so they say that.

Two stale pointers left by the same removal go with it: the README's
redirect warning named `cmsFormConfig`, which is deleted and whose check
`FormBuilder` now does itself, and the story JSDoc sent the reader to a
FormBuilder story that is this one.

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

Copy link
Copy Markdown
Contributor Author

Pushed at 77d4e38. No threads left open.

Adopted — the story name. It is "Form Builder" now, matching every other organism story.

Swept the label out of the six other places it sat: the story and component JSDoc, types/vike.d.ts, .env.example, the FormBuilder README heading and docs/rules/zod-validation.md. Each means the form a content editor authors, so each says that. The PR body's Ladle pointer is updated too. The only "CMS format" left is in MeditationTemplate, about player frames.

Two stale pointers from the same removal went with it: the README's redirect warning named cmsFormConfig, deleted three rounds ago and a check FormBuilder now does itself, and the story JSDoc sent the reader to a FormBuilder story that is this one.

Gate: lint 0 errors, tsc, 682 tests. No source behaviour changed — comments, docs and one story label.

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


Generated by Claude Code

@sydevs-bot sydevs-bot added awaiting and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Sep 18, 2026
@sydevs-bot
sydevs-bot added this pull request to the merge queue Sep 18, 2026
@sydevs-bot sydevs-bot moved this from Revising to Approved in SYDevelopers Technical Roadmap Sep 18, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Sep 18, 2026
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Sep 18, 2026
#117 landed the same payload-types re-sync this branch carries, and answered
the new upstream `video` translations group differently. It moved
`WEB_TRANSLATIONS_SELECT` into `cms-types.ts` and derives `WebTranslations`
from it, so the query and the type have one owner. Took that structure and
dropped this branch's `video: true`, which existed only to satisfy the old
all-groups-required assertion that #117 removed. Nothing reads `video.*`.

FormBuilder's JSDoc and README conflicted on prose describing the `onSubmit`
prop and `FormBuilderConfig`, both deleted on this branch. Kept this branch's
docs: #117's substantive point — stop naming the deleted
`/api/form-submissions` and forward through a route this app owns — is what
`server/api-routes.ts` implements here as `POST /api/submissions`.

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

Copy link
Copy Markdown
Contributor Author

Merged main in. Both sides re-synced the same payload types, so only two hunks were a real choice.

The video translations group. #117 moved WEB_TRANSLATIONS_SELECT into cms-types.ts and derives WebTranslations from it. Took that, and dropped this branch's video: true — it existed only to satisfy the all-groups-required assertion #117 deleted. Nothing reads video.*.

FormBuilder docs. #117 rewrote JSDoc and README prose about the onSubmit prop and FormBuilderConfig, both deleted here. Kept this branch's docs: #117's point — stop naming /api/form-submissions, forward through a route this app owns — is POST /api/submissions in server/api-routes.ts.

⚠ The video: true bullet under "Notes for reviewer" above is now stale.

Gate green after the merge: lint 0 errors, tsc --noEmit, 682 tests, pnpm build.

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


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Sep 18, 2026
@sydevs-bot
sydevs-bot added this pull request to the merge queue Sep 18, 2026
Merged via the queue into main with commit 529164c Sep 18, 2026
11 checks passed
@sydevs-bot
sydevs-bot deleted the claude/feat-78-forms-intake branch September 18, 2026 19:18
@sydevs-bot sydevs-bot moved this from Approved to Done in SYDevelopers Technical Roadmap Sep 18, 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.

feat(forms): render contact & subscribe forms via unified intake

3 participants