@@ -12,7 +12,7 @@ export interface ComposerAttachmentUploadRequest {
1212export type ComposerAttachmentUploadState =
1313 | { readonly status : "uploading" ; readonly progress : number }
1414 | { readonly status : "ready" }
15- | { readonly status : "failed" ; readonly reason : string } ;
15+ | { readonly status : "failed" ; readonly reason : string ; readonly queueOnSend ?: boolean } ;
1616
1717export function composerAttachmentUploadKey (
1818 environmentId : EnvironmentId ,
@@ -80,7 +80,8 @@ export function composerAttachmentUploadBlockReason(input: {
8080 for ( const attachment of input . attachments ) {
8181 if ( ! canUploadComposerAttachment ( attachment , input . serverConfig ) ) continue ;
8282 const state = input . states [ composerAttachmentUploadKey ( input . environmentId , attachment . id ) ] ;
83- if ( state ?. status === "failed" ) return "Retry or remove the failed attachment" ;
83+ if ( state ?. status === "failed" && ! state . queueOnSend )
84+ return "Retry or remove the failed attachment" ;
8485 }
8586 return null ;
8687}
@@ -94,7 +95,7 @@ export function composerAttachmentsStillUploading(input: {
9495 return input . attachments . some ( ( attachment ) => {
9596 if ( ! canUploadComposerAttachment ( attachment , input . serverConfig ) ) return false ;
9697 const state = input . states [ composerAttachmentUploadKey ( input . environmentId , attachment . id ) ] ;
97- return state ?. status !== "ready" && state ?. status !== "failed " ;
98+ return state ?. status === "failed" ? state . queueOnSend === true : state ?. status !== "ready " ;
9899 } ) ;
99100}
100101
@@ -104,6 +105,7 @@ export function createComposerAttachmentUploadQueue(options: {
104105 signal : AbortSignal ,
105106 onProgress : ( progress : number ) => void ,
106107 ) => Promise < boolean > ;
108+ readonly canQueueOnSend ?: ( error : unknown ) => boolean ;
107109 readonly onChange : ( states : Readonly < Record < string , ComposerAttachmentUploadState > > ) => void ;
108110} ) {
109111 const jobs = new Map <
@@ -160,6 +162,7 @@ export function createComposerAttachmentUploadQueue(options: {
160162 setState ( key , {
161163 status : "failed" ,
162164 reason : error instanceof Error ? error . message : "Upload failed. Tap to retry." ,
165+ ...( options . canQueueOnSend ?.( error ) ? { queueOnSend : true } : { } ) ,
163166 } ) ;
164167 }
165168 } )
0 commit comments