import { useId, useState } from "react" import type { FlowDef_Input } from "@/client" import { Button } from "@/components/ui/button" import { Checkbox } from "@/components/ui/checkbox" import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@/components/ui/dialog" import { Switch } from "@/components/ui/switch" import { BoundarySections } from "./FlowBoundary" import { PanelSection, PanelTitle, SidePanel } from "./SidePanel" /** * The flow's own settings, in the same panel its nodes use — down to where the * name sits and how confirming a new one works. */ export function FlowPanel({ open, definition, nodeCount, onChange, onDelete, hasDraft, enabled, toggling, onToggleEnabled, onClose, }: { open: boolean definition: FlowDef_Input nodeCount: number onChange: (next: FlowDef_Input) => void onDelete: (withRuns: boolean) => void hasDraft: boolean enabled: boolean toggling: boolean onToggleEnabled: (next: boolean) => void onClose: () => void }) { const [confirmOpen, setConfirmOpen] = useState(false) const [withRuns, setWithRuns] = useState(false) return ( <> onChange({ ...definition, title })} /> } footer={ } >

{enabled ? "Live" : "Stopped"}

Every message in this flow is named under{" "} {definition.name}, so two flows can use the same short name without colliding. } >

{nodeCount === 0 ? "No nodes yet." : `${nodeCount} node${nodeCount === 1 ? "" : "s"}`}

{hasDraft ? (

The engine is still running the last published version.

) : null}
Delete {definition.title || definition.name}? This removes the flow and the code of its{" "} {nodeCount === 1 ? "node" : `${nodeCount} nodes`}. Its history stays in the flow store's git repository. ) } /** * Whether deleting a flow takes its runs along. Off by default: a run is a * record of what ran, and keeping one keeps the artifacts it recorded. */ export function AlsoDeleteRuns({ checked, onCheckedChange, plural = false, }: { checked: boolean onCheckedChange: (checked: boolean) => void plural?: boolean }) { const id = useId() return (

Otherwise the runs stay, and keep their artifacts on disk.

) }