feat: add duplicate message check and update chat UI styles

This commit is contained in:
2025-09-02 18:30:34 +02:00
parent 01bbb6c00a
commit 204ded71e5
5 changed files with 11 additions and 3 deletions

View File

@@ -20,7 +20,7 @@ const formatted = computed(() => useDateFormat(useNow(), 'D MMMM YYYY, HH:mm', {
<div class="flex flex-col-reverse gap-4 md:flex-row-reverse items-end"> <div class="flex flex-col-reverse gap-4 md:flex-row-reverse items-end">
<UCard <UCard
variant="solid" variant="solid"
class="rounded-xl mt-1 bg-sky-300 md:max-w-3/4" class="rounded-xl mt-1 bg-sky-500 md:max-w-3/4 text-white font-medium"
:ui="{ body: 'sm:p-2', header: 'sm:p-2', footer: 'sm:p-2' }" :ui="{ body: 'sm:p-2', header: 'sm:p-2', footer: 'sm:p-2' }"
> >
<div class="text-justify"> <div class="text-justify">

View File

@@ -136,9 +136,10 @@ export function useChat(t: any) {
] ]
}) })
const { addMessage } = useChatStore() const { addMessage, checkForDuplicateMessages } = useChatStore()
async function submitMessage(type: ChatType, prompt: string, fetchStates: ChatFetchState[]) { async function submitMessage(type: ChatType, prompt: string, fetchStates: ChatFetchState[]) {
checkForDuplicateMessages(type)
addMessage( addMessage(
type, type,
prompt, prompt,

View File

@@ -9,6 +9,13 @@ export const useChatStore = defineStore('chat', () => {
return !messages.value.some(msg => msg.state === ChatState.LOADING) return !messages.value.some(msg => msg.state === ChatState.LOADING)
}) })
function checkForDuplicateMessages(type: ChatType) {
const duplicate = messages.value.findLast(msg => msg.type === type)
if (duplicate) {
messages.value.splice(messages.value.indexOf(duplicate) - 1, 2)
}
}
function addMessage(type: ChatType, content: string, sender: ChatSender, fetchStates: ChatFetchState[]) { function addMessage(type: ChatType, content: string, sender: ChatSender, fetchStates: ChatFetchState[]) {
if (sender === ChatSender.ARTHUR) { if (sender === ChatSender.ARTHUR) {
const message: ChatMessage = { const message: ChatMessage = {
@@ -46,5 +53,5 @@ export const useChatStore = defineStore('chat', () => {
} }
} }
return { messages, addMessage, clearMessages, canSend, setLoadingState } return { messages, addMessage, clearMessages, canSend, setLoadingState, checkForDuplicateMessages }
}) })

Binary file not shown.

Before

Width:  |  Height:  |  Size: 155 KiB

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 202 KiB

After

Width:  |  Height:  |  Size: 1.4 MiB