2026-05-25 14:54:04 +04:00
|
|
|
"use client";
|
|
|
|
|
|
|
|
|
|
import { PanelLeftIcon } from "lucide-react";
|
|
|
|
|
import { memo } from "react";
|
|
|
|
|
import { Button } from "@/components/ui/button";
|
|
|
|
|
import { useSidebar } from "@/components/ui/sidebar";
|
2026-05-25 17:27:08 +04:00
|
|
|
import { UsageBadge } from "./usage-badge";
|
2026-05-25 14:54:04 +04:00
|
|
|
import { VisibilitySelector, type VisibilityType } from "./visibility-selector";
|
|
|
|
|
|
|
|
|
|
function PureChatHeader({
|
|
|
|
|
chatId,
|
|
|
|
|
selectedVisibilityType,
|
|
|
|
|
isReadonly,
|
|
|
|
|
}: {
|
|
|
|
|
chatId: string;
|
|
|
|
|
selectedVisibilityType: VisibilityType;
|
|
|
|
|
isReadonly: boolean;
|
|
|
|
|
}) {
|
|
|
|
|
const { state, toggleSidebar, isMobile } = useSidebar();
|
|
|
|
|
|
|
|
|
|
if (state === "collapsed" && !isMobile) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<header className="sticky top-0 flex h-14 items-center gap-2 bg-sidebar px-3">
|
|
|
|
|
<Button
|
|
|
|
|
className="md:hidden"
|
|
|
|
|
onClick={toggleSidebar}
|
|
|
|
|
size="icon-sm"
|
|
|
|
|
variant="ghost"
|
|
|
|
|
>
|
|
|
|
|
<PanelLeftIcon className="size-4" />
|
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
|
|
{!isReadonly && (
|
|
|
|
|
<VisibilitySelector
|
|
|
|
|
chatId={chatId}
|
|
|
|
|
selectedVisibilityType={selectedVisibilityType}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
|
2026-05-25 17:27:08 +04:00
|
|
|
<div className="ml-auto flex items-center gap-2">
|
|
|
|
|
<UsageBadge />
|
|
|
|
|
</div>
|
2026-05-25 14:54:04 +04:00
|
|
|
</header>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const ChatHeader = memo(PureChatHeader, (prevProps, nextProps) => {
|
|
|
|
|
return (
|
|
|
|
|
prevProps.chatId === nextProps.chatId &&
|
|
|
|
|
prevProps.selectedVisibilityType === nextProps.selectedVisibilityType &&
|
|
|
|
|
prevProps.isReadonly === nextProps.isReadonly
|
|
|
|
|
);
|
|
|
|
|
});
|