mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-07 11:08:52 +01:00
* chore: fix logging for illegal target endpoints in getEndpointFromSetup * fix: prevent querying agent by ID for ephemeral agents * refactor: reorder variable declarations in MessagesView for clarity * fix: localize 'nothing found' message in MessagesView * refactor: streamline navigation logic and enhance loading spinner component in ChatView * refactor: simplify loading spinner logic in ChatView component * fix: ensure message queries are invalidated after new conversation creation in HeaderNewChat, MobileNav, and NewChat components * 🐛 First run dev mode will have error occur. 🐛 First run dev mode will have error occur. * fix font-size localstorage presist bug * Don't ping meilisearch if the search is disabled via env var * simplify logic in search/enable endpoint * refactor: simplify enable endpoint condition check * feat: add useIdChangeEffect hook and integrate it into ChatRoute --------- Co-authored-by: Ne0 <20765145+zeeklog@users.noreply.github.com> Co-authored-by: TinyTin <garychangcn@hotmail.com> Co-authored-by: Denis Palnitsky <denis.palnitsky@zendesk.com>
44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
import { useQueryClient } from '@tanstack/react-query';
|
|
import { QueryKeys, Constants } from 'librechat-data-provider';
|
|
import type { TMessage } from 'librechat-data-provider';
|
|
import { TooltipAnchor, Button } from '~/components/ui';
|
|
import { NewChatIcon } from '~/components/svg';
|
|
import { useChatContext } from '~/Providers';
|
|
import { useLocalize } from '~/hooks';
|
|
|
|
export default function HeaderNewChat() {
|
|
const localize = useLocalize();
|
|
const queryClient = useQueryClient();
|
|
const { conversation, newConversation } = useChatContext();
|
|
|
|
const clickHandler: React.MouseEventHandler<HTMLButtonElement> = (e) => {
|
|
if (e.button === 0 && (e.ctrlKey || e.metaKey)) {
|
|
window.open('/c/new', '_blank');
|
|
return;
|
|
}
|
|
queryClient.setQueryData<TMessage[]>(
|
|
[QueryKeys.messages, conversation?.conversationId ?? Constants.NEW_CONVO],
|
|
[],
|
|
);
|
|
queryClient.invalidateQueries([QueryKeys.messages]);
|
|
newConversation();
|
|
};
|
|
|
|
return (
|
|
<TooltipAnchor
|
|
description={localize('com_ui_new_chat')}
|
|
render={
|
|
<Button
|
|
size="icon"
|
|
variant="outline"
|
|
data-testid="wide-header-new-chat-button"
|
|
aria-label={localize('com_ui_new_chat')}
|
|
className="rounded-xl border border-border-light bg-surface-secondary p-2 hover:bg-surface-hover max-md:hidden"
|
|
onClick={clickHandler}
|
|
>
|
|
<NewChatIcon />
|
|
</Button>
|
|
}
|
|
/>
|
|
);
|
|
}
|