From 68486557dc12ce2b48e155230d8ae7e5ff266adb Mon Sep 17 00:00:00 2001 From: laurentbarontini Date: Sun, 26 Apr 2026 22:58:16 +0200 Subject: [PATCH] Fix mobile voice button initialization --- static/app.js | 19 ++++++++++++++++++- static/styles.css | 6 ++++++ static/sw.js | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/static/app.js b/static/app.js index 4070c7a..b43f08e 100644 --- a/static/app.js +++ b/static/app.js @@ -32,7 +32,11 @@ function getSessionId() { const key = "opensquared_assistant_session"; let value = localStorage.getItem(key); if (!value) { - value = crypto.randomUUID(); + if (window.crypto && typeof window.crypto.randomUUID === "function") { + value = window.crypto.randomUUID(); + } else { + value = `session-${Date.now()}-${Math.random().toString(16).slice(2)}`; + } localStorage.setItem(key, value); } return value; @@ -94,6 +98,19 @@ async function sendText() { async function toggleVoice() { await unlockAudio(); + + if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) { + addBubble("Le micro n'est pas disponible dans ce navigateur. Ouvre l'app en HTTPS avec Chrome.", "error"); + setStatus("Micro indisponible", "error"); + return; + } + + if (typeof MediaRecorder === "undefined") { + addBubble("L'enregistrement audio n'est pas supporte par ce navigateur.", "error"); + setStatus("Enregistrement indisponible", "error"); + return; + } + if (isRecording) { recorder.stop(); return; diff --git a/static/styles.css b/static/styles.css index 77bf4ec..f494230 100644 --- a/static/styles.css +++ b/static/styles.css @@ -31,6 +31,12 @@ textarea { font: inherit; } +button { + cursor: pointer; + touch-action: manipulation; + -webkit-tap-highlight-color: transparent; +} + .app-shell { width: min(100%, 520px); min-height: 100svh; diff --git a/static/sw.js b/static/sw.js index b09f900..c1aa375 100644 --- a/static/sw.js +++ b/static/sw.js @@ -1,4 +1,4 @@ -const CACHE_NAME = "opensquared-assistant-v2"; +const CACHE_NAME = "opensquared-assistant-v3"; const ASSETS = [ "/", "/styles.css",