mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-22 03:10:15 +01:00
🔍 feat: Show Messages from Search Result (#2699)
* refactor(Nav): delegate Search-specific variables/hooks to SearchContext * fix: safely determine firstTodayConvoId if convo is undefined * chore: remove empty line * feat: initial render of search messages * feat: SearchButtons * update Ko.ts * update localizations with new key phrases * chore: localization comparisons * fix: clear conversation state on searchQuery navigation * style: search messages view styling * refactor(Convo): consolidate logic to navigateWithLastTools from useNavigateToConvo * fix(SearchButtons): styling and correct navigation logic * fix(SearchBar): invalidate all message queries and invoke `clearText` if onChange value is empty * refactor(NewChat): consolidate new chat button logic to NewChatButtonIcon * chore: localizations for Nav date groups * chore: update comparisons * fix: early return from sendRequest to avoid quick searchQuery reset * style: Link Icon * chore: bump tiktoken, use o200k_base for gpt-4o
This commit is contained in:
parent
638ac5bba6
commit
e42709bd1f
36 changed files with 2742 additions and 234 deletions
|
|
@ -5,6 +5,7 @@ import {
|
|||
useRecoilState,
|
||||
useRecoilValue,
|
||||
useSetRecoilState,
|
||||
useRecoilCallback,
|
||||
} from 'recoil';
|
||||
import { LocalStorageKeys } from 'librechat-data-provider';
|
||||
import type { TMessage, TPreset, TConversation, TSubmission } from 'librechat-data-provider';
|
||||
|
|
@ -32,6 +33,10 @@ const conversationByIndex = atomFamily<TConversation | null, string | number>({
|
|||
);
|
||||
}
|
||||
|
||||
if (!newValue) {
|
||||
return;
|
||||
}
|
||||
|
||||
storeEndpointSettings(newValue);
|
||||
localStorage.setItem(LocalStorageKeys.LAST_CONVO_SETUP, JSON.stringify(newValue));
|
||||
});
|
||||
|
|
@ -131,6 +136,29 @@ function useCreateConversationAtom(key: string | number) {
|
|||
return { conversation, setConversation };
|
||||
}
|
||||
|
||||
function useClearConvoState() {
|
||||
const clearAllConversations = useRecoilCallback(
|
||||
({ reset, snapshot }) =>
|
||||
async () => {
|
||||
const conversationKeys = await snapshot.getPromise(conversationKeysAtom);
|
||||
|
||||
for (const conversationKey of conversationKeys) {
|
||||
reset(conversationByIndex(conversationKey));
|
||||
|
||||
const conversation = await snapshot.getPromise(conversationByIndex(conversationKey));
|
||||
if (conversation) {
|
||||
reset(latestMessageFamily(conversationKey));
|
||||
}
|
||||
}
|
||||
|
||||
reset(conversationKeysAtom);
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
return clearAllConversations;
|
||||
}
|
||||
|
||||
export default {
|
||||
conversationByIndex,
|
||||
filesByIndex,
|
||||
|
|
@ -146,6 +174,7 @@ export default {
|
|||
showPopoverFamily,
|
||||
latestMessageFamily,
|
||||
allConversationsSelector,
|
||||
useClearConvoState,
|
||||
useCreateConversationAtom,
|
||||
showMentionPopoverFamily,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import { TMessage } from 'librechat-data-provider';
|
||||
import { atom, selector } from 'recoil';
|
||||
import { buildTree } from '~/utils';
|
||||
import { atom } from 'recoil';
|
||||
|
||||
const isSearchEnabled = atom<boolean | null>({
|
||||
key: 'isSearchEnabled',
|
||||
|
|
@ -12,30 +10,7 @@ const searchQuery = atom({
|
|||
default: '',
|
||||
});
|
||||
|
||||
const searchResultMessages = atom<TMessage[] | null>({
|
||||
key: 'searchResultMessages',
|
||||
default: null,
|
||||
});
|
||||
|
||||
const searchResultMessagesTree = selector({
|
||||
key: 'searchResultMessagesTree',
|
||||
get: ({ get }) => {
|
||||
return buildTree({ messages: get(searchResultMessages), groupAll: true });
|
||||
},
|
||||
});
|
||||
|
||||
const isSearching = selector({
|
||||
key: 'isSearching',
|
||||
get: ({ get }) => {
|
||||
const data = get(searchQuery);
|
||||
return !!data;
|
||||
},
|
||||
});
|
||||
|
||||
export default {
|
||||
isSearchEnabled,
|
||||
isSearching,
|
||||
searchResultMessages,
|
||||
searchResultMessagesTree,
|
||||
searchQuery,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue