Feature/v2/filehistory (#4370)

File History

---------

Co-authored-by: Connor Yoh <[email protected]>
This commit is contained in:
ConnorYoh
2025-09-16 15:08:11 +01:00
committed by GitHub
co-authored by Connor Yoh
parent 8e8b417f5e
commit 190178a471
61 changed files with 2279 additions and 1245 deletions
+10 -3
View File
@@ -8,11 +8,12 @@ export type ResponseHandler = (blob: Blob, originalFiles: File[]) => Promise<Fil
* - If a tool-specific responseHandler is provided, it is used.
* - If responseHeaders provided and contains Content-Disposition, uses that filename.
* - Otherwise, create a single file using the filePrefix + original name.
* - If filePrefix is empty, preserves the original filename.
*/
export async function processResponse(
blob: Blob,
originalFiles: File[],
filePrefix: string,
filePrefix?: string,
responseHandler?: ResponseHandler,
responseHeaders?: Record<string, any>
): Promise<File[]> {
@@ -36,7 +37,13 @@ export async function processResponse(
// Default behavior: use filePrefix + original name
const original = originalFiles[0]?.name ?? 'result.pdf';
const name = `${filePrefix}${original}`;
// Only add prefix if it's not empty - this preserves original filenames for file history
const name = filePrefix ? `${filePrefix}${original}` : original;
const type = blob.type || 'application/octet-stream';
return [new File([blob], name, { type })];
// File was modified by tool processing - set lastModified to current time
return [new File([blob], name, {
type,
lastModified: Date.now()
})];
}