From 869e80ee2db43a5f7dc905f540cfba4190a531ea Mon Sep 17 00:00:00 2001 From: rene Date: Wed, 15 Jul 2026 14:20:50 +0200 Subject: [PATCH] web: fallback when crypto.randomUUID() is unavailable Some browsers and insecure contexts (plain HTTP) throw on crypto.randomUUID(), which silently breaks the chat UI. Fall back to a plain UUID v4 generator when the native call fails - same behaviour on modern browsers, works everywhere else. --- web/src/App.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web/src/App.tsx b/web/src/App.tsx index 57e5f98..d4e0e41 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -34,7 +34,11 @@ import { Brain } from "./Brain" import { persistPublicSettings, stored } from "@/lib/storage" import { cn } from "@/lib/utils" -const message = (role: ChatMessage["role"], content: string): ChatMessage => ({ id: crypto.randomUUID(), role, content }) +const message = (role: ChatMessage["role"], content: string): ChatMessage => { + let id: string + try { id = crypto.randomUUID() } catch { id = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => { const r = Math.random() * 16 | 0; return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16) }) } + return { id, role, content } +} export default function App() { // When the page is served by the engine itself (coli web), same-origin is the