@devries-cameron20 / t3code-1 / commits / ad9e87111f
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

feat(web): send messages while attachments upload (#33092)

maria committed Nov 9, 2026 at 20:52 UTC ad9e87111fd9b2f10ec320b4de0a6ad3a092278a
3 files changed +36 -21
apps/web/src/components/chat/ChatComposer.tsx
+9 -5
@@ -758,11 +758,15 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
758 ? needsReattachFileCount === 1
759 ? "Attach the interrupted file again or remove it"
760 : "Attach the interrupted files again or remove them"
761 - : attachmentUploadBlockReason({
762 - imageIds: [...composerImages, ...composerFiles].map((attachment) => attachment.id),
763 - uploadsByImageId,
764 - environmentId,
765 - })
761 + : // A plain send waits for its uploads. Answers and approval redirects need them first.
762 + questionAttachmentTarget ||
763 + pendingApprovals.some((approval) => !heldRequestIds.has(approval.requestId))
764 + ? attachmentUploadBlockReason({
765 + imageIds: [...composerImages, ...composerFiles].map((attachment) => attachment.id),
766 + uploadsByImageId,
767 + environmentId,
768 + })
769 + : null
770 : null);
771 const setComposerDraftPrompt = useComposerDraftStore((store) => store.setPrompt);
772 const addComposerDraftImages = useComposerDraftStore((store) => store.addImages);
apps/web/src/components/chat/chatViewSend.ts
+4 -3
@@ -16,7 +16,7 @@ import {
16 type AtomCommandResult,
17 } from "@t3tools/client-runtime/state/runtime";
18 import { readLocalApi } from "../../localApi";
19 -import { getUploadedAttachments } from "../../lib/attachmentUploadQueue";
19 +import { awaitAttachmentUploads, getUploadedAttachments } from "../../lib/attachmentUploadQueue";
20 import { findRevertCheckpoint } from "../../session-logic";
21 import { type ChatMessage } from "../../types";
22 import { randomUUID } from "~/lib/utils";
@@ -321,7 +321,7 @@ export function resolveMultipleModelTargets(input: {
321
322 /**
323 * The attachments a turn sends: the server's upload records when it takes uploads, otherwise
324 - * images inlined as data URLs. Rejects when an attachment cannot go out.
324 + * images inlined as data URLs. Waits for in-flight uploads; rejects when one cannot go out.
325 */
326 export function prepareTurnAttachments(input: {
327 readonly environmentId: EnvironmentId;
@@ -332,9 +332,10 @@ export function prepareTurnAttachments(input: {
332 return Promise.all(
333 input.attachments.map(async (attachment) => {
334 if (usesAttachmentUploads) {
335 + await awaitAttachmentUploads([attachment.id]);
336 const uploaded = getUploadedAttachments({ environmentId, images: [attachment] })?.[0];
337 if (!uploaded) {
337 - throw new Error(`Attachment '${attachment.name}' did not finish uploading.`);
338 + throw new Error(`Attachment '${attachment.name}' failed to upload.`);
339 }
340 return uploaded;
341 }
apps/web/src/components/chat/useComposerSend.ts
+23 -13
@@ -835,7 +835,8 @@ export function useComposerSend(input: ComposerSendInput) {
835 composerFilesSnapshot.length > 0
836 ? attachmentCapabilitiesBeforeUpload.supportsAttachmentUploads
837 : (readEnvironmentPresentation(environmentId)?.serverConfig ?? null) !== null;
838 - if (turnUsesAttachmentUploads && composerAttachmentsSnapshot.length > 0) {
838 + // Uploads finish after the message shows as sending; the turn starts once they land.
839 + if (turnUsesAttachmentUploads) {
840 for (const attachment of composerAttachmentsSnapshot) {
841 const upload =
842 readAttachmentUpload(attachment.id)?.status === "failed"
@@ -847,18 +848,6 @@ export function useComposerSend(input: ComposerSendInput) {
848 draftTarget: composerDraftTarget,
849 });
850 }
850 - await awaitAttachmentUploads(composerAttachmentsSnapshot.map((attachment) => attachment.id));
851 - const attachmentCapabilitiesAfterUpload = readLiveAttachmentCapabilities();
852 - if (attachmentCapabilitiesAfterUpload.fileBlockReason !== null) {
853 - sendInFlightRef.current = false;
854 - setThreadError(threadIdForSend, attachmentCapabilitiesAfterUpload.fileBlockReason);
855 - return;
856 - }
857 - if (getUploadedAttachments({ environmentId, images: composerAttachmentsSnapshot }) === null) {
858 - sendInFlightRef.current = false;
859 - setThreadError(threadIdForSend, "Retry or remove failed uploads before sending.");
860 - return;
861 - }
851 }
852
853 if (
@@ -903,6 +892,27 @@ export function useComposerSend(input: ComposerSendInput) {
892 );
893 return;
894 }
895 + // Declining is irreversible, so a redirect waits for its uploads instead of failing after.
896 + if (
897 + turnUsesAttachmentUploads &&
898 + composerAttachmentsSnapshot.length > 0 &&
899 + (sendCtx?.shownPendingApprovalIds.length ?? 0) > 0
900 + ) {
901 + await awaitAttachmentUploads(composerAttachmentsSnapshot.map((attachment) => attachment.id));
902 + const uploadBlockReason =
903 + readLiveAttachmentCapabilities().fileBlockReason ??
904 + (getUploadedAttachments({ environmentId, images: composerAttachmentsSnapshot }) === null
905 + ? "Retry or remove failed uploads before sending."
906 + : null);
907 + if (uploadBlockReason !== null) {
908 + sendInFlightRef.current = false;
909 + setThreadError(threadIdForSend, uploadBlockReason);
910 + setDockedDraftHeroThreadKey((currentThreadKey) =>
911 + currentThreadKey === activeThreadKey ? null : currentThreadKey,
912 + );
913 + return;
914 + }
915 + }
916 // A message sent while approvals are pending redirects the agent. They are declined only
917 // here, after everything above has accepted the send, so local commands and rejected
918 // drafts leave them alone. After navigating away during an upload, the shown approvals