Repository navigation
harden(app): route capture timers, streams and listeners through CaptureLifetime - #14375
Git-on-my-level wants to merge 6 commits into
Conversation
Those comments record why-knowledge this file breaks without: mute must survive process death so streamDeviceRecording can re-apply it, and custom STT buffering is surfaced so the UI shows offline instead of Listening. Pay for the lines by extracting BleBridgeCaptureListeners. Co-authored-by: Cursor <[email protected]>
…ureLifetime Wrap the injected scheduler in CaptureLifetime so once/periodic, connectivity listen, BLE finalized/stream subscriptions, and the live-segment listener cancel on dispose. close() now drains every sync cancel before returning so void dispose() stays synchronous. Extract image-chunk emission so the controller shrinks. Co-authored-by: Cursor <[email protected]>
The only CaptureController timer that dispose did not cancel was the 15s voice-command timeout (the class of 05c43c0). After dispose, advancing fake time leaves no pending timers. Also lock close() to cancel every owned timer before the caller awaits. Co-authored-by: Cursor <[email protected]>
…to task/msd-core-c1-disposal
Formatting only; required by the pre-push dart format gate. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…posal Co-authored-by: Cursor <[email protected]> # Conflicts: # app/lib/services/capture/capture_controller.dart # app/lib/services/capture/capture_lifetime.dart # app/test/services/capture/capture_lifetime_test.dart
|
Hey @Git-on-my-level 👋 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:
Before your next PR, please skim:
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! |
|
Auto-closed when base branch was deleted after its parent squash-merged. Head unchanged at |
What changed and why
C1 cut (3):
CaptureControllernow owns aCaptureLifetimewrapping the injected scheduler, so every_scheduling.once/periodic, the constructor connectivitylisten, BLE finalized/stream subscriptions, andCaptureProvider's live-segmentaddListenercancel whendisposeruns. The first commit restores the two why-comments removed to hold 2,710 lines (mute restore; custom-STT buffering UI) and pays for them withBleBridgeCaptureListeners. Production no-argument defaults stay.This is the first C1 cut that changes behavior on purpose: the 15s voice-command timeout used to survive
disposeand could still fire. It no longer does. Evidence class:05c43c014d(late timer after teardown),348d5f31dc(_bleButtonStreamleak — already cancelled in dispose; now bag-owned so it cannot regress).Stacked on the composition tip (
task/msd-core-c1-composition/ forthcoming PR stacked on #14361).origin/maindoes not yet contain #14361.capture_controller.dartshrinks 2710 → 2698.No spine markers retired: remaining C1 contracts are generation/join, adoption, FGS, persistence — not this dispose drain.
Resource inventory (
capture_controller.dart/capture_provider.dart)_keepAliveTimer(_scheduling.periodic15s)_schedulingis the lifetime)_inProgressConversationRefreshTimer_autoSyncFallbackTimer(30s ConversationEvent fallback)05c43c014d_voiceCommandTimeoutTimer(15s)_connectivity.changes.listenlifetime.listenaddBatchRecordingFinalizedListenerlifetime.own_bleBytesStreamlifetime.own+takeSubscription_blePhotoStream_bleButtonStream348d5f31dc)_storageStreamCaptureProvider.addListener(_persistLiveSegments)removeListenerin dispose)lifetime.own; providerdisposeoverride deletedCaptureMetricsTrackerTimer.periodic5scapture_metrics_tracker.dart:124_metrics.dispose()dart:asyncTimerdirectly, notCaptureScheduling. Still cancelled in dispose. Migrating it would pull the metrics helper onto capture's clock; listed rather than expanded._socket?.unsubscribe(this)Future.delayed(20ms)image chunksimage_utils.dartemitBase64ImageChunksTimerheld across dispose_peopleRefreshFutureunawaited(_captureSessionLocation/ auth refresh)Product invariants affected
none
How it was verified
Not exercised as a live device recording session.
Commands run:
python3 scripts/check_spine_contracts.py— 47 pending markers; 17 protected files. No spine-test edits.python3 scripts/check_mobile_boundaries.py --config app/contracts/capture/boundary-baseline.json— 65 changed paths; 0 errors.TZ=UTC flutter test test/services/capture/capture_disposal_test.dart test/services/capture/capture_lifetime_test.dart test/spine/c1_lifetime_test.dart— 16 passed.TZ=UTC bash app/test.sh— exit 0.make mobile-verify ARGS="fast --paths app/lib/services/capture/capture_controller.dart app/lib/providers/capture_provider.dart"— executed 20, passed 20, failed 0 (full-suite fallback becausecapture_provider.dartis outside the capture-wal path rule; j5_capture_interruption_reconnect ran and passed).OMI_PR_BODY_FILE=.local/pr-body-c1-disposal.md make preflight— 21 checks passed in 185.65s.capture_controller.darttouched line ranges (working tree, 2698 lines):ble_bridgeimport (listeners go throughBleBridgeCaptureListeners)capture_lifetime.dartlifetimewraps the injected schedulerlifetime.listen/lifetime.ownfor connectivity, BLE finalized, BLE streams_storageStreamremoved_scheduling.once(now bag-tracked)_bleButtonStreamviatakeSubscription_bleBytesStreamviatakeSubscription_blePhotoStreamviatakeSubscription; image chunks extracteddispose— socket unsubscribe + metrics +lifetime.close()debugArmVoiceCommandTimeouttest seamCaptureConnectivityBoundary.production()remains the no-argument default.Tests
Builder regressions in
app/test/services/capture/capture_disposal_test.dart:isConnectedcapture_lifetime_test.dart:close()cancels every owned timer before the caller awaits (needed becausedisposeis void).Failure class (fixes)
No
fix:commits. This is aharden:adoption of the lifetime bag. The voice-command leak was unreleased C1 code, not a live production bug report.Failure-Class: none
Part of the mobile self-driving program (App core lane, C1 step 3). Stacked on composition / #14361 / #14327. Implemented by Cursor Grok 4.6. Coordinator: metrics sampler, socket unsubscribe, in-flight
Futures, and location/auth unawaited work are listed not migrated.Part of the mobile self-driving program (App core lane, third C1 PR). Stacked on #14367. Implemented by Cursor
cursor-grok-4.6-high. Coordinator verification on the head: spine check passes with no edits to protected tests; the disposal and lifetime tests pass (16);capture_controller.dartshrank from 2,710 to 2,698 lines; the two explanatory comments dropped in #14367 are restored. One genuinely leaked timer is closed here (_voiceCommandTimeoutTimer, 15 s, never cancelled on dispose). Resources deliberately left for later cuts are listed in the inventory above with the reason.🤖 Generated with Claude Code