From cbaede845508a309d6d43ad1217ecb2d3a762298 Mon Sep 17 00:00:00 2001 From: yangdx Date: Wed, 30 Jul 2025 03:11:09 +0800 Subject: [PATCH] Add ScanResponse type for scan endpoint in webui --- lightrag/lightrag.py | 1 - lightrag_webui/src/api/lightrag.ts | 8 +++++++- lightrag_webui/src/features/DocumentManager.tsx | 5 +++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lightrag/lightrag.py b/lightrag/lightrag.py index aa2db374..0efafc14 100644 --- a/lightrag/lightrag.py +++ b/lightrag/lightrag.py @@ -940,7 +940,6 @@ class LightRAG: # Store document status (without content) await self.doc_status.upsert(new_docs) - logger.info(f"New documents: {new_docs}") logger.info(f"Stored {len(new_docs)} new unique documents") async def apipeline_process_enqueue_documents( diff --git a/lightrag_webui/src/api/lightrag.ts b/lightrag_webui/src/api/lightrag.ts index a0fdc86e..f7ba0de0 100644 --- a/lightrag_webui/src/api/lightrag.ts +++ b/lightrag_webui/src/api/lightrag.ts @@ -146,6 +146,12 @@ export type DocActionResponse = { track_id?: string } +export type ScanResponse = { + status: 'scanning_started' + message: string + track_id: string +} + export type DeleteDocResponse = { status: 'deletion_started' | 'busy' | 'not_allowed' message: string @@ -302,7 +308,7 @@ export const getDocuments = async (): Promise => { return response.data } -export const scanNewDocuments = async (): Promise<{ status: string }> => { +export const scanNewDocuments = async (): Promise => { const response = await axiosInstance.post('/documents/scan') return response.data } diff --git a/lightrag_webui/src/features/DocumentManager.tsx b/lightrag_webui/src/features/DocumentManager.tsx index 61b4b5a4..3d182280 100644 --- a/lightrag_webui/src/features/DocumentManager.tsx +++ b/lightrag_webui/src/features/DocumentManager.tsx @@ -420,12 +420,13 @@ export default function DocumentManager() { // Check if component is still mounted before starting the request if (!isMountedRef.current) return; - const { status } = await scanNewDocuments(); + const { status, message, track_id: _track_id } = await scanNewDocuments(); // eslint-disable-line @typescript-eslint/no-unused-vars // Check again if component is still mounted after the request completes if (!isMountedRef.current) return; - toast.message(status); + // Note: _track_id is available for future use (e.g., progress tracking) + toast.message(message || status); } catch (err) { // Only show error if component is still mounted if (isMountedRef.current) {