From 1568cc9eebd4fd4d468f97a286913989285089c5 Mon Sep 17 00:00:00 2001 From: boksbc Date: Mon, 11 May 2026 22:13:48 +0200 Subject: [PATCH] fix: wakeword back-off ceiling, save size limit, LaunchAgent restart-on-crash-only --- electron/mac-agent.js | 3 +++ electron/wakeword.js | 10 ++++++++-- launchagent/at.pxo.fox.plist | 5 ++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/electron/mac-agent.js b/electron/mac-agent.js index 974e4ef..4c26293 100644 --- a/electron/mac-agent.js +++ b/electron/mac-agent.js @@ -67,6 +67,9 @@ async function executeMacCommand(command) { if (resolved.filename.includes('/') || resolved.filename.includes('\\')) { return { success: false, output: 'Ungültiger Dateiname' }; } + if (typeof resolved.content === 'string' && resolved.content.length > 10 * 1024 * 1024) { + return { success: false, output: 'Inhalt zu groß (max. 10 MB)' }; + } const filePath = `${process.env.HOME}/Desktop/${resolved.filename}`; fs.writeFileSync(filePath, resolved.content, 'utf8'); return { success: true, output: `Gespeichert: ${filePath}` }; diff --git a/electron/wakeword.js b/electron/wakeword.js index 9dbba93..731df3d 100644 --- a/electron/wakeword.js +++ b/electron/wakeword.js @@ -4,8 +4,12 @@ const path = require('path'); let wakewordProcess = null; let running = false; -function startWakeword({ onWake }) { +function startWakeword({ onWake }, retries = 0) { if (running) return; + if (retries >= 10) { + console.error('[Wakeword] Maximale Neustartversuche erreicht. Wakeword deaktiviert.'); + return; + } running = true; const scriptPath = path.join(__dirname, '../python/wakeword.py'); @@ -34,7 +38,9 @@ function startWakeword({ onWake }) { running = false; wakewordProcess = null; if (code !== 0 && signal === null) { - setTimeout(() => startWakeword({ onWake }), 2000); + const delay = Math.min(2000 * Math.pow(2, retries), 30000); + console.error(`[Wakeword] Neustart in ${delay / 1000}s (Versuch ${retries + 1}/10)`); + setTimeout(() => startWakeword({ onWake }, retries + 1), delay); } }); } diff --git a/launchagent/at.pxo.fox.plist b/launchagent/at.pxo.fox.plist index 0c68b4e..a6756a6 100644 --- a/launchagent/at.pxo.fox.plist +++ b/launchagent/at.pxo.fox.plist @@ -12,7 +12,10 @@ RunAtLoad KeepAlive - + + Crashed + + StandardOutPath /tmp/fox-desktop.log StandardErrorPath