"use client"; import { useEffect } from "react"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { IconSettings, IconFolder, IconRobot, IconBell, IconCode, IconCpu, IconKey, IconMessageCircle, IconBrandGithub, IconHexagon, IconSparkles, IconWand, IconGitBranch, IconArrowsShuffle, IconTicket, IconPlugConnected, } from "@tabler/icons-react"; import { Sidebar, SidebarContent, SidebarGroup, SidebarGroupLabel, SidebarGroupContent, SidebarMenu, SidebarMenuItem, SidebarMenuButton, SidebarMenuSub, SidebarMenuSubItem, SidebarMenuSubButton, SidebarHeader, useSidebar, } from "@kandev/ui/sidebar"; import { ScrollArea } from "@kandev/ui/scroll-area"; import { ScrollOnOverflow } from "@kandev/ui/scroll-on-overflow"; import { useAppStore } from "@/components/state-provider"; import { useAvailableAgents } from "@/hooks/domains/settings/use-available-agents"; import { AgentLogo } from "@/components/agent-logo"; import { getExecutorIcon } from "@/lib/executor-icons"; import { getCapabilityWarning } from "@/lib/capability-warning"; import type { Workspace, Agent, AgentProfile, Executor } from "@/lib/types/http"; type GeneralSidebarSectionProps = { pathname: string; }; function GeneralSidebarSection({ pathname }: GeneralSidebarSectionProps) { return ( General Notifications Editors ); } type WorkspacesSidebarSectionProps = { pathname: string; workspaces: Workspace[]; }; function WorkspacesSidebarSection({ pathname, workspaces }: WorkspacesSidebarSectionProps) { return ( Workspaces {workspaces.length > 0 && ( {workspaces.map((workspace: Workspace) => { const workspacePath = `/settings/workspace/${workspace.id}`; const workflowsPath = `${workspacePath}/workflows`; const repositoriesPath = `${workspacePath}/repositories`; return ( {workspace.name} Repositories Workflows ); })} )} ); } function IntegrationsSidebarSection({ pathname }: { pathname: string }) { const items: Array<{ href: string; label: string; Icon: typeof IconBrandGithub }> = [ { href: "/settings/integrations/github", label: "GitHub", Icon: IconBrandGithub }, { href: "/settings/integrations/jira", label: "Jira", Icon: IconTicket }, { href: "/settings/integrations/linear", label: "Linear", Icon: IconHexagon }, ]; return ( Integrations {items.map(({ href, label, Icon }) => ( {label} ))} ); } type AgentsSidebarSectionProps = { pathname: string; agents: Agent[]; }; function AgentsSidebarSection({ pathname, agents }: AgentsSidebarSectionProps) { return ( Agents {agents.length > 0 && ( {agents.flatMap((agent: Agent) => agent.profiles.map((profile: AgentProfile) => { const encodedAgent = encodeURIComponent(agent.name); const profilePath = `/settings/agents/${encodedAgent}/profiles/${profile.id}`; const agentLabel = profile.agent_display_name || agent.name; const warning = getCapabilityWarning(agent.capability_status, agent.capability_error); return ( {agentLabel} • {profile.name} {warning && } ); }), )} )} ); } type ExecutorsSidebarSectionProps = { pathname: string; executors: Executor[]; }; function ExecutorsSidebarSection({ pathname, executors }: ExecutorsSidebarSectionProps) { const allProfiles = executors.flatMap((e) => (e.profiles ?? []).map((p) => ({ ...p, executorType: e.type })), ); return ( Executors {allProfiles.length > 0 && ( {allProfiles.map((profile) => { const Icon = getExecutorIcon(profile.executorType); const profilePath = `/settings/executors/${profile.id}`; return ( {profile.name} ); })} )} ); } function SecretsSidebarSection({ pathname }: { pathname: string }) { return ( Secrets ); } export function SettingsAppSidebar() { const pathname = usePathname(); const { setOpenMobile, isMobile } = useSidebar(); const workspaces = useAppStore((state) => state.workspaces.items); const executors = useAppStore((state) => state.executors.items); const agents = useAppStore((state) => state.settingsAgents.items); useAvailableAgents(); // Close mobile sidebar when navigating to a new page useEffect(() => { if (isMobile) { setOpenMobile(false); } }, [pathname, isMobile, setOpenMobile]); return ( KanDev Settings {/* Prompts */} Prompts {/* Utility Agents */} Utility Agents {/* External MCP */} External MCP {/* Changelog */} Changelog ); }