Krish-05 commited on
Commit
33e3679
·
verified ·
1 Parent(s): 68dfde0

added log to find bob

Browse files
frontend/src/components/chat/ChatInputArea.jsx CHANGED
@@ -1,6 +1,5 @@
1
- // src/components/chat/ChatInputArea.jsx
2
  import React, { useState, useEffect, useCallback } from 'react';
3
- import { VoiceVisualizer, useVoiceVisualizer } from 'react-voice-visualizer';
4
 
5
  const ChatInputArea = ({ onSendMessage, onSendVoiceMessage, isLoading }) => {
6
  const [message, setMessage] = useState('');
@@ -21,12 +20,19 @@ const ChatInputArea = ({ onSendMessage, onSendVoiceMessage, isLoading }) => {
21
  // error,
22
  } = voiceVisualizerHook;
23
 
 
 
 
 
24
  // This useEffect will run whenever recordingBlob changes.
25
  useEffect(() => {
26
- debugger; // <--- KEEP THIS HERE FOR YOUR TESTING, REMOVE ONCE IT WORKS
 
27
  if (recordingBlob) {
28
- console.log('Recorded blob is: ', recordingBlob);
29
  onSendVoiceMessage(recordingBlob);
 
 
30
  }
31
  }, [recordingBlob, onSendVoiceMessage]); // onSendVoiceMessage is stable due to useCallback in App.jsx
32
 
@@ -43,17 +49,19 @@ const ChatInputArea = ({ onSendMessage, onSendVoiceMessage, isLoading }) => {
43
  }, [message, onSendMessage]);
44
 
45
  const handleStartRecording = useCallback(() => {
 
46
  if (isLoading) return; // Prevent recording if an action is already in progress
47
- console.log("Attempting to start recording...");
48
  startRecording();
49
- console.log("Recording started status:", isRecording); // This might be true/false depending on async nature
50
- }, [isLoading, startRecording, isRecording]);
 
51
 
52
  const handleStopRecording = useCallback(() => {
53
- console.log("Attempting to stop recording...");
54
  stopRecording();
55
- console.log("Recording stopped status:", isRecording); // This might be true/false depending on async nature
56
- }, [stopRecording, isRecording]);
 
57
 
58
  return (
59
  <div className="chat-input-area">
@@ -97,7 +105,7 @@ const ChatInputArea = ({ onSendMessage, onSendVoiceMessage, isLoading }) => {
97
  className="sound-wave"
98
  mainBarColor="#4CAF50"
99
  secondaryBarColor="#81C784"
100
- hook={voiceVisualizerHook}
101
  // Optional: width="100%" height="50px"
102
  />
103
  )}
 
 
1
  import React, { useState, useEffect, useCallback } from 'react';
2
+ import { VoiceVisualizer, useVoiceVisualizer } from 'react-voice-visualizer'; // Assuming these imports are correct
3
 
4
  const ChatInputArea = ({ onSendMessage, onSendVoiceMessage, isLoading }) => {
5
  const [message, setMessage] = useState('');
 
20
  // error,
21
  } = voiceVisualizerHook;
22
 
23
+ // Logging for render phase (these will fire on every re-render)
24
+ console.log('ChatInputArea render - isRecording:', isRecording);
25
+ console.log('ChatInputArea render - recordingBlob (current state):', recordingBlob);
26
+
27
  // This useEffect will run whenever recordingBlob changes.
28
  useEffect(() => {
29
+ // debugger; // Keep this for your testing, remove once it works
30
+ console.log('ChatInputArea useEffect triggered. recordingBlob:', recordingBlob); // Log inside the effect
31
  if (recordingBlob) {
32
+ console.log('ChatInputArea: recordingBlob IS present!', recordingBlob);
33
  onSendVoiceMessage(recordingBlob);
34
+ } else {
35
+ console.log('ChatInputArea: recordingBlob is NULL or UNDEFINED.');
36
  }
37
  }, [recordingBlob, onSendVoiceMessage]); // onSendVoiceMessage is stable due to useCallback in App.jsx
38
 
 
49
  }, [message, onSendMessage]);
50
 
51
  const handleStartRecording = useCallback(() => {
52
+ console.log("ChatInputArea: handleStartRecording called.");
53
  if (isLoading) return; // Prevent recording if an action is already in progress
 
54
  startRecording();
55
+ // Note: isRecording here might not be immediately true due to async nature of startRecording
56
+ console.log("ChatInputArea: Recording start function called. Current isRecording state:", isRecording);
57
+ }, [isLoading, startRecording, isRecording]); // isRecording added to dependency array for accurate logging
58
 
59
  const handleStopRecording = useCallback(() => {
60
+ console.log("ChatInputArea: handleStopRecording called.");
61
  stopRecording();
62
+ // Note: isRecording here might not be immediately false due to async nature of stopRecording
63
+ console.log("ChatInputArea: Recording stop function called. Current isRecording state:", isRecording);
64
+ }, [stopRecording, isRecording]); // isRecording added to dependency array for accurate logging
65
 
66
  return (
67
  <div className="chat-input-area">
 
105
  className="sound-wave"
106
  mainBarColor="#4CAF50"
107
  secondaryBarColor="#81C784"
108
+ hook={voiceVisualizerHook} // This needs to be 'controls' if the prop name is 'controls' in VoiceVisualizer
109
  // Optional: width="100%" height="50px"
110
  />
111
  )}