refactor(client): extract background file upload service

This commit is contained in:
creatixchu committed 2026-09-03 13:53:25 +08:00
1 parent a1956fa3e2
commit bbb2ca7c9b
61 files changed
+1225 -500

No files matched your search

@@ -92,14 +92,14 @@ export interface ISession {
/**
* Persist one browser file verbatim and stage it for a later prompt on this
* session. The returned opaque receipt is what a prompt file part cites.
* @param data - browser Blob or exact file bytes.
* @param data - browser Blob, exact file bytes, or a one-shot byte stream.
* @param name - optional display name; the host sanitizes the stored leaf name.
* @param signal - optional cancellation for the active upload.
* @param onProgress - optional byte-progress observer for background Blob uploads.
* @param onProgress - optional byte-progress observer for background Blob or stream uploads.
* @returns the staged-upload receipt and durable file reference, or the business error.
*/
uploadFile(
data: Blob | Uint8Array,
data: Blob | Uint8Array | ReadableStream<Uint8Array>,
name?: string,
signal?: AbortSignal,
onProgress?: (progress: { readonly loaded: number; readonly total?: number }) => void,
@@ -31,10 +31,22 @@ export interface PendingSubmissionImage {
readonly height?: number
}
/** Image branch of a local submission echo attachment. */
export interface PendingSubmissionImageAttachment {
readonly type: 'image'
readonly value: PendingSubmissionImage
}
/** File branch of a local submission echo attachment. */
export interface PendingSubmissionFileAttachment {
readonly type: 'file'
readonly value: FileAttachmentRef
}
/** One attachment displayed by a local submission echo, in prompt order. */
export type PendingSubmissionAttachment =
| ({ readonly type: 'image' } & PendingSubmissionImage)
| { readonly type: 'file'; readonly attachment: FileAttachmentRef }
| PendingSubmissionImageAttachment
| PendingSubmissionFileAttachment
/** Client surface selected when a local submission begins. */
export type PendingSubmissionPlacement = 'transcript' | 'queued' | 'steering'