From 313387778a7f10789388e4c9b9e2598918c5d4a1 Mon Sep 17 00:00:00 2001 From: Xin Wang Date: Mon, 13 Jul 2026 08:01:39 +0800 Subject: [PATCH] Enhance MobileCallPage with video functionality and improved view management - Update CallView type from "camera" to "video" for clarity. - Introduce MobileVideoSurface component to handle video stream rendering. - Implement MobileCallVisualWorkspace for managing chat and video views with drag-and-drop functionality for the video panel. - Refactor state management to streamline view transitions between chat and video modes. - Enhance network metrics handling in useVoicePreview for better performance monitoring during calls. --- .../src/components/pages/MobileCallPage.tsx | 237 ++++++++++++----- frontend/src/hooks/use-voice-preview.ts | 240 +++++++++++++++--- 2 files changed, 381 insertions(+), 96 deletions(-) diff --git a/frontend/src/components/pages/MobileCallPage.tsx b/frontend/src/components/pages/MobileCallPage.tsx index a81ef20..3cf3b6a 100644 --- a/frontend/src/components/pages/MobileCallPage.tsx +++ b/frontend/src/components/pages/MobileCallPage.tsx @@ -35,7 +35,7 @@ import { type ChatMessage, } from "@/hooks/use-voice-preview"; -type CallView = "camera" | "chat"; +type CallView = "video" | "chat"; function messageTime(timestamp: string): string { const date = new Date(timestamp); @@ -106,6 +106,171 @@ function MobileCallTranscript({ messages }: { messages: ChatMessage[] }) { ); } +function MobileVideoSurface({ + stream, + compact = false, +}: { + stream: MediaStream | null; + compact?: boolean; +}) { + const videoRef = useRef(null); + + useEffect(() => { + if (videoRef.current) videoRef.current.srcObject = stream; + }, [stream]); + + return ( +