🌡️ 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

@ -1,6 +1,6 @@
import { useEffect, useRef } from 'react';
import { useParams } from 'react-router-dom';
import { EModelEndpoint } from 'librechat-data-provider';
import { Constants, EModelEndpoint } from 'librechat-data-provider';
import {
useGetModelsQuery,
useGetStartupConfig,
@ -8,14 +8,15 @@ import {
} from 'librechat-data-provider/react-query';
import type { TPreset } from 'librechat-data-provider';
import { useNewConvo, useAppStartup, useAssistantListMap } from '~/hooks';
import { useGetConvoIdQuery, useHealthCheck } from '~/data-provider';
import { getDefaultModelSpec, getModelSpecIconURL } from '~/utils';
import { useGetConvoIdQuery } from '~/data-provider';
import ChatView from '~/components/Chat/ChatView';
import useAuthRedirect from './useAuthRedirect';
import { Spinner } from '~/components/svg';
import store from '~/store';
export default function ChatRoute() {
useHealthCheck();
const { data: startupConfig } = useGetStartupConfig();
const { isAuthenticated, user } = useAuthRedirect();
useAppStartup({ startupConfig, user });
@ -32,7 +33,7 @@ export default function ChatRoute() {
refetchOnMount: 'always',
});
const initialConvoQuery = useGetConvoIdQuery(conversationId ?? '', {
enabled: isAuthenticated && conversationId !== 'new',
enabled: isAuthenticated && conversationId !== Constants.NEW_CONVO,
});
const endpointsQuery = useGetEndpointsQuery({ enabled: isAuthenticated });
const assistantListMap = useAssistantListMap();
@ -45,7 +46,7 @@ export default function ChatRoute() {
return;
}
if (conversationId === 'new' && endpointsQuery.data && modelsQuery.data) {
if (conversationId === Constants.NEW_CONVO && endpointsQuery.data && modelsQuery.data) {
const spec = getDefaultModelSpec(startupConfig.modelSpecs?.list);
newConversation({
@ -73,7 +74,7 @@ export default function ChatRoute() {
});
hasSetConversation.current = true;
} else if (
conversationId === 'new' &&
conversationId === Constants.NEW_CONVO &&
assistantListMap[EModelEndpoint.assistants] &&
assistantListMap[EModelEndpoint.azureAssistants]
) {