mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-25 19:15:18 +02:00
refactor: remove team memory components and related settings from user and search space settings
This commit is contained in:
parent
659007bc4d
commit
61234e125f
6 changed files with 0 additions and 326 deletions
|
|
@ -3,7 +3,6 @@
|
||||||
import {
|
import {
|
||||||
BookText,
|
BookText,
|
||||||
Bot,
|
Bot,
|
||||||
Brain,
|
|
||||||
CircleUser,
|
CircleUser,
|
||||||
Earth,
|
Earth,
|
||||||
ImageIcon,
|
ImageIcon,
|
||||||
|
|
@ -27,7 +26,6 @@ export type SearchSpaceSettingsTab =
|
||||||
| "vision-models"
|
| "vision-models"
|
||||||
| "team-roles"
|
| "team-roles"
|
||||||
| "prompts"
|
| "prompts"
|
||||||
| "team-memory"
|
|
||||||
| "public-links";
|
| "public-links";
|
||||||
|
|
||||||
const DEFAULT_TAB: SearchSpaceSettingsTab = "general";
|
const DEFAULT_TAB: SearchSpaceSettingsTab = "general";
|
||||||
|
|
@ -89,11 +87,6 @@ export function SearchSpaceSettingsLayoutShell({
|
||||||
label: t("nav_system_instructions"),
|
label: t("nav_system_instructions"),
|
||||||
icon: <BookText className="h-4 w-4" />,
|
icon: <BookText className="h-4 w-4" />,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
value: "team-memory" as const,
|
|
||||||
label: "Team Memory",
|
|
||||||
icon: <Brain className="h-4 w-4" />,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
value: "public-links" as const,
|
value: "public-links" as const,
|
||||||
label: t("nav_public_links"),
|
label: t("nav_public_links"),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
import { TeamMemoryManager } from "@/components/settings/team-memory-manager";
|
|
||||||
|
|
||||||
export default async function Page({ params }: { params: Promise<{ search_space_id: string }> }) {
|
|
||||||
const { search_space_id } = await params;
|
|
||||||
return <TeamMemoryManager searchSpaceId={Number(search_space_id)} />;
|
|
||||||
}
|
|
||||||
|
|
@ -1,150 +0,0 @@
|
||||||
"use client";
|
|
||||||
|
|
||||||
import { useAtomValue } from "jotai";
|
|
||||||
import { ChevronDown, ClipboardCopy, Download, Info } from "lucide-react";
|
|
||||||
import { toast } from "sonner";
|
|
||||||
import { activeSearchSpaceIdAtom } from "@/atoms/search-spaces/search-space-query.atoms";
|
|
||||||
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, useUserMemory } from "@/hooks/use-memory";
|
|
||||||
|
|
||||||
export function MemoryContent() {
|
|
||||||
const activeSearchSpaceId = useAtomValue(activeSearchSpaceIdAtom);
|
|
||||||
const { memory, displayMemory, limits, loading, saving, reset } = useUserMemory(
|
|
||||||
Number(activeSearchSpaceId)
|
|
||||||
);
|
|
||||||
|
|
||||||
const handleClear = async () => {
|
|
||||||
try {
|
|
||||||
await reset();
|
|
||||||
toast.success("Memory cleared");
|
|
||||||
} catch {
|
|
||||||
toast.error("Failed to clear 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 = "personal-memory.md";
|
|
||||||
document.body.appendChild(a);
|
|
||||||
a.click();
|
|
||||||
document.body.removeChild(a);
|
|
||||||
URL.revokeObjectURL(url);
|
|
||||||
} catch {
|
|
||||||
toast.error("Failed to download memory");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleCopyMarkdown = async () => {
|
|
||||||
if (!memory) return;
|
|
||||||
try {
|
|
||||||
await navigator.clipboard.writeText(memory);
|
|
||||||
toast.success("Copied to clipboard");
|
|
||||||
} catch {
|
|
||||||
toast.error("Failed to copy 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 (
|
|
||||||
<div className="flex items-center justify-center py-12">
|
|
||||||
<Spinner size="md" className="text-muted-foreground" />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!memory) {
|
|
||||||
return (
|
|
||||||
<div className="flex flex-col items-center justify-center py-16 text-center">
|
|
||||||
<h3 className="text-base font-medium text-foreground">What does SurfSense remember?</h3>
|
|
||||||
<p className="mt-2 max-w-sm text-sm text-muted-foreground">
|
|
||||||
Nothing yet. SurfSense picks up on your preferences and context as you chat.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="space-y-4">
|
|
||||||
<Alert>
|
|
||||||
<Info />
|
|
||||||
<AlertDescription>
|
|
||||||
<p>
|
|
||||||
SurfSense uses this personal memory to personalize your responses across all
|
|
||||||
conversations.
|
|
||||||
</p>
|
|
||||||
</AlertDescription>
|
|
||||||
</Alert>
|
|
||||||
|
|
||||||
<div className="relative h-[380px] rounded-lg border bg-background">
|
|
||||||
<div className="h-full overflow-y-auto scrollbar-thin">
|
|
||||||
<PlateEditor
|
|
||||||
markdown={displayMemory}
|
|
||||||
readOnly
|
|
||||||
preset="readonly"
|
|
||||||
variant="default"
|
|
||||||
editorVariant="none"
|
|
||||||
className="px-5 py-4 text-sm min-h-full"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex items-center justify-between gap-2">
|
|
||||||
<span className={`text-xs shrink-0 ${getCounterColor()}`}>{limitState.label}</span>
|
|
||||||
<div className="flex items-center gap-1.5 sm:gap-2">
|
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
variant="destructive"
|
|
||||||
size="sm"
|
|
||||||
className="text-xs sm:text-sm"
|
|
||||||
onClick={handleClear}
|
|
||||||
disabled={saving || !memory}
|
|
||||||
>
|
|
||||||
<span className="hidden sm:inline">Reset Memory</span>
|
|
||||||
<span className="sm:hidden">Reset</span>
|
|
||||||
</Button>
|
|
||||||
<DropdownMenu>
|
|
||||||
<DropdownMenuTrigger asChild>
|
|
||||||
<Button type="button" variant="secondary" size="sm" disabled={!memory}>
|
|
||||||
Export
|
|
||||||
<ChevronDown className="h-3 w-3 opacity-60" />
|
|
||||||
</Button>
|
|
||||||
</DropdownMenuTrigger>
|
|
||||||
<DropdownMenuContent align="end">
|
|
||||||
<DropdownMenuItem onClick={handleCopyMarkdown}>
|
|
||||||
<ClipboardCopy className="h-4 w-4 mr-2" />
|
|
||||||
Copy as Markdown
|
|
||||||
</DropdownMenuItem>
|
|
||||||
<DropdownMenuItem onClick={handleDownload}>
|
|
||||||
<Download className="h-4 w-4 mr-2" />
|
|
||||||
Download as Markdown
|
|
||||||
</DropdownMenuItem>
|
|
||||||
</DropdownMenuContent>
|
|
||||||
</DropdownMenu>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Brain,
|
|
||||||
CircleUser,
|
CircleUser,
|
||||||
Keyboard,
|
Keyboard,
|
||||||
KeyRound,
|
KeyRound,
|
||||||
|
|
@ -26,7 +25,6 @@ export type UserSettingsTab =
|
||||||
| "api-key"
|
| "api-key"
|
||||||
| "prompts"
|
| "prompts"
|
||||||
| "community-prompts"
|
| "community-prompts"
|
||||||
| "memory"
|
|
||||||
| "agent-permissions"
|
| "agent-permissions"
|
||||||
| "agent-status"
|
| "agent-status"
|
||||||
| "purchases"
|
| "purchases"
|
||||||
|
|
@ -75,11 +73,6 @@ export function UserSettingsLayoutShell({ searchSpaceId, children }: UserSetting
|
||||||
label: "Community Prompts",
|
label: "Community Prompts",
|
||||||
icon: <Library className="h-4 w-4" />,
|
icon: <Library className="h-4 w-4" />,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
value: "memory" as const,
|
|
||||||
label: "Memory",
|
|
||||||
icon: <Brain className="h-4 w-4" />,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
value: "agent-permissions" as const,
|
value: "agent-permissions" as const,
|
||||||
label: "Agent Permissions",
|
label: "Agent Permissions",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
import { MemoryContent } from "../components/MemoryContent";
|
|
||||||
|
|
||||||
export default function Page() {
|
|
||||||
return <MemoryContent />;
|
|
||||||
}
|
|
||||||
|
|
@ -1,151 +0,0 @@
|
||||||
"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 (
|
|
||||||
<div className="flex items-center justify-center py-12">
|
|
||||||
<Spinner size="md" className="text-muted-foreground" />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!memory) {
|
|
||||||
return (
|
|
||||||
<div className="flex flex-col items-center justify-center py-16 text-center">
|
|
||||||
<h3 className="text-base font-medium text-foreground">
|
|
||||||
What does SurfSense remember about your team?
|
|
||||||
</h3>
|
|
||||||
<p className="mt-2 max-w-sm text-sm text-muted-foreground">
|
|
||||||
Nothing yet. SurfSense picks up on team decisions and conventions as your team chats.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="space-y-4">
|
|
||||||
<Alert>
|
|
||||||
<Info />
|
|
||||||
<AlertDescription>
|
|
||||||
<p>
|
|
||||||
SurfSense uses this shared memory to provide team-wide context across all conversations
|
|
||||||
in this search space.
|
|
||||||
</p>
|
|
||||||
</AlertDescription>
|
|
||||||
</Alert>
|
|
||||||
|
|
||||||
<div className="relative h-[380px] rounded-lg border bg-background">
|
|
||||||
<div className="h-full overflow-y-auto scrollbar-thin">
|
|
||||||
<PlateEditor
|
|
||||||
markdown={displayMemory}
|
|
||||||
readOnly
|
|
||||||
preset="readonly"
|
|
||||||
variant="default"
|
|
||||||
editorVariant="none"
|
|
||||||
className="px-5 py-4 text-sm min-h-full"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex items-center justify-between gap-2">
|
|
||||||
<span className={`text-xs shrink-0 ${getCounterColor()}`}>{limitState.label}</span>
|
|
||||||
<div className="flex items-center gap-1.5 sm:gap-2">
|
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
variant="destructive"
|
|
||||||
size="sm"
|
|
||||||
className="text-xs sm:text-sm"
|
|
||||||
onClick={handleClear}
|
|
||||||
disabled={saving || !memory}
|
|
||||||
>
|
|
||||||
<span className="hidden sm:inline">Reset Memory</span>
|
|
||||||
<span className="sm:hidden">Reset</span>
|
|
||||||
</Button>
|
|
||||||
<DropdownMenu>
|
|
||||||
<DropdownMenuTrigger asChild>
|
|
||||||
<Button type="button" variant="secondary" size="sm" disabled={!memory}>
|
|
||||||
Export
|
|
||||||
<ChevronDown className="h-3 w-3 opacity-60" />
|
|
||||||
</Button>
|
|
||||||
</DropdownMenuTrigger>
|
|
||||||
<DropdownMenuContent align="end">
|
|
||||||
<DropdownMenuItem onClick={handleCopyMarkdown}>
|
|
||||||
<ClipboardCopy className="h-4 w-4 mr-2" />
|
|
||||||
Copy as Markdown
|
|
||||||
</DropdownMenuItem>
|
|
||||||
<DropdownMenuItem onClick={handleDownload}>
|
|
||||||
<Download className="h-4 w-4 mr-2" />
|
|
||||||
Download as Markdown
|
|
||||||
</DropdownMenuItem>
|
|
||||||
</DropdownMenuContent>
|
|
||||||
</DropdownMenu>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue