Repository navigation
refactor(desktop): converge Bluetooth session ownership - #9550
Conversation
Centralize generation-fenced session, transport, command, and audio lifecycle ownership with deterministic race coverage.\n\nVerification: clean debug/release builds; 55 focused reliability tests; 249 isolated Swift suites; 328 Rust tests; desktop/macos/test.sh; make preflight; independent review approved.
The Bluetooth session cleanup removes two raw inline defaults accesses. Lower the enforced baseline from 180 to 178.\n\nVerification: desktop/macos/scripts/check-userdefaults-key-ratchet.py; make preflight.
fc150d5 to
bbcbea5
Compare
Monitor run — rebased onto latest
|
Summary
Root cause and durable guard
Bluetooth lifecycle state was spread across
BluetoothManager,BleTransport,DeviceProvider, and every device adapter. Raw continuations were keyed only by characteristics or command IDs, reconnect policy inferred intent from persisted UI state, and audio streams coupled one consumer to one physical session without a canonical owner. Recent fixes in the same subsystem repeatedly addressed individual lock, continuation, and teardown symptoms, but no shared boundary prevented the class from recurring.This change assigns one owner to each contract: manager connection leases preserve CoreBluetooth callback identity; tokenized operation brokers arbitrate callbacks, timeouts, cancellation, and teardown while physical starts drain; command queues serialize request/response lifetimes; one session coordinator owns phase, pairing, reconnect intent, and generation fencing; and multicast audio controllers own setup through fail-closed stop.
ARCHITECTURE.mdrecords those boundaries, and production-path tests force late callbacks, held writes, cancellation-unaware timeouts, concurrent teardown, stale reconnect requests, setup/stop races, and session restart contamination.Behavior and risk
Verification
desktop/macos/scripts/swift-test-suites.sh— 249 isolated Swift suites passeddesktop/macos/test.sh— launcher contracts, strict e2e coverage, 328 Rust tests, and 249 Swift suites passed.build— passed in 100.64s.build— passed in 286.39sgit diff --check— passedomi-bluetooth-qualitybundle built and installed throughrun.sh --yolo, launched on isolated automation port 47915, reported bundle IDcom.omi.omi-bluetooth-quality, and navigated from Home to Settings through the in-process bridge (the scoped local ad-hoc Library Validation entitlement from fix(desktop): isolate ad-hoc named-bundle signing #9546 was applied because that separate tooling PR is not on this branch)make preflight— all 13 selected checks passed after rebaseProduct invariants
None affected (
scripts/pr-preflight --suggest).