Skip to content

Add Commerce Client Widget (Cimulate) to PWA Storefront React template - #3890

Merged
sf-praveen-ningappa merged 15 commits into
developfrom
pwa_commerce_client_shopper_agent
Jun 23, 2026
Merged

Add Commerce Client Widget (Cimulate) to PWA Storefront React template#3890
sf-praveen-ningappa merged 15 commits into
developfrom
pwa_commerce_client_shopper_agent

Conversation

@sf-praveen-ningappa

@sf-praveen-ningappa sf-praveen-ningappa commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Description

Adds the Commerce Client messaging widget as an optional shopper-agent provider, selected via a new commerceAgent.provider config switch:

  • miaw (default) — existing Salesforce Embedded Messaging, unchanged.
  • commerce-client — loads the Commerce Client messaging UMD bundle (allowlisted to *.cimulate.ai) and renders it in a configurable display mode (panel/dialog/modal).

Existing MIAW storefronts are unaffected since provider defaults to miaw. No new package dependencies.

GUS Work Item: https://gus.lightning.force.com/lightning/r/ADM_Work__c/a07EE00002cVneQYAS/view

Screenshot 2026-06-19 at 4 02 19 PM
Screen.Recording.2026-06-17.at.10.23.46.AM.mov

Types of Changes

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Breaking change (could cause existing functionality to not work as expected)
  • Other changes (non-breaking changes that does not fit any of the above)

Changes

  • Add provider switch and Commerce Client config keys (commerceClientScriptSourceUrl, esDeveloperName, headerText, disclaimerMarkdown, commerceClientDisplayMode, commerceClientPanelWidth, commerceClientMode, commerceClientLogoUrl) in config/default.js / config-utils.js.
  • New use-commerce-client-messaging hook injects the widget once the bundle loads; new CommerceClientAgentWindow renders it, with panel mode docking a full-height right side panel.
  • ShopperAgent branches on provider; commerceClientScriptSourceUrl is validated against a *.cimulate.ai allowlist.
  • Header/floating-button open action is now provider-aware (openShopperAgentWidget), falling back to MIAW.
  • CSP: allowlist *.cimulate.ai in script-src/connect-src. CHANGELOG updated.

Sample COMMERCE_AGENT_SETTINGS:

{
"enabled": "true",
"provider": "commerce-client",
"commerceClientScriptSourceUrl": "https://cdn.search.cimulate.ai/copilot-widget/1.9.0/messaging.umd.js",
"scrt2Url": "https://q3sdb1504032026zs3.test2.my.pc-rnd.salesforce-scrt.com",
"salesforceOrgId": "00DQZ0000093xsn",
"esDeveloperName": "Q3FreeformAgent",
"headerText": "Commerce Client",
"disclaimerMarkdown": "This is AI and can make mistakes. More details at how-to.ai.",
"enableAgentFromHeader": "true",
"commerceClientMode": "messaging",
"commerceClientLogoUrl": "https://cimulate.ai/wp-content/uploads/2025/07/Parrot-Corner-1.png",
"commerceClientSearchConfig": {
"placeholder": "Search for best outdoor gears..."
}
}

How to Test-Drive This PR

  • Set commerceAgent.enabled truthy and provider: 'commerce-client', then provide scrt2Url, salesforceOrgId, esDeveloperName, and a *.cimulate.ai commerceClientScriptSourceUrl. Confirm the widget opens from the header button.
  • Regression: set provider back to miaw (or omit) and confirm existing MIAW chat is unchanged.
  • Rollback is config-only — flip provider back to miaw.

Checklists

General

  • Changes are covered by test cases
  • CHANGELOG.md updated with a short description of changes (not required for documentation updates)

Accessibility Compliance

Localization

  • Changes include a UI text update in the Retail React App (which requires translation)

@git2gus

git2gus Bot commented Jun 19, 2026

Copy link
Copy Markdown

Git2Gus App is installed but the .git2gus/config.json doesn't have right values. You should add the required configuration.

@cc-prodsec

