"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 { MEMORY_HARD_LIMIT, useTeamMemory } from "@/hooks/use-memory"; interface TeamMemoryManagerProps { searchSpaceId: number; } export function TeamMemoryManager({ searchSpaceId }: TeamMemoryManagerProps) { const { memory, displayMemory, 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 getCounterColor = () => { if (charCount > MEMORY_HARD_LIMIT) return "text-red-500"; if (charCount > 15_000) return "text-orange-500"; if (charCount > 10_000) return "text-yellow-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.

{charCount.toLocaleString()} / {MEMORY_HARD_LIMIT.toLocaleString()} characters chars {charCount > 15_000 && charCount <= MEMORY_HARD_LIMIT && " - Approaching limit"} {charCount > MEMORY_HARD_LIMIT && " - Exceeds limit"}
Copy as Markdown Download as Markdown
); }