import { type EnvironmentId } from "@t3tools/contracts"; import { memo } from "react"; import { readLocalApi } from "~/localApi"; import { cn } from "~/lib/utils"; import { ProjectFavicon } from "../ProjectFavicon"; import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip"; interface ChatHeaderProps { activeThreadEnvironmentId: EnvironmentId; activeThreadTitle: string; activeProjectName: string | undefined; activeProjectCwd: string | null; activeProjectFaviconPath: string | null; activeProjectIcon: import("@t3tools/contracts").ProjectIconOverride | null; rightPanelOpen: boolean; onNewThreadInProject: () => void; onOpenProjectSettings?: (() => void) | undefined; } export const ChatHeader = memo(function ChatHeader({ activeThreadEnvironmentId, activeThreadTitle, activeProjectName, activeProjectCwd, activeProjectFaviconPath, activeProjectIcon, rightPanelOpen, onNewThreadInProject, onOpenProjectSettings, }: ChatHeaderProps) { return (
{ event.preventDefault(); const api = readLocalApi(); if (!api) return; void api.contextMenu .show([{ id: "project-settings", label: "Project settings", icon: "settings" }], { x: event.clientX, y: event.clientY, }) .then((action) => { if (action === "project-settings") onOpenProjectSettings(); }); } } className={cn( "flex min-w-0 flex-1 items-center gap-2 sm:gap-3", rightPanelOpen ? "pr-10" : "pr-24", )} >
{/* The project always leads the header: knowing which project a thread lives in is priority zero, and the thread title alone doesn't answer it. */} {activeProjectName ? ( } > {activeProjectName} New thread in {activeProjectName} / ) : null} {activeThreadTitle} } /> {activeThreadTitle}
); });