Add ScanResponse type for scan endpoint in webui

This commit is contained in:
yangdx 2025-07-30 03:11:09 +08:00
parent 7207598fc4
commit cbaede8455
3 changed files with 10 additions and 4 deletions

View file

@ -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(

View file

@ -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<DocsStatusesResponse> => {
return response.data
}
export const scanNewDocuments = async (): Promise<{ status: string }> => {
export const scanNewDocuments = async (): Promise<ScanResponse> => {
const response = await axiosInstance.post('/documents/scan')
return response.data
}

View file

@ -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) {