@@ -160,9 +160,7 @@ <h3 class="text-lg font-medium leading-6 text-gray-900">Conversation List Displa
160
160
});
161
161
</ textarea >
162
162
</ div >
163
- < button id ="renderConversationListBtn " class ="mt-3 inline-flex items-center rounded-md bg-[#742ddd] px-3 py-2 text-sm text-white shadow-sm hover:bg-[#6211c8] ">
164
- Open Conversation List
165
- </ button >
163
+ < div id ="conversation-list-container "> </ div >
166
164
</ div >
167
165
</ div >
168
166
</ div >
@@ -239,22 +237,47 @@ <h3 class="text-lg font-medium leading-6 text-gray-900">Conversation List Displa
239
237
messenger . close ( ) ;
240
238
} ) ;
241
239
242
- document . getElementById ( 'renderConversationListBtn' ) . addEventListener ( 'click' , async ( ) => {
243
- messenger . destroy ( ) ;
244
- const conversationListMessenger = await loadMessenger ( {
245
- customMainComponent : ( { messenger, react } ) => ( props ) => {
246
- return react . createElement ( messenger . AgentProviderContainer , props , [
247
- react . createElement ( messenger . ConversationList ) ,
248
- ] ) ;
249
- }
250
- } ) ;
251
- await conversationListMessenger . initialize ( {
252
- appId : import . meta. env . VITE_APP_ID ,
253
- aiAgentId : import . meta. env . VITE_AI_AGENT_ID ,
254
- customApiHost : import . meta. env . VITE_CUSTOM_API_HOST ,
255
- customWebSocketHost : import . meta. env . VITE_CUSTOM_WS_HOST ,
256
- rootElement : document . getElementById ( 'messenger-container' ) ,
257
- } ) ;
240
+ const conversationListMessenger = await loadMessenger ( {
241
+ customMainComponent : ( { messenger, react } ) => ( props ) => {
242
+ react . useEffect ( ( ) => {
243
+ const observer = new MutationObserver ( ( mutations ) => {
244
+ const agentEntry = document . getElementById ( 'sb-agent-entry' ) ;
245
+ if ( agentEntry ) {
246
+ agentEntry . style . setProperty ( 'width' , '100%' , 'important' ) ;
247
+ agentEntry . style . setProperty ( 'height' , '100%' , 'important' ) ;
248
+ observer . disconnect ( ) ;
249
+ }
250
+ } ) ;
251
+
252
+ observer . observe ( document . body , {
253
+ childList : true ,
254
+ subtree : true
255
+ } ) ;
256
+
257
+ return ( ) => observer . disconnect ( ) ;
258
+ } , [ ] ) ;
259
+
260
+ return react . createElement ( 'div' ,
261
+ {
262
+ style : {
263
+ width : '300px' ,
264
+ height : '500px' ,
265
+ border : '1px solid #ccc' ,
266
+ marginTop : '20px' ,
267
+ }
268
+ } , react . createElement ( messenger . AgentProviderContainer , props , [
269
+ react . createElement ( messenger . ConversationList ) ,
270
+ ] ) ) ;
271
+ } ,
272
+ containerId : 'conversation-list-container' ,
273
+ useShadowDOM : false ,
274
+ } ) ;
275
+
276
+ await conversationListMessenger . initialize ( {
277
+ appId : import . meta. env . VITE_APP_ID ,
278
+ aiAgentId : import . meta. env . VITE_AI_AGENT_ID ,
279
+ customApiHost : import . meta. env . VITE_CUSTOM_API_HOST ,
280
+ customWebSocketHost : import . meta. env . VITE_CUSTOM_WS_HOST ,
258
281
} ) ;
259
282
</ script >
260
283
</ body >
0 commit comments