Skip to content

feat: shopping assistant FS v4 - SFS-3130 - #3275

Merged
eduardoformiga merged 5 commits into
canary-v2from
feat/shopping-assistant
Apr 21, 2026
Merged

eduardoformiga merged 5 commits into
canary-v2from
feat/shopping-assistant

Conversation

@eduardoformiga

@eduardoformiga eduardoformiga commented Apr 14, 2026 •

Copy link
Copy Markdown
Member

What's the purpose of this pull request?

Adds Shopping Assistant to FS v4.

Summary by CodeRabbit

New Features

  • Shopping Assistant Component: A new Shopping Assistant component is now available for use as a global page section. Users can add this component to their website pages to deliver shopping assistance capabilities throughout their site, powered by Agentic CX. Component setup and initial configuration required in Agentic CX > Dashboard.

…3242)

This feature enhances user interaction by allowing a webchat option that
can be toggled via hCMS.

<img width="600" alt="Screenshot 2026-03-23 at 17 55 23"
src="https://github.com/user-attachments/assets/31f05a33-5eb9-428b-85bb-590b1037f55f"
/>

- Introduced a new Webchat section with a corresponding component and
styles.
- Implemented `useWebchatScript` to manage the webchat script injection.
- Updated `Components.ts` to include the new Webchat component
dynamically.
- Added necessary JSON schema for the Webchat section in sections.json.

Run locally and see the webchat component added from hCMS to the code.

TBD

-
https://docs.google.com/document/d/11nyKPMYjcb87xow1Igc_iy8uHyp9bK1H0CBN7u5FerM/edit?tab=t.0#heading=h.f90kuwq3iwh6

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

