import { ReactNode, useState } from 'react' import { useAtomValue } from 'jotai' import { ChevronDownIcon, MoreVerticalIcon, FolderOpenIcon, PencilIcon, } from 'lucide-react' import { twMerge } from 'tailwind-merge' import { useClickOutside } from '@/hooks/useClickOutside' import { usePath } from '@/hooks/usePath' import { openFileTitle } from '@/utils/titleUtils' import { activeThreadAtom } from '@/helpers/atoms/Thread.atom' interface Props { children: ReactNode rightAction?: ReactNode title: string asChild?: boolean hideMoreVerticalAction?: boolean } export default function CardSidebar({ children, title, asChild, rightAction, hideMoreVerticalAction, }: Props) { const [show, setShow] = useState(true) const [more, setMore] = useState(false) const [menu, setMenu] = useState(null) const [toggle, setToggle] = useState(null) const activeThread = useAtomValue(activeThreadAtom) const { onReviewInFinder, onViewJson } = usePath() useClickOutside(() => setMore(false), null, [menu, toggle]) return (
{title}
{rightAction && rightAction} {!asChild && ( <> {!hideMoreVerticalAction && (
setMore(!more)} >
)} )}
{more && (
{ onReviewInFinder && onReviewInFinder(title) setMore(false) }} > <> {title === 'Model' ? (
{openFileTitle()} Opens thread.json. Changes affect this thread only.
) : ( {openFileTitle()} )}
{ onViewJson && onViewJson(title) setMore(false) }} > <>
Edit Global Defaults for{' '} {activeThread?.assistants[0].model.id} {title === 'Model' ? ( <> Opens {title}.json.  Changes affect all new assistants and threads. ) : ( <> Opens{' '} {title === 'Tools' ? 'assistant' : title}.json.  Changes affect all new threads. )}
)}
{show && (
{children}
)}
) }