Repository navigation
fix(capture): tell the server when the user taps Stop so notes start right away - #25536
Merged
Merged
Conversation
…right away
Since the backend keeps a mobile conversation open when /v4/listen closes
(so a reconnect continues it), a deliberate Stop looked like a drop and the
conversation waited for the quiet check (~5-8 min) before finalizing.
On a user Stop (phone live recording with reason user_stopped, or an
explicit pendant stop) the socket service now sends
{"type":"finalization_reason","reason":"user_stop"} after the last audio
frame and right before close. Drops, BLE disconnects, source restarts and
settings-change reconnects send nothing. The send is best-effort and never
blocks the close.
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.
Why
#25460 keeps a mobile conversation open when its
/v4/listensocket closes, so a phone or pendant reconnect continues the same conversation. A deliberate Stop now looks the same as a network drop, so the server waits for the durable quiet check (~5-8 min) before it finalizes, and notes arrive late.The backend already accepts an explicit signal on the listen socket,
{"type":"finalization_reason","reason":"user_stop"}(backend/routers/listen/receiver.py,finalization_reasonbranch). Any finalization reason makesresumable_after_drop(backend/routers/listen/batch_close.py) return false, so teardown finalizes right away. The app never sent it.What
TranscriptSegmentSocketService.stop(userStop: true)sends that frame right before the socket closes. It is best-effort: skipped when the socket is not connected, and a send error is logged and never blocks the close._stopPhoneLiveBodypassesuserStoponly for reasonuser_stopped(Stop on the live page, the Home button, Siri, and the voice-profile handoff).DeviceStopRequested(cleanDevice: false)) carriesuserStopthrough theSocketCloseeffect.cleanDevice: true/DeviceUpdated(null)), source restarts, transcription-settings reconnects and app backgrounding all leave the conversation open as fix(listen): a mobile socket drop no longer ends the conversation #25460 intends. Phone batch stop does not close the socket, so it is unchanged.Tests
New
app/test/services/capture/capture_user_stop_finalization_test.dartdrives the realCaptureControllerandTranscriptSegmentSocketServiceover the scripted transport, which now records an orderedwirelog of sends and closes:user_stop, after the last audio frame and immediately before close.Mutation check: with the send removed, 3 tests fail. With BLE disconnect also marked
userStop, 1 test fails.Ran locally with the pinned Flutter 3.44.5:
flutter test test/services/capture/ test/services/sockets/ test/unit/capture_recovery_replay_scenarios_test.dart test/unit/composite_transcription_socket_test.dart test/unit/capture_mute_admission_test.dart test/services/live_preview/: 677 passedflutter test --dart-define=OMI_DEV_CONTROLS=1 test/spine: 138 passedapp/scripts/analyze_ratchet.sh: passed;dart format --line-length 120: no changesProduct invariants affected
Failure class (fixes)
Failure-Class: FC-transport-drop-terminalizes-resumable-capture
This is the client half of that class's prevention ("key immediate finalization on the client's close semantics ... and an explicit client finalization reason"). With the server keeping drops open, the explicit reason is what keeps a deliberate Stop immediate.
UI-Evidence: none -- protocol only, no visible UI change
Line-Count-Exception: app/lib/services/capture/capture_coordinator.dart | 3026 -> 3027 | the user-stop flag on the SocketClose effect
🤖 Generated with Claude Code