"use client" import { Logo } from "@ui/assets/Logo" import { Avatar, AvatarFallback, AvatarImage } from "@ui/components/avatar" import { useAuth } from "@lib/auth-context" import { useEffect, useState } from "react" import { ChevronsLeftRight, LayoutGridIcon, Plus, SearchIcon, FolderIcon, LogOut, Settings, Home, Code2, ExternalLink, } from "lucide-react" import { Button } from "@ui/components/button" import { cn } from "@lib/utils" import { dmSansClassName } from "@/lib/fonts" import { Tabs, TabsList, TabsTrigger } from "@ui/components/tabs" import { useProjectName } from "@/hooks/use-project-name" import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@ui/components/dropdown-menu" import { useQuery } from "@tanstack/react-query" import { $fetch } from "@repo/lib/api" import { authClient } from "@lib/auth" import { DEFAULT_PROJECT_ID } from "@repo/lib/constants" import { useProjectMutations } from "@/hooks/use-project-mutations" import { useProject } from "@/stores" import { useRouter } from "next/navigation" import Link from "next/link" import type { Project } from "@repo/lib/types" interface HeaderProps { onAddMemory?: () => void onOpenMCP?: () => void } export function Header({ onAddMemory, onOpenMCP }: HeaderProps) { const { user } = useAuth() const [name, setName] = useState("") const projectName = useProjectName() const { selectedProject } = useProject() const { switchProject } = useProjectMutations() const router = useRouter() const { data: projects = [] } = useQuery({ queryKey: ["projects"], queryFn: async () => { const response = await $fetch("@get/projects") if (response.error) { throw new Error(response.error?.message || "Failed to load projects") } return response.data?.projects || [] }, staleTime: 30 * 1000, }) useEffect(() => { const storedName = localStorage.getItem("username") || localStorage.getItem("userName") || "" setName(storedName) }, []) const userName = name ? `${name.split(" ")[0]}'s` : "My" return (
Home Developer console supermemory.ai

📁 {projectName}

switchProject(DEFAULT_PROJECT_ID)} className={cn( "cursor-pointer", selectedProject === DEFAULT_PROJECT_ID && "bg-accent", )} > Default Project {projects .filter((p: Project) => p.containerTag !== DEFAULT_PROJECT_ID) .map((project: Project) => ( switchProject(project.containerTag)} className={cn( "cursor-pointer", selectedProject === project.containerTag && "bg-accent", )} > {project.name} ))}
Grid Graph
{user && ( {user?.name?.charAt(0)} router.push("/new/settings")}> Settings { authClient.signOut() router.push("/login/new") }} > Logout )}
) }