mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-30 23:28:52 +01:00
* refactor(OpenSidebar): removed useless classNames
* style(Header): update hover styles across various components for improved UI consistency
* style(Nav): update hover styles in AccountSettings and SearchBar for improved UI consistency
* style: update button classes for consistent hover effects and improved UI responsiveness
* style(Nav, OpenSidebar, Header, Convo): improve UI responsiveness and animation transitions
* style(PresetsMenu, NewChat): update icon sizes and improve component styling for better UI consistency
* style(Nav, Root): enhance sidebar mobile animations and responsiveness for better UI experience
* style(ExportAndShareMenu, BookmarkMenu): update icon sizes for improved UI consistency
* style: remove transition duration from button classes for improved UI responsiveness
* style(CustomMenu, ModelSelector): update background colors for improved UI consistency and responsiveness
* style(ExportAndShareMenu): update icon color for improved UI consistency
* style(TemporaryChat): refine button styles for improved UI consistency and responsiveness
* style(BookmarkNav): refactor to use DropdownPopup and remove BookmarkNavItems for improved UI consistency and functionality
* style(CustomMenu, EndpointItem): enhance UI elements for improved consistency and accessibility
* style(EndpointItem): adjust gap in icon container for improved layout consistency
* style(CustomMenu, EndpointItem): update focus ring color for improved UI consistency
* style(EndpointItem): update icon color for improved UI consistency in dark theme
* style: update focus styles for improved accessibility and consistency across components
* refactor(Nav): extract sidebar width to NAV_WIDTH constant
Centralize mobile (320px) and desktop (260px) sidebar widths in a single
exported constant to avoid magic numbers and ensure consistency.
* fix(BookmarkNav): memoize handlers used in useMemo
Wrap handleTagClick and handleClear in useCallback and add them to the
dropdownItems useMemo dependency array to prevent stale closures.
* feat: introduce FilterInput component and replace existing inputs with it across multiple components
* feat(DataTable): replace custom input with FilterInput component for improved filtering
* fix: Nested dialog overlay stacking issue
Fixes overlay appearing behind content when opening nested dialogs.
Introduced dynamic z-index calculation based on dialog depth using React context.
- First dialog: overlay z-50, content z-100
- Nested dialogs increment by 60: overlay z-110/content z-160, etc.
Preserves a11y escape key handling from #10975 and #10851.
Regression from #11008 (afb67fcf1) which increased content z-index
without adjusting overlay z-index for nested dialog scenarios.
* Refactor admin settings components to use a unified AdminSettingsDialog
- Removed redundant code from AdminSettings, MCPAdminSettings, and Memories AdminSettings components.
- Introduced AdminSettingsDialog component to handle permission management for different sections.
- Updated permission handling logic to use a consistent structure across components.
- Enhanced role selection and permission confirmation features in the new dialog.
- Improved UI consistency and maintainability by centralizing dialog functionality.
* refactor(Memory): memory management UI components and replace MemoryViewer with MemoryPanel
* refactor(Memory): enhance UI components for Memory dialogs and improve input styling
* refactor(Bookmarks): improve bookmark management UI with enhanced styling
* refactor(translations): remove redundant filter input and bookmark count entries
* refactor(Convo): integrate useShiftKey hook for enhanced keyboard interaction and improve UI responsiveness
103 lines
3.5 KiB
TypeScript
103 lines
3.5 KiB
TypeScript
import React, { useCallback } from 'react';
|
|
import { useNavigate } from 'react-router-dom';
|
|
import { QueryKeys } from 'librechat-data-provider';
|
|
import { useQueryClient } from '@tanstack/react-query';
|
|
import { TooltipAnchor, NewChatIcon, MobileSidebar, Sidebar, Button } from '@librechat/client';
|
|
import { CLOSE_SIDEBAR_ID, OPEN_SIDEBAR_ID } from '~/components/Chat/Menus/OpenSidebar';
|
|
import { useLocalize, useNewConvo } from '~/hooks';
|
|
import { clearMessagesCache } from '~/utils';
|
|
import store from '~/store';
|
|
|
|
export default function NewChat({
|
|
index = 0,
|
|
toggleNav,
|
|
subHeaders,
|
|
isSmallScreen,
|
|
headerButtons,
|
|
}: {
|
|
index?: number;
|
|
toggleNav: () => void;
|
|
isSmallScreen?: boolean;
|
|
subHeaders?: React.ReactNode;
|
|
headerButtons?: React.ReactNode;
|
|
}) {
|
|
const queryClient = useQueryClient();
|
|
/** Note: this component needs an explicit index passed if using more than one */
|
|
const { newConversation: newConvo } = useNewConvo(index);
|
|
const navigate = useNavigate();
|
|
const localize = useLocalize();
|
|
const { conversation } = store.useCreateConversationAtom(index);
|
|
|
|
const handleToggleNav = useCallback(() => {
|
|
toggleNav();
|
|
// Delay focus until after the sidebar animation completes (200ms)
|
|
setTimeout(() => {
|
|
document.getElementById(OPEN_SIDEBAR_ID)?.focus();
|
|
}, 250);
|
|
}, [toggleNav]);
|
|
|
|
const clickHandler: React.MouseEventHandler<HTMLButtonElement> = useCallback(
|
|
(e) => {
|
|
if (e.button === 0 && (e.ctrlKey || e.metaKey)) {
|
|
window.open('/c/new', '_blank');
|
|
return;
|
|
}
|
|
clearMessagesCache(queryClient, conversation?.conversationId);
|
|
queryClient.invalidateQueries([QueryKeys.messages]);
|
|
newConvo();
|
|
navigate('/c/new', { state: { focusChat: true } });
|
|
if (isSmallScreen) {
|
|
toggleNav();
|
|
}
|
|
},
|
|
[queryClient, conversation, newConvo, navigate, toggleNav, isSmallScreen],
|
|
);
|
|
|
|
return (
|
|
<>
|
|
<div className="flex items-center justify-between py-[2px] md:py-2">
|
|
<TooltipAnchor
|
|
description={localize('com_nav_close_sidebar')}
|
|
render={
|
|
<Button
|
|
id={CLOSE_SIDEBAR_ID}
|
|
size="icon"
|
|
variant="outline"
|
|
data-testid="close-sidebar-button"
|
|
aria-label={localize('com_nav_close_sidebar')}
|
|
aria-expanded={true}
|
|
className="rounded-full border-none bg-transparent duration-0 hover:bg-surface-active-alt md:rounded-xl"
|
|
onClick={handleToggleNav}
|
|
>
|
|
<Sidebar aria-hidden="true" className="max-md:hidden" />
|
|
<MobileSidebar
|
|
aria-hidden="true"
|
|
className="icon-lg m-1 inline-flex items-center justify-center md:hidden"
|
|
/>
|
|
</Button>
|
|
}
|
|
/>
|
|
<div className="flex gap-0.5">
|
|
{headerButtons}
|
|
|
|
<TooltipAnchor
|
|
description={localize('com_ui_new_chat')}
|
|
render={
|
|
<Button
|
|
size="icon"
|
|
variant="outline"
|
|
data-testid="nav-new-chat-button"
|
|
aria-label={localize('com_ui_new_chat')}
|
|
className="rounded-full border-none bg-transparent duration-0 hover:bg-surface-active-alt md:rounded-xl"
|
|
onClick={clickHandler}
|
|
>
|
|
<NewChatIcon className="icon-lg text-text-primary" />
|
|
</Button>
|
|
}
|
|
/>
|
|
</div>
|
|
</div>
|
|
{subHeaders != null ? subHeaders : null}
|
|
</>
|
|
);
|
|
}
|