Pulastya B commited on
Commit
91794cf
·
1 Parent(s): de17ff9

Clear uploaded file state when creating new chat or switching sessions

Browse files
FRRONTEEEND/components/ChatInterface.tsx CHANGED
@@ -63,6 +63,14 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
63
  }
64
  }, [activeSession.messages, isTyping]);
65
 
 
 
 
 
 
 
 
 
66
  // Connect to SSE when we receive a valid backend UUID
67
  useEffect(() => {
68
  // Only connect if we have a backend UUID (contains hyphens)
@@ -515,6 +523,12 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
515
  };
516
  setSessions([newSession, ...sessions]);
517
  setActiveSessionId(newId);
 
 
 
 
 
 
518
  };
519
 
520
  const deleteSession = (e: React.MouseEvent, id: string) => {
 
63
  }
64
  }, [activeSession.messages, isTyping]);
65
 
66
+ // Clear uploaded file when switching sessions
67
+ useEffect(() => {
68
+ setUploadedFile(null);
69
+ if (fileInputRef.current) {
70
+ fileInputRef.current.value = '';
71
+ }
72
+ }, [activeSessionId]);
73
+
74
  // Connect to SSE when we receive a valid backend UUID
75
  useEffect(() => {
76
  // Only connect if we have a backend UUID (contains hyphens)
 
523
  };
524
  setSessions([newSession, ...sessions]);
525
  setActiveSessionId(newId);
526
+
527
+ // Clear file upload state for new chat
528
+ setUploadedFile(null);
529
+ if (fileInputRef.current) {
530
+ fileInputRef.current.value = '';
531
+ }
532
  };
533
 
534
  const deleteSession = (e: React.MouseEvent, id: string) => {