import React from 'react'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu'; import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'; import { RiCheckLine, RiChatNewLine, RiEqualizer2Line, RiFolderAddLine, RiSearchLine, RiCloseLine, RiContractUpDownLine, RiExpandUpDownLine, } from '@remixicon/react'; import { useSessionDisplayStore } from '@/stores/useSessionDisplayStore'; type Props = { hideDirectoryControls: boolean; handleOpenDirectoryDialog: () => void; handleNewSession: () => void; headerActionIconClass: string; reserveHeaderActionsSpace: boolean; headerActionButtonClass: string; isSessionSearchOpen: boolean; setIsSessionSearchOpen: (open: boolean | ((prev: boolean) => boolean)) => void; sessionSearchInputRef: React.RefObject; sessionSearchQuery: string; setSessionSearchQuery: (value: string) => void; hasSessionSearchQuery: boolean; searchMatchCount: number; collapseAllProjects: () => void; expandAllProjects: () => void; }; export function SidebarHeader(props: Props): React.ReactNode { const { hideDirectoryControls, handleOpenDirectoryDialog, handleNewSession, headerActionIconClass, reserveHeaderActionsSpace, headerActionButtonClass, isSessionSearchOpen, setIsSessionSearchOpen, sessionSearchInputRef, sessionSearchQuery, setSessionSearchQuery, hasSessionSearchQuery, searchMatchCount, collapseAllProjects, expandAllProjects, } = props; const displayMode = useSessionDisplayStore((state) => state.displayMode); const setDisplayMode = useSessionDisplayStore((state) => state.setDisplayMode); if (hideDirectoryControls) { return null; } return (
{reserveHeaderActionsSpace ? (

Add project

New session

Search sessions

Display mode

setDisplayMode('default')} className="flex items-center justify-between" > Default {displayMode === 'default' ? : null} setDisplayMode('minimal')} className="flex items-center justify-between" > Minimal {displayMode === 'minimal' ? : null} Collapse all Expand all
{isSessionSearchOpen ? (
{hasSessionSearchQuery ? ( {searchMatchCount} {searchMatchCount === 1 ? 'match' : 'matches'} ) : } Esc to clear
setSessionSearchQuery(event.target.value)} placeholder="Search sessions..." className="h-8 w-full rounded-md border border-border bg-transparent pl-8 pr-8 typography-ui-label text-foreground outline-none focus-visible:ring-2 focus-visible:ring-primary/50" onKeyDown={(event) => { if (event.key === 'Escape') { event.stopPropagation(); if (hasSessionSearchQuery) { setSessionSearchQuery(''); } else { setIsSessionSearchOpen(false); } } }} /> {sessionSearchQuery.length > 0 ? ( ) : null}
) : null}
) : null}
); }