bug: updating so text doesn't delete

This commit is contained in:
Megan Greenberg 2025-08-18 10:19:55 -04:00 committed by Danny Avila
parent 99135a3dc1
commit 1341faec85
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956

View file

@ -81,6 +81,7 @@ const ChatForm = memo(({ index = 0 }: { index?: number }) => {
} = useAddedChatContext();
const assistantMap = useAssistantsMapContext();
const showStopAdded = useRecoilValue(store.showStopButtonByIndex(addedIndex));
const hasHandledSubmit = useRef(false);
const endpoint = useMemo(
() => conversation?.endpointType ?? conversation?.endpoint,
@ -177,6 +178,16 @@ const ChatForm = memo(({ index = 0 }: { index?: number }) => {
}
}, [isEditingBadges, badges, backupBadges.length]);
useEffect(() => {
if (!isSubmitting && !isSubmittingAdded && !hasHandledSubmit.current) {
hasHandledSubmit.current = true;
methods.setValue('text', textValue, { shouldValidate: true });
}
if (isSubmitting || isSubmittingAdded) {
hasHandledSubmit.current = false;
}
}, [isSubmitting, isSubmittingAdded, methods, textValue]);
const handleSaveBadges = useCallback(() => {
setIsEditingBadges(false);
setBackupBadges([]);