MCPcopy Create free account
hub / github.com/Roy3838/Observer / SensorPreviewPanel

Function SensorPreviewPanel

app/src/components/AgentCard/SensorPreviewPanel.tsx:867–1071  ·  view source on GitHub ↗
({
  agentId,
  streams,
  systemPrompt,
})

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

agentHasScreenSensorFunction · 0.90
agentHasCameraSensorFunction · 0.90
agentHasSensorFunction · 0.90

Tested by

no test coverage detected