From e565951bf68ba89d439d0e0c6d24878ea9f2c7d6 Mon Sep 17 00:00:00 2001 From: egg Date: Wed, 17 Dec 2025 15:54:44 +0800 Subject: [PATCH] fix: Add microphone permission handlers for Electron MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added session.setPermissionRequestHandler and setPermissionCheckHandler to automatically grant media/audio capture permissions. This fixes the "could not start audio source" error when trying to start recording. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- client/src/main.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/client/src/main.js b/client/src/main.js index 1700bd5..afd85ef 100644 --- a/client/src/main.js +++ b/client/src/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow, ipcMain } = require("electron"); +const { app, BrowserWindow, ipcMain, session } = require("electron"); const path = require("path"); const fs = require("fs"); const { spawn } = require("child_process"); @@ -445,6 +445,24 @@ app.whenReady().then(async () => { // Load configuration first loadConfig(); + // Grant microphone permission automatically + session.defaultSession.setPermissionRequestHandler((webContents, permission, callback) => { + const allowedPermissions = ['media', 'mediaKeySystem', 'audioCapture']; + if (allowedPermissions.includes(permission)) { + console.log(`Granting permission: ${permission}`); + callback(true); + } else { + console.log(`Denying permission: ${permission}`); + callback(false); + } + }); + + // Also handle permission check (for some Electron versions) + session.defaultSession.setPermissionCheckHandler((webContents, permission) => { + const allowedPermissions = ['media', 'mediaKeySystem', 'audioCapture']; + return allowedPermissions.includes(permission); + }); + // Start backend sidecar if embedded mode is enabled startBackendSidecar();