* **New Features**
* Introduced a new Webchat widget section to the content management
system, enabling integration of webchat functionality into pages. The
widget is fully registered and ready to be configured and deployed
alongside other page sections.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
…nt (#3247)

- Updated sections.json to reflect the name change from "Webchat" to
"ShoppingAssistant" with updated descriptions.
- Replaced `useWebchatScript` with `useShoppingAssistant` in
ThirdPartyScripts.
- Introduced a new `useShoppingAssistant` hook to manage script
injection for the Shopping Assistant.
- Created a new Shopping Assistant component with corresponding styles
and structure.
- Removed the old Webchat component and its references.

This change enhances the user experience by providing a dedicated
Shopping Assistant feature.

<!--- Considering the context, what is the problem we'll solve? Where in
VTEX's big picture our issue fits in? Write a tweet about the context
and the problem itself. --->

<!--- Tell us the role of the new feature, or component, in its context.
Provide details about what you have implemented and screenshots if
applicable. --->

<!--- Describe the steps with bullet points. Is there any external link
that can be used to better test it or an example? --->

<!--- Add a link to a deploy preview from `starter.store` with this
branch being used. --->

<!--- Tip: You can get an installable version of this branch from the
CodeSandbox generated when this PR is created. --->

<!--- Spread the knowledge: is there any content you used to create this
PR that is worth sharing? --->

<!--- Extra tip: adding references to related issues or mentioning
people important to this PR may be good for the documentation and
reviewing process --->

<em>You may erase this after checking them all 😉</em>

**PR Title and Commit Messages**

- [ ] PR title and commit messages follow the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification
- Available prefixes: `feat`, `fix`, `chore`, `docs`, `style`,
`refactor`, `ci` and `test`

**PR Description**

- [ ] Added a label according to the PR goal - `breaking change`, `bug`,
`contributing`, `performance`, `documentation`..

**Dependencies**

- [ ] Committed the `pnpm-lock.yaml` file when there were changes to the
packages

**Documentation**

- [ ] PR description
- [ ] For documentation changes, ping `@Mariana-Caetano` to review and
update (Or submit a doc request)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

* **Documentation**
  * Renamed CMS section from "Webchat" to "Shopping Assistant."
* Updated section title and description with new setup instructions
pointing to the Agentic CX Dashboard.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Introduced a new Shopping Assistant component schema in `schema.json`.
- Updated references in `cms_content_type__globalsections.jsonc` to
include the Shopping Assistant.
- Created a new JSONC file for the Shopping Assistant component with its
properties and description.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

* **New Features**
* Shopping Assistant component is now available in the CMS for page
editors to use and configure.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@eduardoformiga
eduardoformiga requested a review from a team as a code owner April 14, 2026 20:27
@eduardoformiga
eduardoformiga requested review from lemagnetic and lucasfp13 and removed request for a team April 14, 2026 20:27
@coderabbitai

coderabbitai Bot commented Apr 14, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

A new ShoppingAssistant component is added to the FastStore CMS ecosystem, including schema definitions, a React component with a custom hook for third-party script injection, and CMS page configuration to enable it as a global section alongside existing components.

Changes

Cohort / File(s) Summary
CMS Schema & Configuration
packages/core/cms/faststore/components/cms_component__shoppingassistant.jsonc, packages/core/cms/faststore/pages/cms_content_type__globalsections.jsonc, packages/core/cms/faststore/schema.json, packages/core/cms/faststore/sections.json
New ShoppingAssistant component schema definition added with metadata and empty properties object. Global sections schema updated to include ShoppingAssistant as valid section reference. Main schema consolidated with component allowlists updated across multiple section definitions.
ShoppingAssistant Component
packages/core/src/components/sections/ShoppingAssistant/ShoppingAssistant.tsx, packages/core/src/components/sections/ShoppingAssistant/index.ts, packages/core/src/components/sections/ShoppingAssistant/section.module.scss
New React component that creates a container and integrates the useShoppingAssistant hook. Includes basic positioning styles and module export pattern. Component marked with $componentKey for CMS registration.
Third-party Script Hook & Integration
packages/core/src/components/ThirdPartyScripts/useShoppingAssistant.tsx, packages/core/src/components/ThirdPartyScripts/index.ts, packages/core/src/components/cms/global/Components.ts
New useShoppingAssistant hook injects third-party script (https://cdn.cloud.weni.ai/agentic-cx.js) via useEffect with container ref support and 3P script disable flag check. Hook exported from ThirdPartyScripts module. Dynamic component registration added to global COMPONENTS registry.

Sequence Diagram(s)

sequenceDiagram
    participant CMS as CMS Page
    participant React as React App
    participant SA as ShoppingAssistant<br/>Component
    participant Hook as useShoppingAssistant<br/>Hook
    participant ThirdParty as Third-party Script<br/>(CDN)

    CMS->>React: Render global section
    React->>SA: Mount ShoppingAssistant component
    SA->>SA: Create scriptContainerRef
    SA->>Hook: Initialize hook with ref
    alt DISABLE_3P_SCRIPTS not set
        Hook->>Hook: Create script element
        Hook->>SA: Append to containerRef<br/>or document.head
        SA->>ThirdParty: Load agentic-cx.js
        ThirdParty-->>SA: Script initialized
    else DISABLE_3P_SCRIPTS is set
        Hook->>Hook: Skip script injection
    end
    SA->>React: Render Section with hidden container
    React-->>CMS: Display on page
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • lemagnetic
  • renatomaurovtex

Poem

🛍️ A shopping assistant arrives,
Through script injection it thrives,
CMS schema extends with grace,
Third-party magic finds its place,
Hidden but alive, ready to guide! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly summarizes the main change: adding Shopping Assistant functionality to FastStore v4 with the ticket reference SFS-3130.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/shopping-assistant

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
packages/core/cms/faststore/schema.json (1)

4295-4302: Mirror the standard component metadata block here.

Every other component definition in this schema includes readOnly, writeOnly, deprecated, and $abstract. Keeping this entry aligned avoids schema-shape edge cases in downstream CMS tooling.

♻️ Suggested metadata block
     "ShoppingAssistant": {
       "$extends": ["#/$defs/base-component"],
       "$componentKey": "ShoppingAssistant",
       "$componentTitle": "Shopping Assistant",
       "title": "Shopping Assistant",
       "description": "To enable Shopping Assistant, make sure you have finished the setup at Agentic CX > Dashboard.",
       "type": "object",
-      "properties": {}
+      "properties": {},
+      "readOnly": false,
+      "writeOnly": false,
+      "deprecated": false,
+      "$abstract": false
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/core/cms/faststore/schema.json` around lines 4295 - 4302, The
ShoppingAssistant component definition is missing the standard metadata fields
causing schema-shape inconsistencies; update the "ShoppingAssistant" object (in
packages/core/cms/faststore/schema.json) to include the standard metadata keys —
add boolean/readOnly, writeOnly, deprecated and $abstract properties matching
the other component blocks — so its metadata mirrors the existing component
pattern and prevents downstream tooling edge cases.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/core/cms/faststore/schema.json`:
- Around line 4374-4378: The ShoppingAssistant component is currently included
in the $ALLOW_ALL_COMPONENTS list which makes it available to non-global types
(e.g., 404, 500, login); remove the "$ref": "#/components/ShoppingAssistant"
entry from the $ALLOW_ALL_COMPONENTS array and instead add a reference to
"#/components/ShoppingAssistant" only in the globalSections allowlist (or the
specific global section schema entry) so ShoppingAssistant is permitted only at
the page/global mount and not for non-global content types; update the schema
arrays that reference $ALLOW_ALL_COMPONENTS and globalSections accordingly
(symbols to locate: $ALLOW_ALL_COMPONENTS, ShoppingAssistant, globalSections).

In
`@packages/core/src/components/sections/ShoppingAssistant/ShoppingAssistant.tsx`:
- Around line 13-18: Update the ShoppingAssistant component's root Section
element to render a neutral wrapper instead of a semantic landmark by adding
as="div" to the Section props (modify the Section usage in ShoppingAssistant.tsx
where Section renders the container that currently only holds
scriptContainerRef/hidden div), so Section renders a div rather than a section.

In `@packages/core/src/components/ThirdPartyScripts/useShoppingAssistant.tsx`:
- Line 15: The current check in useShoppingAssistant.tsx uses if
(process.env.DISABLE_3P_SCRIPTS) which treats any non-empty string (e.g.,
"false") as truthy; update the hook to explicitly parse the env var (for example
compare lower-cased value to 'true' or '1', or use JSON.parse with a fallback)
and use that boolean to decide early return. Locate the condition inside the
useShoppingAssistant hook and replace the truthiness check with an explicit
boolean evaluation (e.g., const disable3p =
['true','1'].includes(process.env.DISABLE_3P_SCRIPTS?.toLowerCase()); if
(disable3p) return) so behavior matches the explicit handling used elsewhere.

---

Nitpick comments:
In `@packages/core/cms/faststore/schema.json`:
- Around line 4295-4302: The ShoppingAssistant component definition is missing
the standard metadata fields causing schema-shape inconsistencies; update the
"ShoppingAssistant" object (in packages/core/cms/faststore/schema.json) to
include the standard metadata keys — add boolean/readOnly, writeOnly, deprecated
and $abstract properties matching the other component blocks — so its metadata
mirrors the existing component pattern and prevents downstream tooling edge
cases.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1ca236ee-8c89-4d47-890a-d0e02234d1b3

📥 Commits

Reviewing files that changed from the base of the PR and between 0070f89 and a48e763.

📒 Files selected for processing (10)
  • packages/core/cms/faststore/components/cms_component__shoppingassistant.jsonc
  • packages/core/cms/faststore/pages/cms_content_type__globalsections.jsonc
  • packages/core/cms/faststore/schema.json
  • packages/core/cms/faststore/sections.json
  • packages/core/src/components/ThirdPartyScripts/index.ts
  • packages/core/src/components/ThirdPartyScripts/useShoppingAssistant.tsx
  • packages/core/src/components/cms/global/Components.ts
  • packages/core/src/components/sections/ShoppingAssistant/ShoppingAssistant.tsx
  • packages/core/src/components/sections/ShoppingAssistant/index.ts
  • packages/core/src/components/sections/ShoppingAssistant/section.module.scss

Comment on lines 4374 to 4378
"$ref": "#/components/Search"
},
{
"$ref": "#/components/ShoppingAssistant"
}

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.

⚠️ Potential issue | 🟠 Major

Keep ShoppingAssistant out of $ALLOW_ALL_COMPONENTS unless page-level mounts are intentional.

This alias is reused by non-global content types in this file (404, 500, login), so this change makes a script-injecting section available outside globalSections. That also opens the door to duplicate mounts when the assistant is configured globally and locally.

📌 Narrow the allowlist to the global section entry
           {
             "$ref": "#/components/Search"
-          },
-          {
-            "$ref": "#/components/ShoppingAssistant"
           }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/core/cms/faststore/schema.json` around lines 4374 - 4378, The
ShoppingAssistant component is currently included in the $ALLOW_ALL_COMPONENTS
list which makes it available to non-global types (e.g., 404, 500, login);
remove the "$ref": "#/components/ShoppingAssistant" entry from the
$ALLOW_ALL_COMPONENTS array and instead add a reference to
"#/components/ShoppingAssistant" only in the globalSections allowlist (or the
specific global section schema entry) so ShoppingAssistant is permitted only at
the page/global mount and not for non-global content types; update the schema
arrays that reference $ALLOW_ALL_COMPONENTS and globalSections accordingly
(symbols to locate: $ALLOW_ALL_COMPONENTS, ShoppingAssistant, globalSections).

Comment on lines +13 to +18
return (
<Section
className={`${styles.section} section-shopping-assistant layout__section`}
>
<div ref={scriptContainerRef} aria-hidden="true" hidden />
</Section>

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.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Inspecting the Section component used by ShoppingAssistant..."
fd -p '^Section\.(tsx|ts|jsx|js)$' packages/core/src/components/sections | while read -r file; do
  echo "== $file =="
  sed -n '1,220p' "$file"
done

Repository: vtex/faststore

Length of output: 119


🏁 Script executed:

cat -n packages/core/src/components/sections/ShoppingAssistant/ShoppingAssistant.tsx | head -30

Repository: vtex/faststore

Length of output: 830


🏁 Script executed:

fd -i section packages/core/src/components --type f | head -20

Repository: vtex/faststore

Length of output: 1448


🏁 Script executed:

find packages/core/src/components/sections -type f -name "*.tsx" -o -name "*.ts" | head -20

Repository: vtex/faststore

Length of output: 1448


🏁 Script executed:

find packages/core/src/components/sections/Section -type f \( -name "*.tsx" -o -name "*.ts" \) 2>/dev/null | head -10

Repository: vtex/faststore

Length of output: 170


🏁 Script executed:

cat packages/core/src/components/sections/Section/index.tsx 2>/dev/null || cat packages/core/src/components/sections/Section.tsx 2>/dev/null || echo "Not found yet, searching wider..."

Repository: vtex/faststore

Length of output: 91


🏁 Script executed:

cat -n packages/core/src/components/sections/Section/Section.tsx

Repository: vtex/faststore

Length of output: 981


🏁 Script executed:

cat -n packages/core/src/components/sections/Section/index.ts

Repository: vtex/faststore

Length of output: 100


Remove semantic landmark from script-only mount point.

The Section component defaults to rendering a <section> landmark (line 17 of Section.tsx: const Component = as ?? 'section'). Since ShoppingAssistant's only child is a hidden div, this creates an empty landmark that screen readers will announce with no accessible content. Use <Section as="div" ...> to render a neutral wrapper instead.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/core/src/components/sections/ShoppingAssistant/ShoppingAssistant.tsx`
around lines 13 - 18, Update the ShoppingAssistant component's root Section
element to render a neutral wrapper instead of a semantic landmark by adding
as="div" to the Section props (modify the Section usage in ShoppingAssistant.tsx
where Section renders the container that currently only holds
scriptContainerRef/hidden div), so Section renders a div rather than a section.

containerRef?: RefObject<HTMLElement | null>
): void {
useEffect(() => {
if (process.env.DISABLE_3P_SCRIPTS) return

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.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n -C2 "DISABLE_3P_SCRIPTS" --type ts --type tsx

Repository: vtex/faststore

Length of output: 85


🏁 Script executed:

#!/bin/bash
# Search for DISABLE_3P_SCRIPTS with corrected ripgrep syntax
rg -n -C2 "DISABLE_3P_SCRIPTS" --type ts

Repository: vtex/faststore

Length of output: 950


🏁 Script executed:

#!/bin/bash
# Also check for .env files and configuration
fd -e .env -e .env.example -e .env.local 2>/dev/null | head -20

Repository: vtex/faststore

Length of output: 80


🏁 Script executed:

#!/bin/bash
# Examine the specific file to understand the context
if [ -f "packages/core/src/components/ThirdPartyScripts/useShoppingAssistant.tsx" ]; then
  cat -n "packages/core/src/components/ThirdPartyScripts/useShoppingAssistant.tsx"
fi

Repository: vtex/faststore

Length of output: 1354


Parse DISABLE_3P_SCRIPTS explicitly instead of relying on string truthiness.

process.env values are strings; "false" evaluates as truthy, causing the script to disable unintentionally. This contrasts with the negated check in _app.tsx line 44, which suggests inconsistent handling.

Proposed fix
 export function useShoppingAssistant(
   containerRef?: RefObject<HTMLElement | null>
 ): void {
   useEffect(() => {
-    if (process.env.DISABLE_3P_SCRIPTS) return
+    const disable3PScripts =
+      (process.env.DISABLE_3P_SCRIPTS ?? '').toLowerCase() === 'true'
+    if (disable3PScripts) return
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (process.env.DISABLE_3P_SCRIPTS) return
const disable3PScripts =
(process.env.DISABLE_3P_SCRIPTS ?? '').toLowerCase() === 'true'
if (disable3PScripts) return
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/core/src/components/ThirdPartyScripts/useShoppingAssistant.tsx` at
line 15, The current check in useShoppingAssistant.tsx uses if
(process.env.DISABLE_3P_SCRIPTS) which treats any non-empty string (e.g.,
"false") as truthy; update the hook to explicitly parse the env var (for example
compare lower-cased value to 'true' or '1', or use JSON.parse with a fallback)
and use that boolean to decide early return. Locate the condition inside the
useShoppingAssistant hook and replace the truthiness check with an explicit
boolean evaluation (e.g., const disable3p =
['true','1'].includes(process.env.DISABLE_3P_SCRIPTS?.toLowerCase()); if
(disable3p) return) so behavior matches the explicit handling used elsewhere.

@codesandbox-ci

codesandbox-ci Bot commented Apr 14, 2026 •

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@eduardoformiga eduardoformiga changed the title Feat/shopping assistant feat: shopping assistant FS v4 Apr 14, 2026
@eduardoformiga eduardoformiga changed the title feat: shopping assistant FS v4 feat: shopping assistant FS v4 - SFS-3130 Apr 14, 2026

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

lgtm

@eduardoformiga
eduardoformiga merged commit 71dcde6 into canary-v2 Apr 21, 2026
3 checks passed
@eduardoformiga
eduardoformiga deleted the feat/shopping-assistant branch April 21, 2026 22:38
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