Repository navigation
Conversation
The phone starts Watch recording when the Watch connects, but nothing on the phone ever stopped it. Forget Device tore down the connection and disposed the WatchTransport (timers and Dart streams only), so the Watch kept recording after the phone said it was forgotten, and nothing consumed that audio any more. DeviceService.forgetDevice now asks an Apple Watch connection to stop recording before tearing it down. The new AppleWatchDeviceConnection.stopRecording is best effort: the iOS host queues the stop for an unreachable Watch, and an error never blocks the forget. A plain disconnect (reconnects, switching sources) is unchanged. Fixes BasedHardware#20780
Git-on-my-level
approved these changes
Oct 6, 2026
Git-on-my-level
left a comment
Member
There was a problem hiding this comment.
Reviewed file by file — this is a clean, well-scoped fix for #20780.
- app/lib/services/devices.dart — forgetDevice now calls connection.stopRecording() before _teardownConnection, and only when the connection is an AppleWatchDeviceConnection. Correct placement: after clearStaleBondRecoveryRequirement(), before teardown, so the transport is still alive when the stop is sent.
- app/lib/services/devices/connectors/apple_watch_connection.dart — the new best-effort stopRecording is a no-op for non-WatchTransport transports and catches every error, so a failed stop can never block or crash the forget. Consistent with the error handling style of the surrounding methods.
- app/lib/services/devices/transports/watch_transport.dart (context) — the existing stopRecording rethrows, which is why the connector-level catch matters; verified the pigeon call mirrors startRecording exactly.
- ios/Runner/RecorderHostApiImpl.swift (context) — the "queues the stop when the Watch is not reachable" claim checks out: sendMessage with an updateApplicationContext fallback, so an unreachable Watch still gets the stop on next contact.
- app/test/unit/forget_watch_stops_recording_test.dart — good regression test: it mocks the real WatchRecorderHostAPI pigeon channels, drives the real DeviceService through its connectionBuilder seam, and covers the three behaviors that matter (stop on forget, forget still succeeds when stop errors, plain disconnect does NOT stop recording). Keeping disconnect semantics unchanged is the right call for reconnects and source switches.
- app/changelog/unreleased/20261006-forget-watch-stops-mic.json — accurate, user-facing changelog entry.
One non-blocking nit: per repo convention (Definition of Done #7) fix: commits should declare a Failure-Class trailer — worth adding a line to the PR body if you get a chance, no rebase needed.
Thanks for the careful diagnosis and the test design — approving.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR: Forgetting an Apple Watch from device settings now also stops the Watch's microphone. The phone starts Watch recording when the Watch connects, but nothing on the phone ever told it to stop. So after Forget Device the Watch kept recording, and nothing consumed the audio.
DeviceService.forgetDevicenow sends the existingstopRecordingcall to an Apple Watch before tearing the connection down. Best effort; a plain disconnect is unchanged. Mobile only, no backend or Watch app change. Simulator before/after (realDeviceService,AppleWatchDeviceConnectionandWatchTransport) below. Closes #20780.What changed and why
AppleWatchDeviceConnectionstarts the Watch recorder (WatchTransport.startRecording) on connect, butWatchTransport.stopRecordinghad no callers.disconnect()anddispose()only cancel timers and close Dart streams.DeviceService.forgetDevicenow calls the newAppleWatchDeviceConnection.stopRecording()before_teardownConnection.RecorderHostApiImpl.stopRecording) sends the message when the Watch is reachable and queues it as application context when it is not, so it never blocks. An error is logged and the forget continues.disconnectDeviceand the teardown that runs before a reconnect still leave Watch recording alone, so reconnects and source switches behave as before.Closes #20780
Product invariants affected
none
How it was verified
flutter test test/unit/forget_watch_stops_recording_test.dart: 3 passed. Without theforgetDevicechange, the first two fail (nostopRecordingcall reaches the Watch host).flutter test test/unit/device_service_connections_test.dart test/services/devices/ test/widgets/device_page_forget_test.dart test/providers/device_provider*_test.dartplus the new file: 60 passed.DeviceService,AppleWatchDeviceConnectionandWatchTransport. Only theWatchRecorderHostAPIpigeon channel is faked, and it counts start/stop calls. The test connects, starts recording, then callsforgetDevice. There is no Watch on the Simulator, so the evidence is the call log:main(7d85fb5):startRecordingCalls=1 stopRecordingCalls=0 watchStillRecording=true connectionExists=falsestartRecordingCalls=1 stopRecordingCalls=1 watchStillRecording=false connectionExists=falsescripts/pr-preflight --base upstream/main --lane local: passed.make mobile-verify ARGS="fast --paths app/lib/services/devices.dart app/lib/services/devices/connectors/apple_watch_connection.dart": 23/23 hermetic journeys passed.Tests
app/test/unit/forget_watch_stops_recording_test.dart:Failure class (fixes)
Failure-Class: none