Fix mobile voice button initialization

This commit is contained in:
2026-04-26 22:58:16 +02:00
parent 1f815fa1b1
commit 68486557dc
3 changed files with 25 additions and 2 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -1,4 +1,4 @@
const CACHE_NAME = "opensquared-assistant-v2";
const CACHE_NAME = "opensquared-assistant-v3";
const ASSETS = [
"/",
"/styles.css",