🛠️ fix: Conversation Navigation State (#7210)

* refactor: Enhance initial conversation query condition for better state management and prevent unused network requests

* ifx: Add Prettier plugin to ESLint configuration

* chore: linting and typing in convos.spec.ts

* fix: add back fresh data fetching and improve error handling for  conversation navigation

* fix: set conversation only with  conversation state change intent, to prevent double queries for messages
This commit is contained in:
Danny Avila 2025-05-04 10:44:40 -04:00 committed by GitHub
parent ddb2141eac
commit 6e663b2480
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 52 additions and 23 deletions

View file

@ -431,14 +431,14 @@ describe('Conversation Utilities', () => {
pageParams: [],
};
const newConvo = makeConversation('new');
const updated = addConversationToInfinitePages(data, newConvo);
const updated = addConversationToInfinitePages(data, newConvo as TConversation);
expect(updated.pages[0].conversations[0].conversationId).toBe('new');
expect(updated.pages[0].conversations[1].conversationId).toBe('1');
});
it('creates new InfiniteData if data is undefined', () => {
const newConvo = makeConversation('new');
const updated = addConversationToInfinitePages(undefined, newConvo);
const updated = addConversationToInfinitePages(undefined, newConvo as TConversation);
expect(updated.pages[0].conversations[0].conversationId).toBe('new');
expect(updated.pageParams).toEqual([undefined]);
});
@ -531,12 +531,12 @@ describe('Conversation Utilities', () => {
it('stores model for endpoint', () => {
const conversation = {
conversationId: '1',
endpoint: 'openai',
endpoint: 'openAI',
model: 'gpt-3',
};
storeEndpointSettings(conversation as any);
const stored = JSON.parse(localStorage.getItem('lastModel') || '{}');
expect([undefined, 'gpt-3']).toContain(stored.openai);
expect([undefined, 'gpt-3']).toContain(stored.openAI);
});
it('stores secondaryModel for gptPlugins endpoint', () => {
@ -574,14 +574,14 @@ describe('Conversation Utilities', () => {
conversationId: 'a',
updatedAt: '2024-01-01T12:00:00Z',
createdAt: '2024-01-01T10:00:00Z',
endpoint: 'openai',
endpoint: 'openAI',
model: 'gpt-3',
title: 'Conversation A',
} as TConversation;
convoB = {
conversationId: 'b',
updatedAt: '2024-01-02T12:00:00Z',
endpoint: 'openai',
endpoint: 'openAI',
model: 'gpt-3',
} as TConversation;
queryClient.setQueryData(['allConversations'], {