From 66dd6920284cd26bbba8aa8350b24d25e311ff2d Mon Sep 17 00:00:00 2001 From: Marco Beretta <81851188+berry-13@users.noreply.github.com> Date: Thu, 1 Oct 2026 18:39:47 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=9B=EF=B8=8F=20refactor:=20Pass=20the?= =?UTF-8?q?=20New-Chat=20Panel=20Preference=20Into=20the=20Sidebar=20(#166?= =?UTF-8?q?05)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor(client): Pass the new-chat panel preference into the sidebar Both new-chat controls, the desktop rail's and the mobile drawer's, read newChatSwitchToHistory straight from the store. It is an app-global preference the sidebar only consumes, so the host (Root) reads it and passes it down, and the sidebar no longer reaches into the store for it. * test(e2e): Cover the new-chat panel preference on desktop and mobile --- .../UnifiedSidebar/ExpandedPanel.tsx | 9 +- .../src/components/UnifiedSidebar/Sidebar.tsx | 3 + .../UnifiedSidebar/UnifiedSidebar.tsx | 12 +- .../__tests__/ExpandedPanel.spec.tsx | 18 +-- .../__tests__/drawerPaint.spec.tsx | 2 +- .../UnifiedSidebar/mobile/Header.tsx | 4 +- .../UnifiedSidebar/mobile/NewChat.tsx | 11 +- .../mobile/__tests__/Header.spec.tsx | 116 ++++++++++++++---- .../mobile/__tests__/NewChat.spec.tsx | 32 ++++- client/src/routes/Root.tsx | 6 +- .../new-chat-panel-preference.spec.ts | 100 +++++++++++++++ 11 files changed, 264 insertions(+), 49 deletions(-) create mode 100644 e2e/specs/mock/scenarios/new-chat-panel-preference.spec.ts diff --git a/client/src/components/UnifiedSidebar/ExpandedPanel.tsx b/client/src/components/UnifiedSidebar/ExpandedPanel.tsx index 471bf2f987..82c85291db 100644 --- a/client/src/components/UnifiedSidebar/ExpandedPanel.tsx +++ b/client/src/components/UnifiedSidebar/ExpandedPanel.tsx @@ -1,5 +1,4 @@ import { memo, useCallback, lazy, Suspense } from 'react'; -import { useRecoilValue } from 'recoil'; import { SquarePen } from 'lucide-react'; import { useLocation } from 'react-router-dom'; import { Skeleton, Sidebar, Button, TooltipAnchor } from '@librechat/client'; @@ -11,17 +10,17 @@ import { CLOSE_SIDEBAR_ID } from '~/components/Chat/Menus/OpenSidebar'; import useNewChat from '~/hooks/Chat/useNewChat'; import { useLocalize } from '~/hooks'; import { cn } from '~/utils'; -import store from '~/store'; const AccountSettings = lazy(() => import('~/components/Nav/AccountSettings')); const NewChatButton = memo(function NewChatButton({ setActive, + switchToHistory, }: { setActive: (id: string) => void; + switchToHistory: boolean; }) { const localize = useLocalize(); - const switchToHistory = useRecoilValue(store.newChatSwitchToHistory); const tooltipDescription = useShortcutHint('newChat', localize('com_ui_new_chat')); const ariaKey = useShortcutAriaKey('newChat'); @@ -129,6 +128,7 @@ function ExpandedPanel({ onExpand, onNavigate, onLeaveInsights, + switchToHistory, }: { links: NavLink[]; expanded?: boolean; @@ -136,6 +136,7 @@ function ExpandedPanel({ onExpand?: () => void; onNavigate?: () => void; onLeaveInsights?: () => void; + switchToHistory: boolean; }) { const localize = useLocalize(); const location = useLocation(); @@ -169,7 +170,7 @@ function ExpandedPanel({ } /> - +
diff --git a/client/src/components/UnifiedSidebar/Sidebar.tsx b/client/src/components/UnifiedSidebar/Sidebar.tsx index 319b6651ad..ef048b6c60 100644 --- a/client/src/components/UnifiedSidebar/Sidebar.tsx +++ b/client/src/components/UnifiedSidebar/Sidebar.tsx @@ -13,6 +13,7 @@ function Sidebar({ onCollapse, onExpand, onLeaveInsights, + switchToHistory, onResizeStart, onResizeKeyboard, }: { @@ -24,6 +25,7 @@ function Sidebar({ onCollapse: () => void; onExpand: () => void; onLeaveInsights: () => void; + switchToHistory: boolean; onResizeStart: (e: React.MouseEvent) => void; onResizeKeyboard: (direction: 'shrink' | 'grow') => void; }) { @@ -36,6 +38,7 @@ function Sidebar({ onCollapse={onCollapse} onExpand={onExpand} onLeaveInsights={onLeaveInsights} + switchToHistory={switchToHistory} />