From 60e2fb26afca64555de05ca1b2c8b2c030749011 Mon Sep 17 00:00:00 2001 From: william Date: Sat, 31 Oct 2026 11:55:40 +0100 Subject: [PATCH] fix: avatar texture/TTS audio broken in packaged build, allow multiple instances Found by testing the first real Windows installer build end-to-end: - electron-builder.yml: `publisherName` under `win` is invalid in electron-builder 26.x (moved under `win.signtoolOptions`), which made `npm run build:win` fail validation entirely. Removed (no code signing configured, so it wasn't doing anything anyway). - index.ts: the production-only CSP header (added on top of index.html's own meta CSP, only active when !is.dev) was missing `blob:` in img-src and had no media-src directive at all. The GLB avatar's embedded textures and ElevenLabs TTS playback both go through `URL.createObjectURL(new Blob(...))`, so both silently failed in the packaged app while working fine in dev (dev skips this header entirely). Avatar rendered untextured, no audio played. - index.ts: added `app.requestSingleInstanceLock()` + a `second-instance` handler. Without it, every click on the desktop shortcut launched another full instance (own window, own SQLite connections, own review scheduler), which the installed app visibly allowed. Co-Authored-By: Claude Sonnet 5 --- electron-builder.yml | 1 - src/main/index.ts | 22 ++++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/electron-builder.yml b/electron-builder.yml index 429ec57..1928687 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -17,7 +17,6 @@ win: target: - target: nsis arch: [x64] - publisherName: Vandal William nsis: artifactName: ${productName}-Setup-${version}.${ext} shortcutName: ${productName} diff --git a/src/main/index.ts b/src/main/index.ts index e89840b..d2f8f63 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -32,6 +32,21 @@ import { startAutoUpdater } from './updater' let mainWindow: BrowserWindow | null = null +// Empeche de lancer plusieurs instances de Max en parallele (chaque instance ouvrirait sa propre +// fenetre avatar, son propre acces concurrent a la base SQLite et son propre planificateur de +// revisions) : le second lancement se ferme immediatement et reactive la fenetre existante. +if (!app.requestSingleInstanceLock()) { + app.quit() + process.exit(0) +} + +app.on('second-instance', () => { + if (!mainWindow) return + if (mainWindow.isMinimized()) mainWindow.restore() + mainWindow.show() + mainWindow.focus() +}) + function switchMode(next: Mode): void { setMode(next) if (next === 'coach') startVisionCapture() @@ -146,9 +161,12 @@ app responseHeaders: { ...details.responseHeaders, 'Content-Security-Policy': [ + // img-src/media-src incluent blob: : le GLB de l'avatar (textures) et les reponses + // audio ElevenLabs (TTS) sont tous deux lus via URL.createObjectURL(new Blob(...)), + // sans ca le modele reste sans texture et l'audio ne joue pas en production. "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; " + - "img-src 'self' data:; font-src 'self' data:; worker-src 'self' blob:; " + - "connect-src 'self' https://api.elevenlabs.io https://openrouter.ai" + "img-src 'self' data: blob:; media-src 'self' blob:; font-src 'self' data:; " + + "worker-src 'self' blob:; connect-src 'self' https://api.elevenlabs.io https://openrouter.ai" ] } })