Repository navigation
fix(ios): persist pendant reconnect intent and expose recovery evidence - #23517
Conversation
Keep a native saved connection or filtered discovery outstanding across disconnects, restoration and capture authorization changes. Record connect lifetime, scan observations and cancellation reasons. Failure-Class: FC-saved-device-launch-failure-revokes-reconnect Co-Authored-By: Claude Opus 5.5 <[email protected]>
A capture reset that already observed the physical disconnect must not cancel a saved pending connect when its capture budget expires. Failure-Class: FC-saved-device-launch-failure-revokes-reconnect Co-Authored-By: Claude Opus 5.5 <[email protected]>
Count a native saved attempt when establishing a new pending connection, including immediate disconnect and restoration recovery. Failure-Class: FC-saved-device-launch-failure-revokes-reconnect Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
A process can exit between persisting a manual disconnect and cancelling the OS request. Apply the persisted block to connected and pending restored peripherals before replaying readiness. Failure-Class: FC-saved-device-launch-failure-revokes-reconnect Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: caab7b8f80
ℹ️ 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".
| for uuid in Set(peripherals.keys).union(savedReconnect) { | ||
| disconnectPeripheral(uuid: uuid) |
There was a problem hiding this comment.
Preserve saved reconnect intent during termination cleanup
When iOS delivers applicationWillTerminate, AppDelegate.swift:753 calls this method. Routing that cleanup through disconnectPeripheral now invokes reconnectIntent.suppress, which durably removes every saved target and records a manual reconnect block even though the user did not explicitly disconnect the pendant. On the next process launch, native adapter-on/restoration recovery consequently has no saved intent and treats restored peripherals as manually blocked until Flutter issues another manageDevice request. Keep termination cleanup separate from persistent user suppression so the reconnect intent actually survives this restart path.
Useful? React with 👍 / 👎.
Termination cleanup must not persist a manual reconnect block. Leave saved CoreBluetooth owners restorable and retire only unsaved or blocked peripherals through a process-local callback fence. Failure-Class: FC-saved-device-launch-failure-revokes-reconnect Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3646719655
ℹ️ 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".
| if savedReconnect.contains(uuid), shouldAutoReconnect(uuid: uuid, pairingLost: false), | ||
| savedRetryTasks[uuid] == nil, peripheral.state == .disconnected { | ||
| endSavedScan(uuid, reason: "saved_target_discovered") | ||
| issueConnect(peripheral, uuid: uuid, source: "scan_result") |
There was a problem hiding this comment.
Preserve GATT discovery recovery for scan-found saved targets
When a saved peripheral is absent from CoreBluetooth's cache and is subsequently discovered by the reconnect scan, calling issueConnect directly bypasses the readyRequests.insert(uuid) setup previously performed by connectPeripheral. Both scheduleDiscoveryRetry and retryDiscoveryIfNeeded require that pending-request marker, so a service/characteristic discovery error or missing callback now receives neither the bounded retry nor the terminal failure notification. The physical link can remain connected but unusable until Flutter issues another manage request. Initialize the readiness-request state for this path while retaining the new reconnect behavior.
Useful? React with 👍 / 👎.
Native scan, restoration and retry requests must arm the existing bounded GATT discovery retry and terminal failure path, including when no Flutter manageDevice call has run yet. Failure-Class: FC-saved-device-launch-failure-revokes-reconnect Co-Authored-By: Claude Opus 5.5 <[email protected]>
… release Capture recovery retains native saved intent and outstanding connects even when its Dart follow-up is cancelled. Explicit disconnect, forget, DFU pause and service retirement disarm intent before releasing transport. Reconcile intent on already-connected saved targets without another radio connect. Failure-Class: FC-saved-device-launch-failure-revokes-reconnect Co-Authored-By: Claude Opus 5.5 <[email protected]>
A cancelled capture-recovery continuation can leave a native saved owner without a Dart transport. Service shutdown disarms and unmanages that owner too. Failure-Class: FC-saved-device-launch-failure-revokes-reconnect Co-Authored-By: Claude Opus 5.5 <[email protected]>
An in-flight connect that loses its service owner must leave teardown to the retiring caller instead of unmanaging and disposing again. Preserve single ownership during intent disarm and cancellation. Failure-Class: FC-saved-device-launch-failure-revokes-reconnect Co-Authored-By: Claude Opus 5.5 <[email protected]>
Failure-Class: FC-saved-device-launch-failure-revokes-reconnect Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Submit pending connects from capture retry handoffs and rediscovery. Count only real failures, keep GATT cooldowns in CoreBluetooth, duty-cycle cache-miss scans, and continue explicit Dart teardown after an intent-disarm error. Exercise production callbacks with a deterministic radio/scheduler harness. Failure-Class: FC-saved-device-launch-failure-revokes-reconnect Co-Authored-By: Claude Opus 5.5 <[email protected]>
Exercise the production disconnectPeripheral path before its down callback and keep native test defaults isolated. Failure-Class: FC-saved-device-launch-failure-revokes-reconnect Co-Authored-By: Claude Opus 5.5 <[email protected]>
Problem and change
A saved pendant's native retry ownership was lost on process restart. When CoreBluetooth could not retrieve its identifier, recovery used a five-second unfiltered scan with no native continuation; background scans require a service filter. A capture reset could also consume a down callback without returning ownership to saved reconnect.
Persist saved intent and explicit suppression, cancel pending or connected restored links covered by that suppression, reconcile it on adapter-on and state restoration, and establish an outstanding connect in the unexpected-disconnect callback. Process termination keeps saved OS requests restorable and never writes a manual disconnect block. Duty-cycle service-filtered cache-miss discovery for five seconds per minute until the saved target is found. Transient capture transport release retains saved intent and an outstanding native request. Explicit user disconnect, forget, DFU pause and service shutdown disarm intent before teardown. Capture denial terminates capture work without cancelling link reconnection. Native saved connects arm the existing bounded GATT discovery retry and terminal failure path before starting the connection. Preserve the existing pairing-loss recovery block and kill switch.
Record every native connect request and its pending-since timestamp, cancellation reasons, and scan observations. Known targets retain the OS connection request with one five-second diagnostic scan per outage. Capture down callbacks and capture timeout submit the OS connection immediately when scheduling a retry. Discovery cancels a pending retry and submits a connection immediately. Count only actual connection/setup failures for capped backoff. Terminal GATT failures retain a separate cooldown across transport release, foreground and scan entry points; CoreBluetooth owns the delay through CBConnectPeripheralOptionStartDelayKey, so suspension cannot strand it. Failed native intent disarm is logged and remains retryable while explicit Dart disconnect always continues through transport teardown. Diagnostics stay local to the existing bounded BLE log and export.
The original incident cannot establish whether the peripheral stopped advertising: previous logs omitted connect calls and scan observations. This PR fixes demonstrated app recovery gaps without asserting a firmware root cause.
Validation
ec4e289454bdb139c086f5a772b10bb941ab318bpassed the native suite and leaves the validated product source unchanged.72799defb456de19d0e59401a8dc1c053deabd5d, all three repeats and eight scenarios, on m1-mac-studio.make preflightpassed all 34 selected checks and normal pre-push validation passed with no bypasses. Push verified withgit ls-remote; final-head CI is being monitored byci-wait 23517 BasedHardware/omi 120.UI-Evidence: none -- The diagnostics page change only forwards native fields into the exported JSON; no widget, layout, copy, navigation or styling changes.
Invariants: INV-CAP-1, INV-PERF-1. Reconnect retains link intent without adding an uplink pause or changing capture admission. The export map changes outside rendering; the production perf harness stays intact. Recovery timers retain an OS request and filtered discovery is duty-cycled.
Failure-Class: FC-saved-device-launch-failure-revokes-reconnect
🤖 Generated with Claude Code