Skip to content

feat(settings): connect a brand's Webflow site, collection and fields in Settings › Integrations (Send to CMS #1331, phase 2 part 3: Webflow card) - #1505

Merged
gkhngyk merged 7 commits into
ansvisor:mainfrom
cihan-gyk:feature/cms-webflow-settings
Oct 25, 2026
Merged

gkhngyk merged 7 commits into
ansvisor:mainfrom
cihan-gyk:feature/cms-webflow-settings

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

#1331, phase 2, part 3: the Webflow card in Settings › Integrations. Web only. Stacked on #1504, which is stacked on #1503: merge those first. The card uses #1503's routes.

What the person sees (the active brand, under the product catalog):

  • No Webflow on the server (no COMPOSIO_WEBFLOW_AUTH_CONFIG_ID): "Webflow isn't set up on this server yet." Nothing else.
  • Not connected (admins and managers):
    • Token field: paste the site token. The hint says where to make it in Webflow and which scopes it needs (Sites: Read, CMS: Read and write).
    • Where the token goes: it goes from the browser to the API's same-origin proxy once, through lib/webflow-client.ts. It never passes through a server action, and it's cleared from the field once connected. This is the same path the catalog upload uses.
    • Refusals are named from the API's codes: refused, missing scopes, no site, and so on.
  • Connected:
    • a "Connected" badge and the site's name;
    • Replace token and Disconnect (with a confirm dialog);
    • the site picker (only when the token reaches several sites) and the collection picker;
    • Which field takes what: page content (rich text, required), meta title, meta description and JSON-LD.
      • Each picker lists only the fields of the right type that no other part takes, so one field can't take two parts.
      • Required fields are marked "(required)".
      • JSON-LD gets a note: in the template, wrap the field in a JSON-LD script embed.
    • Which map shows: the saved collection shows its saved map. Another collection starts from the map its fields suggest (feat(content): connect a brand's Webflow site for Send to CMS (Send to CMS #1331, phase 2 part 1: Webflow connection) #1503).
    • Save sends the map. If the API refuses it, its reasons (problems) are listed under the fields, e.g. a required field that Send to CMS doesn't fill.
  • Token refused: a "Token refused" badge, an amber note and the token field.
    • The card reads the connection again whenever Webflow answers auth_failed, changed or not_connected while the person works, so a refusal shows without a reload.
  • Members: where pages go ("Pages go to Blog Posts."), or that admins and managers can connect it. No controls, and no admin-only calls.

States kept honest:

  • A failed collections read keeps the site picker and says the collections couldn't be read, not that there are none.
  • A failed fields read says so and disables Save, so the previous collection's map can't be saved for another.
  • A saved site the token no longer reaches is dropped (or replaced by the token's one site).
  • Answers for another brand never show: reads are keyed by brand, site and collection, and their effects are cancelled.

Text: all through en.json (settings.webflow, ICU). The API's problems show as it words them, as the catalog card does with its errors.

Related issue

Part of #1331 (phase 2, Webflow). Stacked on #1504 → #1503.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. Without COMPOSIO_WEBFLOW_AUTH_CONFIG_ID: Settings › Integrations shows the Webflow card saying it isn't set up.
  2. With it (yours, with a real site token):
    • paste the token and Connect;
    • pick the blog collection, check the suggested fields and Save;
    • reload: the saved collection and map are back;
    • Replace token → Cancel goes back to the settings;
    • Disconnect asks first, then shows the token field.
  3. Sign in as a member: you see where pages go, and nothing to change.

I checked it locally in the browser at 1024px, in light and dark, with the API calls stubbed in the page (no Composio here):

  • the token form;
  • connect;
  • the collection and fields with the suggested map;
  • Save, and a refused map's problems;
  • the refused-token note.

Without Composio, it shows "not set up", as it should.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/): 0 errors; the 6 warnings are in files this PR doesn't touch
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

A pre-push review found these, all fixed before the commit:

  • a map that could be saved for the wrong collection after a failed fields read;
  • the site picker lost on a failed collections read;
  • refusals that didn't show until a reload;
  • a saved site that was gone;
  • remounting after each save;
  • one field picked for two parts;
  • strings joined in code, and select labels.

Web: yarn test (3,873 passed) and yarn build pass.

🤖 Generated with Claude Code

cihan-gyk and others added 5 commits October 25, 2026 16:49
…o CMS ansvisor#1331, phase 2 part 1: Webflow connection)

A brand connects its Webflow site with a site token, kept by Composio as
an API-key connected account under the brand's own Composio user, picks
the collection pages go to and which of its fields takes the body, meta
title, meta description and JSON-LD. 00283 adds brand_cms_connections
(members read; the server writes for admins and managers). Routes under
/api/cms/brands/:brandId/webflow connect, list collections and fields
with a suggested map, save the map and disconnect. The token is never
stored, logged or sent back.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…refusals narrowly (pre-push review)

- A new token is a second Composio account until the first is removed,
  so connect with allowMultiple; once the new one is saved, the brand's
  other Webflow accounts go (forgetWebflowAccounts), and a disconnect
  removes them all, keeping the row when Composio can't.
- Writes are tied to the account the request read: a map checked with a
  token replaced meanwhile isn't saved (409 changed), a late refusal marks
  only its own token, and a disconnect leaves a token connected meanwhile.
- Only a 401 or a missing Composio account is auth_failed; a 403 is
  no_access and changes nothing; a successful read connects a refused
  connection again.
- A collection's fields are given only for one on a site the token reaches.
- A missing brand answers not_found; a required field can't be the JSON-LD's.
- Unused exports dropped; composio.test.js covers the Webflow helpers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ction as draft items (Send to CMS ansvisor#1331, phase 2 part 2: Webflow send)

POST /api/content-drafts/send takes target 'webflow': each page becomes a
draft item in the brand's collection (00283) by its field map, or updates
the item its last send made there (a new one when it was deleted in
Webflow). Webflow's rich text has no tables, so a table goes as a list;
images wait for workspace files (CHAT-06); the meta description falls back
to the page's opening words; JSON-LD goes as its JSON to its own field.
The same 200 a day, 25 per send and pause apply. 00284 adds the
delivery's target and the item's collection, and reserve_content_deliveries
takes the target ('webhook' by default, so the earlier API still works).
A token Webflow refuses marks the connection auth_failed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… as they are (pre-push review)

- A table cell keeps its paragraphs, items and lines a space apart, and
  its links; a table a figure wraps is kept, a table in a cell read once;
  words or items outside a block become paragraphs; comments go; a
  picture counts as one image.
- A slug with nothing Latin left falls back to the draft's id, the same on
  every send, not the delivery's.
- 00284: a second Webflow send of a page while one is queued is refused
  under the cap's lock (in_progress), so two sends can't make two items.
- The item's id is kept even when the delivery's row was written meanwhile.
- A batch stops once Webflow refuses the token, closing the rest.
- The webhook callback answers only for webhook deliveries.
- An emptied JSON-LD field clears the item's old one; every "<" in it is
  escaped; the opening words stay within 160 characters.
- A taken slug says what to do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… in Settings › Integrations (Send to CMS ansvisor#1331, phase 2 part 3: Webflow card)

A Webflow card under the product catalog: admins and managers paste the
brand's site token (sent from the browser to the API's proxy once, never
through a server action), pick the site and collection pages go to, and
which field takes the page content, meta title, meta description and
JSON-LD (the collection's suggested map first), replace the token and
disconnect; members see where pages go. A refused token asks for a new
one; a connection changed meanwhile is read again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

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

Looks good, with follow-ups to fix before it's turned on.

What I checked:

  • The token's path. It goes once, from the field to POST /api/cms/brands/:id/webflow, as a JSON body through the same-origin proxy. The proxy forwards the body and logs none of it, and the token never goes in a URL or a server action. The API hands it to Composio and answers with the connection's shape only: no token and no Composio ids. The field is a password input with autocomplete off, as the AI Providers key is. Its value is gone once connected, on Cancel, and on a brand switch, because the form unmounts while the next brand is read. The client's console.error logs only a thrown fetch error, never the request.
  • Who sees what. The controls show for canManage (admin or manager), the same roles as the API's assertWriter. A member's card makes one call: the GET every member of the brand's organization may make. It never makes the collection reads or the writes, and a test checks that.
  • Another brand's answers. Reads are kept by the brand they were made for, effects cancel on a change, and the mapping remounts per brand.
  • States. The card covers not set up, can't be read, not connected, token refused (an amber note and the token form) and connected. If Webflow answers auth_failed, changed or not_connected while the person works, the card reads the connection again without a reload. A failed fields read disables Save, and a failed collections read keeps the site picker. Disconnect asks first.
  • Pickers. Every <Select> gets items of { value, label }, and its label names its trigger. Each part lists only the fields of its type that no other part takes, and the body has no "Not sent".
  • Words. All of them are in settings.webflow. Every code the client can return has a message, and invalid from the token form reads as a token that doesn't look right. The card says pages go as draft items, published in Webflow, and that's what #1504 sends.
  • What's live. Once this is merged, every workspace's Settings › Integrations shows the card. Until the API has COMPOSIO_WEBFLOW_AUTH_CONFIG_ID, it says Webflow isn't set up, as the Google cards do.

Low, follow-up (please fix before Webflow is turned on):

  1. webflow-card.tsx:407 and :513-517: the saved map comes back as it was saved. But if its field was deleted, or its type changed in Webflow, the picker shows "Not sent" ("Pick a field" for the body). map still holds the old slug, so Save sends it, and the API lists a problem about a field the picker doesn't show. When the fields arrive, keep only the parts whose field is among that part's choices, so what's saved is what's shown.
  2. webflow-card.tsx:534-538: each of the API's problems starts with its internal part key ("metaTitle: the collection has no field …", "body: pick the rich text field a page goes to"). Show the part's label (t('parts.metaTitle')) in place of the key, or have the API use the labels. Only the general toast is announced, not the list: give the list role="alert". Also tie the token hint (:301) to its field with aria-describedby, as the Send dialog does for its slug hint.
  3. webflow-card.tsx:201-208: with a refused token, a member sees "Token refused" beside "Pages go to Blog Posts.", but no page can go until someone pastes a new token. In that state, say so, e.g. "Webflow refused the token. Pages can't go there until an admin or manager pastes a new one."

cihan-gyk and others added 2 commits October 25, 2026 19:40
…-settings

# Conflicts:
#	server/.env.example
#	supabase/schema.sql
…sed parts by their labels, tell members a refused token stops sends (review)

- A saved part whose field was deleted or changed type in Webflow is left
  out when the fields arrive, so what's saved is what the pickers show.
- The API's problems name a part by its label ("Meta title: …"), in a
  list read out as an alert; the token hint describes its field.
- With the token refused, a member reads that pages can't go to Webflow
  until an admin or manager pastes a new one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

Thanks. All three are fixed, and main is merged forward.

@github-actions github-actions Bot removed the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 25, 2026

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

Looks good.

What I checked:

  • Earlier items.
    1. Done. When the fields arrive, fitting (webflow-card.tsx:49-61) keeps a part only while its field is still one of that part's choices. It uses the pickers' own rules: the part's type, never Name or Slug, and one part per field. So what's saved is what the pickers show. If the body's field is gone, Save stays off until one is picked. There's a test.
    2. Done. A problem names its part by its label (:458-461), from the API's part: … prefix (checkFieldMap), and the list is role="alert". The token hint is tied to its field with aria-describedby.
    3. Done. With the token refused, a member reads that pages can't go until an admin or manager pastes a new one (:220-221). There's a test.
  • Merge da34b6b6 changes nothing beyond merging its parents. Its server/.env.example and schema.sql are main's. On main, the PR is its six web files, and it merges cleanly.
  • Before the API is deployed. The card makes one read, GET /api/cms/brands/:id/webflow. An API without #1503 answers it with Express's plain 404, and the card reads that as a failure. Every member of every workspace then sees "Couldn't read the Webflow connection right now." under the catalog card in Settings › Integrations. Nothing else is called: no token form shows, so no one can try to connect. Nothing that works today changes.
  • After the deploy, until the API has COMPOSIO_WEBFLOW_AUTH_CONFIG_ID, the card says Webflow isn't set up.

If this merges before the API is deployed:

  1. web/src/lib/webflow-client.ts:107-121 and webflow-card.tsx:97-108: until the deploy, every workspace sees a failure in Settings for a feature it doesn't have yet. These routes always send a code with their own 404s (not_found for a brand that's gone). A 404 with no code means the API has no Webflow routes yet. Read it as not_configured, and have the card show notConfigured for that code. It then says "Webflow isn't set up on this server yet." until the deploy, which is what it says after the deploy until the setting is on. useCmsTarget (#1506) can treat the same code as a brand without Webflow, not as a failed read. The other way out is to merge this after the API is deployed.

@gkhngyk
gkhngyk merged commit f34bf4d into ansvisor:main Oct 25, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants