Skip to content

Commit 76b1254

Browse files
committed
Fix conversationList style
1 parent 39779cb commit 76b1254

File tree

3 files changed

+44
-20
lines changed

3 files changed

+44
-20
lines changed

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
node-version: '20'
3030

3131
- name: Setup pnpm
32-
uses: pnpm/action-setup@v2
32+
uses: pnpm/action-setup@v4
3333
with:
3434
version: '8'
3535

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
**/node_modules
22
**/dist
3+
**/.vite

js/samples/basic/index.html

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,7 @@ <h3 class="text-lg font-medium leading-6 text-gray-900">Conversation List Displa
160160
});
161161
</textarea>
162162
</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>
166164
</div>
167165
</div>
168166
</div>
@@ -239,22 +237,47 @@ <h3 class="text-lg font-medium leading-6 text-gray-900">Conversation List Displa
239237
messenger.close();
240238
});
241239

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,
258281
});
259282
</script>
260283
</body>

0 commit comments

Comments
 (0)