Skip to content

Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.

fix(settings): ask for the Webflow site first when a token reaches several, and focus its picker (#1676)

Cihan235f7a48c14c
diff --git a/web/messages/en.json b/web/messages/en.json
index c9916d440..e0efec68b 100644
--- a/web/messages/en.json
+++ b/web/messages/en.json
@@ -8309,6 +8309,7 @@
"connecting": "Connecting…",
"connectedToast": "Webflow connected",
"connectedSetupToast": "Webflow connected. Now pick a collection and save.",
+ "connectedPickSiteToast": "Webflow connected. Now pick the site and the collection, and save.",
"refusedNote": "Webflow refused the saved token. Paste a new one to send pages again.",
"replaceToken": "Replace token",
"cancel": "Cancel",
@@ -8319,6 +8320,7 @@
"siteLabel": "Site",
"sitePlaceholder": "Pick a site",
"setupStep": "Last step: pick the collection your pages go to, check which field takes what, then Save. Pages can't be sent to Webflow until then.",
+ "setupStepSite": "Last step: pick the site and the collection your pages go to, check which field takes what, then Save. Pages can't be sent to Webflow until then.",
"collectionLabel": "Collection",
"collectionPlaceholder": "Pick a collection",
"loadingCollections": "Reading the site's collections…",
diff --git a/web/src/components/settings/webflow-card.test.tsx b/web/src/components/settings/webflow-card.test.tsx
index 4754a8036..f4ee4593b 100644
--- a/web/src/components/settings/webflow-card.test.tsx
+++ b/web/src/components/settings/webflow-card.test.tsx
@@ -78,6 +78,8 @@ const badges = () =>
[...container.querySelectorAll('[data-slot="badge"]')].map((b) => b.textContent);
const SETUP_STEP =
"Last step: pick the collection your pages go to, check which field takes what, then Save. Pages can't be sent to Webflow until then.";
+const SETUP_STEP_SITE =
+ "Last step: pick the site and the collection your pages go to, check which field takes what, then Save. Pages can't be sent to Webflow until then.";
const option = (text: string) =>
[...document.querySelectorAll<HTMLElement>('[role="option"]')].find(
(o) => o.textContent === text,
@@ -158,6 +160,80 @@ describe('WebflowCard', () => {
expect(document.activeElement).toBe(picker('Collection'));
});
+ it('asks for the site first when the token reaches several, and focuses its picker (#1601)', async () => {
+ client.connectWebflow.mockResolvedValue({
+ ok: true,
+ connection: {
+ ...CONNECTED,
+ siteId: null,
+ collectionId: null,
+ collectionName: null,
+ fieldMap: {},
+ },
+ sites: [],
+ });
+ client.listWebflowCollections.mockImplementation(async (_brand: string, siteId?: string) => ({
+ ok: true,
+ sites: [
+ { id: 's1', name: 'Acme' },
+ { id: 's2', name: 'Acme Shop' },
+ ],
+ siteId: siteId ?? null,
+ collections: siteId ? [{ id: 'c1', name: 'Blog Posts', slug: 'post' }] : [],
+ }));
+ await render();
+ await typeToken('wf-token-123');
+ expect(toast.success).toHaveBeenCalledWith(
+ 'Webflow connected. Now pick the site and the collection, and save.',
+ );
+ expect(container.textContent).toContain(SETUP_STEP_SITE);
+ expect(document.activeElement).toBe(picker('Site'));
+
+ await click(picker('Site'));
+ const shop = option('Acme Shop')!;
+ await act(async () => {
+ shop.dispatchEvent(new MouseEvent('mousemove', { bubbles: true }));
+ });
+ await click(shop);
+ expect(client.listWebflowCollections).toHaveBeenLastCalledWith('b1', 's2');
+ // The site picked, the line asks for the collection alone.
+ expect(container.textContent).toContain(SETUP_STEP);
+ });
+
+ it('asks for the site while the sites are read, not for the collection alone first (#1601)', async () => {
+ client.readWebflow.mockResolvedValue({
+ ok: true,
+ configured: true,
+ connection: {
+ ...CONNECTED,
+ siteId: null,
+ collectionId: null,
+ collectionName: null,
+ fieldMap: {},
+ },
+ });
+ let answer!: (value: unknown) => void;
+ client.listWebflowCollections.mockReturnValue(new Promise((resolve) => (answer = resolve)));
+ await render();
+ expect(container.textContent).toContain("Reading the site's collections…");
+ expect(container.textContent).toContain(SETUP_STEP_SITE);
+ expect(container.textContent).not.toContain(SETUP_STEP);
+
+ await act(async () => {
+ answer({
+ ok: true,
+ sites: [
+ { id: 's1', name: 'Acme' },
+ { id: 's2', name: 'Acme Shop' },
+ ],
+ siteId: null,
+ collections: [],
+ });
+ });
+ expect(container.textContent).toContain(SETUP_STEP_SITE);
+ expect(container.textContent).not.toContain(SETUP_STEP);
+ });
+
it('says the setup isn’t finished until a collection is saved', async () => {
client.readWebflow.mockResolvedValue({
ok: true,
diff --git a/web/src/components/settings/webflow-card.tsx b/web/src/components/settings/webflow-card.tsx
index 238c9c822..ab4bf7600 100644
--- a/web/src/components/settings/webflow-card.tsx
+++ b/web/src/components/settings/webflow-card.tsx
@@ -295,8 +295,17 @@ function TokenForm({
return;
}
setToken('');
- // A new token for the same site keeps its collection; else the setup's last step is left.
- toast.success(t(result.connection.collectionId ? 'connectedToast' : 'connectedSetupToast'));
+ // A new token for the same site keeps its collection; else the setup's last step is left,
+ // with the site to pick first when the token reaches several (none saved then).
+ toast.success(
+ t(
+ result.connection.collectionId
+ ? 'connectedToast'
+ : result.connection.siteId
+ ? 'connectedSetupToast'
+ : 'connectedPickSiteToast',
+ ),
+ );
onConnected(result.connection);
};
@@ -493,6 +502,9 @@ function WebflowMapping({
return part ? `${t(`parts.${part}`)}: ${problem.slice(part.length + 2)}` : problem;
};
const siteItems = sites.map((s) => ({ value: s.id, label: s.name }));
+ // A token for several sites saves none (#1601): the site comes first. While
+ // the sites are read, no site means several, so the line doesn't change.
+ const siteFirst = !siteId && (siteRead === null || sites.length > 1);
const collectionItems = (collections ?? []).map((c) => ({ value: c.id, label: c.name }));
const required = new Set((fields ?? []).filter((f) => f.required).map((f) => f.slug));
@@ -501,7 +513,7 @@ function WebflowMapping({
{!connection.collectionId && (
<div className="flex items-start gap-2 rounded-md border border-amber-200 bg-amber-50 p-3 text-sm text-amber-800 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-300">
<AlertTriangle className="mt-0.5 h-4 w-4 shrink-0" />
- <span>{t('setupStep')}</span>
+ <span>{t(siteFirst ? 'setupStepSite' : 'setupStep')}</span>
</div>
)}
{sites.length > 1 && (
@@ -510,6 +522,8 @@ function WebflowMapping({
items={siteItems}
value={siteId}
placeholder={t('sitePlaceholder')}
+ // A token for several sites saves none: the site comes first (#1601).
+ autoFocus={focusCollection && !siteId}
onChange={(value) => {
setSiteId(value);
setCollectionId(null);