@qafka/react-native 2.3.6 → 2.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -358,12 +358,21 @@ function useVoiceChat({ apiUrl, apiKey, userContext, contextDescription, onToolS
358
358
  }
359
359
  }, []);
360
360
  const connect = (0, react_1.useCallback)(async () => {
361
- if (serviceRef.current?.isConnected) {
362
- // Re-entering the voice page after a swipe to chat (which calls pauseMic
363
- // and stops native capture). The socket is still open, so the fresh-
364
- // connect path below would no-op and leave the mic stopped resume
365
- // capture so the user can be heard again.
366
- await serviceRef.current.resumeMic();
361
+ // A service already exists for this voice session — do NOT create a second.
362
+ // The scroll handler fires connect() repeatedly while the pager settles on
363
+ // the voice page; the previous `isConnected` guard passed for two near-
364
+ // simultaneous calls (the first WS hadn't opened yet), so each spawned a
365
+ // RealtimeService and the first was orphaned but kept streaming mic + audio
366
+ // (two interleaved audio streams = choppy playback; the orphan still heard
367
+ // the mic = "mute didn't work"). Guard on existence, set synchronously
368
+ // below before any await, to close that race.
369
+ if (serviceRef.current) {
370
+ if (serviceRef.current.isConnected) {
371
+ // Re-entering the voice page after a swipe to chat (which calls pauseMic
372
+ // and stops native capture). The socket is still open — resume capture
373
+ // so the user can be heard again.
374
+ await serviceRef.current.resumeMic();
375
+ }
367
376
  return;
368
377
  }
369
378
  setState('connecting');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qafka/react-native",
3
- "version": "2.3.6",
3
+ "version": "2.3.7",
4
4
  "description": "Drop-in AI assistant for React Native: chat, voice, and tool execution with screen-aware navigation.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",