Skip to content
Closed
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
23 changes: 13 additions & 10 deletions site/src/pages/AgentsPage/components/AttachmentPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@ import {
} from "../utils/fetchTextAttachment";

export type UploadState = {
// "processing" covers any pre-upload client work (e.g. resize),
// so paste/drop handlers can commit the attachment synchronously
// without the send gate believing it is ready to dispatch.
status: "pending" | "processing" | "uploading" | "uploaded" | "error";
fileId?: string;
error?: string;
draftWarning?: string;
};
} & (
| {
// "processing" covers any pre-upload client work (e.g. resize),
// so paste/drop handlers can commit the attachment synchronously
// without the send gate believing it is ready to dispatch.
status: "pending" | "processing" | "uploading";
fileId?: never;
error?: never;
}
| { status: "uploaded"; fileId: string; error?: never }
| { status: "error"; error: string; fileId?: never }
);

export const isUploadInProgress = (state: UploadState | undefined): boolean =>
state?.status === "pending" ||
Expand Down Expand Up @@ -209,9 +214,7 @@ export const AttachmentPreview: React.FC<{
</div>
</TooltipTrigger>
<TooltipContent side="top">
<p className="max-w-xs text-xs">
{uploadState.error ?? "Upload failed"}
</p>
<p className="max-w-xs text-xs">{uploadState.error}</p>
</TooltipContent>
</Tooltip>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ const uploadStatusLabel = (upload: WorkspaceFileUpload): string => {
case "uploading":
return "Uploading to workspace...";
case "uploaded":
return upload.response
? `${prettyBytes(upload.response.size)} in workspace`
: "In workspace";
return `${prettyBytes(upload.response.size)} in workspace`;
case "error":
return upload.error ?? "Upload failed";
return upload.error;
}
};

Expand All @@ -46,7 +44,11 @@ export const WorkspaceUploadPreview: React.FC<{
return (
<div className="flex flex-wrap gap-2 px-3 pt-3">
{uploads.map((upload) => {
const name = upload.response?.name ?? upload.file.name;
let name = upload.file.name;
if (upload.status === "uploaded") {
name = upload.response.name;
}

return (
<div
key={upload.id}
Expand Down
Loading
Loading