"use client"; import { ChevronDown, ClipboardCopy, Download, Info } from "lucide-react"; import { toast } from "sonner"; import { PlateEditor } from "@/components/editor/plate-editor"; import { Alert, AlertDescription } from "@/components/ui/alert"; import { Button } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Spinner } from "@/components/ui/spinner"; import { getMemoryLimitState, useTeamMemory } from "@/hooks/use-memory"; interface TeamMemoryManagerProps { searchSpaceId: number; } export function TeamMemoryManager({ searchSpaceId }: TeamMemoryManagerProps) { const { memory, displayMemory, limits, loading, saving, reset } = useTeamMemory(searchSpaceId); const handleClear = async () => { try { await reset(); toast.success("Team memory cleared"); } catch { toast.error("Failed to clear team memory"); } }; const handleDownload = () => { if (!memory) return; try { const blob = new Blob([memory], { type: "text/markdown;charset=utf-8" }); const url = URL.createObjectURL(blob); const a = document.createElement("a"); a.href = url; a.download = "team-memory.md"; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); } catch { toast.error("Failed to download team memory"); } }; const handleCopyMarkdown = async () => { if (!memory) return; try { await navigator.clipboard.writeText(memory); toast.success("Copied to clipboard"); } catch { toast.error("Failed to copy team memory"); } }; const charCount = memory.length; const limitState = getMemoryLimitState(charCount, limits); const getCounterColor = () => { if (limitState.level === "error") return "text-red-500"; if (limitState.level === "warning") return "text-orange-500"; return "text-muted-foreground"; }; if (loading) { return (
); } if (!memory) { return (

What does SurfSense remember about your team?

Nothing yet. SurfSense picks up on team decisions and conventions as your team chats.

); } return (

SurfSense uses this shared memory to provide team-wide context across all conversations in this search space.

{limitState.label}
Copy as Markdown Download as Markdown
); }