mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-02-12 12:34:24 +01:00
📢 fix: Invalid engineTTS and Conversation State on Navigation (#6904)
* fix: handle invalid engineTTS values and prevent VoiceDropdown render errors * refactor: add verbose developer logging for debugging conversation state issues * refactor: remove unnecessary effect for conversationId changes * chore: imports * fix: include model and entity IDs in conversation query selection * feat: add fetchFreshData function to retrieve conversation data on navigation * fix: remove unnecessary comment in fetchFreshData function * chore: reorder imports in useNavigateToConvo for consistency --------- Co-authored-by: Danny Avila <danny@librechat.ai>
This commit is contained in:
parent
d32f34e5d7
commit
000f3a3733
11 changed files with 75 additions and 18 deletions
|
|
@ -1,16 +1,16 @@
|
|||
import { useEffect, useRef } from 'react';
|
||||
import { useEffect } from 'react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { Constants, EModelEndpoint } from 'librechat-data-provider';
|
||||
import { useGetModelsQuery } from 'librechat-data-provider/react-query';
|
||||
import type { TPreset } from 'librechat-data-provider';
|
||||
import {
|
||||
useGetConvoIdQuery,
|
||||
useHealthCheck,
|
||||
useGetEndpointsQuery,
|
||||
useGetConvoIdQuery,
|
||||
useGetStartupConfig,
|
||||
useGetEndpointsQuery,
|
||||
} from '~/data-provider';
|
||||
import { useNewConvo, useAppStartup, useAssistantListMap } from '~/hooks';
|
||||
import { getDefaultModelSpec, getModelSpecIconURL } from '~/utils';
|
||||
import { getDefaultModelSpec, getModelSpecIconURL, logger } from '~/utils';
|
||||
import { ToolCallsMapProvider } from '~/Providers';
|
||||
import ChatView from '~/components/Chat/ChatView';
|
||||
import useAuthRedirect from './useAuthRedirect';
|
||||
|
|
@ -38,11 +38,6 @@ export default function ChatRoute() {
|
|||
const { hasSetConversation, conversation } = store.useCreateConversationAtom(index);
|
||||
const { newConversation } = useNewConvo();
|
||||
|
||||
// Reset the guard flag whenever conversationId changes
|
||||
useEffect(() => {
|
||||
hasSetConversation.current = false;
|
||||
}, [conversationId]);
|
||||
|
||||
const modelsQuery = useGetModelsQuery({
|
||||
enabled: isAuthenticated,
|
||||
refetchOnMount: 'always',
|
||||
|
|
@ -53,6 +48,9 @@ export default function ChatRoute() {
|
|||
const endpointsQuery = useGetEndpointsQuery({ enabled: isAuthenticated });
|
||||
const assistantListMap = useAssistantListMap();
|
||||
|
||||
/** This effect is mainly for the first conversation state change on first load of the page.
|
||||
* Adjusting this may have unintended consequences on the conversation state.
|
||||
*/
|
||||
useEffect(() => {
|
||||
const shouldSetConvo =
|
||||
(startupConfig && !hasSetConversation.current && !modelsQuery.data?.initial) ?? false;
|
||||
|
|
@ -63,7 +61,7 @@ export default function ChatRoute() {
|
|||
|
||||
if (conversationId === Constants.NEW_CONVO && endpointsQuery.data && modelsQuery.data) {
|
||||
const spec = getDefaultModelSpec(startupConfig);
|
||||
|
||||
logger.log('conversation', 'ChatRoute, new convo effect', conversation);
|
||||
newConversation({
|
||||
modelsData: modelsQuery.data,
|
||||
template: conversation ? conversation : undefined,
|
||||
|
|
@ -80,6 +78,7 @@ export default function ChatRoute() {
|
|||
|
||||
hasSetConversation.current = true;
|
||||
} else if (initialConvoQuery.data && endpointsQuery.data && modelsQuery.data) {
|
||||
logger.log('conversation', 'ChatRoute initialConvoQuery', initialConvoQuery.data);
|
||||
newConversation({
|
||||
template: initialConvoQuery.data,
|
||||
/* this is necessary to load all existing settings */
|
||||
|
|
@ -94,6 +93,7 @@ export default function ChatRoute() {
|
|||
assistantListMap[EModelEndpoint.azureAssistants]
|
||||
) {
|
||||
const spec = getDefaultModelSpec(startupConfig);
|
||||
logger.log('conversation', 'ChatRoute new convo, assistants effect', conversation);
|
||||
newConversation({
|
||||
modelsData: modelsQuery.data,
|
||||
template: conversation ? conversation : undefined,
|
||||
|
|
@ -112,6 +112,7 @@ export default function ChatRoute() {
|
|||
assistantListMap[EModelEndpoint.assistants] &&
|
||||
assistantListMap[EModelEndpoint.azureAssistants]
|
||||
) {
|
||||
logger.log('conversation', 'ChatRoute convo, assistants effect', initialConvoQuery.data);
|
||||
newConversation({
|
||||
template: initialConvoQuery.data,
|
||||
preset: initialConvoQuery.data as TPreset,
|
||||
|
|
@ -127,7 +128,6 @@ export default function ChatRoute() {
|
|||
endpointsQuery.data,
|
||||
modelsQuery.data,
|
||||
assistantListMap,
|
||||
conversationId,
|
||||
]);
|
||||
|
||||
if (endpointsQuery.isLoading || modelsQuery.isLoading) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue