Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

fix(permissions): verify system audio access with binary probe, simplify accessibility request

Gabriel Steinc708af08f2b2
diff --git a/src/helpers/audioTapManager.js b/src/helpers/audioTapManager.js
index fbcfeac50..f85021c9d 100644
--- a/src/helpers/audioTapManager.js
+++ b/src/helpers/audioTapManager.js
@@ -43,6 +43,7 @@ class AudioTapManager {
this.isStopping = false;
this.permissionStatus = this._loadPermissionStatus();
this._requestPromise = null;
+ this._verifiedGranted = false;
}
isSupported() {
@@ -78,6 +79,41 @@ class AudioTapManager {
return { granted: status === "granted", status };
}
+ /**
+ * Async check that verifies a cached "granted" status by probing the binary
+ * once per session. Detects permission revocations that the disk cache misses.
+ */
+ async verifyAccess() {
+ if (!this.isSupported()) {
+ return { granted: false, status: "unsupported" };
+ }
+
+ // Active process means definitely granted.
+ if (this.process) {
+ return { granted: true, status: "granted" };
+ }
+
+ // Only probe when cached status is "granted" — trust "denied" and "unknown".
+ if (this.permissionStatus !== "granted" || this._verifiedGranted) {
+ const status = this.getPermissionStatus();
+ return { granted: status === "granted", status };
+ }
+
+ // Cached says "granted" but no process running — verify once per session.
+ try {
+ const result = await this._probeForAccess();
+ if (result.granted) {
+ this._verifiedGranted = true;
+ }
+ return result;
+ } catch {
+ // Probe rejected — permission was likely revoked.
+ // _probeForAccess already persisted the updated status.
+ const status = this.getPermissionStatus();
+ return { granted: status === "granted", status };
+ }
+ }
+
_statusFilePath() {
const { app } = require("electron");
return path.join(app.getPath("userData"), ".system-audio-permission");
diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.js
index b222c3fe3..b1bab82bd 100644
--- a/src/helpers/ipcHandlers.js
+++ b/src/helpers/ipcHandlers.js
@@ -2379,7 +2379,7 @@ class IPCHandlers {
return { granted: status === "granted", status };
});
- ipcMain.handle("check-system-audio-access", () => {
+ ipcMain.handle("check-system-audio-access", async () => {
if (process.platform !== "darwin") {
return { granted: true, status: "granted", mode: "unsupported" };
}
@@ -2388,7 +2388,7 @@ class IPCHandlers {
return { granted: false, status: "unsupported", mode: "unsupported" };
}
- const result = this.audioTapManager.checkAccess();
+ const result = await this.audioTapManager.verifyAccess();
return { granted: result.granted, status: result.status, mode: "native" };
});
diff --git a/src/hooks/usePermissions.ts b/src/hooks/usePermissions.ts
index e17f36a2e..eeae85721 100644
--- a/src/hooks/usePermissions.ts
+++ b/src/hooks/usePermissions.ts
@@ -250,18 +250,8 @@ export const usePermissions = (
return;
}
- // Trigger the macOS TCC prompt (creates entry in System Settings)
- try {
- const granted = await window.electronAPI?.promptAccessibilityPermission?.();
- if (granted) {
- setAccessibilityPermissionGranted(true);
- return;
- }
- } catch {
- // Falls through to opening System Settings
- }
-
- // Open System Settings for manual toggle
+ // Open System Settings directly — avoids the undismissable macOS TCC dialog
+ // that isTrustedAccessibilityClient(true) would show.
await openSystemSettings("accessibility", window.electronAPI?.openAccessibilitySettings);
return;
}