Skip to content

Commit 62fcc36

Browse files
committed
fix(web): failed attachment uploads no longer block sending
A failed upload disabled Send, leaving only the small retry icon on the thumbnail as a way out. Send now retries failed uploads and only reports an error if the retry fails too.
1 parent 79ad856 commit 62fcc36

3 files changed

Lines changed: 12 additions & 12 deletions

File tree

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,9 @@ import { useComposerHandleContext } from "../composerHandleContext";
504504
import {
505505
awaitAttachmentUploads,
506506
getUploadedAttachments,
507+
readAttachmentUpload,
507508
releaseDraftAttachments,
509+
retryAttachmentUpload,
508510
startAttachmentUpload,
509511
} from "../lib/attachmentUploadQueue";
510512
import { sanitizeThreadErrorMessage } from "~/rpc/transportError";
@@ -6521,7 +6523,11 @@ export default function ChatView(props: ChatViewProps) {
65216523
: supportsAttachmentUploads;
65226524
if (turnUsesAttachmentUploads && composerAttachmentsSnapshot.length > 0) {
65236525
for (const attachment of composerAttachmentsSnapshot) {
6524-
startAttachmentUpload({
6526+
const upload =
6527+
readAttachmentUpload(attachment.id)?.status === "failed"
6528+
? retryAttachmentUpload
6529+
: startAttachmentUpload;
6530+
upload({
65256531
environmentId,
65266532
image: attachment,
65276533
draftTarget: composerDraftTarget,

‎apps/web/src/lib/attachmentUploadState.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe("attachmentUploadBlockReason", () => {
3737
).toBe("Attachments still uploading");
3838
});
3939

40-
it("asks the user to retry or remove failed uploads", () => {
40+
it("leaves send enabled for failed uploads so sending can retry them", () => {
4141
expect(
4242
attachmentUploadBlockReason({
4343
imageIds: ["image-1"],
@@ -46,7 +46,7 @@ describe("attachmentUploadBlockReason", () => {
4646
"image-1": { status: "failed", environmentId, reason: "Upload failed" },
4747
},
4848
}),
49-
).toBe("Retry or remove the failed attachment");
49+
).toBeNull();
5050
});
5151

5252
it("does not accept an upload from another environment", () => {

‎apps/web/src/lib/attachmentUploadState.ts‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,16 @@ export function attachmentUploadBlockReason(input: {
3232
readonly environmentId: EnvironmentId;
3333
}): string | null {
3434
let pending = 0;
35-
let failed = 0;
3635

3736
for (const imageId of input.imageIds) {
3837
const upload = input.uploadsByImageId[imageId];
39-
if (upload?.status === "failed" && upload.environmentId === input.environmentId) {
40-
failed += 1;
41-
} else if (upload?.status !== "ready" || upload.environmentId !== input.environmentId) {
38+
// Send retries failed uploads, so they must not disable it.
39+
if (upload?.status === "failed" && upload.environmentId === input.environmentId) continue;
40+
if (upload?.status !== "ready" || upload.environmentId !== input.environmentId) {
4241
pending += 1;
4342
}
4443
}
4544

46-
if (failed > 0) {
47-
return failed === 1
48-
? "Retry or remove the failed attachment"
49-
: "Retry or remove the failed attachments";
50-
}
5145
if (pending > 0) {
5246
return pending === 1 ? "Attachment still uploading" : "Attachments still uploading";
5347
}

0 commit comments

Comments
 (0)