"use client"; import { motion, AnimatePresence } from "framer-motion"; import { useState, useEffect } from "react"; import type { Node } from "@xyflow/react"; interface InputVariable { name: string; type: "string" | "number" | "boolean" | "url" | "object"; required: boolean; defaultValue?: string; description?: string; } interface StartNodePanelProps { node: Node | null; onClose: () => void; onUpdate: (nodeId: string, data: any) => void; } export default function StartNodePanel({ node, onClose, onUpdate }: StartNodePanelProps) { const nodeData = node?.data as any; const [inputVariables, setInputVariables] = useState( nodeData?.inputVariables || [ { name: "input_as_text", type: "string", required: false, defaultValue: "", description: "", } ] ); // Auto-save changes useEffect(() => { if (!node) return; const timeoutId = setTimeout(() => { onUpdate(node.id, { inputVariables, }); }, 500); return () => clearTimeout(timeoutId); }, [inputVariables, node, onUpdate]); const addVariable = () => { setInputVariables([ ...inputVariables, { name: `input${inputVariables.length + 1}`, type: "string", required: false, description: "", }, ]); }; const updateVariable = (index: number, updates: Partial) => { setInputVariables( inputVariables.map((v, i) => (i === index ? { ...v, ...updates } : v)) ); }; const removeVariable = (index: number) => { setInputVariables(inputVariables.filter((_, i) => i !== index)); }; return ( {node && ( {/* Header */}

Start

Define the workflow inputs

{/* Content */}
{/* Input Variables List */}

Input variables

{inputVariables.length === 0 ? (

No input variables defined

) : ( inputVariables.map((variable, index) => (
{/* Name */}
updateVariable(index, { name: e.target.value })} className="w-full px-12 py-8 bg-accent-white border border-border-faint rounded-8 text-sm text-accent-black font-mono focus:outline-none focus:border-heat-100" placeholder="variable_name" />
{/* Type */}
{/* Description */}
updateVariable(index, { description: e.target.value })} className="w-full px-12 py-8 bg-accent-white border border-border-faint rounded-8 text-sm text-accent-black focus:outline-none focus:border-heat-100" placeholder="Describe this input..." />
{/* Default Value */}
updateVariable(index, { defaultValue: e.target.value })} className="w-full px-12 py-8 bg-accent-white border border-border-faint rounded-8 text-sm text-accent-black focus:outline-none focus:border-heat-100" placeholder="Default value..." />
{/* Required Toggle & Delete */}
)) )}
{/* Help Text */}

Input Variables

Input variables define the data your workflow accepts when it starts. These will be shown as form fields when running the workflow.

Use {`{{variable_name}}`} in any node to reference these values.

)}
); }