Repository navigation
fix(desktop): present microphone alerts without blocking - #11453
Conversation
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_27420b19-ed1f-461f-958b-ca5dfb679c54) |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5d49f5b59a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| else { | ||
| log("Unable to present alert without a visible window") | ||
| return | ||
| } | ||
|
|
There was a problem hiding this comment.
Keep the alert when no window is visible
When a recording runs in the background with the main shell ordered out and the floating bar disabled or snoozed, all three window lookups can be nil. This branch then only logs and returns, so handleSharedCaptureSilentMicDetection has already stopped transcription but the user never sees why; the previous runModal() created its own visible alert. Present a nonblocking standalone alert or summon an appropriate window, and add coverage for the no-visible-window outcome.
AGENTS.md reference: desktop/macos/AGENTS.md:L185-L189
Useful? React with 👍 / 👎.
| let presenter = RecordingAlertPresenter() | ||
| state.alertPresenter = presenter | ||
|
|
||
| state.showAlert(title: "Microphone Isn't Capturing Audio", message: "Check your input device and try again.") |
There was a problem hiding this comment.
Exercise the real sheet presenter in the regression test
Because this test replaces AppKitSheetAlertPresenter before calling showAlert, it passes whether the production presenter uses beginSheetModal, reintroduces runModal, or does nothing at all. It therefore would not have caught the blocking behavior this fix targets; inject the AppKit alert/window operations beneath AppKitSheetAlertPresenter and exercise that production presenter so the test asserts that the sheet path, rather than the modal path, is selected.
AGENTS.md reference: AGENTS.md:L43-L45
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Addressed in current head: testShowAlertPresentsThroughTheNonBlockingSheetSeam now exercises the production AppKitSheetAlertPresenter with an injected appKitOperations recorder (asserting the sheet operation is what production selects), replacing the stub presenter. The other tests in this file already exercise the real presenter for reveal/defer/coalesce paths.
There was a problem hiding this comment.
All reported issues were addressed across 5 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks for taking on the blocking microphone alert path. I agree with the direction of moving showAlert away from NSAlert.runModal(), but I think this needs one production fix before merge.
Blocking issue:
desktop/macos/Desktop/Sources/AppState/AppState+Permissions.swift:AppKitSheetAlertPresenter.presentnow returns after only logging whenNSApp.keyWindow,NSApp.mainWindow, and visible windows are all unavailable. That is a behavior regression from the oldrunModal()path: the silent-microphone warning,Device Not Connected, andCouldn't Start Transcriptioncan now be dropped entirely in menu-bar / no-visible-window states. Please preserve a user-visible fallback, or queue/defer the non-blocking sheet until an appropriate app window exists, rather than losing the alert.
Other file-specific notes:
desktop/macos/Desktop/Sources/AppState.swift: theDesktopAlertPresentingseam andalertPresenterinjection are a good way to makeshowAlerttestable, but this also makes the default presenter behavior the critical production path to cover.desktop/macos/Desktop/Tests/AppStateAlertPresentationTests.swift: the new XCTest verifies delegation through the seam, but it stubs outAppKitSheetAlertPresenter, so it would still pass if the real presenter drops alerts in the no-window case or uses the wrong presentation mode. Please add coverage for the real presenter/window-selection behavior, or extract the AppKit window/alert operations behind a smaller seam that can provebeginSheetModaland fallback behavior.desktop/macos/changelog/unreleased/20260812-silent-microphone-alert.json: the changelog entry matches the intended user-facing fix, but it should only land once alerts are guaranteed not to disappear when no sheet host is available.desktop/macos/e2e/flows/audio-recording.yaml: the new S4B flow is the right manual scenario; please make sure it explicitly covers a no/hidden-main-window state if that is a supported desktop usage mode.
CI note: current Desktop Swift CI is not green (Desktop Swift Static & Test Contracts was cancelled and Desktop Swift Build & Tests failed because the required verification result was cancelled). I’m requesting changes for the production alert-dropping path above; CI should also be rerun once that is fixed.
Leaving this for the macOS desktop alert behavior to be fixed and verified before merge.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_327c6b51-a8d0-4065-9093-6e711bc92cf1) |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ff01180522
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| guard let window = windowProvider() else { | ||
| activateApplication() | ||
| return |
There was a problem hiding this comment.
Summon a window before deferring the alert
When silent-mic recovery stops a background recording while both the shell and floating bar are hidden, windowProvider() returns nil and this fallback only activates the process; it neither creates nor orders a window. The separate reveal calls in OmiApp.openMainAppWindow() confirm that activation alone is insufficient, so no key-window notification is guaranteed and the queued warning can remain invisible indefinitely. Fresh evidence after the earlier review is that the new fallback still waits for a future window rather than summoning one; present a standalone nonblocking alert or explicitly reveal the shell, and cover the terminal no-window outcome.
AGENTS.md reference: desktop/macos/AGENTS.md:L185-L189
Useful? React with 👍 / 👎.
| func present(title: String, message: String) { | ||
| pendingAlerts.append(.init(title: title, message: message)) | ||
| presentPendingAlertIfPossible() |
There was a problem hiding this comment.
Deduplicate alerts while one is already presented
When a sheet is attached to one Omi window, the floating bar, another app window, and global shortcuts can remain usable; repeatedly triggering a failing action such as starting with a disconnected wearable therefore calls present again. Each call blindly appends the same request while isPresentingAlert is true, so dismissing the first warning presents every duplicate sequentially. Coalesce requests that match the active or pending alert so one repeated action cannot create an alert storm.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Deduplication is implemented: present(title:message:) coalesces via guard activeAlert != request, !pendingAlerts.contains(request) (AppState+Permissions.swift:85) before enqueueing, so repeated identical requests while one is active or pending cannot queue duplicates. Covered by testAppKitPresenterCoalescesMatchingPendingAlerts and testAppKitPresenterCoalescesMatchingActiveAlerts.
ff01180 to
d24eb2f
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d24eb2fe7a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return window | ||
| }, | ||
| sheetPresenter: @escaping SheetPresenter = { alert, window, completion in | ||
| alert.beginSheetModal(for: window) { _ in completion() } |
There was a problem hiding this comment.
Defer the alert while the shell already owns a sheet
When silent-mic detection fires while an existing SwiftUI sheet is open—for example, one of the conversation or goal sheets in DashboardPage.applyHomeSheets—this attempts to attach a second sheet to the same shell window. AppKit cannot present two attached sheets on one window, so the new warning can fail or raise an exception after its request has already been removed from the queue. Check window.attachedSheet and retain the request until the current sheet ends, then retry presentation.
Useful? React with 👍 / 👎.
|
|
||
| init( | ||
| shellWindowProvider: @escaping () -> NSWindow? = { | ||
| guard let window = ShellSummon.shellWindow(), window.isVisible, !window.isMiniaturized else { return nil } |
There was a problem hiding this comment.
Reveal ordered-in shells before presenting the alert
When recording runs in the background while the shell remains ordered in behind another application or on another Space, window.isVisible is still true, so this provider skips openMainAppWindow() and attaches the sheet without activating or summoning Omi. The recording then stops but the warning remains behind the foreground application. Fresh evidence beyond the earlier no-window case is that ShellSummon.toggleAction explicitly documents that an ordered-in shell is usually sitting behind whatever the user is working in; require an active/foreground shell or run the reveal path before presenting.
Useful? React with 👍 / 👎.
|
Addressed the remaining open threads from the 2026-08-12 codex review on head
New regression coverage exercises the real presenter through injected seams: deferral-until-sheet-ends drains queued alerts in order, reveal-when-no-window-remains, and the active-app gate. Ran |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_c1fe4eb8-64e1-4f15-9e3c-0d84d6cb400d) |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 31a1f65753
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| var revealCount = 0 | ||
| let presenter = AppKitSheetAlertPresenter( | ||
| shellWindowProvider: { windowSource.window }, | ||
| sheetPresenter: recorder.present, |
There was a problem hiding this comment.
Exercise the default AppKit presentation path
Fresh evidence in the final version is that every production-presenter test replaces sheetPresenter with recorder.present, so none executes the default closure containing beginSheetModal; these tests would still pass if that closure reintroduced runModal() or became a no-op, leaving the original main-actor freeze without a regression guard. Inject the AppKit operations beneath the default presentation path and assert that production selects the nonblocking sheet operation.
AGENTS.md reference: AGENTS.md:L45-L45
Useful? React with 👍 / 👎.
31a1f65 to
82fb556
Compare
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_8f382600-9763-4fab-86d6-cb80491856f1) |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 82fb5566f2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| - id: S4B | ||
| name: Verify silent microphone failure alert | ||
| do: "If the active microphone returns no audio until Omi exhausts capture recovery, verify recording stops and 'Microphone Isn't Capturing Audio' appears with an OK action while the window remains responsive. Repeat with the main shell hidden: Omi should reveal its main window and present the same non-blocking alert instead of losing it or attaching it to the floating bar." |
There was a problem hiding this comment.
Align the silent-mic E2E step with production behavior
This scenario cannot produce the alert it requires: when capture recovery is exhausted for an authorized microphone, AppState+Transcription.swift lines 815–820 deliberately stops without presenting a modal, while the permission branch presents an alert titled “Omi Needs Microphone Access.” Consequently, this manual E2E step always reports a failure against the current production path and provides misleading verification evidence; update it to assert the actual permission/hardware outcomes or restore the claimed alert.
Useful? React with 👍 / 👎.
82fb556 to
ee39a3f
Compare
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_267c1f9e-d02e-4d74-9726-afea3cb7ba60) |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ee39a3fa1c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| alert.alertStyle = .warning | ||
| alert.addButton(withTitle: "OK") | ||
| alert.runModal() | ||
| alertPresenter.present(title: title, message: message) |
There was a problem hiding this comment.
Delay opening Settings until the alert completes
When microphone authorization is denied, surfaceMicrophonePermissionAlert() calls showAlert() and then immediately opens the Microphone pane with NSWorkspace.shared.open. This line now only begins or queues a nonblocking sheet, so it returns before the user acknowledges the warning; System Settings then takes the foreground, leaving the sheet behind Omi or still pending when the shell had to be revealed. Preserve a completion callback and open Settings after dismissal, or otherwise avoid presenting two competing surfaces.
Useful? React with 👍 / 👎.
ee39a3f to
5d1037b
Compare
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_d862943e-c3e7-4756-91eb-dd092af47eea) |
|
@Git-on-my-level Addressed the P2 'delay opening Settings until the alert completes' on head
Coverage: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 98504c69e1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| pending.completion?() | ||
| self?.presentPendingAlertIfPossible() |
There was a problem hiding this comment.
Pause queue draining after opening System Settings
When the microphone-permission alert has a different alert queued behind it, dismissing the permission sheet runs its completion—which opens System Settings—and then immediately drains the next alert. If Settings has already activated, this calls the reveal path and pulls Omi back over the requested settings pane; if activation is still pending, the next sheet is attached and then hidden behind Settings. This can occur when a floating-bar or shortcut action queues another transcription error while the permission sheet is active, so defer draining until Omi becomes active again after a completion that changes the foreground application.
Useful? React with 👍 / 👎.
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_7ae4f601-fbbc-416a-bdec-9b714da2d106) |
Re-review request — blocker resolved (head
|
Failure-Class: none
Failure-Class: none
Failure-Class: none
Address the last two open review threads on the alert presenter: - Attach only when the shell window can host a sheet: if it already owns one (a SwiftUI sheet, for example) the request stays queued and presentation retries on NSWindow.didEndSheetNotification, so a second beginSheetModal can never raise on a window that already has a sheet. - Present only to an active app: a visible-but-inactive shell is usually ordered in behind the foreground application, so requiring NSApp.isActive routes through the reveal path (openMainAppWindow / ShellSummon.summon) before attaching, keeping the warning in front. Both behaviors get real presenter coverage: deferral-until-sheet-ends, reveal when no window remains, and the active-app gate on the window selection. Tests: bash scripts/test-pre-commit-pinned-toolchains.sh N/A; ran ./scripts/dev-feedback.py --once swift 'AppStateAlertPresentationTests' -> 8/8 passed (Sparkle loaded via DYLD_FRAMEWORK_PATH against the signed bundle's copy, the known local test-bundle env gap). Failure-Class: none
Failure-Class: none
…verage The regression test for the non-blocking alert path swapped in a stub presenter, so it passed whether AppKitSheetAlertPresenter used beginSheetModal, reintroduced runModal, or did nothing. Route the test through the real AppKitSheetAlertPresenter with an injected AppKit operations recorder so it asserts the non-blocking sheet path selected by production.
…t toolchains Swift 6.4 (Xcode 26+) rejects the main-actor-isolated static 'live' used as a nonisolated default argument. Default the injected operations to nil and resolve .live inside the main-actor init body; mark the static @mainactor explicitly. Semantics unchanged under the pinned Swift 6.1 toolchain.
…pletes surfaceMicrophonePermissionAlert opened System Settings immediately after queuing the non-blocking permission sheet, burying the warning under the pane. AppKitSheetAlertPresenter now carries a per-alert completion and fires it when that alert's sheet ends; the microphone call site defers NSWorkspace.open until then. DesktopAlertPresenting gains an optional completion with a default shim so existing two-argument callers are unaffected. Behavioral coverage: testAppKitPresenterRunsCompletionAfterTheSheetEnds asserts the completion runs after the sheet ends, not before.
…tings The microphone-permission alert's completion opens System Settings the moment the sheet is dismissed. Immediately draining the next queued alert then summons Omi back over the user's settings pane, or attaches a sheet that lands hidden behind it. After any completion, only continue the queue drain while Omi is still the active app; the existing active/window/sheet observers resume the queue when the user returns to Omi. Add a regression test: with a permission alert queued behind the microphone alert, ending the sheet with Omi deactivated (as opening System Settings does) must not present the queued alert; it presents once Omi becomes active again.
391d25c to
24ecd0c
Compare
💡 Codex ReviewWhen another alert is queued behind the microphone-permission alert, ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
NSWorkspace.open can return while Omi is still active, so inferring a pause from the current shell window drained the next sheet behind Settings. Completions that hand off the foreground now request the pause explicitly; didBecomeActive resumes the queue.
|
Addressed the post-rebase Codex P2 on head (pushed just now): pause draining before launching System Settings.
New coverage: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8035d97588
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| alertPresenter.pauseQueueUntilAppActive() | ||
| if let url = URL(string: "x-apple.systempreferences:com.apple.preference.security?Privacy_Microphone") { | ||
| NSWorkspace.shared.open(url) |
There was a problem hiding this comment.
Resume the queue when Settings fails to open
If macOS cannot handle the System Settings URL, NSWorkspace.open returns false without deactivating Omi, but the presenter has already paused its queue. Because only a subsequent didBecomeActive notification clears that pause—and the already-active app will not emit one—all later shared alerts remain queued indefinitely until the user happens to switch away and back. Check the return value and cancel the pause when the handoff fails.
Useful? React with 👍 / 👎.
kodjima33
left a comment
There was a problem hiding this comment.
Desktop mic-alert bug fix — re-confirmed still approve-only: Desktop Swift Build/Release/Contracts CI and Backend Hermetic Merge Gate are still failing on this head, and reviewDecision remains CHANGES_REQUESTED from a human. Not overriding either; approving to keep pace with new commits, no merge.
Resolved in subsequent commits (alert queue/defer/summon added Aug 25)
The pinned CI toolchain (Xcode 16.4 / Swift 6.1.2) crashes compiling AppState: signal 11 in SILGen emitStoredPropertyInitialization while lowering the default-value expression `var alertPresenter: any DesktopAlertPresenting = AppKitSheetAlertPresenter()` (stack: emitExistentialErasure -> emitApply -> signal 11, Xcode-16.4-only; Xcode 26 compiles it). Landed via #11453 whose branch never ran the Desktop Swift CI workflow, and it now fails every desktop PR and main's own push runs. Fix: declare the property without a default and assign it as the first statement of AppState.init() — the same initializer call, just not in a stored-property default-value expression, so the crashing vpfi lowering path is never emitted. No behavior change on either toolchain. Adopted onto this PR (whose diff is telemetry-only) the same way 7ae0eb3 adopted the other pre-existing main-level build unblock, so its required checks can actually run. Verification: git diff --check clean; xcrun swiftc -parse AppState.swift clean; swift-format lint-scope clean. Failure-Class: none
Summary
Present microphone recovery alerts as non-blocking sheets instead of blocking the main actor. When no Omi window is available, queue the alert until the application becomes active or a window becomes key.
Sentry issue
Related: #11421 prevents repeated silent-mic recovery from reaching this alert; this PR removes the separate blocking modal when an alert is presented.
Failure class
Failure-Class: none
Verification
Note
Medium Risk
Changes main-thread alert presentation and window activation for all
showAlertcall sites (transcription, permissions, device errors); incorrect queueing or summon logic could hide alerts or steal focus, though tests cover the main edge cases.Overview
Replaces blocking
NSAlert.runModal()for sharedshowAlertpaths with a non-blocking sheet on the main shell window, so microphone and transcription warnings no longer freeze the main actor (addresses the silent-mic / permission alert freeze).Introduces
DesktopAlertPresentingandAppKitSheetAlertPresenter, wired viaAppState.alertPresenter. The presenter queues alerts, coalesces duplicates, reveals the main window when no shell is presentable, defers when another sheet is attached, and runs optional completions after dismiss—so opening System Settings → Microphone happens only after the user dismisses "Omi Needs Microphone Access", not underneath it.Adds
AppStateAlertPresentationTestsand extends the audio-recording e2e flow for silent-mic recovery and permission alert behavior; changelog notes the freeze fix.Reviewed by Cursor Bugbot for commit 24ecd0c. Configure here.
Line-Count-Exception: desktop/macos/Desktop/Sources/AppState/AppState+Transcription.swift | 1738 -> 1743 | permission alert gains a sheet-completion callback that opens the microphone settings pane only after the non-blocking alert is seen