From 02c1f49db5b7d8a1113feacc7b5c7ef0e5894ce0 Mon Sep 17 00:00:00 2001 From: Catherine Renelle <32781029+catrenelle@users.noreply.github.com> Date: Mon, 9 Feb 2026 23:37:24 -0500 Subject: [PATCH] Fix crypto.randomUUID not available in all environments Replace with a simple counter-based temp ID generator for optimistic UI messages. Co-Authored-By: Claude Opus 4.6 --- frontend/src/views/chat/ChatView.vue | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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,