feat(voice-call): Improve socket connection and mic permission handling
This commit is contained in:
@@ -576,6 +576,16 @@ class AppIntentCoordinator extends _$AppIntentCoordinator {
|
||||
throw StateError('Choose a model before starting a voice call.');
|
||||
}
|
||||
|
||||
// Pre-warm socket connection before navigating to voice call.
|
||||
// This reduces the chance of "websocket not connected" errors when
|
||||
// opening voice call right after app start or from deep links.
|
||||
final socketService = ref.read(socketServiceProvider);
|
||||
if (socketService != null && !socketService.isConnected) {
|
||||
// Start connection attempt in parallel, don't wait for full connection
|
||||
// The VoiceCallService.startCall() will wait with extended timeout
|
||||
unawaited(socketService.connect());
|
||||
}
|
||||
|
||||
await NavigationService.navigateToChat();
|
||||
|
||||
// Wait a tick for navigation to settle so navigator/context are present.
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -139,6 +140,16 @@ class AndroidAssistantHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
// Pre-warm socket connection before navigating to voice call.
|
||||
// This reduces the chance of "websocket not connected" errors when
|
||||
// opening voice call right after app start or from Android assistant.
|
||||
final socketService = _ref.read(socketServiceProvider);
|
||||
if (socketService != null && !socketService.isConnected) {
|
||||
// Start connection attempt in parallel, don't wait for full connection
|
||||
// The VoiceCallService.startCall() will wait with extended timeout
|
||||
unawaited(socketService.connect());
|
||||
}
|
||||
|
||||
// Navigate to chat if not already there
|
||||
final isOnChatRoute = NavigationService.currentRoute == Routes.chat;
|
||||
if (!isOnChatRoute) {
|
||||
|
||||
Reference in New Issue
Block a user