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.
This commit is contained in:
Classic298 2026-10-25 01:11:35 +02:00 • committed by GitHub
parent f32de07dde
commit 0a568f6a81
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 8 deletions

View file

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

View file

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