mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-03-04 07:10:18 +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
40
client/src/components/Chat/Messages/SearchButtons.tsx
Normal file
40
client/src/components/Chat/Messages/SearchButtons.tsx
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import { Link } from 'lucide-react';
|
||||
import type { TMessage } from 'librechat-data-provider';
|
||||
import { useLocalize, useNavigateToConvo } from '~/hooks';
|
||||
import { useSearchContext } from '~/Providers';
|
||||
import { getConversationById } from '~/utils';
|
||||
|
||||
export default function SearchButtons({ message }: { message: TMessage }) {
|
||||
const localize = useLocalize();
|
||||
const { searchQueryRes } = useSearchContext();
|
||||
const { navigateWithLastTools } = useNavigateToConvo();
|
||||
|
||||
if (!message.conversationId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const clickHandler = (event: React.MouseEvent<HTMLAnchorElement>) => {
|
||||
event.preventDefault();
|
||||
|
||||
const conversation = getConversationById(searchQueryRes?.data, message.conversationId);
|
||||
if (!conversation) {
|
||||
return;
|
||||
}
|
||||
|
||||
document.title = message.title ?? '';
|
||||
navigateWithLastTools(conversation);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="visible mt-0 flex items-center justify-center gap-1 self-end text-gray-400 lg:justify-start">
|
||||
<a
|
||||
className="ml-0 flex cursor-pointer items-center gap-1.5 rounded-md p-1 text-xs hover:text-gray-900 hover:underline dark:text-gray-400/70 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400"
|
||||
onClick={clickHandler}
|
||||
title={localize('com_ui_go_to_conversation')}
|
||||
>
|
||||
<Link className="icon-sm" />
|
||||
{message.title}
|
||||
</a>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue