Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
import { memo } from 'react';
import type { NavLink } from '~/common';
import { isRtlElement } from '~/hooks/Nav/useDirection';
import SidePanelNav from '~/components/SidePanel/Nav';
import ExpandedPanel from './ExpandedPanel';
import { cn } from '~/utils';
function Sidebar({
links,
expanded,
width,
minWidth,
maxWidth,
onCollapse,
onExpand,
onLeaveInsights,
switchToHistory,
onResizeStart,
onResizeKeyboard,
}: {
links: NavLink[];
expanded: boolean;
width: number;
minWidth: number;
maxWidth: number;
onCollapse: () => void;
onExpand: () => void;
onLeaveInsights: () => void;
switchToHistory: boolean;
onResizeStart: (e: React.MouseEvent<HTMLElement>) => void;
onResizeKeyboard: (direction: 'shrink' | 'grow') => void;
}) {
return (
<>
<div className="flex h-full w-full overflow-hidden">
<ExpandedPanel
links={links}
expanded={expanded}
onCollapse={onCollapse}
onExpand={onExpand}
onLeaveInsights={onLeaveInsights}
switchToHistory={switchToHistory}
/>
<nav
className={cn(
/** The resize separator at the inline end is transparent until hovered, so
* the edge is drawn here. The panel and the content beside it now sit
* on the same surface, so the fill no longer separates them on its
* own and the boundary has to be a line in every theme. */
'border-border-light bg-surface-sidebar min-h-0 flex-1 overflow-hidden border-e',
expanded ? 'opacity-100' : 'pointer-events-none opacity-0',
)}
style={{ transition: expanded ? 'opacity 200ms ease 80ms' : 'opacity 150ms ease' }}
aria-hidden={!expanded}
>
<SidePanelNav links={links} />
</nav>
</div>
<div
role="separator"
aria-orientation="vertical"
aria-label="Resize sidebar"
aria-valuenow={Math.round(width)}
aria-valuemin={Math.round(minWidth)}
aria-valuemax={Math.round(maxWidth)}
tabIndex={expanded ? 0 : -1}
className={cn(
'hover:bg-border-medium active:bg-border-heavy absolute inset-e-0 top-0 z-10 h-full w-1 cursor-col-resize transition-colors',
expanded ? 'opacity-100' : 'pointer-events-none opacity-0',
)}
style={{ transition: expanded ? 'opacity 200ms ease 80ms' : 'opacity 150ms ease' }}
onMouseDown={onResizeStart}
onKeyDown={(e) => {
if (e.key !== 'ArrowLeft' && e.key !== 'ArrowRight') {
return;
}
/** The handle sits on the inline-end edge, so the arrow pointing away from the
* sidebar grows it: right in LTR, left in RTL. */
const towardEnd = (e.key === 'ArrowRight') !== isRtlElement(e.currentTarget);
onResizeKeyboard(towardEnd ? 'grow' : 'shrink');
}}
/>
</>
);
}
export default memo(Sidebar);