mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-07 07:55:16 +02:00
fix: fix ui of webrtc call
This commit is contained in:
parent
895af47482
commit
efd93adfa8
2 changed files with 35 additions and 5 deletions
|
|
@ -1,4 +1,4 @@
|
|||
pipecat-ai[cartesia,deepgram,openai,elevenlabs,groq,google,azure,soundfile,silero,webrtc] @ git+https://github.com/dograh-hq/pipecat.git@d03d892
|
||||
pipecat-ai[cartesia,deepgram,openai,elevenlabs,groq,google,azure,soundfile,silero,webrtc] @ git+https://github.com/dograh-hq/pipecat.git@9b0eba6
|
||||
langfuse==3.4.0
|
||||
fastapi==0.116.2
|
||||
asyncpg==0.30.0
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { useCallback,useEffect, useRef, useState } from "react";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
|
||||
import { client } from "@/client/client.gen";
|
||||
import { validateUserConfigurationsApiV1UserConfigurationsUserValidateGet, validateWorkflowApiV1WorkflowWorkflowIdValidatePost } from "@/client/sdk.gen";
|
||||
|
|
@ -100,8 +100,37 @@ export const useWebSocketRTC = ({ workflowId, workflowRunId, accessToken, initia
|
|||
logger.info(`ICE connection state changed: ${pc.iceConnectionState}`);
|
||||
if (pc.iceConnectionState === 'connected' || pc.iceConnectionState === 'completed') {
|
||||
setConnectionStatus('connected');
|
||||
} else if (pc.iceConnectionState === 'failed' || pc.iceConnectionState === 'disconnected') {
|
||||
} else if (pc.iceConnectionState === 'failed') {
|
||||
setConnectionStatus('failed');
|
||||
} else if (pc.iceConnectionState === 'disconnected') {
|
||||
// Server-initiated disconnect - clean up gracefully
|
||||
logger.info('Server initiated disconnect - cleaning up connection');
|
||||
|
||||
// Close WebSocket if still open
|
||||
if (wsRef.current) {
|
||||
wsRef.current.close();
|
||||
wsRef.current = null;
|
||||
}
|
||||
|
||||
// Mark as completed to trigger recording check
|
||||
setConnectionActive(false);
|
||||
setIsCompleted(true);
|
||||
setConnectionStatus('idle');
|
||||
|
||||
// Clean up peer connection
|
||||
if (pc.getTransceivers) {
|
||||
pc.getTransceivers().forEach((transceiver) => {
|
||||
if (transceiver.stop) {
|
||||
transceiver.stop();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
pc.getSenders().forEach((sender) => {
|
||||
if (sender.track) {
|
||||
sender.track.stop();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -136,7 +165,8 @@ export const useWebSocketRTC = ({ workflowId, workflowRunId, accessToken, initia
|
|||
ws.onclose = () => {
|
||||
logger.info('WebSocket closed');
|
||||
wsRef.current = null;
|
||||
if (connectionActive) {
|
||||
// Don't set failed status if already completed (graceful disconnect)
|
||||
if (connectionActive && !isCompleted) {
|
||||
setConnectionStatus('failed');
|
||||
}
|
||||
};
|
||||
|
|
@ -193,7 +223,7 @@ export const useWebSocketRTC = ({ workflowId, workflowRunId, accessToken, initia
|
|||
}
|
||||
};
|
||||
});
|
||||
}, [getWebSocketUrl, connectionActive]);
|
||||
}, [getWebSocketUrl, connectionActive, isCompleted]);
|
||||
|
||||
const negotiate = async () => {
|
||||
const pc = pcRef.current;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue