"use client"
import { Brain, Loader, X } from "lucide-react"
import { motion } from "motion/react"
import { useEffect, useState } from "react"
import { dmSans125ClassName, dmSansClassName } from "@/lib/fonts"
import { useSpaceProfile } from "@/hooks/use-space-profile"
import {
useSpaceContext,
useUpdateSpaceContext,
} from "@/hooks/use-space-context"
import { cn } from "@lib/utils"
type SpaceProfilePanelProps = {
containerTag: string
isOpen: boolean
onClose: () => void
}
type SpaceProfileContentProps = {
containerTag: string
onClose?: () => void
}
function CountBadge({ children }: { children: React.ReactNode }) {
return (
{children}
)
}
function LoadingState() {
return (
{Array.from({ length: 5 }).map((_, index) => (
))}
)
}
function EmptyState() {
return (
No profile yet
Add more memories and Nova will learn about this space.
)
}
function ProfileSection({ label, items }: { label: string; items: string[] }) {
if (items.length === 0) return null
return (
{label}
{items.length}
{items.map((item, index) => (
))}
)
}
function SpaceContextEditor({ containerTag }: { containerTag: string }) {
const { data, isLoading } = useSpaceContext(containerTag)
const update = useUpdateSpaceContext()
const [value, setValue] = useState("")
const saved = data?.entityContext ?? ""
useEffect(() => {
setValue(data?.entityContext ?? "")
}, [data?.entityContext])
const dirty = value.trim() !== saved.trim()
const handleSave = () => {
update.mutate({
containerTag,
entityContext: value.trim() ? value.trim() : null,
})
}
return (
What to remember
Tell Nova what matters in this space — it shapes which memories get
extracted.
)
}
export function SpaceProfileContent({
containerTag,
onClose,
}: SpaceProfileContentProps) {
const { data, isLoading, error } = useSpaceProfile(containerTag)
const keyFacts = data?.static ?? []
const recentContext = data?.dynamic ?? []
const totalCount = keyFacts.length + recentContext.length
return (
Space Profile
What Nova knows in this space
{onClose ? (
) : null}
{isLoading ? (
) : error ? (
Failed to load space profile.
) : totalCount === 0 ? (
) : (
)}
)
}
export function SpaceProfilePanel({
containerTag,
isOpen,
onClose,
}: SpaceProfilePanelProps) {
if (!isOpen) return null
return (
)
}