Skip to content

feat(desktop): microphone picker with Ray-Ban Meta glasses support - #9181

Closed
eulicesl wants to merge 11 commits into
BasedHardware:mainfrom
eulicesl:feature/rayban-meta-desktop-mic
Closed

eulicesl wants to merge 11 commits into
BasedHardware:mainfrom
eulicesl:feature/rayban-meta-desktop-mic

Conversation

@eulicesl

@eulicesl eulicesl commented Jul 7, 2026 •

Copy link
Copy Markdown
Collaborator

What

  • Microphone card in Settings → Transcription: System Default or any input device, enumerated via the same CoreAudio HAL walk as findBuiltInMicDeviceID, persisted by device UID (IDs aren't stable across reconnects), applied through the existing AudioCaptureService(overrideDeviceID:) path. Neutral styling; changelog fragments included.
  • Listening button shows the live capture source — the explicitly-selected device's name (or "Ray-Ban Meta" when the name matches a Meta product).
  • PTT/mic-contention fix: push-to-talk could open a second CoreAudio IOProc against a device the transcription capture already holds (or join a Bluetooth mic's A2DP↔HFP profile flap), racing both captures' stream-format reconfiguration. AudioCaptureService gains a process-wide active-capture registry, and preferredPTTInputOverrideDeviceID() now yields to the built-in mic when the would-be input is held by another capture or is Bluetooth while any capture runs — extending the existing isDefaultOutputBluetooth() guard's philosophy.
  • Review follow-up refresh: rebased/merged current main, fixed the stale active-capture registry windows, replaced fixed-interval microphone-device polling with a CoreAudio hardware-device listener, and hardened the relevant regression tests.

Why

Ray-Ban Meta glasses pair to a Mac as a Bluetooth HFP microphone, but the app only captured from the system-default input with no picker and no visible indication of the live source. Companion to the mobile-side #9178.

Product invariants affected

  • INV-AGENT-*
  • INV-AUTH-1
  • INV-CHAT-1
  • INV-INT-1
  • INV-MEM-1

How it was tested

  • git diff --check HEAD~1 HEAD — passed.
  • python3 desktop/macos/scripts/check-e2e-flow-coverage.py --strict --base upstream/main — passed, 8 changed desktop Swift files covered, 0 uncovered.
  • xcrun swift build -c debug --package-path Desktop — passed.
  • xcrun swift test --package-path Desktop --filter PushToTalkStateMachineTests — passed, 8 tests, 0 failures.
  • xcrun swift test --package-path Desktop --filter TranscriptionTransportTests — passed, 7 tests, 0 failures.
  • dart format --line-length 120 --set-exit-if-changed --output=none ... on the previously failing formatting paths — passed.
  • Hardware-validated earlier in the branch: Ray-Ban Meta glasses (Bluetooth codename "EL AI 000F") selected in the picker in a named bundle (omi-rayban, prod backend) captured live speech → transcript end-to-end; recordingInputDeviceName flows to input_device_name as before.

Review notes

  • Silent-mic watchdog unchanged — a dead Bluetooth mic still falls back to the built-in mic.
  • HFP voice-quality tradeoff stated in plain language in the picker.
  • The microphone picker now refreshes from CoreAudio kAudioHardwarePropertyDevices notifications instead of a fixed 3-second polling loop.

🤖 Generated with Claude Code

Review in cubic

eulicesl added 3 commits July 6, 2026 22:12
Ray-Ban Meta glasses pair to the Mac as a Bluetooth HFP microphone; the
desktop app captured only from the system-default input with no way to pick
a device or see which one is live. Now:

- Settings -> Transcription gains a Microphone card: System Default or any
  input device, enumerated via the same CoreAudio HAL walk as
  findBuiltInMicDeviceID; persisted by device UID (IDs aren't stable across
  reconnects) and resolved at capture start via the existing
  AudioCaptureService(overrideDeviceID:) path.
- Meta glasses are detected by precise product-name match (Ray-Ban / Oakley
  Meta — never generic 'glass') and labeled, with the HFP voice-quality
  tradeoff stated in plain language.
- The Dashboard Listening button shows 'Ray-Ban Meta' while the glasses are
  the active capture source (recordingInputDeviceName already feeds
  input_device_name on memories, so provenance lands server-side too).
- Silent-mic watchdog behavior is unchanged: a dead Bluetooth mic still
  falls back to the built-in mic so capture never silently records nothing.
- Neutral styling (no purple) per design rules.

Verified: xcrun swift build -c debug --package-path Desktop — zero errors
(after merging upstream b4370fc, which fixes a pre-existing AgentBridge
break at this branch's original base). On-device run via named bundle next.
On-hardware finding: Ray-Ban Meta glasses advertise a Bluetooth codename
(observed: 'EL AI 000F'), not a Meta product name, so product-name matching
alone can't identify them. When the user has explicitly chosen a microphone,
show that device's real name on the Listening button (still 'Ray-Ban Meta'
when the name does match a Meta product). Verified on hardware: glasses
selected in the picker captured live audio end-to-end to transcript.
With the Settings microphone picker pinning transcription capture to a
Bluetooth mic (e.g. Ray-Ban Meta glasses), push-to-talk could open a second
CoreAudio IOProc against the same device — or join its A2DP-HFP profile
flap — racing both captures' stream-format reconfiguration. PTT's existing
guard only considered Bluetooth output.

- AudioCaptureService gains a process-wide active-capture registry
  (register on successful start/reconfigure, unregister on stop).
- preferredPTTInputOverrideDeviceID() now also yields to the built-in mic
  when the would-be input is held by another capture, or is Bluetooth while
  any capture is live — mirroring the existing isDefaultOutputBluetooth
  guard's philosophy.

Verified: xcrun swift build — zero errors; behavior check on hardware
(glasses Listening + chat shortcut concurrently) is the follow-up step.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a user-selectable microphone input for macOS transcription (including Ray-Ban Meta glasses), surfaces the live capture source in the Listening UI, and introduces a process-wide “active capture” registry to reduce push-to-talk (PTT) contention with ongoing transcription capture.

Changes:

  • Add a Settings → Transcription “Microphone” card to pick System Default vs a specific input device (persisted by device UID).
  • Show the selected/live capture source name on the Listening button (with a “Ray-Ban Meta” label when name-matched).
  • Add an active-capture registry in AudioCaptureService and extend PTT mic override logic to yield to the built-in mic under contention/Bluetooth conditions.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
desktop/macos/Desktop/Sources/MainWindow/Pages/Settings/Sections/SettingsContentView+Transcription.swift Inserts the new microphone picker card into the Transcription settings section.
desktop/macos/Desktop/Sources/MainWindow/Pages/Settings/Sections/MicrophonePickerCard.swift New SwiftUI card that enumerates input devices and persists the preferred device UID.
desktop/macos/Desktop/Sources/MainWindow/Pages/DashboardPage.swift Updates Listening button title to reflect capture source / Meta labeling.
desktop/macos/Desktop/Sources/FloatingControlBar/PushToTalkManager.swift Extends PTT override selection to avoid active-capture and Bluetooth contention.
desktop/macos/Desktop/Sources/AudioCaptureService.swift Adds input-device enumeration helpers + active-capture registry APIs.
desktop/macos/Desktop/Sources/AppState/AppState+Transcription.swift Initializes AudioCaptureService with an override device ID when a preferred UID is set.
desktop/macos/changelog/unreleased/20260707-ptt-mic-contention.json Changelog fragment for PTT contention fix.
desktop/macos/changelog/unreleased/20260706-rayban-meta-microphone-picker.json Changelog fragment for microphone picker + capture source display.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@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 8 files

Confidence score: 5/5

  • Safe to merge after the addressed issues were fixed.

Tip: cubic used a learning from your PR history. Let your coding agent read cubic learnings directly with the cubic MCP.

Re-trigger cubic

@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 the focused desktop microphone-picker work here — the shape makes sense for Omi’s desktop transcription/smart-glasses use case, especially persisting CoreAudio UIDs rather than device IDs and reusing the explicit AudioCaptureService(overrideDeviceID:) path.

I’m going to hold this before merge for one concrete reason: the required Desktop Swift Build & Tests check is failing in the e2e flow coverage gate, not in compilation. The failing job reports these changed Swift files still need e2e flow coverage entries:

  • desktop/macos/Desktop/Sources/AppState/AppState+Transcription.swift
  • desktop/macos/Desktop/Sources/FloatingControlBar/PushToTalkManager.swift
  • desktop/macos/Desktop/Sources/MainWindow/Pages/Settings/Sections/MicrophonePickerCard.swift
  • desktop/macos/Desktop/Sources/MainWindow/Pages/Settings/Sections/SettingsContentView+Transcription.swift

Please add/extend the relevant desktop/macos/e2e/flows/*.yaml coverage for the Settings → Transcription microphone picker and the PTT/mic-contention path (or otherwise satisfy the strict coverage checker), then rerun the desktop check.

A couple of maintainer notes for the human pass:

  • Product fit looks qualitatively reasonable: a desktop microphone picker and explicit Ray-Ban Meta capture indication are aligned with Omi’s smart-glasses/transcription surface.
  • This is still a nontrivial feature PR touching capture routing, Bluetooth/HFP behavior, dashboard UX, and PTT contention, so it should get human maintainer review after CI is green rather than an automated approval.
  • I did not find an agent-instruction or AI-reviewer behavior change in this PR.

Once the coverage gate is fixed, I’d expect this to be a good candidate for a final desktop maintainer review with hardware/UX confirmation.

@Git-on-my-level Git-on-my-level added needs-tests PR introduces logic that should be covered by tests needs-maintainer-review Needs a human maintainer to sign off before merge labels Jul 7, 2026
beginTurn() refreshes the voice seed asynchronously and then calls
reconnectWarmSessionIfSeedStale(). When the seed fetch is slow (~5s
observed), the check lands after a short turn has already committed and
teardownSession() destroys the session the turn is awaiting its reply on —
the reply silently never arrives. Observed on hardware (glasses Listening +
chat shortcut): 'turn committed' at t+0ms, 'voice seed changed —
reconnecting warm session' at t+13ms, no reply.

Guard the reconnect on inputTurnInProgress/responding and defer to the next
turn's check. Verified: xcrun swift build zero errors; hardware re-test of
Listening+PTT is the follow-up.
@eulicesl

eulicesl commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

Hardware verification of the PTT fixes (Ray-Ban Meta glasses paired, Listening active on the glasses, chat shortcut concurrently):

  • Mic coordination: PTT captured from the built-in mic while transcription held the glasses — no crash, turns committed with real audio.
  • Hub seed-reconnect race (2810b0245): previously 'turn committed' was followed ~13ms later by 'voice seed changed — reconnecting warm session' and the reply never arrived. After the guard, four consecutive turns each logged 'voice seed changed but a turn is in flight — deferring reconnect' and every reply was delivered (e.g. heard "Testing, testing, can you hear me?" → reply returned, turn done).
  • Known behavior, unchanged and documented: while the realtime hub holds audio output, the glasses stay in A2DP so their mic reads silent for transcription; the existing silent-mic watchdog falls back to the built-in mic and capture continues.

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

1 issue found across 2 files (changes from recent commits).

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/FloatingControlBar/RealtimeHubController.swift">

<violation number="1" location="desktop/macos/Desktop/Sources/FloatingControlBar/RealtimeHubController.swift:731">
P1: This guard makes the seed-stale reconnect a no-op from the only call site: `beginTurn()` always has `inputTurnInProgress == true` by the time the async refresh returns, so the warm session never reconnects and stale context can persist indefinitely.</violation>
</file>

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

Re-trigger cubic

Opening a CoreAudio input can take seconds under load (observed ~5s with
the capture pipeline spinning up, Bluetooth contention, or cold audiomxd
state). PTT cold-started a new AudioCaptureService every press, so short
turns heard nothing ('discarding hub turn — audio 0.00s') and even
successfully opened devices were thrown away when the open completed after
the turn ended.

- Turn end now PARKS the running capture (running-but-dropped via a
  lock-guarded lease the frame closures consult per chunk) for 120s instead
  of destroying it; the next press adopts it and hears audio immediately.
- Late-completing opens are parked warm instead of stopped.
- Frame/silent-mic closures route by lease (generation + batchMode), so a
  parked capture never leaks frames and adoption needs no closure rebinding
  on the live IOProc thread.
- Device-failure paths (silent-mic fallback, CoreAudio rebuild) discard
  rather than park, so a broken device is never kept warm.

Verified: xcrun swift build zero errors; hardware retest (Capture ON +
Listening on glasses + rapid PTT turns incl. barge-in) is the follow-up.

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

3 issues found across 2 files (changes from recent commits).

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/AudioCaptureService.swift">

<violation number="1" location="desktop/macos/Desktop/Sources/AudioCaptureService.swift:489">
P2: PTT contention checks can use a stale captured device after a live capture reconfigures to a new input. Consider refreshing `activeCaptures` with `newDeviceID` after the successful restart path in `reconfigureAfterChange`.</violation>

<violation number="2" location="desktop/macos/Desktop/Sources/AudioCaptureService.swift:511">
P1: Registry entries are only removed via `unregisterActiveCapture()` in `stopCapture()`. If an `AudioCaptureService` instance is deallocated while `isCapturing` is still true (the class reportedly has a `deinit` cleanup path for that case), its entry leaks in `activeCaptures`. This permanently makes `hasActiveCapture()` return `true` and poisons PTT routing. Adding `unregisterActiveCapture()` to `deinit` would prevent this leak.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

eulicesl added 2 commits July 7, 2026 18:26
# Conflicts:
#	desktop/macos/Desktop/Sources/DefaultsKey.swift
#	desktop/macos/e2e/flows/settings.yaml
@eulicesl

eulicesl commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed the latest PR review comments in 318b0d50e, then merged current upstream/main in 4f88e8ab0 to clear conflicts.

Changes covered:

  • Kept AudioCaptureService active-capture ownership registered until HAL stop/destroy completes, refreshed the registry after live reconfigure, and unregisters during deinit cleanup.
  • Routed the microphone preference key through DefaultsKey.
  • Moved microphone enumeration off the main actor and refreshed the picker while Settings is visible.
  • Deferred realtime hub seed-stale reconnects until cancel/turn-done instead of dropping them forever mid-turn.
  • Fixed warm PTT mic reuse/cancel handling and excluded this manager’s parked capture from contention checks.
  • Added/updated e2e flow coverage for transcription settings and PTT microphone routing.

Local checks run:

  • git diff --check --cached
  • python3 desktop/macos/scripts/check-userdefaults-key-ratchet.py
  • python3 desktop/macos/scripts/check-e2e-flow-coverage.py --strict ...
  • Ruby YAML parse for desktop/macos/e2e/flows/*.yaml
  • xcrun swift -frontend -parse on touched Swift sources/tests

CI is running on the updated branch.

@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 11 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

@eulicesl

Copy link
Copy Markdown
Collaborator Author

@copilot resolve the merge conflicts on this branch.

@eulicesl
eulicesl force-pushed the feature/rayban-meta-desktop-mic branch from 8064c2d to 02f63fe Compare July 12, 2026 02:07
@eulicesl
eulicesl force-pushed the feature/rayban-meta-desktop-mic branch from 02f63fe to 71c516e Compare July 12, 2026 02:52
@eulicesl
eulicesl force-pushed the feature/rayban-meta-desktop-mic branch from 4957623 to f4fc857 Compare July 12, 2026 03:02
@eulicesl

Copy link
Copy Markdown
Collaborator Author

@copilot resolve the merge conflicts on this branch.

undivisible added a commit that referenced this pull request Jul 24, 2026
Theory
Multi-device support failed because the app persisted one active BLE
device and the onboarding scanner rendered only live scan results. A
second saved device displaced the first, and offline saved devices
disappeared from the connect flow.

Scope
- Adds `SharedPreferencesUtil.btDevices` list storage with legacy
`btDevice` fallback.
- Keeps `btDeviceSet` updating active device while preserving unique
saved devices.
- Adds `OnboardingProvider.savedDeviceList` and `visibleDeviceList`.
- Updates Find Devices UI to render saved offline devices and replace
them with live scan data when seen.

Cut from #9084
- Meta glasses provider/page/runtime.
- On-device transcription.
- Android/iOS native recording churn.
- Docs/plugin examples/auth changes.

Tests
- Red first: `flutter test
test/providers/onboarding_provider_multi_device_test.dart` failed on
missing `btDevices`, `savedDeviceList`, and `visibleDeviceList`.
- Green: `flutter test
test/providers/onboarding_provider_multi_device_test.dart`.
- Green: `dart analyze lib/backend/preferences.dart
lib/providers/onboarding_provider.dart
lib/pages/onboarding/find_device/found_devices.dart
test/providers/onboarding_provider_multi_device_test.dart`.

Notes
- Draft PR. Surgical generic multi-device persistence/UI slice of #9084.
- Low overlap with #9181; this branch does not touch
`app/lib/pages/home/page.dart`.

<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/9311?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
@github-actions

Copy link
Copy Markdown
Contributor

Hey @eulicesl 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing.

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community!

Copy link
Copy Markdown
Collaborator Author

Closing as superseded: this branch predates the repository history rewrite and could no longer be merged. The same feature set — re-integrated with current main, adapted to Swift 6 strict concurrency and the new PTT routing seam, and hardened through seven review rounds — landed in #10917. Hardware-verification follow-ups are tracked in #10921.


Generated by Claude Code

aryanorastar pushed a commit to aryanorastar/omi that referenced this pull request Jul 31, 2026
Port of PR BasedHardware#9181 onto current main (the original branch predates the repo
history rewrite and cannot be merged). Same feature set, re-integrated with
the code that landed on main since July 7:

- Microphone card in Settings -> Transcription: System Default or any
  CoreAudio input, persisted by device UID (IDs are not stable across
  reconnects), applied through the existing AudioCaptureService
  overrideDeviceID path and honored when transcription starts
  (AppState+Transcription). Refreshes from a kAudioHardwarePropertyDevices
  listener, not polling.
- Listening button surfaces the live capture source; an explicitly selected
  Meta-glasses mic shows as "Ray-Ban Meta". Integrated into
  CaptureListeningLogic (main's shared status derivation) so the persistent
  status bar and Home header both get it.
- PTT mic contention: AudioCaptureService gains a process-wide
  active-capture registry; PTT routing yields to the built-in mic when the
  would-be input is held by another capture, or is Bluetooth while any
  capture runs. Integrated into PTTInputDeviceRouting's off-main-actor
  probe/snapshot seam (registry reads are lock-guarded process state, not
  HAL reads, so resolution stays main-actor safe).
- PTT warm mic keep-alive: a finished turn parks its capture for 120s and
  the next turn with the same routing adopts it via a lock-guarded lease,
  instead of tearing down and rebuilding the CoreAudio IOProc.

Adaptations vs the original branch, forced by current main:
- listeningModeTitle override moved into CaptureListeningLogic (new home of
  that logic).
- Contention policy reads default-input/built-in/transport info from the
  probe snapshot instead of calling the HAL on the main actor, honoring the
  PTT routing seam's no-main-actor-HAL invariant; explicit user mic choices
  are always respected.
- MicrophonePickerCard uses availableInputDevices()/isBluetoothTransport
  (main's enumeration) rather than the original listInputDevices().
- Source-inspection tripwires live in PTTWarmMicKeepAliveTests.swift and
  assert current main's publish()-based coordinator strings; the hub
  seed-stale reconnect deferral they guard already landed on main, so its
  changelog fragment is not re-shipped here.

Verification: python3 desktop/macos/scripts/check-e2e-flow-coverage.py
--strict --base origin/main passes (8/8 changed Swift files covered); flow
YAML parses; changelog fragments are valid JSON. No Swift toolchain exists
in this Linux environment, so the Swift sources are NOT compiled here — CI
must be the compile/test authority for this PR. Hardware validation of the
original branch (glasses as picker selection, end-to-end transcript) was
done on the fork before the rewrite; see PR BasedHardware#9181.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-maintainer-review Needs a human maintainer to sign off before merge needs-tests PR introduces logic that should be covered by tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants