import { ChevronsUpDown, Folder, FolderPlus, Settings2 } from "lucide-react"; import { useRef, useState } from "react"; import type { AgentTopic } from "../api/client"; import { Button } from "@/shared/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuTrigger } from "@/shared/ui/dropdown-menu"; import { AgentTopicDialog } from "./agent-topic-dialog"; export type AgentTopicControlsProps = { topics: AgentTopic[]; topicId?: string | null; loading?: boolean; error?: string; onOpen: () => Promise; onSelect: (id: string | null) => void; onCreate: (name: string) => Promise; onRename: (id: string, name: string) => Promise; onDelete: (id: string) => Promise; }; export function AgentTopicControls({ topics, topicId, loading, error, onOpen, onSelect, onCreate, onRename, onDelete }: AgentTopicControlsProps) { const triggerRef = useRef(null); const [open, setOpen] = useState(false); const [mode, setMode] = useState<"create" | "manage">("create"); const [dialogKey, setDialogKey] = useState(0); const current = topics.find((topic) => topic.id === topicId); const begin = (next: "create" | "manage") => { setMode(next); setDialogKey((key) => key + 1); setOpen(true); }; return <> { if (next) void onOpen().catch(() => {}); }}> 切换主题 onSelect(id === "unclassified" ? null : id)} className="max-h-[min(45dvh,15rem)] overflow-y-auto"> 未分类 {topics.map((topic) => {topic.name} )} {loading ?

正在加载主题…

: null} {error ?

{error}

: null} begin("create")}>新建主题 begin("manage")}>管理主题
; }