Replace inline data-URL image handling with a persistent attachment storage service, add draft lifecycle states (active/abandoned/sent) with generation tracking, and update fetchAgent to return project placement alongside agent snapshots.
37 lines
891 B
TypeScript
37 lines
891 B
TypeScript
import type { StreamItem, UserMessageImageAttachment } from "@/types/stream";
|
|
|
|
type MergePendingCreateImagesParams = {
|
|
streamItems: StreamItem[];
|
|
clientMessageId: string;
|
|
images?: UserMessageImageAttachment[];
|
|
};
|
|
|
|
export function mergePendingCreateImages({
|
|
streamItems,
|
|
clientMessageId,
|
|
images,
|
|
}: MergePendingCreateImagesParams): StreamItem[] {
|
|
if (!images || images.length === 0) {
|
|
return streamItems;
|
|
}
|
|
|
|
const targetIndex = streamItems.findIndex(
|
|
(item) => item.kind === "user_message" && item.id === clientMessageId
|
|
);
|
|
if (targetIndex < 0) {
|
|
return streamItems;
|
|
}
|
|
|
|
const target = streamItems[targetIndex];
|
|
if (target.kind !== "user_message") {
|
|
return streamItems;
|
|
}
|
|
if (target.images && target.images.length > 0) {
|
|
return streamItems;
|
|
}
|
|
|
|
const next = [...streamItems];
|
|
next[targetIndex] = { ...target, images };
|
|
return next;
|
|
}
|