From f7a00a6e8503acadbc6e8faab7b88125073ae2df Mon Sep 17 00:00:00 2001 From: rahul-aot Date: Tue, 6 Jan 2026 21:11:28 -0800 Subject: [PATCH] feat: Implement core frontend UI with document ingestion and chat functionality. --- frontend/src/App.tsx | 12 ++++++++++-- frontend/src/components/Chat.tsx | 2 ++ frontend/src/components/Ingester.tsx | 7 +++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 18df27a..63a9f5b 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -3,6 +3,7 @@ import './App.css'; import { Ingester } from './components/Ingester'; import { Chat } from './components/Chat'; import { clearSession } from './api'; +import { Toaster, toast } from 'react-hot-toast'; function App() { @@ -11,12 +12,19 @@ function App() { }, []); const handleManualClear = async () => { - await clearSession(); - window.location.reload(); + try { + await clearSession(); + toast.success('Session cleared successfully'); + setTimeout(() => window.location.reload(), 1000); + } catch (error) { + console.error(error); + toast.error('Failed to clear session'); + } } return (
+
🔍 SearchlyAI diff --git a/frontend/src/components/Chat.tsx b/frontend/src/components/Chat.tsx index 2c05395..cfcb915 100644 --- a/frontend/src/components/Chat.tsx +++ b/frontend/src/components/Chat.tsx @@ -1,4 +1,5 @@ import { useState, useRef, useEffect } from 'react'; +import { toast } from 'react-hot-toast'; import { querySearch } from '../api'; interface Message { @@ -36,6 +37,7 @@ export const Chat = () => { setHistory((prev) => [...prev, aiMsg]); } catch (err) { console.error(err); + toast.error('Failed to get answer'); setHistory((prev) => [...prev, { role: 'ai', content: 'Sorry, something went wrong.' }]); } finally { setLoading(false); diff --git a/frontend/src/components/Ingester.tsx b/frontend/src/components/Ingester.tsx index f1a4be8..252ec5f 100644 --- a/frontend/src/components/Ingester.tsx +++ b/frontend/src/components/Ingester.tsx @@ -1,4 +1,5 @@ import { useState } from 'react'; +import { toast } from 'react-hot-toast'; import { ingestDocument, ingestWeb } from '../api'; interface IngesterProps { @@ -14,12 +15,15 @@ export const Ingester = ({ onIngestComplete }: IngesterProps) => { if (!e.target.files?.[0]) return; setLoading(true); setError(''); + const toastId = toast.loading('Uploading document...'); try { const res = await ingestDocument(e.target.files[0]); onIngestComplete(res.data.chunks_added); + toast.success('Document uploaded successfully!', { id: toastId }); } catch (err) { console.error(err); setError('Failed to upload file.'); + toast.error('Failed to upload file.', { id: toastId }); } finally { setLoading(false); } @@ -29,13 +33,16 @@ export const Ingester = ({ onIngestComplete }: IngesterProps) => { if (!url) return; setLoading(true); setError(''); + const toastId = toast.loading('Ingesting URL...'); try { const res = await ingestWeb(url); onIngestComplete(res.data.chunks_added); setUrl(''); + toast.success('URL ingested successfully!', { id: toastId }); } catch (err) { console.error(err); setError('Failed to ingest URL.'); + toast.error('Failed to ingest URL.', { id: toastId }); } finally { setLoading(false); }