cc-prodsec commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@sf-praveen-ningappa
sf-praveen-ningappa marked this pull request as ready for review June 19, 2026 23:08
@sf-praveen-ningappa
sf-praveen-ningappa requested a review from a team as a code owner June 19, 2026 23:08
Comment thread packages/template-retail-react-app/app/ssr.js
@sf-praveen-ningappa sf-praveen-ningappa changed the title Integrate Cimulate Widget to PWA Storefront React template Add Commerce Client Widget (Cimulate) to PWA Storefront React template Jun 19, 2026
Signed-off-by: sf-praveen-ningappa <pningappa@salesforce.com>
Comment thread packages/template-retail-react-app/app/hooks/use-commerce-client-messaging.js Outdated
Comment thread packages/template-retail-react-app/app/components/shopper-agent/index.jsx Outdated
shethj
shethj previously approved these changes Jun 23, 2026
Signed-off-by: sf-praveen-ningappa <pningappa@salesforce.com>
@sf-praveen-ningappa
sf-praveen-ningappa merged commit 85d3251 into develop Jun 23, 2026
72 of 73 checks passed
@sf-praveen-ningappa
sf-praveen-ningappa deleted the pwa_commerce_client_shopper_agent branch June 23, 2026 21:36
sf-praveen-ningappa added a commit that referenced this pull request Jul 10, 2026
Add cimulate.ai and sfcc-store-internal.net to the Content Security
Policy directives (script-src, connect-src, img-src) in the
pwa-kit-create-app ssr.js.hbs templates. This mirrors the CSP changes
already applied to template-retail-react-app in PR #3890, ensuring
newly scaffolded projects also allow the Commerce Client messaging
widget to load and connect.
sf-praveen-ningappa added a commit that referenced this pull request Jul 13, 2026
Add cimulate.ai and sfcc-store-internal.net to the Content Security
Policy directives (script-src, connect-src, img-src) in the
pwa-kit-create-app ssr.js.hbs templates. This mirrors the CSP changes
already applied to template-retail-react-app in PR #3890, ensuring
newly scaffolded projects also allow the Commerce Client messaging
widget to load and connect.
sf-praveen-ningappa added a commit that referenced this pull request Jul 13, 2026
Add cimulate.ai and sfcc-store-internal.net to the Content Security
Policy directives (script-src, connect-src, img-src) in the
pwa-kit-create-app ssr.js.hbs templates. This mirrors the CSP changes
already applied to template-retail-react-app in PR #3890, ensuring
newly scaffolded projects also allow the Commerce Client messaging
widget to load and connect.
vcua-mobify added a commit that referenced this pull request Jul 14, 2026
…cycle (#3930)

* Bump versions and update changelogs for 3.19.0-preview.0 release (#3920)

* feat: add Commerce Client CSP entries to create-app templates

Add cimulate.ai and sfcc-store-internal.net to the Content Security
Policy directives (script-src, connect-src, img-src) in the
pwa-kit-create-app ssr.js.hbs templates. This mirrors the CSP changes
already applied to template-retail-react-app in PR #3890, ensuring
newly scaffolded projects also allow the Commerce Client messaging
widget to load and connect.

* @W-23406559@ - Storefront Preview: honor x-pwakit-preview-parent header for session-cookie SameSite (#3922)

* @W-23406559@ - Storefront Preview: honor x-pwakit-preview-parent header for session-cookie SameSite

The __Host-pwakit_preview_ctx marker cookie set on the iframe document load can be bypassed by a CDN cache hit (the document is cacheable via s-maxage), so session cookies fall back to SameSite=Lax and are blocked in the cross-site Runtime Admin preview iframe.

Add a client-sent x-pwakit-preview-parent header (set by commerce-sdk-react when the storefront detects it is framed by a trusted, non-localhost Runtime Admin parent). It rides the never-cached SLAS token POST so it always reaches the origin. The BFF re-validates the header against STOREFRONT_PREVIEW_PARENT_ALLOW_LIST and, when trusted, issues session cookies as SameSite=None; Partitioned. Either signal (marker cookie or header) now suffices. The header is stripped before forwarding upstream to SLAS/SCAPI.

* @W-23406559@ - Strip x-pwakit-preview-parent upstream regardless of HttpOnly flag

The private-client SLAS proxy is wired whenever useSLASPrivateClient is
true, independent of MRT_ENABLE_HTTPONLY_SESSION_COOKIES, but the
x-pwakit-preview-parent strip lived inside handleHttpOnlyCookiesOnProxyReq
which only runs when the flag is on. A private-client deploy with the flag
off would therefore forward the internal preview-context header upstream to
SLAS.

Move the removeHeader(X_PREVIEW_PARENT) call out of the helper and run it
unconditionally right after applyProxyRequestHeaders() in both the private-
and public-client onProxyReq handlers. Add a regression test asserting the
header never reaches the upstream SLAS mock with the flag off.

* @W-23409029@ - Preserve SSR guest-login token when cookieDomain is set (order host-scoped deletion before Domain write) (#3924)

* @W-23409029@ - Preserve SSR guest-login token when cookieDomain is set (order host-scoped deletion before Domain write)

When commerceAPI.cookieDomain is set, makeAppendCookie now emits the host-scoped cookie deletion BEFORE the real Domain-scoped cookie. On a cookieless SSR load, commerce-sdk-isomorphic reconstructs the guest-login TokenResponse from the response's Set-Cookie headers with last-write-wins per name; the prior order let the trailing empty host-scoped deletion clobber the real token, leaving the SSR shopper token empty and 401-ing data-bearing routes (e.g. a PLP deep link). Regression of W-23388089. Browser cookie scoping (host vs Domain) is order-independent, so no browser-side behavior change.

* @W-23409029@ - Fix refresh-token SSR clobber; lock cookie emission order with tests

Addresses review feedback on #3924:

- Emit the opposite-refresh-cookie deletion (cc-nx / cc-nx-g) BEFORE the
  real refresh-token write. Both names map to refresh_token in
  commerce-sdk-isomorphic's SSR TokenResponse reconstruction
  (last-write-wins per token field, Domain ignored), so a trailing empty
  deletion clobbered the reconstructed refresh_token. Latent regardless of
  cookieDomain; benign only because SSR does not refresh within the request.
- Add a raw-emission-order test (host-scoped deletion before the real
  Domain write, for cc-at and cc-nx-g) and an SSR last-write-wins
  reconstruction test that recovers both the access and refresh tokens,
  with and without cookieDomain.
- Extend the CHANGELOG Bug Fix entry to cover the refresh-token path.

* @W-23409029@ - Address PR review: registered/logout/idp reconstruction tests + SDK pointer

Follow-up to #3924 review feedback:

- Add a registered-login reconstruction test (mirror of the guest case:
  cc-nx is the real refresh cookie, cc-nx-g the empty opposite-deletion), so
  the deletion-before-real ordering is pinned for both branches.
- Add a logout test asserting both cc-nx and cc-nx-g are emitted empty, so SSR
  cannot reconstruct a refresh token after expireHttpOnlySessionCookies.
- Extend the reconstruction test and the reconstructSsrTokens helper to also
  cover idp_access_token (SDK-reconstructed and body-stripped, same
  deletion-before-real ordering dependency as the access token).
- Document the cross-repo invariant in makeAppendCookie: the parser is
  commerce-sdk-isomorphic's server-side TokenResponse reconstruction
  (helpers/slasHelper), last-write-wins keyed by cookie name (Domain ignored);
  revisit this emission order if a future SDK version changes that.
- Fix prettier line-wrap in the test file (CI lint).

* Bump versions and update changelogs for 3.19.0 release (#3929)

* Bump versions to next dev cycle

Monorepo/SDK 3.19.0 -> 3.20.0-dev, commerce-sdk-react 5.3.0 -> 5.4.0-dev,
retail-react-app 10.1.0 -> 10.2.0-dev. pwa-kit-mcp is left at 0.5.0
(released independently, pinned to its latest published npm version).

---------

Co-authored-by: sf-praveen-ningappa <pningappa@salesforce.com>
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.

5 participants