Skip to content

fix(app): restore pendant unmute after capture goes idle - #24740

Merged
Git-on-my-level merged 5 commits into
BasedHardware:mainfrom
jshph:fix/pendant-unmute-from-idle
Nov 16, 2026
Merged

Git-on-my-level merged 5 commits into
BasedHardware:mainfrom
jshph:fix/pendant-unmute-from-idle

Conversation

@jshph

@jshph jshph commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

What changed and why

Fixes #24664. Refs #24762.

  • Double-tap unmute from idle: device resume now uses the same resume reducer as the Home control, so a CV1 double-tap clears a persisted mute after capture has gone idle.
  • Reconnect while muted: a device start under persisted user mute keeps a paused pendant session and its button listener, instead of failing closed with capture_unavailable.
  • Foreground recovery while muted: _recoverCaptureOnResume restarted a connected pendant that capture left idle, but only when unmuted. A muted pendant whose start failed or was skipped stayed dead: no Paused card, no button listener, so the double-tap could not reach the app (the iOS pendant Pause/Resume controls disappear after app relaunch #24762 relaunch symptom). It is now restarted too and lands paused. A pendant the user stopped, batch mode, calls and phone-owned capture stay excluded, and orphan-audio recovery keeps its mute check.

Rebased on main after #24393 (CV1 3.0.23 device mute). Device resume still delegates to _reduceResume, so it carries PersistDeviceMuteStage like every other resume. On 3.0.21, which has no mute characteristic, setCaptureMuted is a no-op. A muted reconnect now resolves the device mute first and then lands paused.

The reporter reproduced this on iOS app 1.0.586 / CV1 firmware 3.0.21. App-icon quick action Mute → Unmute followed by reopening the app restored capture.

Line-Count-Exception: app/lib/services/capture/capture_controller.dart | 4916 -> 4926 | Keep muted-connect pause handling at the existing BLE admission boundary; splitting this controller is outside this regression fix.

Product invariants affected

INV-CAP-1: explicit user mute permits suspended audio, and unmute restores live delivery. The paused state stays visible while audio admission is denied, including after a relaunch or a failed start.

How it was verified

On the rebased head:

  • bash app/test.sh: 8,728 passed, 5 skipped. This Linux host used a local g++ shim for the script's unavailable clang++.
  • flutter test test/services/capture/: 441 passed.
  • bash scripts/analyze_ratchet.sh: passed.
  • Earlier head: make preflight, make mobile-verify j5 (3/3), and the offline iPhone/BLE harness all passed.
  • iOS build and a physical-device retest are not possible on this Linux host.

Tests

New coordinator tests cover:

  • muted idle resume, plus call/phone/no-device exclusions;
  • a muted ended session;
  • a persisted-mute relaunch through a tracked BLE button listener;
  • foreground recovery of a muted idle pendant (Paused card, button listener, double-tap resumes);
  • a pendant the user stopped staying stopped.

The idle-resume, relaunch and foreground tests failed before their fixes.

UI evidence

UI-Evidence: none -- no widget or layout changes.

Failure class (fixes)

Failure-Class: none

🤖 Generated with Claude Code

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

Reply to a comment to ask cubic a question or push back. It learns from your replies.

View guided diff | Re-trigger cubic

@Git-on-my-level

Copy link
Copy Markdown
Member

Verdict: this fix looks correct and well-tested — no blocking findings. Credit for the diagnosis in #24664; the ble_log evidence made reviewing this straightforward.

Findings by file:

  • app/lib/services/capture/capture_coordinator.dart — the _reduceDeviceResume rewrite is behavior-preserving on every legacy path, and I traced each one: the dropped env.silencePaused branch is preserved because _reduceResume delegates to _reduceSilenceResume on its first line, and _reduceSilenceResume itself no-ops when phoneOwns or a call is active; the phonePaused/phoneBatchPaused and pendantPaused/pendantBatchPaused paths land on identical effects (PolicyWrite(false) + ResumeDeviceTailStage for pendant, socket reopen + NativeMicStart for phone). The two real behavior changes are both intentional and covered by new tests: (1) from muted idle with a connected pendant and no phone/call, device resume now emits PolicyWrite(false) — the fix, letting a double-tap clear a persisted mute from idle; (2) while a live phone owns capture, a device resume event no longer clears wasPaused on a suspended pendant, so the pendant resumes paused rather than silently flipping to live. The second is a small semantic tightening in the safe direction.
  • app/lib/services/capture/capture_controller.dart — the new guard in _initiateDeviceAudioStreaming sits at the foreground-audio-denied boundary, re-checks _deviceIdentityStale first, and requires both the persisted mute (capturePolicy.muted) and the coordinator's paused phase (stagedReadModel.deviceMuted, i.e. pendantPaused/pendantBatchPaused) before surfacing the paused state — so it cannot mask other admission failures, which still reach the debug log. Minor note: this path skips _armUplinkSilence(), which the normal pause path calls; that seems right with no audio flowing, just worth knowing.
  • app/test/services/capture/capture_coordinator_test.dart — the five new tests cover both deltas, the no-device and during-call invariants, and a full relaunch replay with BLE button-listener tracking (_ButtonTrackingConnection) ending in double-tap → policy cleared → audio resubscribed, with the UI-state assertions requested by an earlier review (addressed on this head).
  • app/changelog/unreleased/20261105-pendant-unmute-recovery.json — appropriate user-facing fragment.

Security: no new data flows, permissions, or network surface — pure state-machine/recovery logic.
Blast radius: capture recovery for muted pendant users; if wrong, worst case is a stale paused card or a mute needing a second tap to clear.

USER IMPACT: pendant users who muted can unmute with a double-tap after the app went idle or reconnected, instead of capture staying dead until an app reinstall.

What I'd still want before merge: CI has produced zero check-runs on this head, so the local suite runs in the PR body are unconfirmed by the repo — the app test lane needs to run (a trivial push re-triggers if it stays silent), and iOS on-device verification (the reported platform) is outstanding. Leaving merge sign-off to human maintainers for exactly those two reasons.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@jshph

jshph commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review.

CI: the workflows did trigger on both heads (0a50690eb, 0fb5c243d). All 9 are waiting at action_required because this is a first-time contributor fork, so a push won't start them. Could a maintainer approve the workflow runs?

On-device: I can't produce a signed iOS build that works against production. Per app/README.md, the beta bundle has to be registered with Omi's Firebase project and Apple team. Additional offline evidence on 0fb5c243d:

  • wearable_radio_trace_replay_test, physical_capture_lifecycle_test, physical_qualification_test: pass
  • scripts/dev-harness/run-tests.sh: 574 passed, 7 skipped, 20 xfailed

I'm the reporter in #24664 and will run the 6-step repro on my iPhone (CV1, fw 3.0.21) as soon as this is in an internal or TestFlight build. Happy to do it earlier if you can share one.

jshph and others added 3 commits November 11, 2026 21:29
…turns

Foreground recovery restarted a connected pendant that capture left idle,
but only when unmuted. A muted pendant whose start failed or was skipped
stayed idle: no Paused card, no button listener, so the double-tap unmute
could not reach the app (BasedHardware#24762). A muted device start now lands paused, so
foreground recovery admits it too. A pendant the user stopped stays stopped.

Also updates the idle device-resume test for the new PersistDeviceMuteStage.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jshph
jshph force-pushed the fix/pendant-unmute-from-idle branch from 0fb5c24 to 2b2e95a Compare November 11, 2026 21:56
@jshph

jshph commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Rebased on main after #24393 (CV1 3.0.23 device mute) to clear the conflict. Device resume still delegates to _reduceResume, so it now carries PersistDeviceMuteStage like the other resume paths.

New commit 2b2e95ae0a closes one more path to the same stuck state, matching #24762. Foreground recovery restarted an idle connected pendant only when unmuted, so a muted pendant whose start failed or was skipped had no Paused card and no button listener. It now restarts and lands paused. A user-stopped pendant stays stopped. Regression tests cover both cases, and the first fails without the fix.

On this head: app/test.sh 8,728 passed / 5 skipped, capture tests 441 passed, analyzer ratchet passed. CI is still waiting for maintainer approval of the workflow runs.

@jshph

jshph commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

@Git-on-my-level, a quick heads-up since this now builds on your #24393. After the rebase:

  • Device resume delegates to _reduceResume, so it emits PersistDeviceMuteStage like the other resume paths.
  • A muted reconnect resolves the device mute and then lands paused instead of failing closed.
  • One new commit (2b2e95ae0a, matching iOS pendant Pause/Resume controls disappear after app relaunch #24762) lets foreground recovery start a muted idle pendant as paused, so the card and the double-tap come back.

CI is still waiting for approval to run.

@Git-on-my-level

Copy link
Copy Markdown
Member

Since my last review: addressed (rebase onto #24393 verified - device resume now delegates to _reduceResume, which carries PersistDeviceMuteStage(false) on the pendant arms, so a double-tap unmute also clears the device-side mute; the new foreground-recovery commit closes the relaunch path from #24762) - still open (all CI workflows on this head were waiting on first-time-contributor approval - I have approved them, so the lanes should start; on-device iOS spot-check of the #24664 repro) - newly introduced (none).

Verdict: the new head holds up - no blocking findings; this closes one more path into the same stuck state, and the guard rails stayed where they should be.

New code, checked on this head:

  • app/lib/services/capture/capture_live_recovery.dart - admitMuted is threaded narrowly: _orphanAudioAdmitted(ignoreMute:) keeps every other exclusion (batch mode, deviceStoppedByCaller, pendantSuspension, phone-owned capture, active call), and the only caller bypassing the mute gate is the appResumed recovery (line 209). The orphan-audio trigger (line 195) and the packet admission path (line 148) still honor mute - correct, since no audio can flow from a muted device anyway. _idlePendantNeedsCapture relaxing !isPaused only under admitMuted matches the semantics: a muted failed start leaves phase idle while the UI reads paused.
  • app/lib/services/capture/capture_controller.dart - the muted-reconnect guard is unchanged by the rebase and still requires both the persisted policy mute and the coordinator's deviceMuted phase before surfacing pause, so other admission failures still fail closed to the log.
  • app/lib/services/capture/capture_coordinator.dart - _reduceDeviceResume now reads as a two-line ownership check plus delegation; I re-traced each arm against _reduceResume on the new base and legacy effects are identical, with PersistDeviceMuteStage now inherited from the pendant arms.
  • app/test/services/capture/capture_coordinator_test.dart - the new foreground tests pin the three cases that matter: a muted-idle restart lands paused with a live button listener and a working double-tap; a pendant the user stopped is not restarted; unmute after the muted session ended clears policy for the next start. _ButtonTrackingConnection counting open subscriptions is a clean way to assert the listener lifecycle.
  • app/changelog/unreleased/20261105-pendant-unmute-recovery.json - wording matches the extended behavior.

Security: no new surfaces - state machine and recovery logic only.

USER IMPACT: a muted pendant comes back as a Paused card with a working double-tap unmute after a relaunch or a failed start, instead of capture staying dead until an app reinstall.

I approved the pending workflow runs for this fork, so Mobile App Checks should start shortly - the suite run described in the PR still needs to be confirmed by that lane. Beyond that, an on-device iOS check of the original repro is the one thing automated tests cannot cover. Leaving merge sign-off to the human maintainers for those two items.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

…ed settle

The recovery start does real WAL and device I/O outside settle()'s tracking,
so a loaded CI runner asserted before it finished (3/8 local runs under CPU
load failed the same way). Poll for the paused state with a 10 s bound; the
test still fails without the fix.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level

Copy link
Copy Markdown
Member

Since my last review: addressed (the only failing lane on the previous head, Mobile App Checks, failed only in "foreground restores a muted pendant left idle as paused with a working double-tap" - it asserted liveCaptureSource before the unawaited recovery start finished; I confirmed this in the CI log, and the new head replaces that test's fixed settle with a bounded poll) - still open (this push re-triggered the fork workflow gate, so all lanes were back at action_required - I have approved them, so CI can now confirm the flake fix on this head; the on-device iOS repro of #24664 is still outstanding until a build is available) - newly introduced (none; the delta is test-only).

Verdict: no blocking findings - the fix remains correct and well-scoped, and the new commit only hardens the wait in the test that flaked under a loaded runner.

Checked on this head:

  • app/test/services/capture/capture_coordinator_test.dart - the new wait polls for recordingState == pause with a 10 s deadline and 20 ms settle ticks, instead of assuming one settle covers the unawaited recovery start (which does real WAL/device I/O outside settle()'s tracking). The failure mode it fixes matches the CI log exactly, and the bound keeps the test failing rather than hanging if the regression ever returns.
  • The four files carrying the fix (capture_controller.dart, capture_coordinator.dart, capture_live_recovery.dart, and the changelog fragment) are unchanged from the head reviewed earlier - my file-by-file notes there still stand.

USER IMPACT: a muted pendant reconnects into a visible paused state with a working double-tap unmute, instead of silently dead capture until an app reinstall.

Still wanted: green Mobile App Checks on this head once the lanes run, and the on-device repro of the #24664 flow when an internal or TestFlight build is available. Merge sign-off stays with a human maintainer; no escalation urgency - the technical surface is verified.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level

Copy link
Copy Markdown
Member

Since my last review: addressed (the one outstanding automated item — green CI on this head — is now confirmed: Dart Analyze & Tests, Formatting, Hygiene, and Mobile Release Eligibility all pass; the skipped lanes are path filtering, not failures, and the lone neutral result is an advisory reviewer bot) · still open (the on-device run of the #24664 repro on iOS/CV1, which needs an internal or TestFlight build) · newly introduced (none — the head is unchanged since the last review).

Verdict: from the automation side this is merge-ready. The fix was verified file-by-file in my earlier reviews, and re-checking the delegation on this head holds up: _reduceDeviceResume no-ops only while a live phone owns the channel, and _reduceResume's first line preserves the silence-paused routing, the pendant resume arms carry PersistDeviceMuteStage(false), and the muted-idle arm emits exactly PersistDeviceMuteStage(false) + PolicyWrite(false) with no capture stage — which is the double-tap-unmute-from-idle fix, asserted by the new tests.

USER IMPACT: a muted pendant comes back as a Paused card with a working double-tap unmute after a relaunch, reconnect, or failed start, instead of capture staying dead until an app reinstall.

Remaining before merge: the on-device check of the original repro (the author has offered to run it as soon as a build is shareable) and human merge sign-off — no escalation urgency; the technical surface is verified.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@jshph

jshph commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

Thanks David. I can't produce a signed iOS build myself, since the beta bundle has to be registered with Omi's Firebase project and Apple team. Any of these works for me:

  1. Merge, and I'll run the repro on the next internal or TestFlight build and report back here.

  2. Share a TestFlight build of this branch, and I'll run it right away.

  3. Have a maintainer with a CV1 run it. Steps (iOS, double-tap set to Mute/Unmute, conversation timeout 5 min):

    1. Start a live recording.
    2. Double-tap to mute.
    3. Wait more than 5 minutes for the conversation to auto-end.
    4. Double-tap to unmute.

    Expected: the live card returns and recording resumes. Also check that relaunching the app while muted shows a Paused card, and that a double-tap resumes from it.

Keep main's device-resume routing and committed muted-start handling.
Retain the contributor's foreground recovery and cover muted sync-fence recovery.

Failure-Class: none
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit 5097caa into BasedHardware:main Nov 16, 2026
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flutter flutter work positive-signal Automation verified a genuine fix/quality contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iOS: pendant capture fails closed on every reconnect after a mute with a storage backlog; persists until the app is reinstalled

2 participants