@@ -280,6 +280,7 @@ export const useAgentTimeoutIdStore = (): {
280280 agentTimeoutFailureReason : string | null ;
281281 startAgentTimeout : ( agentConnectTimeoutMilliseconds ?: number ) => void ;
282282 clearAgentTimeout : ( ) => void ;
283+ clearAgentTimeoutFailureReason : ( ) => void ;
283284 updateAgentTimeoutState : ( agentState : AgentState ) => void ;
284285 updateAgentTimeoutParticipantExists : ( agentParticipantExists : boolean ) => void ;
285286} => {
@@ -333,6 +334,9 @@ export const useAgentTimeoutIdStore = (): {
333334 agentStateRef . current = 'connecting' ;
334335 agentParticipantExistsRef . current = false ;
335336 } , [ agentTimeoutId ] ) ,
337+ clearAgentTimeoutFailureReason : React . useCallback ( ( ) => {
338+ setAgentTimeoutFailureReason ( null ) ;
339+ } , [ ] ) ,
336340
337341 updateAgentTimeoutState : React . useCallback ( ( agentState : AgentState ) => {
338342 agentStateRef . current = agentState ;
@@ -479,6 +483,7 @@ export function useAgent(session?: SessionStub): UseAgentReturn {
479483 agentTimeoutFailureReason,
480484 startAgentTimeout,
481485 clearAgentTimeout,
486+ clearAgentTimeoutFailureReason,
482487 updateAgentTimeoutState,
483488 updateAgentTimeoutParticipantExists,
484489 } ,
@@ -572,6 +577,15 @@ export function useAgent(session?: SessionStub): UseAgentReturn {
572577 } ;
573578 } , [ room ] ) ;
574579
580+ // When the agent participant connects, reset the timeout failure state
581+ React . useEffect ( ( ) => {
582+ if ( ! agentParticipant ) {
583+ return ;
584+ }
585+
586+ clearAgentTimeoutFailureReason ( ) ;
587+ } , [ agentParticipant ] ) ;
588+
575589 // If the agent participant disconnects in the middle of a conversation unexpectedly, mark that as an explicit failure
576590 const [ agentDisconnectedFailureReason , setAgentDisconnectedFailureReason ] = React . useState <
577591 string | null
0 commit comments