test: lock in that "disconnecting" outlives the audio pipeline teardown - #1010
Open
kraenhansen wants to merge 2 commits into
Open
kraenhansen wants to merge 2 commits into
kraenhansen wants to merge 2 commits into
Conversation
Lock in that a session stays in "disconnecting" until AudioSession.stopAudioSession() has resolved, so the status never claims the session is gone while the platform still owns the microphone. Adds Vitest to the package (there was no test setup) and drives the real React Native setup strategy through VoiceConversation.startSession/ endSession against a mocked native audio session.
VoiceConversation must not report "disconnected" until the platform strategy's detach has settled, since that is where each platform releases its audio pipeline (wake lock on web, native audio session on React Native).
kraenhansen
marked this pull request as ready for review
September 10, 2026 11:20
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.
What
Makes the "the client stays in
disconnectinguntilAudioSession.stopAudioSession()has resolved" guarantee enforced rather than incidental.The behaviour already holds on
main: the React NativedetachawaitsstopAudioSession()in afinally,VoiceConversation.handleEndSessionawaits thatdetachascleanUp(), andBaseConversation.endSessionWithDetailsonly callsupdateStatus("disconnected")afterhandleEndSession()settles. Nothing in the test suite covered that chain, though, and every link in it is a plainawaitthat a refactor could drop without any test noticing.Changes
packages/react-native: added Vitest (the package had no test setup) plussrc/index.react-native.test.ts, which drives the real React Native setup strategy throughVoiceConversation.startSession()/endSession()with a mocked native audio session. One case gatesstopAudioSession()on a deferred and asserts the status sequence stops atdisconnecting(andonDisconnecthas not fired) until it resolves; the other asserts the audio session is still stopped when the connection detach throws.packages/client: addedsrc/VoiceConversation.test.tscovering the platform-agnostic half — a setup strategy whosedetachnever settles must keep the conversation indisconnecting, with the input/output controllers still open.packages/react-native/src/index.react-native.ts: a comment recording why thestopAudioSession()call is awaited rather than fire-and-forget.No published behaviour changes, so no changeset.
Testing
Both new tests were mutation-checked against the regressions they exist to catch.
Replacing
await AudioSession.stopAudioSession()withvoid AudioSession.stopAudioSession()fails the React Native test:Replacing
await this.cleanUp()withvoid this.cleanUp()inVoiceConversationfails both the client test and the React Native test the same way, confirming the React Native case covers the whole chain and not just the wrapper.Unmutated runs:
packages/react-native: 2/2 pass (pnpm exec vitest run)packages/client: 260/260 pass across 19 files (pnpm exec vitest run --browser.headless)pnpm exec turbo test lint check-typesforclient,react, andreact-native: all green except the client browser project, which cannot launch a headed Chromium in this VM (no XServer) and passes with--browser.headless.