Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions app/lib/services/sockets/composite_transcription_socket.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,13 @@ class CompositeTranscriptionSocket implements IPureSocket {
CustomSttLogService.instance.info('Composite', 'Disconnecting...');
DebugLogManager.logEvent('composite_socket_disconnecting', {});

// Mark disconnected before touching the children: their disconnect()
// fires onClosed, which would otherwise hit _onSocketClosed while the
// composite still looks connected and trigger a spurious
// "socket closed unexpectedly" teardown on top of this intentional one.
_status = PureSocketStatus.disconnected;
await _disconnectBothQuietly();

_status = PureSocketStatus.disconnected;
onClosed();
}

Expand All @@ -101,9 +105,9 @@ class CompositeTranscriptionSocket implements IPureSocket {
CustomSttLogService.instance.info('Composite', 'Stopping...');
DebugLogManager.logEvent('composite_socket_stopping', {});

await Future.wait([primarySocket.stop(), secondarySocket.stop()]);

// Same ordering requirement as disconnect().
_status = PureSocketStatus.disconnected;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve final custom-STT transcripts during stop

When the primary is a custom STT socket, stop() is where the final transcript can be emitted: PurePollingSocket.disconnect() flushes buffered audio before closing, and PureStreamingSttSocket.disconnect() sends CloseStream then waits for final results. Setting the composite status to disconnected here makes _forwardAsSuggestedTranscript() return immediately, so those final suggested_transcript messages never reach the backend, which in custom_stt mode does not run STT on the raw audio. This loses the tail of recordings or settings-change reconnects whenever the primary emits a final result during stop; suppress the close callback without blocking primary messages until child stops finish.

Useful? React with 👍 / 👎.

await Future.wait([primarySocket.stop(), secondarySocket.stop()]);
}

/// Called when either socket closes unexpectedly
Expand Down
Loading