diff --git a/frontend/src/views/chat/ChatView.vue b/frontend/src/views/chat/ChatView.vue index 7976826..0a8b007 100644 --- a/frontend/src/views/chat/ChatView.vue +++ b/frontend/src/views/chat/ChatView.vue @@ -133,6 +133,11 @@ import { chatApi } from '@/services/chat' import ChatToolResult from './ChatToolResult.vue' import type { ChatConversation, ChatMessage } from '@/types' +let _idCounter = 0 +function tempId(): string { + return `temp-${Date.now()}-${++_idCounter}` +} + const conversations = ref([]) const messages = ref([]) const activeConversationId = ref(null) @@ -189,7 +194,7 @@ async function sendMessage() { // Add user message optimistically const userMsg: ChatMessage = { - id: crypto.randomUUID(), + id: tempId(), role: 'user', content: text, toolResultType: null, @@ -218,7 +223,7 @@ async function sendMessage() { messages.value.push(data.assistantMessage) } catch (err: any) { messages.value.push({ - id: crypto.randomUUID(), + id: tempId(), role: 'assistant', content: err.response?.data?.message || 'Sorry, something went wrong. Please check that Ollama is running and try again.', toolResultType: null,