import { useState } from "react"; import { IconSettings, IconServer, IconLogout, IconLogin, IconLoader2, IconRefresh, IconFileText, IconFolder } from "@tabler/icons-react"; import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; import { Button } from "@/components/ui/button"; import { Separator } from "@/components/ui/separator"; import { useSettingsStore } from "@/stores"; import { bridge } from "@/services"; import { toast } from "@/components/ui/sonner"; import { cn } from "@/lib/utils"; interface ActionMenuProps { className?: string; onAuthAction?: () => void; } function MenuSection({ title, subtitle, children }: { title: string; subtitle?: string; children: React.ReactNode }) { return (
{title} {subtitle && {subtitle}}
{children}
); } function MenuItem({ onClick, disabled, danger, children }: { onClick: () => void; disabled?: boolean; danger?: boolean; children: React.ReactNode }) { return ( ); } export function ActionMenu({ className, onAuthAction }: ActionMenuProps) { const [open, setOpen] = useState(false); const [loading, setLoading] = useState(false); const { setMCPModalOpen, isLoggedIn, setIsLoggedIn, extensionConfig } = useSettingsStore(); const handleOpenSettings = () => { void bridge.openSettings(); setOpen(false); }; const handleOpenMCPServers = () => { setMCPModalOpen(true); setOpen(false); }; const handleChangeWorkDir = () => { useSettingsStore.getState().setWorkDirModalOpen(true); setOpen(false); }; const handleReset = () => { setOpen(false); void bridge.reloadWebview(); }; const handleShowLogs = () => { void bridge.showLogs(); setOpen(false); }; const handleAuthAction = async () => { setLoading(true); try { if (isLoggedIn) { await bridge.logout(); setIsLoggedIn(false); } else { const result = await bridge.login(); if (result.success) { setIsLoggedIn(true); } else { toast.error(result.error ?? "Sign-in failed. Check the logs for details."); } } } finally { setLoading(false); setOpen(false); } onAuthAction?.(); }; return ( Working Directory MCP Servers General Config ↗ Show Logs Reset Kimi { void handleAuthAction(); }} disabled={loading} danger={isLoggedIn} > {loading ? : isLoggedIn ? : } {loading ? "Processing…" : isLoggedIn ? "Sign out" : "Sign in"} ); }