fraudTech commited on
Commit
8617819
·
1 Parent(s): 68f9cbb

"New Chat" button clears the conversation history.

Browse files
Files changed (1) hide show
  1. web/src/App.tsx +22 -1
web/src/App.tsx CHANGED
@@ -613,13 +613,34 @@ function App() {
613
  setIsAuthenticated(true);
614
  };
615
 
616
- const handleNewChat = () => {
617
  // Cancel any ongoing request
618
  if (abortControllerRef.current) {
619
  abortControllerRef.current.abort();
620
  abortControllerRef.current = null;
621
  }
622
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
623
  setMessages([]);
624
  setInput('');
625
  setIsLoading(false);
 
613
  setIsAuthenticated(true);
614
  };
615
 
616
+ const handleNewChat = async () => {
617
  // Cancel any ongoing request
618
  if (abortControllerRef.current) {
619
  abortControllerRef.current.abort();
620
  abortControllerRef.current = null;
621
  }
622
 
623
+ // Clear backend conversation history
624
+ try {
625
+ const headers: HeadersInit = {
626
+ 'Content-Type': 'application/json'
627
+ };
628
+ if (sessionId) {
629
+ headers['Authorization'] = `Bearer ${sessionId}`;
630
+ }
631
+
632
+ await fetch(`${GATEWAY_URL}/api/chat/clear`, {
633
+ method: 'POST',
634
+ headers,
635
+ body: JSON.stringify({
636
+ user: user
637
+ })
638
+ });
639
+ } catch (error) {
640
+ console.error('Failed to clear chat history:', error);
641
+ }
642
+
643
+ // Clear frontend state
644
  setMessages([]);
645
  setInput('');
646
  setIsLoading(false);