"use client"; import { useState, type ReactElement, isValidElement } from "react"; import { CheckIcon, CopyIcon } from "lucide-react"; import { Dialog as DialogPrimitive } from "@base-ui/react/dialog"; import { XIcon } from "lucide-react"; import type { BuilderConfig } from "./types"; import { configMatchesPreset } from "./presets"; import { encodeConfig } from "@/lib/playground-url-state"; import { BASE_URL } from "@/lib/constants"; import { analytics } from "@/lib/analytics"; interface CreateDialogProps { config: BuilderConfig; children: React.ReactNode; container?: React.RefObject; onOpenCodeView?: () => void; } export function CreateDialog({ config, children, container, onOpenCodeView, }: CreateDialogProps) { const [open, setOpen] = useState(false); const commands = generateCliCommands(config); const handleOpenChange = (isOpen: boolean) => { if (isOpen) { analytics.builder.createDialogOpened(); } setOpen(isOpen); }; const handleOpenCodeView = () => { setOpen(false); onOpenCodeView?.(); }; return ( {isValidElement(children) ? ( ) : ( {children} )} Create your assistant

Or set up manually:

{commands.manual.slice(0, 2).map((cmd, index) => ( ))}
3. Copy code

Copy the code from the{" "} {" "} into your thread.tsx

Configuration

{commands.summary.map((item, index) => (
{item}
))}
Close
); } function CommandBlock({ label, description, command, commandType, }: { label: string; description?: string; command?: string; commandType?: "create" | "shadcn" | "manual_init" | "manual_add"; }) { const [copied, setCopied] = useState(false); const handleCopy = async () => { if (!command) return; if (commandType) { analytics.builder.commandCopied(commandType); } await navigator.clipboard.writeText(command); setCopied(true); setTimeout(() => setCopied(false), 2000); }; return (
{label}
{description && (

{description}

)} {command && (
            {command}
          
)}
); } interface CliCommand { label: string; description?: string; command?: string; } interface CliCommands { primary: CliCommand; alternative: CliCommand; manual: CliCommand[]; summary: string[]; } function generateCliCommands(config: BuilderConfig): CliCommands { const { components } = config; const matchingPreset = configMatchesPreset(config); const playgroundInitUrl = `${BASE_URL}/playground/init`; const presetUrl = matchingPreset ? `${playgroundInitUrl}?preset=${matchingPreset.id}` : `${playgroundInitUrl}?c=${encodeConfig(config)}`; const componentsToAdd: string[] = ["thread"]; if (components.markdown) { componentsToAdd.push("markdown-text", "tool-fallback"); } componentsToAdd.push("tooltip-icon-button"); if (components.attachments) { componentsToAdd.push("attachment"); } if (components.reasoning) { componentsToAdd.push("reasoning"); } if (components.sources) { componentsToAdd.push("sources"); } const addCommand = `npx assistant-ui@latest add ${componentsToAdd.join(" ")}`; const enabledFeatures: string[] = []; if (components.markdown) enabledFeatures.push("Markdown"); if (components.attachments) enabledFeatures.push("Attachments"); if (components.branchPicker) enabledFeatures.push("Branch Picker"); if (components.editMessage) enabledFeatures.push("Edit Message"); if (components.threadWelcome) enabledFeatures.push("Welcome Screen"); if (components.suggestions) enabledFeatures.push("Suggestions"); if (components.scrollToBottom) enabledFeatures.push("Scroll to Bottom"); if (components.reasoning) enabledFeatures.push("Reasoning"); if (components.sources) enabledFeatures.push("Sources"); if (components.followUpSuggestions) enabledFeatures.push("Follow-ups"); if (components.avatar) enabledFeatures.push("Avatar"); if (components.actionBar.copy) enabledFeatures.push("Copy"); if (components.actionBar.reload) enabledFeatures.push("Reload"); if (components.actionBar.speak) enabledFeatures.push("Speak"); if (components.actionBar.feedback) enabledFeatures.push("Feedback"); const summary: string[] = [ `Style: ${config.styles.borderRadius} radius, ${config.styles.fontFamily}`, `Enabled: ${enabledFeatures.length > 0 ? enabledFeatures.join(", ") : "None"}`, ]; return { primary: { label: "One-command setup", description: "Install with your current configuration", command: `npx assistant-ui@latest create my-app --preset "${presetUrl}"`, }, alternative: { label: "Using shadcn", command: `npx shadcn@latest add "${presetUrl}"`, }, manual: [ { label: "Initialize", command: "npx assistant-ui@latest init", }, { label: "Add components", command: addCommand, }, { label: "Copy code", description: "Copy the code from the Code view into your thread.tsx", }, ], summary, }; }