🌡️ feat: Periodic Health Check to prevent UI Inactivity Connection Errors (#3589)

* 🌡️ feat: Periodic Health Check to prevent UI Inactivity Connection Errors

* feat: Add refetchOnWindowFocus option for health check

* feat: programmatically scroll to end when a chat request is initiated (and messages have rendered)
This commit is contained in:
Danny Avila 2024-08-08 14:52:12 -04:00 committed by GitHub
parent cf393b1308
commit 6ea2628b56
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 81 additions and 14 deletions

View file

@ -18,8 +18,8 @@ import type {
import type { SetterOrUpdater } from 'recoil';
import type { TAskFunction, ExtendedFile } from '~/common';
import useSetFilesToDelete from '~/hooks/Files/useSetFilesToDelete';
import { getEndpointField, logger, scrollToEnd } from '~/utils';
import useGetSender from '~/hooks/Conversations/useGetSender';
import { getEndpointField, logger } from '~/utils';
import useUserKey from '~/hooks/Input/useUserKey';
import store from '~/store';
@ -249,6 +249,8 @@ export default function useChatFunctions({
if (index === 0 && setLatestMessage) {
setLatestMessage(initialResponse);
}
scrollToEnd();
setSubmission(submission);
logger.log('Submission:');
logger.dir(submission, { depth: null });

View file

@ -8,6 +8,7 @@ import { forceResize, insertTextAtCursor, getAssistantName } from '~/utils';
import { useAssistantsMapContext } from '~/Providers/AssistantsMapContext';
import useGetSender from '~/hooks/Conversations/useGetSender';
import useFileHandling from '~/hooks/Files/useFileHandling';
import { useInteractionHealthCheck } from '~/data-provider';
import { useChatContext } from '~/Providers/ChatContext';
import useLocalize from '~/hooks/useLocalize';
import { globalAudioId } from '~/common';
@ -29,6 +30,7 @@ export default function useTextarea({
const isComposing = useRef(false);
const { handleFiles } = useFileHandling();
const assistantMap = useAssistantsMapContext();
const checkHealth = useInteractionHealthCheck();
const enterToSend = useRecoilValue(store.enterToSend);
const {
@ -152,6 +154,8 @@ export default function useTextarea({
return;
}
checkHealth();
const isNonShiftEnter = e.key === 'Enter' && !e.shiftKey;
const isCtrlEnter = e.key === 'Enter' && e.ctrlKey;
@ -185,7 +189,7 @@ export default function useTextarea({
submitButtonRef.current?.click();
}
},
[isSubmitting, filesLoading, enterToSend, textAreaRef, submitButtonRef],
[isSubmitting, checkHealth, filesLoading, enterToSend, textAreaRef, submitButtonRef],
);
const handleCompositionStart = () => {