Repository navigation
feat(desktop): unify audio recording modes - #11520
Conversation
| ) -> AudioRecordingMode { | ||
| if legacyTranscriptionEnabled == false { return .off } | ||
| switch legacySystemAudioModeRaw { | ||
| case "always", "never": return .always |
There was a problem hiding this comment.
🔒 Agentic Security Review
Severity: HIGH
[Privacy Guard] Legacy users with systemAudioCaptureMode == "never" are migrated to audioRecordingMode == .always, which silently broadens recording scope from mic-only to always-on mode eligibility (including system audio when permission already exists) without an explicit re-consent step.
Impact: Existing users who previously opted out of system-audio capture can have broader audio capture activated after upgrade, creating a consent-boundary and privacy expectation regression.
Reviewed by Cursor Security Reviewer for commit b989fc3. Configure here.
There was a problem hiding this comment.
16 issues found across 46 files
Confidence score: 3/5
desktop/macos/Desktop/Sources/AppState/AppState+Transcription.swifthas a timing hazard wherereconcileCapture()can start a new capture beforefinishConversation()finishes clearing/rotating state, which can corrupt session transitions or drop audio state during handoff — serialize these paths or gate new capture start until teardown completion.- Mode-toggle logic is inconsistent across
DashboardPage.swift,CaptureListeningLogic.swift,AppState.swift,SidebarView.swift, andDesktopAutomationBridge.swift: re-enabling listening can downgrade.alwaysto.onlyMeetings(and in one path persist non-off state even when paywalled), causing user preference loss and surprising behavior — centralize enable/disable through one transition helper that preserves the last non-off mode. - Settings migration/initialization flow in
AssistantSettings.swift,ShellStatusIcons.swift, andscripts/omi-settings-seed.shcan delete or ignore legacy keys at the wrong time, temporarily misreport upgraded users’ mode and leave stale/invalid persisted values — only remove legacy keys after confirmed migration and ensure reads go through migrated settings. desktop/macos/Desktop/Sources/Onboarding/SecondBrain/SBPostOnboardingGuidance.swiftmaps “Audio Recording Off + mic granted” to a microphone-disabled cue, which can mislead users into fixing the wrong thing — update the mapping so guidance reflects recording intent vs permission state.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="desktop/macos/Desktop/Sources/DesktopAutomationBridge.swift">
<violation number="1" location="desktop/macos/Desktop/Sources/DesktopAutomationBridge.swift:1245">
P2: `toggle_transcription` no longer mirrors the menu-bar transition: enabling while the selected mode is `.always` downgrades it to `.onlyMeetings`, and a paywalled enable still persists a non-off mode. Call `SystemCaptureControls.setAudioRecording` and return its `resultingIsOn` so the shared mode-preservation and paywall logic applies.</violation>
</file>
<file name="desktop/macos/Desktop/Sources/Onboarding/SecondBrain/SBPostOnboardingGuidance.swift">
<violation number="1" location="desktop/macos/Desktop/Sources/Onboarding/SecondBrain/SBPostOnboardingGuidance.swift:31">
P2: When Audio Recording is Off but microphone permission is granted, this mapping produces the `.disabled` cue and tells the user to enable the microphone, even though the microphone is available and recording is intentionally disabled. Preserve Off separately from denied microphone access and render an appropriate Off-state cue.</violation>
</file>
<file name="desktop/macos/scripts/omi-settings-seed.sh">
<violation number="1" location="desktop/macos/scripts/omi-settings-seed.sh:95">
P2: The legacy-to-`audioRecordingMode` migration table is duplicated verbatim in `AssistantSettings.migratedAudioRecordingMode` and in this seed script's `source_audio_recording_mode`. They must return identical results or seeded dev bundles will diverge from real production upgrades. Since the precedence (transcription-off first, then the mode map) is business logic, keep a single source of truth — e.g. add a focused unit test that pins the Swift mapping cases and a comment in each location cross-referencing the other, or better, consolidate the shared mapping so a future change cannot desync the two.</violation>
<violation number="2" location="desktop/macos/scripts/omi-settings-seed.sh:163">
P2: When reseeding a target bundle that still has legacy capture keys, this cleanup does not delete them because `target_data` still contains the exported target values. Remove both legacy keys from `target_data` before import, or make their deletion unconditional.</violation>
</file>
<file name="desktop/macos/Desktop/Sources/Providers/ChatProvider.swift">
<violation number="1" location="desktop/macos/Desktop/Sources/Providers/ChatProvider.swift:5578">
P3: The ternary collapses the new `.off` policy into `.meetingsOnly`, so when `audioRecordingMode` is `.off` the post-onboarding opener subline still tells the user "I'm set up and I'll listen during your meetings." The subline is driven only by whether the mode is `.always` or not (`OnboardingOpenerComposer.subline`), so `off` produces the meetings-only claim even though the user has disabled recording. Since onboarding's CaptureSelection only offers `onlyMeetings`/`always`, this is reachable today mainly via the lazy-dev-permissions path that sets `.off`, but once Off is a first-class user policy the opener should not advertise listening. Consider handling `.off` distinctly (or guarding the opener) rather than folding it into `.meetingsOnly`.</violation>
</file>
<file name="desktop/macos/Desktop/Sources/MainWindow/QueryShell/ShellStatusIcons.swift">
<violation number="1" location="desktop/macos/Desktop/Sources/MainWindow/QueryShell/ShellStatusIcons.swift:324">
P2: When the shell is constructed before `AssistantSettings.shared` has initialized, this `@AppStorage` read bypasses the legacy-settings migration and temporarily reports every upgraded user as `Only Meetings`, regardless of their saved policy. Initialize `AssistantSettings.shared` before constructing the UI (or expose a migration-safe canonical read) so the icon never renders from an unmigrated default.</violation>
</file>
<file name="desktop/macos/Desktop/Sources/MainWindow/Pages/DashboardPage.swift">
<violation number="1" location="desktop/macos/Desktop/Sources/MainWindow/Pages/DashboardPage.swift:1802">
P2: When a user selects Always On, clicking the Dashboard Listening control off and back on changes the policy to Only Meetings. Preserve the last non-off mode when re-enabling, as the old separate enable toggle did.</violation>
</file>
<file name="desktop/macos/Desktop/Sources/AppState.swift">
<violation number="1" location="desktop/macos/Desktop/Sources/AppState.swift:896">
P2: The `.off` branch of the `.audioRecordingModeDidChange` observer calls `stopTranscription()` unconditionally, but the replaced `reconcileCapture()` path (and the sibling `.always/.onlyMeetings` branch) is gated by the `guard isTranscribing` check at the top of `reconcileCapture`. `stopTranscription()` is not idle-safe: it bumps `recordingGeneration`, calls `captureCurrentFinishedRecordingForLifecycle()`, `stopAudioCapture()`, and `clearTranscriptionState()` — which always posts `AnalyticsManager.transcriptionStopped` and clears live-notes/session state. Several callers write `.off` while no recording is active (e.g. `OnboardingView` sets `audioRecordingMode = .off` under lazy dev permissions), so setting the mode to Off while idle now fires a spurious stop, analytics event, and a `recordingGeneration` bump that can invalidate a concurrently starting session. Guard the branch on `isTranscribing`, or make `stopTranscription()` a no-op when not transcribing.</violation>
<violation number="2" location="desktop/macos/Desktop/Sources/AppState.swift:898">
P2: When a local-STT user switches Off and back to Always or Only Meetings during teardown, this branch reconciles the dying session instead of starting a replacement. `stopTranscription()` clears `isTranscribing` asynchronously, so the selected recording mode can remain enabled while capture stays stopped. Track or await the pending stop, then reapply the selected mode after teardown.</violation>
</file>
<file name="desktop/macos/Desktop/Sources/AppState/AppState+Transcription.swift">
<violation number="1" location="desktop/macos/Desktop/Sources/AppState/AppState+Transcription.swift:652">
P1: When the next meeting or a capture recovery arrives before this task finishes, `reconcileCapture()` can start the new capture while the old `finishConversation()` is still clearing session state and rotating the stream. Keep the capture gate held until finalization completes, or serialize this fallback through `handleMeetingObservation` before allowing another reconciliation.</violation>
</file>
<file name="desktop/macos/Desktop/Sources/ProactiveAssistants/Services/AssistantSettings.swift">
<violation number="1" location="desktop/macos/Desktop/Sources/ProactiveAssistants/Services/AssistantSettings.swift:82">
P2: When `audioRecordingMode` already exists, this migration skips consuming the legacy values but still deletes them here. Remove legacy keys only after this invocation actually migrates them, so stale or invalid new data cannot irreversibly lose the user’s recording choice.</violation>
</file>
<file name="desktop/macos/Desktop/Sources/MainWindow/SidebarView.swift">
<violation number="1" location="desktop/macos/Desktop/Sources/MainWindow/SidebarView.swift:804">
P2: When the persisted policy is `.always` but `appState.isTranscribing` is temporarily false, the sidebar enable path rewrites it to `.onlyMeetings`. Preserve the current non-off mode when enabling, as the other audio toggles already do.</violation>
<violation number="2" location="desktop/macos/Desktop/Sources/MainWindow/SidebarView.swift:805">
P3: This path now changes `audioRecordingMode` but still emits the legacy `transcription` analytics event. Emit `audio_recording_mode_\(mode.rawValue)` so sidebar changes match the mode switcher and shared listening toggle.</violation>
</file>
<file name="desktop/macos/Desktop/Sources/MainWindow/Pages/SettingsPage.swift">
<violation number="1" location="desktop/macos/Desktop/Sources/MainWindow/Pages/SettingsPage.swift:201">
P3: This PR introduces the new UserDefaults key "audioRecordingMode" (via `AssistantSettings.audioRecordingModeDefaultsKey`), but it is not routed through the `DefaultsKey` enum. `DefaultsKey.swift` documents that new keys are added there so a typo becomes a compile error instead of a silent `nil` read, and the `omi_inline_userdefaults_key` CI rule exists to enforce that. The constant is centralized so it is not a literal-typo risk today, but adding a `DefaultsKey.audioRecordingMode` case and referencing it from `@AppStorage`/`AssistantSettings` keeps the convention consistent and lets the ratchet track the key. Prefer that over leaving the new key as a bare string constant alongside the enum.</violation>
</file>
<file name="desktop/macos/Desktop/Sources/MainWindow/CaptureListeningLogic.swift">
<violation number="1" location="desktop/macos/Desktop/Sources/MainWindow/CaptureListeningLogic.swift:64">
P2: Toggling the listening pill in `.always` mode loses the Always On preference. `toggleListening` computes `nextMode = currentMode == .off ? .onlyMeetings : .off`, so a user in Always On who toggles the shell/home pill off then back on is silently downgraded to Only Meetings instead of returning to Always On. `AppState.toggleTranscription()` intentionally preserves the selected non-off mode (`selected == .off ? .onlyMeetings : selected`), so restore that semantics here too so the pill respects the user's Always On choice.</violation>
</file>
<file name="desktop/macos/Desktop/Sources/DesktopDiagnosticsManager.swift">
<violation number="1" location="desktop/macos/Desktop/Sources/DesktopDiagnosticsManager.swift:1271">
P3: commonProperties() reports the raw persisted `audioRecordingMode` string and falls back to a hardcoded `"onlyMeetings"`, bypassing the canonical `AssistantSettings.shared.audioRecordingMode` getter that normalizes invalid values via `AudioRecordingMode(rawValue:) ?? defaultAudioRecordingMode`. If the stored value is ever invalid/corrupt, the diagnostic value disagrees with the mode the app actually applies. Read through the getter (or the enum's validated rawValue) so telemetry reflects the effective mode and the fallback isn't a duplicated literal.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| { | ||
| meetingEndFinalizationInProgress = true | ||
| log("Transcription: Meeting ended — finishing conversation and waiting for the next meeting") | ||
| Task { @MainActor in |
There was a problem hiding this comment.
P1: When the next meeting or a capture recovery arrives before this task finishes, reconcileCapture() can start the new capture while the old finishConversation() is still clearing session state and rotating the stream. Keep the capture gate held until finalization completes, or serialize this fallback through handleMeetingObservation before allowing another reconciliation.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/Desktop/Sources/AppState/AppState+Transcription.swift, line 652:
<comment>When the next meeting or a capture recovery arrives before this task finishes, `reconcileCapture()` can start the new capture while the old `finishConversation()` is still clearing session state and rotating the stream. Keep the capture gate held until finalization completes, or serialize this fallback through `handleMeetingObservation` before allowing another reconciliation.</comment>
<file context>
@@ -628,6 +638,35 @@ extension AppState {
+ {
+ meetingEndFinalizationInProgress = true
+ log("Transcription: Meeting ended — finishing conversation and waiting for the next meeting")
+ Task { @MainActor in
+ defer { self.meetingEndFinalizationInProgress = false }
+ guard
</file context>
| AssistantSettings.shared.audioRecordingMode = enabled ? .onlyMeetings : .off | ||
| return ["enabled": enabled ? "true" : "false"] |
There was a problem hiding this comment.
P2: toggle_transcription no longer mirrors the menu-bar transition: enabling while the selected mode is .always downgrades it to .onlyMeetings, and a paywalled enable still persists a non-off mode. Call SystemCaptureControls.setAudioRecording and return its resultingIsOn so the shared mode-preservation and paywall logic applies.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/Desktop/Sources/DesktopAutomationBridge.swift, line 1245:
<comment>`toggle_transcription` no longer mirrors the menu-bar transition: enabling while the selected mode is `.always` downgrades it to `.onlyMeetings`, and a paywalled enable still persists a non-off mode. Call `SystemCaptureControls.setAudioRecording` and return its `resultingIsOn` so the shared mode-preservation and paywall logic applies.</comment>
<file context>
@@ -1242,9 +1242,7 @@ final class DesktopAutomationActionRegistry {
- AssistantSettings.shared.transcriptionEnabled = enabled
- NotificationCenter.default.post(
- name: .toggleTranscriptionRequested, object: nil, userInfo: ["enabled": enabled])
+ AssistantSettings.shared.audioRecordingMode = enabled ? .onlyMeetings : .off
return ["enabled": enabled ? "true" : "false"]
}
</file context>
| AssistantSettings.shared.audioRecordingMode = enabled ? .onlyMeetings : .off | |
| return ["enabled": enabled ? "true" : "false"] | |
| let outcome = SystemCaptureControls.setAudioRecording(enabled) | |
| return ["enabled": outcome.resultingIsOn ? "true" : "false"] |
| case AssistantSettings.SystemAudioCaptureMode.never.rawValue: | ||
| self = .microphoneOnly | ||
| case AssistantSettings.AudioRecordingMode.off.rawValue: | ||
| self = .disabled |
There was a problem hiding this comment.
P2: When Audio Recording is Off but microphone permission is granted, this mapping produces the .disabled cue and tells the user to enable the microphone, even though the microphone is available and recording is intentionally disabled. Preserve Off separately from denied microphone access and render an appropriate Off-state cue.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/Desktop/Sources/Onboarding/SecondBrain/SBPostOnboardingGuidance.swift, line 31:
<comment>When Audio Recording is Off but microphone permission is granted, this mapping produces the `.disabled` cue and tells the user to enable the microphone, even though the microphone is available and recording is intentionally disabled. Preserve Off separately from denied microphone access and render an appropriate Off-state cue.</comment>
<file context>
@@ -14,25 +14,21 @@ import Foundation
- case AssistantSettings.SystemAudioCaptureMode.never.rawValue:
- self = .microphoneOnly
+ case AssistantSettings.AudioRecordingMode.off.rawValue:
+ self = .disabled
default:
// An unknown persisted value is not evidence for a more permissive
</file context>
| "disableSystemAudioCapture", | ||
| "screenAnalysisAutoStartFixed_v2", | ||
| "screenAnalysisAutoStartFixed_v3", | ||
| "transcriptionEnabled", |
There was a problem hiding this comment.
P2: When reseeding a target bundle that still has legacy capture keys, this cleanup does not delete them because target_data still contains the exported target values. Remove both legacy keys from target_data before import, or make their deletion unconditional.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/scripts/omi-settings-seed.sh, line 163:
<comment>When reseeding a target bundle that still has legacy capture keys, this cleanup does not delete them because `target_data` still contains the exported target values. Remove both legacy keys from `target_data` before import, or make their deletion unconditional.</comment>
<file context>
@@ -148,7 +156,13 @@ with tempfile.NamedTemporaryFile(suffix=".plist") as plist:
+ "disableSystemAudioCapture",
+ "screenAnalysisAutoStartFixed_v2",
+ "screenAnalysisAutoStartFixed_v3",
+ "transcriptionEnabled",
+ "systemAudioCaptureMode",
+):
</file context>
| @AppStorage("transcriptionEnabled") private var transcriptionEnabled = true | ||
| @AppStorage("systemAudioCaptureMode") private var systemAudioCaptureModeRaw = | ||
| AssistantSettings.SystemAudioCaptureMode.onlyDuringMeetings.rawValue | ||
| @AppStorage(AssistantSettings.audioRecordingModeDefaultsKey) private var audioRecordingModeRaw = |
There was a problem hiding this comment.
P2: When the shell is constructed before AssistantSettings.shared has initialized, this @AppStorage read bypasses the legacy-settings migration and temporarily reports every upgraded user as Only Meetings, regardless of their saved policy. Initialize AssistantSettings.shared before constructing the UI (or expose a migration-safe canonical read) so the icon never renders from an unmigrated default.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/Desktop/Sources/MainWindow/QueryShell/ShellStatusIcons.swift, line 324:
<comment>When the shell is constructed before `AssistantSettings.shared` has initialized, this `@AppStorage` read bypasses the legacy-settings migration and temporarily reports every upgraded user as `Only Meetings`, regardless of their saved policy. Initialize `AssistantSettings.shared` before constructing the UI (or expose a migration-safe canonical read) so the icon never renders from an unmigrated default.</comment>
<file context>
@@ -321,9 +321,8 @@ struct ShellStatusIcons: View {
- @AppStorage("transcriptionEnabled") private var transcriptionEnabled = true
- @AppStorage("systemAudioCaptureMode") private var systemAudioCaptureModeRaw =
- AssistantSettings.SystemAudioCaptureMode.onlyDuringMeetings.rawValue
+ @AppStorage(AssistantSettings.audioRecordingModeDefaultsKey) private var audioRecordingModeRaw =
+ AssistantSettings.AudioRecordingMode.onlyMeetings.rawValue
</file context>
| guard let self else { return } | ||
| switch AssistantSettings.shared.audioRecordingMode { | ||
| case .off: | ||
| self.stopTranscription() |
There was a problem hiding this comment.
P2: The .off branch of the .audioRecordingModeDidChange observer calls stopTranscription() unconditionally, but the replaced reconcileCapture() path (and the sibling .always/.onlyMeetings branch) is gated by the guard isTranscribing check at the top of reconcileCapture. stopTranscription() is not idle-safe: it bumps recordingGeneration, calls captureCurrentFinishedRecordingForLifecycle(), stopAudioCapture(), and clearTranscriptionState() — which always posts AnalyticsManager.transcriptionStopped and clears live-notes/session state. Several callers write .off while no recording is active (e.g. OnboardingView sets audioRecordingMode = .off under lazy dev permissions), so setting the mode to Off while idle now fires a spurious stop, analytics event, and a recordingGeneration bump that can invalidate a concurrently starting session. Guard the branch on isTranscribing, or make stopTranscription() a no-op when not transcribing.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/Desktop/Sources/AppState.swift, line 896:
<comment>The `.off` branch of the `.audioRecordingModeDidChange` observer calls `stopTranscription()` unconditionally, but the replaced `reconcileCapture()` path (and the sibling `.always/.onlyMeetings` branch) is gated by the `guard isTranscribing` check at the top of `reconcileCapture`. `stopTranscription()` is not idle-safe: it bumps `recordingGeneration`, calls `captureCurrentFinishedRecordingForLifecycle()`, `stopAudioCapture()`, and `clearTranscriptionState()` — which always posts `AnalyticsManager.transcriptionStopped` and clears live-notes/session state. Several callers write `.off` while no recording is active (e.g. `OnboardingView` sets `audioRecordingMode = .off` under lazy dev permissions), so setting the mode to Off while idle now fires a spurious stop, analytics event, and a `recordingGeneration` bump that can invalidate a concurrently starting session. Guard the branch on `isTranscribing`, or make `stopTranscription()` a no-op when not transcribing.</comment>
<file context>
@@ -877,14 +882,25 @@ class AppState: ObservableObject {
+ guard let self else { return }
+ switch AssistantSettings.shared.audioRecordingMode {
+ case .off:
+ self.stopTranscription()
+ case .always, .onlyMeetings:
+ if self.isTranscribing {
</file context>
| let name = Self.firstName(AuthService.shared.givenName) | ||
| let mode: OnboardingOpenerComposer.ListeningMode = | ||
| AssistantSettings.shared.systemAudioCaptureMode == .always ? .always : .meetingsOnly | ||
| AssistantSettings.shared.audioRecordingMode == .always ? .always : .meetingsOnly |
There was a problem hiding this comment.
P3: The ternary collapses the new .off policy into .meetingsOnly, so when audioRecordingMode is .off the post-onboarding opener subline still tells the user "I'm set up and I'll listen during your meetings." The subline is driven only by whether the mode is .always or not (OnboardingOpenerComposer.subline), so off produces the meetings-only claim even though the user has disabled recording. Since onboarding's CaptureSelection only offers onlyMeetings/always, this is reachable today mainly via the lazy-dev-permissions path that sets .off, but once Off is a first-class user policy the opener should not advertise listening. Consider handling .off distinctly (or guarding the opener) rather than folding it into .meetingsOnly.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/Desktop/Sources/Providers/ChatProvider.swift, line 5578:
<comment>The ternary collapses the new `.off` policy into `.meetingsOnly`, so when `audioRecordingMode` is `.off` the post-onboarding opener subline still tells the user "I'm set up and I'll listen during your meetings." The subline is driven only by whether the mode is `.always` or not (`OnboardingOpenerComposer.subline`), so `off` produces the meetings-only claim even though the user has disabled recording. Since onboarding's CaptureSelection only offers `onlyMeetings`/`always`, this is reachable today mainly via the lazy-dev-permissions path that sets `.off`, but once Off is a first-class user policy the opener should not advertise listening. Consider handling `.off` distinctly (or guarding the opener) rather than folding it into `.meetingsOnly`.</comment>
<file context>
@@ -5575,7 +5575,7 @@ class ChatProvider: ObservableObject {
let name = Self.firstName(AuthService.shared.givenName)
let mode: OnboardingOpenerComposer.ListeningMode =
- AssistantSettings.shared.systemAudioCaptureMode == .always ? .always : .meetingsOnly
+ AssistantSettings.shared.audioRecordingMode == .always ? .always : .meetingsOnly
let baseStarters = HomeSuggestionComposer.compose(
personalized: HomeSuggestionsStore.shared.personalizedQuestions,
</file context>
| appState.stopTranscription() | ||
| } | ||
| let mode: AssistantSettings.AudioRecordingMode = enabled ? .onlyMeetings : .off | ||
| audioRecordingModeRaw = mode.rawValue |
There was a problem hiding this comment.
P3: This path now changes audioRecordingMode but still emits the legacy transcription analytics event. Emit audio_recording_mode_\(mode.rawValue) so sidebar changes match the mode switcher and shared listening toggle.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/Desktop/Sources/MainWindow/SidebarView.swift, line 805:
<comment>This path now changes `audioRecordingMode` but still emits the legacy `transcription` analytics event. Emit `audio_recording_mode_\(mode.rawValue)` so sidebar changes match the mode switcher and shared listening toggle.</comment>
<file context>
@@ -800,14 +801,9 @@ struct SidebarView: View {
- appState.stopTranscription()
- }
+ let mode: AssistantSettings.AudioRecordingMode = enabled ? .onlyMeetings : .off
+ audioRecordingModeRaw = mode.rawValue
+ AssistantSettings.shared.audioRecordingMode = mode
</file context>
| @State var isTogglingTranscription: Bool = false | ||
| @State var transcriptionError: String? | ||
| // The sole ambient-audio preference. Runtime activity remains on AppState. | ||
| @AppStorage(AssistantSettings.audioRecordingModeDefaultsKey) var audioRecordingModeRaw = |
There was a problem hiding this comment.
P3: This PR introduces the new UserDefaults key "audioRecordingMode" (via AssistantSettings.audioRecordingModeDefaultsKey), but it is not routed through the DefaultsKey enum. DefaultsKey.swift documents that new keys are added there so a typo becomes a compile error instead of a silent nil read, and the omi_inline_userdefaults_key CI rule exists to enforce that. The constant is centralized so it is not a literal-typo risk today, but adding a DefaultsKey.audioRecordingMode case and referencing it from @AppStorage/AssistantSettings keeps the convention consistent and lets the ratchet track the key. Prefer that over leaving the new key as a bare string constant alongside the enum.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/Desktop/Sources/MainWindow/Pages/SettingsPage.swift, line 201:
<comment>This PR introduces the new UserDefaults key "audioRecordingMode" (via `AssistantSettings.audioRecordingModeDefaultsKey`), but it is not routed through the `DefaultsKey` enum. `DefaultsKey.swift` documents that new keys are added there so a typo becomes a compile error instead of a silent `nil` read, and the `omi_inline_userdefaults_key` CI rule exists to enforce that. The constant is centralized so it is not a literal-typo risk today, but adding a `DefaultsKey.audioRecordingMode` case and referencing it from `@AppStorage`/`AssistantSettings` keeps the convention consistent and lets the ratchet track the key. Prefer that over leaving the new key as a bare string constant alongside the enum.</comment>
<file context>
@@ -197,10 +197,9 @@ struct SettingsContentView: View {
- @State var isTogglingTranscription: Bool = false
- @State var transcriptionError: String?
+ // The sole ambient-audio preference. Runtime activity remains on AppState.
+ @AppStorage(AssistantSettings.audioRecordingModeDefaultsKey) var audioRecordingModeRaw =
+ AssistantSettings.AudioRecordingMode.onlyMeetings.rawValue
</file context>
| properties["system_audio_mode"] = | ||
| UserDefaults.standard.string(forKey: "systemAudioCaptureMode") ?? "onlyDuringMeetings" | ||
| properties["audio_recording_mode"] = | ||
| UserDefaults.standard.string(forKey: AssistantSettings.audioRecordingModeDefaultsKey) ?? "onlyMeetings" |
There was a problem hiding this comment.
P3: commonProperties() reports the raw persisted audioRecordingMode string and falls back to a hardcoded "onlyMeetings", bypassing the canonical AssistantSettings.shared.audioRecordingMode getter that normalizes invalid values via AudioRecordingMode(rawValue:) ?? defaultAudioRecordingMode. If the stored value is ever invalid/corrupt, the diagnostic value disagrees with the mode the app actually applies. Read through the getter (or the enum's validated rawValue) so telemetry reflects the effective mode and the fallback isn't a duplicated literal.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/Desktop/Sources/DesktopDiagnosticsManager.swift, line 1271:
<comment>commonProperties() reports the raw persisted `audioRecordingMode` string and falls back to a hardcoded `"onlyMeetings"`, bypassing the canonical `AssistantSettings.shared.audioRecordingMode` getter that normalizes invalid values via `AudioRecordingMode(rawValue:) ?? defaultAudioRecordingMode`. If the stored value is ever invalid/corrupt, the diagnostic value disagrees with the mode the app actually applies. Read through the getter (or the enum's validated rawValue) so telemetry reflects the effective mode and the fallback isn't a duplicated literal.</comment>
<file context>
@@ -1267,8 +1267,8 @@ final class DesktopDiagnosticsManager {
- properties["system_audio_mode"] =
- UserDefaults.standard.string(forKey: "systemAudioCaptureMode") ?? "onlyDuringMeetings"
+ properties["audio_recording_mode"] =
+ UserDefaults.standard.string(forKey: AssistantSettings.audioRecordingModeDefaultsKey) ?? "onlyMeetings"
return properties
}
</file context>


Summary
QA
/Applications/omi-audio-recording-mode.appxcrun swift build -c debug --package-path desktop/macos/Desktopcodesign --verify --deep --strict /Applications/omi-audio-recording-mode.appProduct invariants affected