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 <noreply@anthropic.com>
This commit is contained in:
william
2026-10-31 11:55:40 +01:00
co-authored by Claude Sonnet 5
parent 9a66ff7f17
commit 60e2fb26af
2 changed files with 20 additions and 3 deletions
-1
View File
@@ -17,7 +17,6 @@ win:
target: target:
- target: nsis - target: nsis
arch: [x64] arch: [x64]
publisherName: Vandal William
nsis: nsis:
artifactName: ${productName}-Setup-${version}.${ext} artifactName: ${productName}-Setup-${version}.${ext}
shortcutName: ${productName} shortcutName: ${productName}
+20 -2
View File
@@ -32,6 +32,21 @@ import { startAutoUpdater } from './updater'
let mainWindow: BrowserWindow | null = null 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 { function switchMode(next: Mode): void {
setMode(next) setMode(next)
if (next === 'coach') startVisionCapture() if (next === 'coach') startVisionCapture()
@@ -146,9 +161,12 @@ app
responseHeaders: { responseHeaders: {
...details.responseHeaders, ...details.responseHeaders,
'Content-Security-Policy': [ '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'; " + "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; " +
"img-src 'self' data:; font-src 'self' data:; worker-src 'self' blob:; " + "img-src 'self' data: blob:; media-src 'self' blob:; font-src 'self' data:; " +
"connect-src 'self' https://api.elevenlabs.io https://openrouter.ai" "worker-src 'self' blob:; connect-src 'self' https://api.elevenlabs.io https://openrouter.ai"
] ]
} }
}) })