diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 4d24911d..c495b2f3 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -179,9 +179,13 @@ jobs:
echo "::error::node-llama-cpp is missing from $RESOURCES/llama (scripts/prepare-llama.cjs)"
exit 1
fi
- if [ "$RUNNER_OS" = macOS ] && [ ! -x "$RESOURCES/micwatch" ]; then
- echo "::error::the micwatch helper is missing from $RESOURCES (scripts/build-mac-helpers.cjs)"
- exit 1
+ if [ "$RUNNER_OS" = macOS ]; then
+ for helper in micwatch audiocapture; do
+ if [ ! -x "$RESOURCES/$helper" ]; then
+ echo "::error::the $helper helper is missing from $RESOURCES (scripts/build-mac-helpers.cjs)"
+ exit 1
+ fi
+ done
fi
if [ "$RUNNER_OS" = Linux ]; then xvfb-run -a "$APP" smoke; else "$APP" smoke; fi
# Both Mac builds write latest-mac.yml; the Intel one is renamed so the publish job can merge
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 03a5c63d..7633cdc7 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -12,7 +12,7 @@ pnpm install
pnpm dev
```
-On macOS, grant microphone access when prompted. The first **Record** click downloads the Whisper `large-v3-turbo` model (~575 MB) into the app data folder.
+On macOS, grant microphone access when prompted. In development macOS asks on behalf of **Electron**, not your terminal (`pnpm dev` starts it through `build/helpers/devlaunch`, built with the other helpers; it needs Xcode's command line tools), so System Audio Recording is listed under Electron. The first **Record** click downloads the Whisper `large-v3-turbo` model (~575 MB) into the app data folder.
The website lives in `apps/website` (Next.js). Run it with `pnpm dev:web` and open http://localhost:3100.
diff --git a/README.md b/README.md
index b26cd474..7800c8f7 100644
--- a/README.md
+++ b/README.md
@@ -48,7 +48,7 @@ Grant microphone access when prompted. Models download on first use:
for non-commercial use only (see [THIRD_PARTY.md](THIRD_PARTY.md))
- **Search model** (~146 MB), only if you turn on search by meaning
-On macOS, capturing a call's audio needs Screen Recording permission.
+On macOS, capturing a call's audio needs System Audio Recording permission; Lyra asks the first time.
## Privacy
diff --git a/apps/lyra/electron-builder.yml b/apps/lyra/electron-builder.yml
index 31839eb4..2f29482f 100644
--- a/apps/lyra/electron-builder.yml
+++ b/apps/lyra/electron-builder.yml
@@ -45,6 +45,8 @@ mac:
extraResources:
- from: build/helpers/micwatch
to: micwatch
+ - from: build/helpers/audiocapture
+ to: audiocapture
entitlementsInherit: build/entitlements.mac.plist
extendInfo:
NSMicrophoneUsageDescription: Lyra records audio so it can transcribe your pages on this device.
diff --git a/apps/lyra/native/mac/audiocapture.swift b/apps/lyra/native/mac/audiocapture.swift
new file mode 100644
index 00000000..2d86e79e
--- /dev/null
+++ b/apps/lyra/native/mac/audiocapture.swift
@@ -0,0 +1,56 @@
+// Reads or asks for macOS's System Audio Recording permission (TCC's kTCCServiceAudioCapture),
+// which Chromium's Core Audio tap needs to record computer audio. Chromium only checks it and
+// never asks, so without this the track ends at once and macOS never lists Lyra to allow.
+//
+// audiocapture status prints granted | denied | not-determined | unknown
+// audiocapture request asks (a system prompt the first time), then prints granted | denied
+//
+// TCC has no public API for this service; this is the same private call macOS's own apps make.
+// A missing symbol (an older macOS) prints "unknown". TCC answers for the app that launched the
+// helper (Lyra, or the terminal running `pnpm dev`), so the prompt names that app.
+//
+// Build: swiftc -O native/mac/audiocapture.swift -o build/helpers/audiocapture
+
+import Foundation
+
+let service = "kTCCServiceAudioCapture" as CFString
+
+typealias Preflight = @convention(c) (CFString, CFDictionary?) -> Int
+typealias Request = @convention(c) (CFString, CFDictionary?, @escaping (Bool) -> Void) -> Void
+
+let tcc = dlopen("/System/Library/PrivateFrameworks/TCC.framework/Versions/A/TCC", RTLD_NOW)
+
+func symbol(_ name: String, as _: T.Type) -> T? {
+ guard let tcc, let pointer = dlsym(tcc, name) else { return nil }
+ return unsafeBitCast(pointer, to: T.self)
+}
+
+func status() -> String {
+ guard let preflight = symbol("TCCAccessPreflight", as: Preflight.self) else { return "unknown" }
+ switch preflight(service, nil) {
+ case 0: return "granted"
+ case 1: return "denied"
+ case 2: return "not-determined"
+ default: return "unknown"
+ }
+}
+
+func request() -> String {
+ guard let ask = symbol("TCCAccessRequest", as: Request.self) else { return "unknown" }
+ let done = DispatchSemaphore(value: 0)
+ var granted = false
+ ask(service, nil) { answer in
+ granted = answer
+ done.signal()
+ }
+ done.wait()
+ return granted ? "granted" : "denied"
+}
+
+switch CommandLine.arguments.dropFirst().first {
+case "status": print(status())
+case "request": print(request())
+default:
+ FileHandle.standardError.write("usage: audiocapture status|request\n".data(using: .utf8) ?? Data())
+ exit(2)
+}
diff --git a/apps/lyra/native/mac/devlaunch.c b/apps/lyra/native/mac/devlaunch.c
new file mode 100644
index 00000000..2e89010c
--- /dev/null
+++ b/apps/lyra/native/mac/devlaunch.c
@@ -0,0 +1,66 @@
+// Development only: starts Electron as its own "responsible" process, then waits for it.
+//
+// macOS asks for privacy permissions (TCC) on behalf of the app that launched a process, so
+// under `pnpm dev` it asks for the terminal. Most terminals (Warp, Terminal, iTerm) don't declare
+// NSAudioCaptureUsageDescription, and macOS then refuses System Audio Recording without asking.
+// Disclaiming makes Electron.app, which declares it, the one asked. `pnpm dev`
+// (scripts/dev.cjs) points electron-vite here through ELECTRON_EXEC_PATH and names the real
+// Electron binary in DEVLAUNCH_TARGET; the packaged app never uses it.
+//
+// Usage: DEVLAUNCH_TARGET= devlaunch [args...]
+// Build: clang -O2 native/mac/devlaunch.c -o build/helpers/devlaunch
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+extern char **environ;
+
+// Private but stable since macOS 10.14; Chromium, LLDB and Xcode use it for the same reason.
+int responsibility_spawnattrs_setdisclaim(posix_spawnattr_t *attrs, int disclaim);
+
+static pid_t child = 0;
+
+static void forward(int signal) {
+ if (child > 0) kill(child, signal);
+}
+
+int main(int argc, char **argv) {
+ const char *target = getenv("DEVLAUNCH_TARGET");
+ if (target == NULL || argc < 1) {
+ fprintf(stderr, "usage: DEVLAUNCH_TARGET= devlaunch [args...]\n");
+ return 2;
+ }
+ argv[0] = (char *)target;
+ posix_spawnattr_t attrs;
+ posix_spawnattr_init(&attrs);
+ responsibility_spawnattrs_setdisclaim(&attrs, 1);
+ int error = posix_spawn(&child, target, NULL, &attrs, argv, environ);
+ posix_spawnattr_destroy(&attrs);
+ if (error != 0) {
+ fprintf(stderr, "devlaunch: could not start %s (error %d)\n", target, error);
+ return 1;
+ }
+ // electron-vite stops and restarts Electron by signalling the process it spawned: this one.
+ signal(SIGTERM, forward);
+ signal(SIGINT, forward);
+ signal(SIGHUP, forward);
+ int status = 0;
+ while (waitpid(child, &status, 0) < 0) {
+ // Interrupted by a forwarded signal: keep waiting for Electron to exit. Anything else
+ // (ECHILD) would loop forever.
+ if (errno != EINTR) {
+ perror("devlaunch: waitpid");
+ return 1;
+ }
+ }
+ if (WIFSIGNALED(status)) {
+ signal(WTERMSIG(status), SIG_DFL);
+ raise(WTERMSIG(status));
+ }
+ return WIFEXITED(status) ? WEXITSTATUS(status) : 1;
+}
diff --git a/apps/lyra/package.json b/apps/lyra/package.json
index 316dd99d..b021a18d 100644
--- a/apps/lyra/package.json
+++ b/apps/lyra/package.json
@@ -8,7 +8,7 @@
"license": "MIT",
"homepage": "https://github.com/osbytes/lyra",
"scripts": {
- "dev": "electron-vite dev",
+ "dev": "node scripts/dev.cjs",
"start": "electron-vite preview",
"build": "pnpm check && electron-vite build",
"typecheck:node": "tsc --noEmit -p tsconfig.node.json --composite false",
diff --git a/apps/lyra/scripts/build-mac-helpers.cjs b/apps/lyra/scripts/build-mac-helpers.cjs
index 1bc19241..05b07049 100644
--- a/apps/lyra/scripts/build-mac-helpers.cjs
+++ b/apps/lyra/scripts/build-mac-helpers.cjs
@@ -1,6 +1,8 @@
// Compiles the small native helpers Lyra ships on macOS (see native/mac).
+// `--if-stale` (used by `pnpm dev`) builds only helpers older than their source, and warns
+// instead of failing when a compiler is missing: the app runs without them, minus what they do.
const { execFileSync } = require('node:child_process')
-const { mkdirSync } = require('node:fs')
+const { existsSync, mkdirSync, statSync } = require('node:fs')
const { join } = require('node:path')
if (process.platform !== 'darwin') {
@@ -8,12 +10,28 @@ if (process.platform !== 'darwin') {
process.exit(0)
}
+const ifStale = process.argv.includes('--if-stale')
const root = join(__dirname, '..')
const outDir = join(root, 'build', 'helpers')
mkdirSync(outDir, { recursive: true })
-const out = join(outDir, 'micwatch')
-execFileSync('swiftc', ['-O', join(root, 'native', 'mac', 'micwatch.swift'), '-o', out], {
- stdio: 'inherit'
-})
-console.log(`build-mac-helpers: built ${out}`)
+// devlaunch is for `pnpm dev` only (scripts/dev.cjs); electron-builder ships the other two.
+const helpers = [
+ { name: 'micwatch', file: 'micwatch.swift', compiler: 'swiftc', flags: ['-O'] },
+ { name: 'audiocapture', file: 'audiocapture.swift', compiler: 'swiftc', flags: ['-O'] },
+ { name: 'devlaunch', file: 'devlaunch.c', compiler: 'clang', flags: ['-O2', '-Wall'] }
+]
+
+for (const { name, file, compiler, flags } of helpers) {
+ const source = join(root, 'native', 'mac', file)
+ const out = join(outDir, name)
+ if (ifStale && existsSync(out) && statSync(out).mtimeMs >= statSync(source).mtimeMs) continue
+ try {
+ execFileSync(compiler, [...flags, source, '-o', out], { stdio: 'inherit' })
+ } catch (error) {
+ if (!ifStale) throw error
+ console.warn(`build-mac-helpers: could not build ${name} (${String(error)}); continuing without it`)
+ continue
+ }
+ console.log(`build-mac-helpers: built ${out}`)
+}
diff --git a/apps/lyra/scripts/dev.cjs b/apps/lyra/scripts/dev.cjs
new file mode 100644
index 00000000..c3267f0d
--- /dev/null
+++ b/apps/lyra/scripts/dev.cjs
@@ -0,0 +1,31 @@
+// `pnpm dev`: electron-vite dev, after building the macOS helpers that are missing or stale.
+// On macOS Electron starts through build/helpers/devlaunch, so macOS asks for privacy
+// permissions (System Audio Recording) for Electron.app rather than the terminal running this,
+// which usually can't be asked at all (see native/mac/devlaunch.c).
+const { execFileSync, spawn } = require('node:child_process')
+const { existsSync } = require('node:fs')
+const { dirname, join } = require('node:path')
+
+const root = join(__dirname, '..')
+execFileSync(process.execPath, [join(__dirname, 'build-mac-helpers.cjs'), '--if-stale'], {
+ stdio: 'inherit'
+})
+
+const env = { ...process.env }
+const devlaunch = join(root, 'build', 'helpers', 'devlaunch')
+if (process.platform === 'darwin' && existsSync(devlaunch) && !env.ELECTRON_EXEC_PATH) {
+ // Requiring the electron package from Node gives the path to its binary.
+ env.DEVLAUNCH_TARGET = require('electron')
+ env.ELECTRON_EXEC_PATH = devlaunch
+}
+
+const cli = join(dirname(require.resolve('electron-vite/package.json')), 'bin', 'electron-vite.js')
+const child = spawn(process.execPath, [cli, 'dev', ...process.argv.slice(2)], {
+ cwd: root,
+ env,
+ stdio: 'inherit'
+})
+for (const signal of ['SIGINT', 'SIGTERM']) process.on(signal, () => child.kill(signal))
+child.on('exit', (code, signal) => {
+ process.exit(code ?? (signal ? 1 : 0))
+})
diff --git a/apps/lyra/src/main/audioCapturePermission.test.ts b/apps/lyra/src/main/audioCapturePermission.test.ts
new file mode 100644
index 00000000..27768fec
--- /dev/null
+++ b/apps/lyra/src/main/audioCapturePermission.test.ts
@@ -0,0 +1,26 @@
+import { describe, expect, it } from 'vitest'
+import { parseAudioCaptureReply, shouldRequestAudioCapture } from './audioCapturePermission'
+
+describe('parseAudioCaptureReply', () => {
+ it('reads each state the helper prints', () => {
+ expect(parseAudioCaptureReply('granted\n')).toBe('granted')
+ expect(parseAudioCaptureReply('denied\n')).toBe('denied')
+ expect(parseAudioCaptureReply('not-determined\n')).toBe('not-determined')
+ expect(parseAudioCaptureReply('unknown')).toBe('unknown')
+ })
+
+ it('reads anything else as unknown', () => {
+ expect(parseAudioCaptureReply('')).toBe('unknown')
+ expect(parseAudioCaptureReply('restricted')).toBe('unknown')
+ expect(parseAudioCaptureReply('usage: audiocapture status|request')).toBe('unknown')
+ })
+})
+
+describe('shouldRequestAudioCapture', () => {
+ it('asks only when macOS has never asked', () => {
+ expect(shouldRequestAudioCapture('not-determined')).toBe(true)
+ expect(shouldRequestAudioCapture('granted')).toBe(false)
+ expect(shouldRequestAudioCapture('denied')).toBe(false)
+ expect(shouldRequestAudioCapture('unknown')).toBe(false)
+ })
+})
diff --git a/apps/lyra/src/main/audioCapturePermission.ts b/apps/lyra/src/main/audioCapturePermission.ts
new file mode 100644
index 00000000..7cef814a
--- /dev/null
+++ b/apps/lyra/src/main/audioCapturePermission.ts
@@ -0,0 +1,19 @@
+import { z } from 'zod'
+import type { PermissionState } from '../shared/types'
+
+/** One line from `native/mac/audiocapture.swift`. */
+const HelperReply = z.enum(['granted', 'denied', 'not-determined', 'unknown'])
+
+/** The helper's answer; anything it shouldn't print reads as unknown, which flags nothing. */
+export function parseAudioCaptureReply(stdout: string): PermissionState {
+ const parsed = HelperReply.safeParse(stdout.trim())
+ return parsed.success ? parsed.data : 'unknown'
+}
+
+/**
+ * Whether to ask before capturing computer audio: only while macOS has never been asked.
+ * Asking again after a refusal shows nothing; the user changes it in System Settings.
+ */
+export function shouldRequestAudioCapture(state: PermissionState): boolean {
+ return state === 'not-determined'
+}
diff --git a/apps/lyra/src/main/index.ts b/apps/lyra/src/main/index.ts
index d289b601..0be7f6e1 100644
--- a/apps/lyra/src/main/index.ts
+++ b/apps/lyra/src/main/index.ts
@@ -15,7 +15,7 @@ import {
import { homedir, release } from 'node:os'
import { join } from 'node:path'
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
-import { systemAudioSource } from './systemAudioSource'
+import { systemAudioSource, usesAudioTap } from './systemAudioSource'
import { installAppMenu } from './appMenu'
import { isAppPage, type AppPages } from './appOrigin'
import { checkConfig, config, ConfigError, configSummary } from './config'
@@ -94,7 +94,7 @@ import { getDiagnostics, noteWhisperUsed, revealFolder } from './diagnostics'
import { cancelModelDownload } from './models'
import { modelStatuses, onModelRetry, retryModel } from './modelStatus'
import { detectServers, listServerModels, testWriter } from './notesServers'
-import { openPermissionSettings, permissionStatus } from './permissions'
+import { ensureSystemAudioAsked, openPermissionSettings, permissionStatus } from './permissions'
import { installedPromptApps, openInPromptApp } from './promptApps'
import { PromptAppRequest } from '../shared/promptApps'
import { createTray } from './tray'
@@ -514,7 +514,8 @@ function registerPermissions(): void {
// Meetings ask for system audio via getDisplayMedia; answer with the loopback
// device and the primary screen (its video track is discarded), so no picker shows.
const audio = systemAudioSource(process.platform, release())
- log('capture', 'system audio source', { audio })
+ const audioTap = usesAudioTap(process.platform, release())
+ log('capture', 'system audio source', { audio, audioTap })
session.defaultSession.setDisplayMediaRequestHandler((request, callback) => {
const main = getMainWindow()
const frame = request.frame
@@ -522,6 +523,16 @@ function registerPermissions(): void {
callback({})
return
}
+ if (audioTap) {
+ // macOS 14.2+ records computer audio through a Core Audio tap, which needs System Audio
+ // Recording; ask for it here, the first time, since Chromium only checks it. The video
+ // track is discarded, so it comes from Lyra's own window: a screen would need Screen
+ // Recording too, for nothing.
+ void ensureSystemAudioAsked().then(() => {
+ callback({ video: frame, audio: 'loopback' })
+ })
+ return
+ }
desktopCapturer.getSources({ types: ['screen'] }).then(
([screen]) => {
// Electron types `audio` as 'loopback' | 'loopbackWithMute', but hands any of Chromium's
diff --git a/apps/lyra/src/main/ipcSchemas.ts b/apps/lyra/src/main/ipcSchemas.ts
index 4c0c733e..114f7dfa 100644
--- a/apps/lyra/src/main/ipcSchemas.ts
+++ b/apps/lyra/src/main/ipcSchemas.ts
@@ -119,7 +119,7 @@ export const ModelNameArg = z
export const ModelFeatureArg = z.enum(['semanticSearch', 'localNotes'])
/** `permissions:openSettings`. Main maps each to a fixed system settings page. */
-export const PermissionKindArg = z.enum(['microphone', 'screen'])
+export const PermissionKindArg = z.enum(['microphone', 'systemAudio'])
/** `diagnostics:reveal`. Main maps each to a fixed folder. */
export const RevealTargetArg = z.enum(['logs', 'models'])
diff --git a/apps/lyra/src/main/permissionPanes.test.ts b/apps/lyra/src/main/permissionPanes.test.ts
index ea7fbf22..87f84905 100644
--- a/apps/lyra/src/main/permissionPanes.test.ts
+++ b/apps/lyra/src/main/permissionPanes.test.ts
@@ -6,14 +6,14 @@ describe('permissionPane', () => {
expect(permissionPane('darwin', 'microphone')).toBe(
'x-apple.systempreferences:com.apple.preference.security?Privacy_Microphone'
)
- expect(permissionPane('darwin', 'screen')).toBe(
+ expect(permissionPane('darwin', 'systemAudio')).toBe(
'x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture'
)
})
it('has only the microphone page on Windows and nothing elsewhere', () => {
expect(permissionPane('win32', 'microphone')).toBe('ms-settings:privacy-microphone')
- expect(permissionPane('win32', 'screen')).toBeNull()
+ expect(permissionPane('win32', 'systemAudio')).toBeNull()
expect(permissionPane('linux', 'microphone')).toBeNull()
})
})
diff --git a/apps/lyra/src/main/permissionPanes.ts b/apps/lyra/src/main/permissionPanes.ts
index 806f68b9..0ed1fcae 100644
--- a/apps/lyra/src/main/permissionPanes.ts
+++ b/apps/lyra/src/main/permissionPanes.ts
@@ -7,9 +7,10 @@ import type { PermissionKind } from '../shared/types'
const PANES: Partial>>> = {
darwin: {
microphone: 'x-apple.systempreferences:com.apple.preference.security?Privacy_Microphone',
- screen: 'x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture'
+ // Screen & System Audio Recording: Lyra is listed under "System Audio Recording Only".
+ systemAudio: 'x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture'
},
- // Windows has no screen-capture permission; loopback audio needs none.
+ // Windows loopback audio needs no permission.
win32: { microphone: 'ms-settings:privacy-microphone' }
}
diff --git a/apps/lyra/src/main/permissions.ts b/apps/lyra/src/main/permissions.ts
index 639f1287..6376ceb0 100644
--- a/apps/lyra/src/main/permissions.ts
+++ b/apps/lyra/src/main/permissions.ts
@@ -1,15 +1,21 @@
-import { shell, systemPreferences } from 'electron'
+import { app, shell, systemPreferences } from 'electron'
+import { execFile } from 'node:child_process'
+import { existsSync } from 'node:fs'
+import { release } from 'node:os'
+import { join } from 'node:path'
import type { PermissionKind, PermissionState, PermissionStatus } from '../shared/types'
+import { parseAudioCaptureReply, shouldRequestAudioCapture } from './audioCapturePermission'
import { log } from './log'
import { permissionPane } from './permissionPanes'
+import { usesAudioTap } from './systemAudioSource'
/**
- * Whether the OS lets Lyra use the microphone and capture the screen (macOS needs Screen
- * Recording for computer audio). Asked locally; nothing here prompts the user.
+ * Whether the OS lets Lyra use the microphone and record computer audio (macOS's System Audio
+ * Recording, for the Core Audio tap that records it). Asked locally; nothing here prompts the
+ * user except `ensureSystemAudioAsked`.
*/
-function mediaStatus(kind: PermissionKind): PermissionState {
- const media = kind === 'microphone' ? 'microphone' : 'screen'
+function mediaStatus(media: 'microphone' | 'screen'): PermissionState {
try {
return systemPreferences.getMediaAccessStatus(media)
} catch {
@@ -17,13 +23,61 @@ function mediaStatus(kind: PermissionKind): PermissionState {
}
}
-export function permissionStatus(): PermissionStatus {
+function audioCaptureHelperPath(): string {
+ return app.isPackaged
+ ? join(process.resourcesPath, 'audiocapture')
+ : join(__dirname, '../../build/helpers/audiocapture')
+}
+
+/**
+ * Runs the System Audio Recording helper. A missing helper or a failed run reads as unknown,
+ * which flags nothing: Chromium's own failure still shows as "couldn't capture computer audio".
+ */
+function runAudioCaptureHelper(command: 'status' | 'request'): Promise {
+ const path = audioCaptureHelperPath()
+ if (!existsSync(path)) {
+ log('permissions', 'system audio helper missing', { path })
+ return Promise.resolve('unknown')
+ }
+ // `request` waits for the user to answer the system prompt.
+ const timeout = command === 'status' ? 5_000 : 120_000
+ return new Promise((resolve) => {
+ execFile(path, [command], { timeout }, (error, stdout) => {
+ if (error) {
+ log('permissions', 'system audio helper failed', { command, error: error.message })
+ resolve('unknown')
+ return
+ }
+ resolve(parseAudioCaptureReply(stdout))
+ })
+ })
+}
+
+export async function permissionStatus(): Promise {
if (process.platform === 'darwin') {
- return { microphone: mediaStatus('microphone'), screen: mediaStatus('screen') }
+ // Before macOS 14.2 computer audio comes through ScreenCaptureKit, under Screen Recording.
+ const systemAudio = usesAudioTap(process.platform, release())
+ ? await runAudioCaptureHelper('status')
+ : mediaStatus('screen')
+ return { microphone: mediaStatus('microphone'), systemAudio }
}
- // Windows has a microphone switch but no screen-capture permission; Linux asks for neither.
- if (process.platform === 'win32') return { microphone: mediaStatus('microphone'), screen: 'granted' }
- return { microphone: 'granted', screen: 'granted' }
+ // Windows has a microphone switch but no loopback permission; Linux asks for neither.
+ const microphone = process.platform === 'win32' ? mediaStatus('microphone') : 'granted'
+ return { microphone, systemAudio: 'granted' }
+}
+
+/**
+ * Shows macOS's System Audio Recording prompt if it has never been asked. Chromium only checks
+ * this permission, so without asking first the capture fails silently and Lyra is never listed
+ * in System Settings to allow.
+ */
+export async function ensureSystemAudioAsked(): Promise {
+ if (!usesAudioTap(process.platform, release())) return
+ const before = await runAudioCaptureHelper('status')
+ if (!shouldRequestAudioCapture(before)) return
+ log('permissions', 'asking for system audio recording')
+ const after = await runAudioCaptureHelper('request')
+ log('permissions', 'system audio recording answered', { state: after })
}
/** Opens the system settings page for `kind`; false when this platform has none. */
diff --git a/apps/lyra/src/main/systemAudioSource.test.ts b/apps/lyra/src/main/systemAudioSource.test.ts
index 6c605d70..f4d40e1b 100644
--- a/apps/lyra/src/main/systemAudioSource.test.ts
+++ b/apps/lyra/src/main/systemAudioSource.test.ts
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
-import { systemAudioSource } from './systemAudioSource'
+import { systemAudioSource, usesAudioTap } from './systemAudioSource'
describe('systemAudioSource', () => {
it('uses process loopback on Windows builds that have it', () => {
@@ -21,3 +21,22 @@ describe('systemAudioSource', () => {
expect(systemAudioSource('linux', '6.8.0-45-generic')).toBe('loopback')
})
})
+
+describe('usesAudioTap', () => {
+ it('uses the tap from macOS 14.2 (Darwin 23.2)', () => {
+ expect(usesAudioTap('darwin', '23.2.0')).toBe(true)
+ expect(usesAudioTap('darwin', '24.1.0')).toBe(true)
+ expect(usesAudioTap('darwin', '25.6.0')).toBe(true)
+ })
+
+ it('keeps ScreenCaptureKit before macOS 14.2', () => {
+ expect(usesAudioTap('darwin', '23.1.0')).toBe(false)
+ expect(usesAudioTap('darwin', '22.6.0')).toBe(false)
+ })
+
+ it('is off elsewhere and when the release cannot be read', () => {
+ expect(usesAudioTap('win32', '10.0.22631')).toBe(false)
+ expect(usesAudioTap('linux', '6.8.0')).toBe(false)
+ expect(usesAudioTap('darwin', '')).toBe(false)
+ })
+})
diff --git a/apps/lyra/src/main/systemAudioSource.ts b/apps/lyra/src/main/systemAudioSource.ts
index 4b1ba367..7178eee5 100644
--- a/apps/lyra/src/main/systemAudioSource.ts
+++ b/apps/lyra/src/main/systemAudioSource.ts
@@ -19,3 +19,20 @@ export function systemAudioSource(platform: string, release: string): SystemAudi
const build = Number(release.split('.')[2])
return Number.isInteger(build) && build >= PROCESS_LOOPBACK_BUILD ? 'loopbackWithoutChrome' : 'loopback'
}
+
+/** Darwin 23.2 is macOS 14.2, the first with Core Audio taps. */
+const AUDIO_TAP_DARWIN = [23, 2] as const
+
+/**
+ * Whether macOS records computer audio through a Core Audio tap (14.2+), which needs System
+ * Audio Recording and no screen. Older macOS falls back to ScreenCaptureKit, which captures
+ * audio alongside a display and so needs a screen source and Screen Recording.
+ * `release` is `os.release()`: "25.6.0" on macOS 26.
+ */
+export function usesAudioTap(platform: string, release: string): boolean {
+ if (platform !== 'darwin') return false
+ const [major = Number.NaN, minor = 0] = release.split('.').map(Number)
+ if (!Number.isInteger(major)) return false
+ const [tapMajor, tapMinor] = AUDIO_TAP_DARWIN
+ return major > tapMajor || (major === tapMajor && minor >= tapMinor)
+}
diff --git a/apps/lyra/src/main/tasks/smoke.ts b/apps/lyra/src/main/tasks/smoke.ts
index c796fa7d..a4ed97de 100644
--- a/apps/lyra/src/main/tasks/smoke.ts
+++ b/apps/lyra/src/main/tasks/smoke.ts
@@ -1706,7 +1706,7 @@ export async function runUiSmoke(win: BrowserWindow): Promise {
if (!info.version || !Array.isArray(info.places) || info.places.length !== 4) fail('diagnostics: ' + JSON.stringify(info))
if (info.text.includes('Smoke page') || info.text.includes('hello from smoke')) fail('diagnostics carried note text')
const perms = await window.api.permissionStatus()
- if (!perms.microphone || !perms.screen) fail('permission status: ' + JSON.stringify(perms))
+ if (!perms.microphone || !perms.systemAudio) fail('permission status: ' + JSON.stringify(perms))
if ((await window.api.cancelModelDownload('no-such-model.bin')) !== false) fail('cancelled a download that was not running')
if (!(await refuses(() => window.api.cancelModelDownload('../settings.json')))) fail('models:cancel took a path')
// Model status: a list of known features, a subscription, and Retry only for real features.
diff --git a/apps/lyra/src/renderer/src/components/Capture.tsx b/apps/lyra/src/renderer/src/components/Capture.tsx
index 7cc4081c..44aea5cd 100644
--- a/apps/lyra/src/renderer/src/components/Capture.tsx
+++ b/apps/lyra/src/renderer/src/components/Capture.tsx
@@ -227,7 +227,7 @@ export function SystemAudioMessage({
type="button"
className="toast-action"
onClick={() => {
- window.api.openPermissionSettings('screen').then(
+ window.api.openPermissionSettings('systemAudio').then(
(opened) => {
if (!opened) notify('Open your system settings to change this.')
},
diff --git a/apps/lyra/src/renderer/src/components/Permissions.tsx b/apps/lyra/src/renderer/src/components/Permissions.tsx
index b0ddb672..a249b76d 100644
--- a/apps/lyra/src/renderer/src/components/Permissions.tsx
+++ b/apps/lyra/src/renderer/src/components/Permissions.tsx
@@ -9,9 +9,9 @@ const WHAT: Record
mac: 'Allowed in System Settings → Privacy & Security → Microphone.',
win: 'Allowed in Windows Settings → Privacy & security → Microphone.'
},
- screen: {
- label: 'Screen Recording access',
- mac: 'macOS asks for it to record computer audio. Allowed in System Settings → Privacy & Security → Screen & System Audio Recording.',
+ systemAudio: {
+ label: 'System Audio Recording access',
+ mac: 'Records the other side of your calls. Allowed in System Settings → Privacy & Security → Screen & System Audio Recording, under System Audio Recording Only.',
win: ''
}
}
diff --git a/apps/lyra/src/renderer/src/components/Settings.tsx b/apps/lyra/src/renderer/src/components/Settings.tsx
index 5bc162ea..4197b18d 100644
--- a/apps/lyra/src/renderer/src/components/Settings.tsx
+++ b/apps/lyra/src/renderer/src/components/Settings.tsx
@@ -445,7 +445,7 @@ function RecordingSection({
label="Capture computer audio"
hint={
mac
- ? 'Records the other side of calls (Zoom, Meet, Teams). macOS asks for Screen Recording permission for this.'
+ ? 'Records the other side of calls (Zoom, Meet, Teams). macOS asks for System Audio Recording permission for this.'
: 'Records the other side of calls (Zoom, Meet, Teams).'
}
>
@@ -472,7 +472,7 @@ function RecordingSection({
Recording other people usually requires their consent. Session audio, transcripts and
voiceprints stay on this computer.
- {settings.captureSystemAudio ? : null}
+ {settings.captureSystemAudio ? : null}
)
diff --git a/apps/lyra/src/renderer/src/hooks/useDictation.ts b/apps/lyra/src/renderer/src/hooks/useDictation.ts
index a2ae0c44..a4ae12fc 100644
--- a/apps/lyra/src/renderer/src/hooks/useDictation.ts
+++ b/apps/lyra/src/renderer/src/hooks/useDictation.ts
@@ -208,7 +208,9 @@ export function useDictation({ getDeviceId }: Options) {
// Why, when the OS can say: a refused permission has a settings page to send them to.
window.api.permissionStatus().then(
(status) => {
- if (status.screen !== 'granted') changeSystem('blocked')
+ // Unknown (no helper, older macOS) isn't a refusal.
+ const refused = status.systemAudio === 'denied' || status.systemAudio === 'restricted'
+ if (refused) changeSystem('blocked')
},
() => {
// The plain message stands.
diff --git a/apps/lyra/src/shared/types.ts b/apps/lyra/src/shared/types.ts
index 1b2e0c5d..8f32bf84 100644
--- a/apps/lyra/src/shared/types.ts
+++ b/apps/lyra/src/shared/types.ts
@@ -226,7 +226,7 @@ export type NotesBackfillResult = { written: number; failed: number; stopped: bo
export type NotesTestResult = { ok: true; ms: number; onDevice: boolean } | { ok: false; error: string }
/** A permission the OS asks the user for. */
-export type PermissionKind = 'microphone' | 'screen'
+export type PermissionKind = 'microphone' | 'systemAudio'
/** As `systemPreferences.getMediaAccessStatus` reports it; 'granted' where the OS doesn't ask. */
export type PermissionState = 'not-determined' | 'granted' | 'denied' | 'restricted' | 'unknown'
export type PermissionStatus = Record
diff --git a/docs/PLAN.md b/docs/PLAN.md
index fa3f7de2..107861f4 100644
--- a/docs/PLAN.md
+++ b/docs/PLAN.md
@@ -144,7 +144,7 @@ Speaker labeling is far more accurate on a full recording after the session than
- **Session type:** sessions are either *Dictation* (today's behavior) or *Meeting* (record audio, capture system audio, run the speaker pass when the session ends). Pick it from the dock, the hotkey (a second hotkey or a modifier) or the §5 popup. The popup defaults to *Meeting*, since another app holding the mic usually means a call.
- **System audio (the other side of a call):**
- **Windows:** `session.setDisplayMediaRequestHandler` with `audio: 'loopback'`, then `getDisplayMedia` in the renderer. No picker or permission prompt.
- - **macOS:** Electron's ScreenCaptureKit loopback, macOS 13+ only. Needs the Screen Recording permission, so add an onboarding step that explains why. Older macOS gets mic only and Settings says so.
+ - **macOS:** Chromium's Core Audio tap loopback, macOS 14.2+. Needs the System Audio Recording permission, which Lyra asks for the first time (`native/mac/audiocapture.swift`); the discarded video track is Lyra's own window, so no Screen Recording. Before 14.2 it falls back to ScreenCaptureKit with the primary screen, which needs Screen Recording.
- **Linux:** capture the PulseAudio/PipeWire `.monitor` source as a regular input device. Best effort.
- **Mixing:** keep mic and system audio as **two tracks**.
- The mic track is almost always *you*, which is a free speaker hint.