Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
feat: enable file in resending message
  • Loading branch information
Na2CuCl4 committed Dec 21, 2025
commit 2ccd30b4bae92437a3a646bb02afe9c0a73746cb
25 changes: 24 additions & 1 deletion app/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,30 @@ function _Chat() {
setIsLoading(true);
const textContent = getMessageTextContent(userMessage);
const images = getMessageImages(userMessage);
chatStore.onUserInput(textContent, images).then(() => setIsLoading(false));
const files = (userMessage.attachFiles ?? []).map((meta) => ({
name: meta.name,
// create a dummy empty File to satisfy type; text content is used when available
content: new File([], meta.name, {
type: meta.type || "application/octet-stream",
}),
size: meta.size,
type: meta.type,
status: "success" as const,
text: meta.text,
textSize: meta.textSize,
}));

// show previews in input panel while resending
setAttachImages(images);
setAttachFiles(files);

// pass both images and files when resending
chatStore.onUserInput(textContent, images, files).then(() => {
setIsLoading(false);
// clear previews after resend completes (consistent with doSubmit)
setAttachImages([]);
setAttachFiles([]);
});
inputRef.current?.focus();
};

Expand Down
2 changes: 2 additions & 0 deletions app/store/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export type AttachedFileMeta = {
name: string;
size: number;
type: string;
text?: string;
textSize?: number;
};

Expand Down Expand Up @@ -466,6 +467,7 @@ export const useChatStore = createPersistStore(
name: file.name,
size: file.size,
type: file.type,
text: file.text,
textSize: file.textSize,
})) ?? [];

Expand Down