From 944deec4826f75617008174c3c6a781a6c56bf7e Mon Sep 17 00:00:00 2001 From: Xin Wang Date: Wed, 10 Dec 2025 16:48:27 +0800 Subject: [PATCH] add instruction window --- src/components/playground/PhoneSimulator.tsx | 12 +++- src/components/playground/Playground.tsx | 69 ++++++++++++++++++-- src/hooks/useConfig.tsx | 3 + src/hooks/useConnection.tsx | 21 +++--- 4 files changed, 87 insertions(+), 18 deletions(-) diff --git a/src/components/playground/PhoneSimulator.tsx b/src/components/playground/PhoneSimulator.tsx index e66bba8..3969f7c 100644 --- a/src/components/playground/PhoneSimulator.tsx +++ b/src/components/playground/PhoneSimulator.tsx @@ -20,9 +20,10 @@ export interface PhoneSimulatorProps { onDisconnect: () => void; phoneMode?: "normal" | "capture"; onCapture?: (image: File) => void; + capturePrompt?: string; } -export function PhoneSimulator({ onConnect, onDisconnect, phoneMode = "normal", onCapture }: PhoneSimulatorProps) { +export function PhoneSimulator({ onConnect, onDisconnect, phoneMode = "normal", onCapture, capturePrompt }: PhoneSimulatorProps) { const { config, setUserSettings } = useConfig(); const { setToastMessage } = useToast(); const room = useRoomContext(); @@ -517,6 +518,15 @@ export function PhoneSimulator({ onConnect, onDisconnect, phoneMode = "normal", {/* Center Focus Indicator */}
+ + {/* Prompt Display */} + {capturePrompt && ( +
+
+ {capturePrompt} +
+
+ )} )} diff --git a/src/components/playground/Playground.tsx b/src/components/playground/Playground.tsx index d230fb1..0cfa4b4 100644 --- a/src/components/playground/Playground.tsx +++ b/src/components/playground/Playground.tsx @@ -66,6 +66,7 @@ export default function Playground({ const tracks = useTracks(); const room = useRoomContext(); const [phoneMode, setPhoneMode] = useState<"normal" | "capture">("normal"); + const [capturePrompt, setCapturePrompt] = useState(""); const [rpcMethod, setRpcMethod] = useState(""); const [rpcPayload, setRpcPayload] = useState(""); @@ -106,7 +107,17 @@ export default function Playground({ localParticipant.registerRpcMethod( 'enterImageCaptureMode', - async () => { + async (data: RpcInvocationData) => { + if (data.payload) { + try { + const payload = JSON.parse(data.payload); + if (payload.prompt) { + setCapturePrompt(payload.prompt); + } + } catch (e) { + console.error("Failed to parse enterImageCaptureMode payload", e); + } + } setPhoneMode("capture"); return JSON.stringify({ success: true }); } @@ -116,6 +127,7 @@ export default function Playground({ 'exitImageCaptureMode', async () => { setPhoneMode("normal"); + setCapturePrompt(""); return JSON.stringify({ success: true }); } ); @@ -315,6 +327,24 @@ export default function Playground({ voiceAssistant.agent, ]); + const instructionsContent = ( + +