Skip to content

Commit 540913a

Browse files
committed
chore: improve microphone permission handling
- Fix macOS microphone permission key - Add permission request handler - Update @jarvis-agent dependencies
1 parent 47adf9c commit 540913a

File tree

5 files changed

+42
-17
lines changed

5 files changed

+42
-17
lines changed

assets/entitlements.mac.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<true/>
2828

2929
<!-- Allows access to microphone for speech recognition -->
30-
<key>com.apple.security.device.microphone</key>
30+
<key>com.apple.security.device.audio-input</key>
3131
<true/>
3232

3333
<!-- Allows access to camera -->

electron/main/services/task-window-manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class TaskWindowManager {
4141
throw new Error(`Maximum concurrent tasks reached (${this.maxConcurrentTasks})`);
4242
}
4343

44-
const taskWindow = createWindow(`http://localhost:5173/main?taskId=${taskId}&executionId=${executionId}`)
44+
const taskWindow = await createWindow(`http://localhost:5173/main?taskId=${taskId}&executionId=${executionId}`)
4545
const detailView = createView(`https://www.google.com`, "view", '2');
4646

4747
taskWindow.contentView.addChildView(detailView);

electron/main/ui/window.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
1-
import { app, BrowserWindow } from 'electron';
1+
import { app, BrowserWindow, systemPreferences } from 'electron';
22
import path from 'node:path';
33
import { isDev } from '../utils/constants';
44
import { store } from '../utils/store';
55

6-
export function createWindow(rendererURL: string) {
6+
async function setupMacPermissions() {
7+
// macOS requires explicit microphone permission request
8+
if (process.platform === 'darwin') {
9+
const status = systemPreferences.getMediaAccessStatus('microphone');
10+
console.log('[Window] Current microphone permission status:', status);
11+
12+
if (status !== 'granted') {
13+
const result = await systemPreferences.askForMediaAccess('microphone');
14+
console.log('[Window] Permission request result:', result);
15+
}
16+
}
17+
}
18+
19+
export async function createWindow(rendererURL: string) {
720
const preloadPath = isDev
821
? path.join(app.getAppPath(), '..', 'preload', 'index.cjs')
922
: path.join(app.getAppPath(), 'dist', 'electron', 'preload', 'index.cjs');
@@ -23,6 +36,18 @@ export function createWindow(rendererURL: string) {
2336
},
2437
});
2538

39+
win.webContents.session.setPermissionRequestHandler((_webContents, permission, callback) => {
40+
// Allow media permissions (includes microphone and camera)
41+
if (permission === 'media') {
42+
console.log(`[Window] Granting ${permission} permission`);
43+
setupMacPermissions();
44+
callback(true);
45+
} else {
46+
console.log(`[Window] Denying ${permission} permission`);
47+
callback(false);
48+
}
49+
});
50+
2651
win.loadURL(rendererURL).catch(err => {
2752
console.error('[Window] Failed to load URL:', err);
2853
});

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
"dependencies": {
3030
"@ant-design/cssinjs": "^1.23.0",
3131
"@ant-design/icons": "5.x",
32-
"@jarvis-agent/core": "^0.1.4",
33-
"@jarvis-agent/electron": "^0.1.9",
32+
"@jarvis-agent/core": "^0.1.5",
33+
"@jarvis-agent/electron": "^0.1.10",
3434
"@jest/globals": "^30.1.2",
3535
"@react-spring/web": "^10.0.1",
3636
"antd": "^5.26.5",

pnpm-lock.yaml

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)