diff --git a/package.json b/package.json index 02c5e90..d951ad1 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ "lint": "eslint 'src/**/*.{ts,vue}'", "test": "vitest", "test-ci": "vitest --run", - "prepublishOnly": "npm run build" + "prepublishOnly": "npm run build", + "prepare": "npm run build" }, "peerDependencies": { "vue": "^3.0.4" diff --git a/src/components/chat/ChatInterface.vue b/src/components/chat/ChatInterface.vue index a082cd3..f73ba51 100644 --- a/src/components/chat/ChatInterface.vue +++ b/src/components/chat/ChatInterface.vue @@ -44,7 +44,6 @@ " @session-click="handleSessionClick" @collection-click="handleCollectionClick" - @share-session="handleShareSession" /> @@ -472,6 +471,10 @@ const props = defineProps({ type: Boolean, default: true, }, + customCanvasHandlers: { + type: Array, + default: () => [], + }, }); const emit = defineEmits([]); @@ -563,7 +566,7 @@ watch(chatAttachments, async (newAttachments) => { throw Error("Upload failed"); } } catch (e) { - console.log("something went wrong", e); + console.error("something went wrong", e); attachment.upload_status = "error"; } } @@ -579,6 +582,14 @@ registerMessageHandler("meeting_recorder", MeetingRecorder); registerCanvasHandler("meeting_recorder", MeetingRecorderCanvas); +if (Array.isArray(props.customCanvasHandlers)) { + for (const handler of props.customCanvasHandlers) { + if (handler && handler.type && handler.component) { + registerCanvasHandler(handler.type, handler.component); + } + } +} + const isStaticPage = ref(false); const chatWindowRef = ref(null); const headerRef = ref(null); @@ -729,20 +740,28 @@ watch( { immediate: true }, ); -const scrollToBottom = () => { +const scrollToLatestUserMessage = () => { const chatWindow = chatWindowRef.value; if (!chatWindow) return; + nextTick(() => { - chatWindow.scroll({ - top: chatWindow.scrollHeight, - behavior: "smooth", - }); + const userMessages = chatWindow.querySelectorAll('[data-msg-type="input"]'); + + if (userMessages.length > 0) { + const latestUserMessage = userMessages[userMessages.length - 1]; + + latestUserMessage.scrollIntoView({ + behavior: "smooth", + block: "start", + inline: "nearest", + }); + } }); }; watch(chatLoading, (val) => { if (val) { - scrollToBottom(); + scrollToLatestUserMessage(); } }); @@ -814,11 +833,6 @@ const handleUpdateSessionName = async ({ sessionId: _sessionId, name }) => { } }; -const handleShareSession = (session) => { - sessionToShare.value = session; - showShareModal.value = true; -}; - // --- Upload Dialog Handlers --- const showUploadDialog = ref(false); const handleUpload = async (uploadData) => { diff --git a/src/components/chat/ChatMessage.vue b/src/components/chat/ChatMessage.vue index 090969c..41dba8b 100644 --- a/src/components/chat/ChatMessage.vue +++ b/src/components/chat/ChatMessage.vue @@ -4,7 +4,8 @@ :class="[ 'vdb-c-flex vdb-c-h-auto vdb-c-w-full vdb-c-justify-start vdb-c-py-8 md:vdb-c-py-12', { - 'vdb-c-border-b vdb-c-border-kilvish-300 vdb-c-bg-white': isUser, + 'user-message vdb-c-border-b vdb-c-border-kilvish-300 vdb-c-bg-white': + isUser, }, ]" > diff --git a/src/components/chat/ChatMessageContainer.vue b/src/components/chat/ChatMessageContainer.vue index 6b46b15..97539dd 100644 --- a/src/components/chat/ChatMessageContainer.vue +++ b/src/components/chat/ChatMessageContainer.vue @@ -1,11 +1,11 @@