"use client" import { cn } from "@lib/utils" import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "@ui/components/alert-dialog" import { Blocks, BookOpenText, CalendarClock, Cpu, ScrollText, } from "lucide-react" import Link from "next/link" import { usePathname, useRouter } from "next/navigation" import { useState } from "react" import CompanyBrainConnections from "@/components/settings/company-brain-connections" import CompanyBrainModels from "@/components/settings/company-brain-models" import CompanyBrainProactivity from "@/components/settings/company-brain-proactivity" import CompanyBrainSkills from "@/components/settings/company-brain-skills" import Proactiveness from "@/components/settings/proactiveness" import { ProactivenessIcon } from "@/components/settings/proactiveness-icon" import { WorkspacePrompt } from "@/components/settings/workspace-prompt" import { ErrorBoundary } from "@/components/error-boundary" import { useAuth } from "@lib/auth-context" import { type ConfigureSection, configureSectionToPath, DEFAULT_CONFIGURE_SECTION, pathToConfigureSection, } from "@/lib/configure-routes" import { dmSans125ClassName } from "@/lib/fonts" const SECTIONS: { id: ConfigureSection label: string description: string icon: React.ComponentType<{ className?: string }> }[] = [ { id: "tools", label: "Integrations", description: "Connect the tools your brain works with. Your account covers your own actions and reads; workspace accounts are a shared fallback.", icon: Blocks, }, { id: "models", label: "Models", description: "Pick how fast or thorough your brain should be. Fine-tune each task under Advanced.", icon: Cpu, }, { id: "workspace-prompt", label: "Workspace Prompt", description: "Persistent guidance for how your brain works across the workspace. Fixed safety, access, and approval constraints still apply.", icon: ScrollText, }, { id: "proactivity", label: "Proactivity", description: "When Company Brain speaks up in Slack without being asked. Quiet channels are still read and remembered.", icon: ProactivenessIcon, }, { id: "automations", label: "Automations", description: "Read-only scheduled summaries posted to Slack channels or DMs. You manage the ones you create.", icon: CalendarClock, }, { id: "skills", label: "Skills", description: "Teach Company Brain your team's repeatable processes, formats, and voice with reusable Markdown playbooks.", icon: BookOpenText, }, ] export function ConfigureView() { const { org } = useAuth() const pathname = usePathname() const router = useRouter() // Reachable via ?view=configure too, where the path carries no section. const activeSection = pathToConfigureSection(pathname) ?? DEFAULT_CONFIGURE_SECTION const [skillsDirty, setSkillsDirty] = useState(false) const [pendingSection, setPendingSection] = useState( null, ) const active = SECTIONS.find((section) => section.id === activeSection) if (!active) return null const requestSection = ( event: React.MouseEvent, section: ConfigureSection, ) => { if (section === activeSection) return if (activeSection !== "skills" || !skillsDirty) return event.preventDefault() setPendingSection(section) } const confirmSectionChange = () => { if (!pendingSection) return setSkillsDirty(false) router.push(configureSectionToPath(pendingSection)) setPendingSection(null) } return (

{active.label}

{active.description}

Something went wrong loading this section.

} > {activeSection === "tools" ? ( ) : activeSection === "models" ? ( ) : activeSection === "workspace-prompt" ? ( ) : activeSection === "proactivity" ? ( ) : activeSection === "skills" ? ( ) : ( )}
{ if (!open) setPendingSection(null) }} > Discard unsaved changes? Leaving Skills will discard your unsaved skill changes. Keep editing Discard and leave
) }