File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -85,9 +85,28 @@ export const permissions: Permissions = {
8585 async requestMicrophone ( ) : Promise < boolean > {
8686 logger . info ( 'Requesting microphone permission...' ) ;
8787 try {
88- const granted = await systemPreferences . askForMediaAccess ( 'microphone' ) ;
89- logger . info ( `Microphone permission request result: ${ granted ? 'granted' : 'denied' } ` ) ;
90- return granted ;
88+ // Check current status first
89+ const status = systemPreferences . getMediaAccessStatus ( 'microphone' ) ;
90+ logger . info ( `Current microphone permission status: ${ status } ` ) ;
91+
92+ if ( status === 'granted' ) {
93+ return true ;
94+ }
95+
96+ if ( status === 'not-determined' ) {
97+ // First time request - system dialog will appear
98+ const granted = await systemPreferences . askForMediaAccess ( 'microphone' ) ;
99+ logger . info ( `Microphone permission request result: ${ granted ? 'granted' : 'denied' } ` ) ;
100+ return granted ;
101+ }
102+
103+ // Status is 'denied' or 'restricted' - must open System Preferences
104+ // askForMediaAccess won't show a dialog in this case
105+ logger . info ( 'Microphone permission denied/restricted, opening System Preferences...' ) ;
106+ await execAsync (
107+ 'open "x-apple.systempreferences:com.apple.preference.security?Privacy_Microphone"'
108+ ) ;
109+ return false ;
91110 } catch ( error ) {
92111 logger . error ( 'Failed to request microphone permission:' , error ) ;
93112 return false ;
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ type RendererElectronAPI = {
66 checkPermissions : ( ) => Promise < {
77 screenRecording : boolean ;
88 accessibility : boolean ;
9+ microphone : boolean ;
910 } > ;
1011 requestPermissions : ( ) => Promise < void > ;
1112 startRecording : ( config : RecordingConfig ) => Promise < { success : boolean } > ;
You can’t perform that action at this time.
0 commit comments