fix(input): ignore stale attachment reads (#1150)
* fix(input): ignore stale attachment reads * fix(input): centralize attachment replacement * fix(input): route queued attachment restores through store action --------- Co-authored-by: Isaac Sanchez <isanchez-hawkins@arize.com> Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
This commit is contained in:
committed by
GitHub
co-authored by
Isaac Sanchez
Bohdan Triapitsyn
parent
01c19706f4
commit
811aa50312
@@ -1646,21 +1646,21 @@ const ChatInputComponent: React.FC<ChatInputProps> = ({ onOpenSettings, scrollTo
|
||||
if (normalized.includes('payload too large') || normalized.includes('413') || normalized.includes('entity too large')) {
|
||||
toast.error(t('chat.chatInput.toast.attachmentsTooLarge'));
|
||||
if (allAttachments.length > 0) {
|
||||
useInputStore.setState({ attachedFiles: allAttachments });
|
||||
useInputStore.getState().setAttachedFiles(allAttachments);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (isSoftNetworkError) {
|
||||
if (allAttachments.length > 0) {
|
||||
useInputStore.setState({ attachedFiles: allAttachments });
|
||||
useInputStore.getState().setAttachedFiles(allAttachments);
|
||||
toast.error(t('chat.chatInput.toast.sendAttachmentsFailed'));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (allAttachments.length > 0) {
|
||||
useInputStore.setState({ attachedFiles: allAttachments });
|
||||
useInputStore.getState().setAttachedFiles(allAttachments);
|
||||
}
|
||||
toast.error(rawMessage || t('chat.chatInput.toast.messageSendFailed'));
|
||||
});
|
||||
|
||||
@@ -88,9 +88,7 @@ export const QueuedMessageChips = memo(({ onEditMessage }: QueuedMessageChipsPro
|
||||
if (popped) {
|
||||
if (popped.attachments && popped.attachments.length > 0) {
|
||||
const currentAttachments = useInputStore.getState().attachedFiles;
|
||||
useInputStore.setState({
|
||||
attachedFiles: [...currentAttachments, ...popped.attachments]
|
||||
});
|
||||
useInputStore.getState().setAttachedFiles([...currentAttachments, ...popped.attachments]);
|
||||
}
|
||||
onEditMessage(popped.content, popped.attachments);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user