From 0a568f6a813d49ca6e7797c7940647782e44ad48 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Sun, 25 Oct 2026 01:11:35 +0200 Subject: [PATCH] fix: knowledge base files stay on "Uploading" instead of switching to "Processing" (#32982) * fix: knowledge base files stay on "Uploading" instead of switching to "Processing" A file added to a knowledge base is uploaded in a moment, and the long wait after that is the text extraction, which the file list still called "Uploading". Nothing updated on its own either, so the only way to find out whether a file had moved on or finished was to leave the knowledge base and come back. The file now switches to "Processing" as soon as it has reached the server, and the list keeps itself current until the file is ready, so slow text extraction no longer looks like a stuck upload. Adding a folder or a web page goes through a different flow and is not touched here. * refac: inline the processing status update for knowledge base uploads Moves the status update straight into the upload call with no change in behaviour. * refac: drop a stray blank line and comment from the upload handler Removes a blank line and a comment the previous follow-up added, with no change in behaviour. --- src/lib/apis/files/index.ts | 7 +++++- .../workspace/Knowledge/KnowledgeBase.svelte | 24 +++++++++++++------ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/lib/apis/files/index.ts b/src/lib/apis/files/index.ts index 633d048932..d2651e030f 100644 --- a/src/lib/apis/files/index.ts +++ b/src/lib/apis/files/index.ts @@ -6,7 +6,8 @@ export const uploadFile = async ( file: File, metadata?: object | null, process?: boolean | null, - stream: boolean = true + stream: boolean = true, + onUploaded?: (uploadedFile: { id: string }) => void ) => { const data = new FormData(); data.append('file', file); @@ -43,6 +44,10 @@ export const uploadFile = async ( throw error; } + if (res) { + onUploaded?.(res); + } + if (res && stream) { const status = await getFileProcessStatus(token, res.id); diff --git a/src/lib/components/workspace/Knowledge/KnowledgeBase.svelte b/src/lib/components/workspace/Knowledge/KnowledgeBase.svelte index 4c4d17421f..8cede075ed 100644 --- a/src/lib/components/workspace/Knowledge/KnowledgeBase.svelte +++ b/src/lib/components/workspace/Knowledge/KnowledgeBase.svelte @@ -285,19 +285,29 @@ : {}) }; - const uploadedFile = await uploadFile(localStorage.token, file, metadata).catch((e) => { + const uploadedFile = await uploadFile( + localStorage.token, + file, + metadata, + null, + true, + ({ id }: { id: string }) => { + fileItems = fileItems.map((item) => { + if (item.itemId === fileItem.itemId) { + item.id = id; + item.status = 'processing'; + } + return item; + }); + init(); + } + ).catch((e) => { toast.error(`${e}`); return null; }); if (uploadedFile) { console.log(uploadedFile); - fileItems = fileItems.map((item) => { - if (item.itemId === fileItem.itemId) { - item.id = uploadedFile.id; - } - return item; - }); if (uploadedFile.error) { console.warn('File upload warning:', uploadedFile.error);