Skip to content

fix(desktop): present microphone alerts without blocking - #11453

Merged
undivisible merged 10 commits into
mainfrom
codex/sentry-silent-mic-alert
Aug 26, 2026
Merged

undivisible merged 10 commits into
mainfrom
codex/sentry-silent-mic-alert

Conversation

@undivisible

@undivisible undivisible commented Aug 12, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • Swift format, parse, test-quality, e2e coverage, and diff checks passed.
  • The focused XCTest compiled and linked locally; its runtime is blocked by the host's missing Sparkle.framework.

Note

Medium Risk
Changes main-thread alert presentation and window activation for all showAlert call 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 shared showAlert paths 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 DesktopAlertPresenting and AppKitSheetAlertPresenter, wired via AppState.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 AppStateAlertPresentationTests and 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

@cursor

cursor Bot commented Aug 12, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +20 to +24
else {
log("Unable to present alert without a visible window")
return
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +9 to +12
let presenter = RecordingAlertPresenter()
state.alertPresenter = presenter

state.showAlert(title: "Microphone Isn't Capturing Audio", message: "Check your input device and try again.")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 5 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

@Git-on-my-level Git-on-my-level added needs-tests PR introduces logic that should be covered by tests security-review Touches auth, provider routing, secrets, or security-sensitive surfaces macOS labels Aug 12, 2026

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.present now returns after only logging when NSApp.keyWindow, NSApp.mainWindow, and visible windows are all unavailable. That is a behavior regression from the old runModal() path: the silent-microphone warning, Device Not Connected, and Couldn't Start Transcription can 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: the DesktopAlertPresenting seam and alertPresenter injection are a good way to make showAlert testable, 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 out AppKitSheetAlertPresenter, 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 prove beginSheetModal and 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.

@cursor

cursor Bot commented Aug 12, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +66 to +68
guard let window = windowProvider() else {
activateApplication()
return

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +59 to +61
func present(title: String, message: String) {
pendingAlerts.append(.init(title: title, message: message))
presentPendingAlertIfPossible()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@undivisible
undivisible force-pushed the codex/sentry-silent-mic-alert branch from ff01180 to d24eb2f Compare August 12, 2026 15:39

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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() }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@undivisible

Copy link
Copy Markdown
Collaborator Author

Addressed the remaining open threads from the 2026-08-12 codex review on head d24eb2fe7a (pushed 31a1f65753):

  • P2 — defer while the shell already owns a sheet: AppKitSheetAlertPresenter now checks canHostSheet (window.attachedSheet == nil) before presenting; when the shell hosts another sheet (e.g. a SwiftUI sheet), the request stays queued and presentation retries on NSWindow.didEndSheetNotification. A second beginSheetModal can no longer raise on a sheet-owning window.
  • P1 — reveal ordered-in shells before presenting: shellWindowProvider now requires NSApp.isActive (via presentableShellWindow(_:isActive:)), mirroring ShellSummon.toggleAction. A visible-but-inactive shell routes through openMainAppWindow / ShellSummon.summon before the sheet attaches, so the warning lands in front.

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 ./scripts/dev-feedback.py --once swift 'AppStateAlertPresentationTests' → 8/8 passed (loaded Sparkle via DYLD_FRAMEWORK_PATH against the signed bundle's copy — the known local test-bundle dylib gap). scripts/check_desktop_test_quality.py green.

@cursor

cursor Bot commented Aug 13, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking presentation with a queue until a window is key is the right shape, and it pairs with #11421 rather than duplicating it. Held from merge only by the stale desktop Swift red (fixed on main by #11504; the PR's merge ref predates it).

@undivisible
undivisible force-pushed the codex/sentry-silent-mic-alert branch from 31a1f65 to 82fb556 Compare August 14, 2026 01:27
@cursor

cursor Bot commented Aug 14, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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."

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@undivisible
undivisible force-pushed the codex/sentry-silent-mic-alert branch from 82fb556 to ee39a3f Compare August 14, 2026 08:00
@cursor

cursor Bot commented Aug 14, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@undivisible
undivisible force-pushed the codex/sentry-silent-mic-alert branch from ee39a3f to 5d1037b Compare August 14, 2026 08:23
@cursor

cursor Bot commented Aug 14, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@undivisible

Copy link
Copy Markdown
Collaborator Author

@Git-on-my-level Addressed the P2 'delay opening Settings until the alert completes' on head 98504c69e1 (pushed just now).

DesktopAlertPresenting.present now accepts an optional per-alert completion, and AppKitSheetAlertPresenter runs it when that alert's sheet ends (not when the request is enqueued). surfaceMicrophonePermissionAlert therefore defers NSWorkspace.open (Microphone pane) until after the non-blocking permission sheet has been seen — the old runModal() path implicitly blocked here, so the pane now opens at the same logical point.

Coverage: testAppKitPresenterRunsCompletionAfterTheSheetEnds proves the completion runs after the sheet ends, not before (using a deferred-completion recorder). Verified locally: xcrun swift test --filter AppStateAlertPresentationTests = 9/9 passing, swift-format + swiftlint + test-quality ratchet clean. CI should re-run on the new head.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +121 to +122
pending.completion?()
self?.presentPendingAlertIfPossible()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@cursor

cursor Bot commented Aug 16, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@undivisible

Copy link
Copy Markdown
Collaborator Author

Re-review request — blocker resolved (head 391d25cc05)

@Git-on-my-level the no-window/drop blocker and the remaining P2 thread are addressed. Commits 97747c4c5b–98504c69 already landed the defer-until-window design (queue + reveal + coalescing + active-sheet gate) with tests exercising the real AppKitSheetAlertPresenter via the injected AppKitAlertOperations/shellWindowProvider seams; commit 020ebf769a (this round) closes the last open thread:

  • Pause queue draining after a completion that drops the foreground. After any sheet's completion runs, the presenter only continues draining while Omi is still the active app. When the microphone-permission alert's completion opens System Settings (deactivating Omi), the next queued alert is held rather than summoning Omi back over the settings pane; the existing didBecomeActive/didBecomeKey/didEndSheet observers resume the queue when the user returns.
  • Regression test: testAppKitPresenterPausesQueuedAlertsAfterACompletionDropsTheForeground — ends the permission sheet with Omi deactivated and asserts the queued Device Not Connected alert is NOT dragged forward, then presents once Omi is active again.

Verification (local): AppStateAlertPresentationTests ran 10/10 green (swift test --filter AppStateAlertPresentationTests). Local toolchain caveat: this repo's CI pins Xcode 16.4; the machine only has Xcode 27 (Swift 6.4), which rejects an unrelated pre-existing file (ShellClickThrough.swift, newer ImplicitStrongCapture diagnostic — root-caused in main issue #11563/#11573), so a temporary local-only, un-reverted build workaround was applied just long enough to run the suite, then reverted. Ratchet gates pass: check_desktop_test_quality.py green, swift-format lint green, product-file-line-count-ratchet OK after merging origin/main.

CI status — pre-existing main red, not this PR: Desktop Swift Release Compile, Static & Test Contracts, and Build & Tests were already red at the untouched head 98504c69 (before this round's commit) and remain red on main itself — tracked in open issues #11563 (77 failures/3 suites on main) and #11573 (3 suites SIGSEGV on CI only), root-caused to 15a51fb985. The current failures are signal 11 segfaults in the release -O/emit-module compile of the Omi_Computer module (which abort before any test runs) plus an unrelated desktop launcher script harness failure — none exercise the alert-presenter change, and the alert suite passes locally under a stricter toolchain.

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
…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.
@undivisible
undivisible force-pushed the codex/sentry-silent-mic-alert branch from 391d25c to 24ecd0c Compare August 25, 2026 15:46
@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

guard let self, self.shellWindowProvider() != nil else { return }

P2 Badge Pause draining before launching System Settings

When another alert is queued behind the microphone-permission alert, NSWorkspace.open can return before macOS deactivates Omi, so this immediate provider check still sees an active, visible shell and drains the next alert; System Settings then takes focus and leaves that sheet hidden behind it. Fresh evidence beyond the existing review is that the regression test preemptively sets windowSource.window = nil before ending the sheet, rather than exercising the production ordering where the completion initiates an asynchronous foreground change. Have the completion explicitly request a queue pause (or resume only after a later activation) instead of inferring it synchronously here.

ℹ️ 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".

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.
@undivisible

Copy link
Copy Markdown
Collaborator Author

Addressed the post-rebase Codex P2 on head (pushed just now): pause draining before launching System Settings.

DesktopAlertPresenting.pauseQueueUntilAppActive() is an explicit request. The microphone-permission completion calls it before NSWorkspace.open, because that hand-off can return while Omi is still the active app. The presenter then refuses to drain until NSApplication.didBecomeActive. Inferring the pause from shellWindowProvider() synchronously is no longer the gate.

New coverage: testAppKitPresenterHonorsAnExplicitQueuePauseFromCompletion keeps the shell window presentable through the completion and asserts the queued alert stays queued until didBecomeActive.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +848 to +850
alertPresenter.pauseQueueUntilAppActive()
if let url = URL(string: "x-apple.systempreferences:com.apple.preference.security?Privacy_Microphone") {
NSWorkspace.shared.open(url)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@undivisible
undivisible dismissed Git-on-my-level’s stale review August 26, 2026 18:13

Resolved in subsequent commits (alert queue/defer/summon added Aug 25)

@undivisible
undivisible merged commit d49f978 into main Aug 26, 2026
21 of 27 checks passed
@undivisible
undivisible deleted the codex/sentry-silent-mic-alert branch August 26, 2026 18:14
Git-on-my-level added a commit that referenced this pull request Aug 27, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

macOS needs-tests PR introduces logic that should be covered by tests security-review Touches auth, provider routing, secrets, or security-sensitive surfaces

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants