Repository navigation
feat: shopping assistant FS v4 - SFS-3130 - #3275
Conversation
…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 -->
WalkthroughA new Changes
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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (10)
packages/core/cms/faststore/components/cms_component__shoppingassistant.jsoncpackages/core/cms/faststore/pages/cms_content_type__globalsections.jsoncpackages/core/cms/faststore/schema.jsonpackages/core/cms/faststore/sections.jsonpackages/core/src/components/ThirdPartyScripts/index.tspackages/core/src/components/ThirdPartyScripts/useShoppingAssistant.tsxpackages/core/src/components/cms/global/Components.tspackages/core/src/components/sections/ShoppingAssistant/ShoppingAssistant.tsxpackages/core/src/components/sections/ShoppingAssistant/index.tspackages/core/src/components/sections/ShoppingAssistant/section.module.scss
| "$ref": "#/components/Search" | ||
| }, | ||
| { | ||
| "$ref": "#/components/ShoppingAssistant" | ||
| } |
There was a problem hiding this comment.
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).
| return ( | ||
| <Section | ||
| className={`${styles.section} section-shopping-assistant layout__section`} | ||
| > | ||
| <div ref={scriptContainerRef} aria-hidden="true" hidden /> | ||
| </Section> |
There was a problem hiding this comment.
🧩 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"
doneRepository: vtex/faststore
Length of output: 119
🏁 Script executed:
cat -n packages/core/src/components/sections/ShoppingAssistant/ShoppingAssistant.tsx | head -30Repository: vtex/faststore
Length of output: 830
🏁 Script executed:
fd -i section packages/core/src/components --type f | head -20Repository: vtex/faststore
Length of output: 1448
🏁 Script executed:
find packages/core/src/components/sections -type f -name "*.tsx" -o -name "*.ts" | head -20Repository: 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 -10Repository: 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.tsxRepository: vtex/faststore
Length of output: 981
🏁 Script executed:
cat -n packages/core/src/components/sections/Section/index.tsRepository: 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 |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
rg -n -C2 "DISABLE_3P_SCRIPTS" --type ts --type tsxRepository: 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 tsRepository: 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 -20Repository: 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"
fiRepository: 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.
| 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.
|
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. |
What's the purpose of this pull request?
Adds Shopping Assistant to FS v4.
Summary by CodeRabbit
New Features