Skip to content

Restore saved pendant connections during native iOS launch - #26085

Merged
Git-on-my-level merged 3 commits into
BasedHardware:mainfrom
Git-on-my-level:lane/ios-ble-restore-relaunch
Nov 23, 2026
Merged

Git-on-my-level merged 3 commits into
BasedHardware:mainfrom
Git-on-my-level:lane/ios-ble-restore-relaunch

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Recreate the restorable iOS central during native launch when UIKit identifies it or a saved reconnect target exists. Core Bluetooth restoration and launch diagnostics run before a Flutter scene. A saved legacy/live-mode Omi pendant stays disconnected during headless launch, and iOS cancels any inherited pending or connected link. The pendant can keep recording offline until Dart explicitly manages it and resumes its normal capture path.
  • A saved Limitless pendant in Transcribe Later still reconnects headlessly when its persisted native drain configuration matches the peripheral UUID and the Limitless flash service/RX characteristic. A fresh BLE link does not activate live streaming. The pendant retains audio in flash while the native engine subscribes and drains, and the engine acknowledges pages only after fsync. An inherited connected link is retired first because it could still be in live mode. Other headless targets wait for Dart.
  • Record launch, foreground, background, memory warning, terminate and restore callbacks in the opt-in debug log. An atomic marker records the previous process's last lifecycle state and whether UIKit delivered termination. An unclean marker alone cannot distinguish force quit, jetsam and crash.
  • Default on. Set the native Boolean UserDefaults key omi_ble_native_restore_enabled to false to disable early central initialization and the new lifecycle diagnostics. The custody gate is deliberately not behind this switch: with the switch off, a saved legacy pendant still waits for Dart to manage the device before connecting (it is never connected without an audio consumer). Only Limitless flash drain in Transcribe Later reconnects natively.

Incident

A native restore launch could bypass the Flutter scene that previously registered the singleton. The incident logs stop during a reconnect attempt and resume at a user launch, so they do not establish whether this defect caused the 21-hour gap. Existing saved-target callbacks submit OS-owned requests and leave them pending; app timers still matter when a peripheral cannot be retrieved and scan retries are paused between windows. Apple's TN3115 describes relaunch conditions and exceptions.

Verification

  • The native Swift callback harness covers legacy cold launch, pending/connected restoration before the adapter is ready, Dart adoption, and reconnect for a matching Limitless Transcribe Later route. Swift parsed all affected native files against the iOS Simulator SDK. The BGTask launch suite and all 52 focused Flutter debug-log, BLE bridge, transport and saved-reconnect tests passed.
  • The unsigned iOS dev device build completed through omi-heavy and produced Runner.app. Local preflight passed all 42 checks.
  • Physical iPhone background relaunch and live Dart capture remain unverified.

Release and David must complete this device checklist on internal TestFlight before any external release:

  • Connect the pendant, background the app, and trigger a CoreBluetooth relaunch.
  • Confirm restore_launch appears in the debug log.
  • With Limitless in Transcribe Later, confirm a fresh headless reconnect and verify the flash drain produces a durable batch recording.
  • With a legacy Omi pendant in live mode, trigger a headless cold relaunch and record identifiable speech during the headless interval. Confirm iOS does not keep a BLE link open before Dart starts. Open Omi, confirm normal live capture resumes, and sync/play back the offline recording to verify that the headless interval is present without an audio gap.
  • Set the native Boolean omi_ble_native_restore_enabled=false and confirm early central init and lifecycle diagnostics are off, and that a saved pendant reconnects once the app is foregrounded (custody gate stays on).

Product invariants affected

  • INV-CAP-1

Failure-Class: FC-saved-device-launch-failure-revokes-reconnect
UI-Evidence: none -- Native reconnect and debug diagnostics only.

View guided diff

Failure-Class: FC-saved-device-launch-failure-revokes-reconnect
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T13:01:46.713594Z c6535d9 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: ab77a4bd0f

ℹ️ 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 +186 to +187
!OmiSavedReconnectIntent().saved.isEmpty {
_ = OmiBleManager.shared

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 Preserve capture before connecting pendants headlessly

When iOS cold-launches a background task with a saved legacy live-mode pendant but no Flutter scene or restored audio subscription, this now actively connects it through centralManagerDidUpdateState. In a fresh process, captureReconnects is empty and flutterApi is nil, so completeDeviceReady (OmiBleManager.swift:631-648) never subscribes to audio; native batch writing cannot help without notifications either. The legacy pendant then discards audio while connected/unsubscribed instead of retaining it offline, as documented in app/lib/services/capture/CAPTURE_POLICY.md:121-128, causing silent recording loss until Dart starts and violating INV-CAP-1. Establish a native durable consumer or verify device-side retention before allowing this saved-target headless connection.

AGENTS.md reference: AGENTS.md:L17-L17

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in c6535d93e793ae6ba7161c948543512646f5f94a. Native startup still restores the central and records lifecycle diagnostics. A saved legacy pendant now stays disconnected until Dart explicitly manages it. The restore and connect callbacks cancel inherited links without capture custody, including pending connections that complete during cancellation. A saved Limitless pendant in Transcribe Later remains eligible for a fresh headless reconnect via the matching native flash drain. Its pages stay on the pendant until the native writer has fsynced them.

The Swift callback harness, 52 focused Dart tests, local preflight, and unsigned iOS dev build passed. The PR checklist now calls for playback of the legacy headless interval on internal TestFlight.

Git-on-my-level and others added 2 commits November 23, 2026 14:52
Failure-Class: FC-saved-device-launch-failure-revokes-reconnect
Defer legacy BLE connections until Dart manages the target. Cancel inherited links before they can hold a pendant in live mode, and allow a fresh headless connection for the native Limitless flash-drain route.

Failure-Class: FC-saved-device-launch-failure-revokes-reconnect

Co-Authored-By: Codex <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit e08b043 into BasedHardware:main Nov 23, 2026
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant