Skip to content

fix(watch): stop watch recording on transport disconnect and dispose (#20780) - #20818

Closed
Aj2280 wants to merge 1 commit into
BasedHardware:mainfrom
Aj2280:fix/apple-watch-stop-recording-on-forget
Closed

Aj2280 wants to merge 1 commit into
BasedHardware:mainfrom
Aj2280:fix/apple-watch-stop-recording-on-forget

Conversation

@Aj2280

@Aj2280 Aj2280 commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #20780: Forgetting or disconnecting an Apple Watch from Settings invokes DeviceService._teardownConnection, which disconnects and disposes the WatchTransport. Previously, neither WatchTransport.disconnect() nor WatchTransport.dispose() invoked stopRecording(). Because only stopRecording() sends the stop message through WCSession to WatchAudioRecorderViewModel on the Watch, the Apple Watch microphone was left continuously recording after being forgotten.

This PR:

  1. Adds best-effort await stopRecording() to WatchTransport.disconnect().
  2. Adds best-effort await stopRecording() to WatchTransport.dispose().
  3. Adds constructor dependency injection for WatchRecorderHostAPI to enable hermetic testing.
  4. Adds hermetic unit tests in app/test/unit/watch_transport_disconnect_test.dart validating that both disconnect(), dispose(), and AppleWatchDeviceConnection.disconnect() invoke stopRecording() and handle communication failures gracefully.

Product Invariants Affected

none

Failure Class (fixes)

Failure-Class: none

Review in cubic

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The fix itself looks right and well-scoped — nice catch on the root cause, and the changelog entry is accurate. One blocking problem in the new tests:

WatchTransport._state starts as DeviceTransportState.disconnected (watch_transport.dart:17), and disconnect() early-returns at the if (_state == DeviceTransportState.disconnected) guard (lines 126-128) before reaching the new stopRecording() call. So in watch_transport_disconnect_test.dart:

  • 'disconnect calls stopRecording...' expects 1, will see 0
  • 'AppleWatchDeviceConnection.disconnect delegates...' expects 1, will see 0
  • 'disconnect and dispose handle stopRecording errors gracefully' expects 2, will see 1

Only the dispose-only test passes as written. Note the Dart Analyze & Tests check is skipped for this PR, so CI won't catch this — running flutter test test/unit/watch_transport_disconnect_test.dart locally should show the failures.

Two ways to fix (either works):

  1. Drive the transport through a successful connect() first (stub isWatchPaired / isWatchReachable on the fake in addition to isWatchSessionSupported), so _state is connected when disconnect() is called; or
  2. Move the best-effort stopRecording() above the state guard in disconnect() — arguably more robust, since we want the watch mic off regardless of the tracked Dart-side state.

Once the tests actually exercise the new path, this should be in good shape. Leaving for human maintainer review after the fixes; no security concerns in this diff.


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 Git-on-my-level added the flutter flutter work label Oct 6, 2026
@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks for this contribution! Our review requested some changes (see above) and we haven't heard back in a while. If you're still working on it, just push a commit or leave a comment within the next 7 days. To keep the queue healthy we'll close this PR in 14 days if it stays inactive — and it can always be reopened once updates land. Happy to re-review!

@github-actions

Copy link
Copy Markdown
Contributor

Hey @Aj2280 👋

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:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flutter flutter work stale-candidate Candidate for kind stale follow-up

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Forget Device on an Apple Watch does not stop the Watch microphone

3 participants