📢 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:
Marco Beretta 2025-04-16 03:00:06 +02:00 committed by GitHub
parent d32f34e5d7
commit 000f3a3733
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 75 additions and 18 deletions

View file

@ -1,7 +1,13 @@
import { useSetRecoilState } from 'recoil';
import { useNavigate } from 'react-router-dom';
import { useQueryClient } from '@tanstack/react-query';
import { QueryKeys, EModelEndpoint, LocalStorageKeys, Constants } from 'librechat-data-provider';
import {
QueryKeys,
Constants,
dataService,
EModelEndpoint,
LocalStorageKeys,
} from 'librechat-data-provider';
import type { TConversation, TEndpointsConfig, TModelsConfig } from 'librechat-data-provider';
import { buildDefaultConvo, getDefaultEndpoint, getEndpointField, logger } from '~/utils';
import store from '~/store';
@ -14,6 +20,21 @@ const useNavigateToConvo = (index = 0) => {
const setSubmission = useSetRecoilState(store.submissionByIndex(index));
const { hasSetConversation, setConversation } = store.useCreateConversationAtom(index);
const fetchFreshData = async (conversationId?: string | null) => {
if (!conversationId) {
return;
}
try {
const data = await queryClient.fetchQuery([QueryKeys.conversation, conversationId], () =>
dataService.getConversationById(conversationId),
);
logger.log('conversation', 'Fetched fresh conversation data', data);
setConversation(data);
} catch (error) {
console.error('Error fetching conversation data on navigation', error);
}
};
const navigateToConvo = (
conversation?: TConversation | null,
_resetLatestMessage = true,
@ -23,6 +44,7 @@ const useNavigateToConvo = (index = 0) => {
logger.warn('conversation', 'Conversation not provided to `navigateToConvo`');
return;
}
logger.log('conversation', 'Navigating to conversation', conversation);
hasSetConversation.current = true;
setSubmission(null);
if (_resetLatestMessage) {
@ -60,6 +82,10 @@ const useNavigateToConvo = (index = 0) => {
clearAllConversations(true);
setConversation(convo);
navigate(`/c/${convo.conversationId ?? Constants.NEW_CONVO}`);
if (convo.conversationId !== Constants.NEW_CONVO && convo.conversationId) {
queryClient.invalidateQueries([QueryKeys.conversation, convo.conversationId]);
fetchFreshData(convo.conversationId);
}
};
const navigateWithLastTools = (