@salesforce/webapp-template-app-react-template-vibe-experimental 1.36.3 → 1.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.37.0](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.36.4...v1.37.0) (2026-02-19)
7
+
8
+ **Note:** Version bump only for package @salesforce/webapp-template-base-sfdx-project-experimental
9
+
10
+
11
+
12
+
13
+
14
+ ## [1.36.4](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.36.3...v1.36.4) (2026-02-19)
15
+
16
+ **Note:** Version bump only for package @salesforce/webapp-template-base-sfdx-project-experimental
17
+
18
+
19
+
20
+
21
+
6
22
  ## [1.36.3](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.36.2...v1.36.3) (2026-02-19)
7
23
 
8
24
  **Note:** Version bump only for package @salesforce/webapp-template-base-sfdx-project-experimental
@@ -11,7 +11,7 @@
11
11
  "@radix-ui/react-label": "^2.1.8",
12
12
  "@radix-ui/react-select": "^2.2.6",
13
13
  "@radix-ui/react-slot": "^1.2.4",
14
- "@salesforce/agentforce-conversation-client": "^1.36.2",
14
+ "@salesforce/agentforce-conversation-client": "^1.36.4",
15
15
  "@salesforce/sdk-data": "^1.11.2",
16
16
  "@salesforce/webapp-experimental": "*",
17
17
  "@tailwindcss/vite": "^4.1.17",
@@ -4380,9 +4380,9 @@
4380
4380
  ]
4381
4381
  },
4382
4382
  "node_modules/@salesforce/agentforce-conversation-client": {
4383
- "version": "1.36.2",
4384
- "resolved": "https://registry.npmjs.org/@salesforce/agentforce-conversation-client/-/agentforce-conversation-client-1.36.2.tgz",
4385
- "integrity": "sha512-P6RTHgjQpGjznC7lKNZVC/oi+QEXuWROS7mzYNfg00Y/pIfEpLCWpcMVoGCSkQToRfYiY7/pyGOxyWptiLxnGA==",
4383
+ "version": "1.36.4",
4384
+ "resolved": "https://registry.npmjs.org/@salesforce/agentforce-conversation-client/-/agentforce-conversation-client-1.36.4.tgz",
4385
+ "integrity": "sha512-FIb73SFH1qjUm++aCj6a4uS2mYGZSvoefNLO/6DoyYGkh27GXCnUfgVHD0MR8ymt4WENgBIsujEz2cA4brpqxQ==",
4386
4386
  "license": "SEE LICENSE IN LICENSE.txt",
4387
4387
  "dependencies": {
4388
4388
  "@lightning-out/application": "2.1.1-rc.2"
@@ -17,7 +17,7 @@
17
17
  "@radix-ui/react-label": "^2.1.8",
18
18
  "@radix-ui/react-select": "^2.2.6",
19
19
  "@radix-ui/react-slot": "^1.2.4",
20
- "@salesforce/agentforce-conversation-client": "^1.36.2",
20
+ "@salesforce/agentforce-conversation-client": "^1.36.4",
21
21
  "@salesforce/sdk-data": "^1.11.2",
22
22
  "@salesforce/webapp-experimental": "*",
23
23
  "@tailwindcss/vite": "^4.1.17",
@@ -4,23 +4,46 @@
4
4
  * For full license text, see the LICENSE.txt file
5
5
  */
6
6
 
7
- import {
8
- embedAgentforceClient,
9
- type EmbedAgentforceClientResult,
10
- } from "@salesforce/agentforce-conversation-client";
11
- import { useEffect, useRef } from "react";
7
+ import { embedAgentforceClient } from "@salesforce/agentforce-conversation-client";
8
+ import { useEffect } from "react";
12
9
  import type {
13
10
  ResolvedEmbedOptions,
14
11
  AgentforceConversationClientProps,
15
12
  } from "../types/conversation";
16
13
 
17
- async function resolveEmbedOptions(): Promise<ResolvedEmbedOptions> {
18
- if (window.location.hostname === "localhost") {
19
- const res = await fetch("/__lo/frontdoor");
20
- if (!res.ok) console.error("frontdoor fetch failed");
21
- const { frontdoorUrl } = await res.json();
22
- return { frontdoorUrl: frontdoorUrl };
14
+ const GLOBAL_HOST_ID = "agentforce-conversation-client-global-host";
15
+ const SINGLETON_KEY = "__agentforceConversationClientSingleton";
16
+
17
+ interface AgentforceConversationClientSingleton {
18
+ initPromise?: Promise<void>;
19
+ initialized: boolean;
20
+ }
21
+
22
+ interface WindowWithAgentforceSingleton extends Window {
23
+ [SINGLETON_KEY]?: AgentforceConversationClientSingleton;
24
+ }
25
+
26
+ function getSingleton(): AgentforceConversationClientSingleton {
27
+ const win = window as WindowWithAgentforceSingleton;
28
+ if (!win[SINGLETON_KEY]) {
29
+ win[SINGLETON_KEY] = {
30
+ initialized: false,
31
+ };
23
32
  }
33
+ return win[SINGLETON_KEY]!;
34
+ }
35
+
36
+ function getOrCreateGlobalHost(): HTMLDivElement {
37
+ let host = document.getElementById(GLOBAL_HOST_ID) as HTMLDivElement | null;
38
+ if (!host) {
39
+ host = document.createElement("div");
40
+ host.id = GLOBAL_HOST_ID;
41
+ document.body.appendChild(host);
42
+ }
43
+ return host;
44
+ }
45
+
46
+ function getDefaultEmbedOptions(): ResolvedEmbedOptions {
24
47
  return { salesforceOrigin: window.location.origin };
25
48
  }
26
49
 
@@ -34,39 +57,71 @@ export function AgentforceConversationClient({
34
57
  salesforceOrigin,
35
58
  frontdoorUrl,
36
59
  }: AgentforceConversationClientProps) {
37
- const containerRef = useRef<HTMLDivElement>(null);
38
- const embedResultRef = useRef<EmbedAgentforceClientResult | null>(null);
39
-
40
60
  useEffect(() => {
41
- const container = containerRef.current;
42
- if (!container) return;
61
+ const singleton = getSingleton();
62
+ if (singleton.initialized || singleton.initPromise) {
63
+ return;
64
+ }
43
65
 
44
- resolveEmbedOptions().then((options) => {
45
- try {
46
- const result = embedAgentforceClient({
47
- container,
48
- salesforceOrigin: salesforceOrigin ?? options.salesforceOrigin,
49
- frontdoorUrl: frontdoorUrl ?? options.frontdoorUrl,
50
- agentforceClientConfig: agentforceClientConfig,
51
- });
52
- embedResultRef.current = result;
53
- } catch (err) {
54
- console.error("AgentforceConversationClient: failed to embed Agentforce client", err);
66
+ const initialize = (options: ResolvedEmbedOptions) => {
67
+ // If already initialized while this flow was in progress, no-op.
68
+ if (singleton.initialized) {
69
+ return;
55
70
  }
56
- });
71
+ const existingEmbed = document.querySelector('lightning-out-application[data-lo="acc"]');
72
+ if (existingEmbed) {
73
+ singleton.initialized = true;
74
+ return;
75
+ }
76
+ const host = getOrCreateGlobalHost();
77
+
78
+ embedAgentforceClient({
79
+ container: host,
80
+ salesforceOrigin: salesforceOrigin ?? options.salesforceOrigin,
81
+ frontdoorUrl: frontdoorUrl ?? options.frontdoorUrl,
82
+ agentforceClientConfig: agentforceClientConfig,
83
+ });
84
+ singleton.initialized = true;
85
+ };
86
+
87
+ const shouldFetchFrontdoor = window.location.hostname === "localhost";
88
+
89
+ if (shouldFetchFrontdoor) {
90
+ singleton.initPromise = fetch("/__lo/frontdoor")
91
+ .then(async (res) => {
92
+ if (!res.ok) {
93
+ console.error("frontdoor fetch failed");
94
+ return;
95
+ }
96
+ const { frontdoorUrl: resolvedFrontdoorUrl } = await res.json();
97
+ initialize({ frontdoorUrl: resolvedFrontdoorUrl });
98
+ })
99
+ .catch((err) => {
100
+ console.error("AgentforceConversationClient: failed to fetch frontdoor URL", err);
101
+ })
102
+ .finally(() => {
103
+ singleton.initPromise = undefined;
104
+ });
105
+ } else {
106
+ singleton.initPromise = Promise.resolve()
107
+ .then(() => {
108
+ initialize(getDefaultEmbedOptions());
109
+ })
110
+ .catch((err) => {
111
+ console.error("AgentforceConversationClient: failed to embed Agentforce client", err);
112
+ })
113
+ .finally(() => {
114
+ singleton.initPromise = undefined;
115
+ });
116
+ }
57
117
 
58
118
  return () => {
59
- embedResultRef.current = null;
119
+ // Intentionally no cleanup:
120
+ // This component guarantees a single LO initialization per window.
60
121
  };
61
122
  }, [salesforceOrigin, frontdoorUrl, agentforceClientConfig]);
62
123
 
63
- return (
64
- <div
65
- ref={containerRef}
66
- className="agentforce-conversation-client-container"
67
- id="agentforce-conversation-client-container"
68
- />
69
- );
124
+ return null;
70
125
  }
71
126
 
72
127
  export default AgentforceConversationClient;
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/webapp-template-base-sfdx-project-experimental",
3
- "version": "1.36.3",
3
+ "version": "1.37.0",
4
4
  "description": "Base SFDX project template",
5
5
  "private": true,
6
6
  "files": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/webapp-template-app-react-template-vibe-experimental",
3
- "version": "1.36.3",
3
+ "version": "1.37.0",
4
4
  "description": "Vibe coding starter app template",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "author": "",
@@ -14,9 +14,6 @@
14
14
  },
15
15
  "scripts": {
16
16
  "clean": "rm -rf dist",
17
- "build": "npx tsx ../../cli/src/index.ts apply-patches packages/template/app/appreacttemplatevibe packages/template/base-app/base-react-app packages/template/app/appreacttemplatevibe/dist --reset",
18
- "test": "npm run build && cd dist/force-app/main/default/webapplications/appreacttemplatevibe && npm ci && npm run build",
19
- "test:coverage": "npm run test",
20
17
  "dev": "cd dist/force-app/main/default/webapplications/appreacttemplatevibe && npm install && npm run dev",
21
18
  "watch": "npx tsx ../../cli/src/index.ts watch-patches packages/template/app/appreacttemplatevibe packages/template/base-app/base-react-app packages/template/app/appreacttemplatevibe/dist"
22
19
  },
@@ -37,10 +34,10 @@
37
34
  "build": {
38
35
  "executor": "@salesforce/webapp-template-cli-experimental:apply-patches"
39
36
  },
40
- "test": {
37
+ "build:dist-app": {
41
38
  "executor": "@salesforce/webapp-template-cli-experimental:build-dist-app"
42
39
  }
43
40
  }
44
41
  },
45
- "gitHead": "7eef94f53086bb08b0545f5f61d3cbfed3fe0197"
42
+ "gitHead": "0b6a6bfed73f248fb4e32cdbcee05fd0af19752b"
46
43
  }