@@ -313,11 +313,19 @@ const useLayercodeAgent = (
313313
314314 // Class methods
315315 const mute = useCallback ( ( ) => {
316- clientRef . current ?. mute ( ) ;
316+ if ( ! clientRef . current ) {
317+ console . warn ( '[Layercode] mute() called but no client exists. Did you call connect() first?' ) ;
318+ return ;
319+ }
320+ clientRef . current . mute ( ) ;
317321 } , [ ] ) ;
318322
319323 const unmute = useCallback ( ( ) => {
320- clientRef . current ?. unmute ( ) ;
324+ if ( ! clientRef . current ) {
325+ console . warn ( '[Layercode] unmute() called but no client exists. Did you call connect() first?' ) ;
326+ return ;
327+ }
328+ clientRef . current . unmute ( ) ;
321329 } , [ ] ) ;
322330
323331 const setAudioInput = useCallback (
@@ -407,6 +415,7 @@ const useLayercodeAgent = (
407415 } , [ createClient , internalConversationId , onError , refreshInputDevices ] ) ;
408416 const disconnect = useCallback ( async ( ) => {
409417 if ( ! clientRef . current ) {
418+ console . warn ( '[Layercode] disconnect() called but no client exists' ) ;
410419 return ;
411420 }
412421
@@ -417,10 +426,9 @@ const useLayercodeAgent = (
417426 await client . disconnect ( ) ;
418427 } catch ( error ) {
419428 console . error ( 'Failed to disconnect from agent:' , error ) ;
420- onError ?.( error as Error ) ;
421429 throw error ;
422430 }
423- } , [ onError ] ) ;
431+ } , [ ] ) ;
424432
425433 // Return methods and state
426434 return {
0 commit comments