({
agentId,
streams,
systemPrompt,
})
| 879 | } |
| 880 | |
| 881 | const SensorPreviewPanel: React.FC<SensorPreviewPanelProps> = ({ |
| 882 | agentId, |
| 883 | streams, |
| 884 | systemPrompt, |
| 885 | }) => { |
| 886 | const audioStreamsToDisplay = useMemo(() => getActiveAudioStreamsForDisplay(streams), [streams]); |
| 887 | |
| 888 | // Loading states for start buttons |
| 889 | const [isStartingScreen, setIsStartingScreen] = useState(false); |
| 890 | const [isStartingCamera, setIsStartingCamera] = useState(false); |
| 891 | const [isStartingMicrophone, setIsStartingMicrophone] = useState(false); |
| 892 | const [isStartingScreenAudio, setIsStartingScreenAudio] = useState(false); |
| 893 | const [isStartingAllAudio, setIsStartingAllAudio] = useState(false); |
| 894 | |
| 895 | // Detect which sensors this agent actually uses |
| 896 | const hasScreenSensor = useMemo(() => agentHasScreenSensor(systemPrompt), [systemPrompt]); |
| 897 | const hasCameraSensor = useMemo(() => agentHasCameraSensor(systemPrompt), [systemPrompt]); |
| 898 | const hasMemorySensor = useMemo(() => agentHasSensor(systemPrompt, 'MEMORY'), [systemPrompt]); |
| 899 | const hasImageMemorySensor = useMemo(() => agentHasSensor(systemPrompt, 'IMEMORY') || agentHasSensor(systemPrompt, 'IMEMORY_OCR'), [systemPrompt]); |
| 900 | const hasClipboardSensor = useMemo(() => agentHasSensor(systemPrompt, 'CLIPBOARD'), [systemPrompt]); |
| 901 | const hasMicrophoneSensor = useMemo(() => agentHasSensor(systemPrompt, 'MICROPHONE'), [systemPrompt]); |
| 902 | const hasScreenAudioSensor = useMemo(() => agentHasSensor(systemPrompt, 'SCREEN_AUDIO'), [systemPrompt]); |
| 903 | const hasAllAudioSensor = useMemo(() => agentHasSensor(systemPrompt, 'ALL_AUDIO'), [systemPrompt]); |
| 904 | |
| 905 | // Check if we have any sensors configured (not necessarily active) |
| 906 | const hasAnySensorsConfigured = hasScreenSensor || hasCameraSensor || hasMemorySensor || hasImageMemorySensor || hasClipboardSensor || hasMicrophoneSensor || hasScreenAudioSensor || hasAllAudioSensor; |
| 907 | |
| 908 | // Start handler functions |
| 909 | const handleStartScreen = async () => { |
| 910 | setIsStartingScreen(true); |
| 911 | try { |
| 912 | await StreamManager.requestStreamsForAgent(agentId, ['screenVideo']); |
| 913 | } catch (error) { |
| 914 | console.error('Failed to start screen share:', error); |
| 915 | } finally { |
| 916 | setIsStartingScreen(false); |
| 917 | } |
| 918 | }; |
| 919 | |
| 920 | const handleStartCamera = async () => { |
| 921 | setIsStartingCamera(true); |
| 922 | try { |
| 923 | await StreamManager.requestStreamsForAgent(agentId, ['camera']); |
| 924 | } catch (error) { |
| 925 | console.error('Failed to start camera:', error); |
| 926 | } finally { |
| 927 | setIsStartingCamera(false); |
| 928 | } |
| 929 | }; |
| 930 | |
| 931 | const handleStartMicrophone = async () => { |
| 932 | setIsStartingMicrophone(true); |
| 933 | try { |
| 934 | await StreamManager.requestStreamsForAgent(agentId, ['microphone']); |
| 935 | } catch (error) { |
| 936 | console.error('Failed to start microphone:', error); |
| 937 | } finally { |
| 938 | setIsStartingMicrophone(false); |
nothing calls this directly
no test coverage detected