mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-19 18:00: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
|
|
@ -2,6 +2,7 @@ import { useMemo, memo } from 'react';
|
|||
import { parseISO, isToday } from 'date-fns';
|
||||
import { TConversation } from 'librechat-data-provider';
|
||||
import { groupConversationsByDate } from '~/utils';
|
||||
import { useLocalize } from '~/hooks';
|
||||
import Convo from './Convo';
|
||||
|
||||
const Conversations = ({
|
||||
|
|
@ -13,12 +14,14 @@ const Conversations = ({
|
|||
moveToTop: () => void;
|
||||
toggleNav: () => void;
|
||||
}) => {
|
||||
const localize = useLocalize();
|
||||
const groupedConversations = useMemo(
|
||||
() => groupConversationsByDate(conversations),
|
||||
[conversations],
|
||||
);
|
||||
const firstTodayConvoId = useMemo(
|
||||
() => conversations.find((convo) => isToday(parseISO(convo.updatedAt)))?.conversationId,
|
||||
() =>
|
||||
conversations.find((convo) => convo && isToday(parseISO(convo.updatedAt)))?.conversationId,
|
||||
[conversations],
|
||||
);
|
||||
|
||||
|
|
@ -37,7 +40,7 @@ const Conversations = ({
|
|||
paddingLeft: '10px',
|
||||
}}
|
||||
>
|
||||
{groupName}
|
||||
{localize(groupName) || groupName}
|
||||
</div>
|
||||
{convos.map((convo, i) => (
|
||||
<Convo
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { useRecoilValue } from 'recoil';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { useState, useRef, useMemo } from 'react';
|
||||
import { EModelEndpoint, LocalStorageKeys } from 'librechat-data-provider';
|
||||
import { useGetEndpointsQuery } from 'librechat-data-provider/react-query';
|
||||
import type { MouseEvent, FocusEvent, KeyboardEvent } from 'react';
|
||||
import { useUpdateConversationMutation } from '~/data-provider';
|
||||
|
|
@ -26,8 +25,8 @@ export default function Conversation({ conversation, retainView, toggleNav, isLa
|
|||
const updateConvoMutation = useUpdateConversationMutation(currentConvoId ?? '');
|
||||
const activeConvos = useRecoilValue(store.allConversationsSelector);
|
||||
const { data: endpointsConfig } = useGetEndpointsQuery();
|
||||
const { navigateWithLastTools } = useNavigateToConvo();
|
||||
const { refreshConversations } = useConversations();
|
||||
const { navigateToConvo } = useNavigateToConvo();
|
||||
const { showToast } = useToastContext();
|
||||
|
||||
const { conversationId, title } = conversation;
|
||||
|
|
@ -51,23 +50,7 @@ export default function Conversation({ conversation, retainView, toggleNav, isLa
|
|||
|
||||
// set document title
|
||||
document.title = title;
|
||||
|
||||
// set conversation to the new conversation
|
||||
if (conversation?.endpoint === EModelEndpoint.gptPlugins) {
|
||||
let lastSelectedTools = [];
|
||||
try {
|
||||
lastSelectedTools =
|
||||
JSON.parse(localStorage.getItem(LocalStorageKeys.LAST_TOOLS) ?? '') ?? [];
|
||||
} catch (e) {
|
||||
// console.error(e);
|
||||
}
|
||||
navigateToConvo({
|
||||
...conversation,
|
||||
tools: conversation?.tools?.length ? conversation?.tools : lastSelectedTools,
|
||||
});
|
||||
} else {
|
||||
navigateToConvo(conversation);
|
||||
}
|
||||
navigateWithLastTools(conversation);
|
||||
};
|
||||
|
||||
const renameHandler = (e: MouseEvent<HTMLButtonElement>) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue