Private
Public Access
1
0

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 <noreply@anthropic.com>
This commit is contained in:
Catherine Renelle
2026-02-09 23:37:24 -05:00
parent 846edad2a4
commit 02c1f49db5
+7 -2
View File
@@ -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<ChatConversation[]>([])
const messages = ref<ChatMessage[]>([])
const activeConversationId = ref<string | null>(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,