Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion apps/web/src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,9 @@ import { useComposerHandleContext } from "../composerHandleContext";
import {
awaitAttachmentUploads,
getUploadedAttachments,
readAttachmentUpload,
releaseDraftAttachments,
retryAttachmentUpload,
startAttachmentUpload,
} from "../lib/attachmentUploadQueue";
import { sanitizeThreadErrorMessage } from "~/rpc/transportError";
Expand Down Expand Up @@ -6521,7 +6523,11 @@ export default function ChatView(props: ChatViewProps) {
: supportsAttachmentUploads;
if (turnUsesAttachmentUploads && composerAttachmentsSnapshot.length > 0) {
for (const attachment of composerAttachmentsSnapshot) {
startAttachmentUpload({
const upload =
readAttachmentUpload(attachment.id)?.status === "failed"
? retryAttachmentUpload
: startAttachmentUpload;
upload({
environmentId,
image: attachment,
draftTarget: composerDraftTarget,
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/lib/attachmentUploadState.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe("attachmentUploadBlockReason", () => {
).toBe("Attachments still uploading");
});

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

it("does not accept an upload from another environment", () => {
Expand Down
12 changes: 3 additions & 9 deletions apps/web/src/lib/attachmentUploadState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,16 @@ export function attachmentUploadBlockReason(input: {
readonly environmentId: EnvironmentId;
}): string | null {
let pending = 0;
let failed = 0;

for (const imageId of input.imageIds) {
const upload = input.uploadsByImageId[imageId];
if (upload?.status === "failed" && upload.environmentId === input.environmentId) {
failed += 1;
} else if (upload?.status !== "ready" || upload.environmentId !== input.environmentId) {
// Send retries failed uploads, so they must not disable it.
if (upload?.status === "failed" && upload.environmentId === input.environmentId) continue;
if (upload?.status !== "ready" || upload.environmentId !== input.environmentId) {
pending += 1;
}
}

if (failed > 0) {
return failed === 1
? "Retry or remove the failed attachment"
: "Retry or remove the failed attachments";
}
if (pending > 0) {
return pending === 1 ? "Attachment still uploading" : "Attachments still uploading";
}
Expand Down
Loading