@@ -102,6 +102,8 @@ import { usePlanFollowUpSend } from "./useProposedPlanSend";
102102import { useMultipleModelSend } from "./useMultipleModelSend" ;
103103import { type ComposerDispatchMode } from "@t3tools/client-runtime/state/composer-dispatch" ;
104104import {
105+ awaitAttachmentUploads ,
106+ getUploadedAttachments ,
105107 readAttachmentUpload ,
106108 releaseDraftAttachments ,
107109 retryAttachmentUpload ,
@@ -1031,6 +1033,22 @@ export function useComposerSend(input: ComposerSendInput) {
10311033 ) ;
10321034 return ;
10331035 }
1036+ // Declining is irreversible, so a redirect waits for its uploads instead of failing after.
1037+ if (
1038+ turnUsesAttachmentUploads &&
1039+ composerAttachmentsSnapshot . length > 0 &&
1040+ ( sendCtx ?. shownPendingApprovalIds . length ?? 0 ) > 0
1041+ ) {
1042+ await awaitAttachmentUploads ( composerAttachmentsSnapshot . map ( ( attachment ) => attachment . id ) ) ;
1043+ if ( getUploadedAttachments ( { environmentId, images : composerAttachmentsSnapshot } ) === null ) {
1044+ sendInFlightRef . current = false ;
1045+ setThreadError ( threadIdForSend , "Retry or remove failed uploads before sending." ) ;
1046+ setDockedDraftHeroThreadKey ( ( currentThreadKey ) =>
1047+ currentThreadKey === activeThreadKey ? null : currentThreadKey ,
1048+ ) ;
1049+ return ;
1050+ }
1051+ }
10341052 // A message sent while approvals are pending redirects the agent. They are declined only
10351053 // here, after everything above has accepted the send, so local commands and rejected
10361054 // drafts leave them alone. After navigating away during an upload, the shown approvals
0 commit comments