fix(KB-649): fix multi-step scheduled task editor step addition and validation

- Fix step addition flow in ScheduleStepsEditor component
- Add form validation for multi-step schedules in ScheduleForm
- Add integration tests for multi-step scheduled task flow
- Update related CLI and core tests for consistency
- Include changeset for the fix
This commit is contained in:
gsxdsm
2026-03-31 19:53:35 -07:00
parent 3d7c9ef070
commit 40164e6b04
5 changed files with 247 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
import { useState, useCallback } from "react";
import { useState, useCallback, useEffect } from "react";
import { Plus, Trash2, ChevronUp, ChevronDown, Pencil, GripVertical } from "lucide-react";
import type { AutomationStep, AutomationStepType } from "@fusion/core";
import { StepTypeBadge } from "./StepTypeBadge";
@@ -6,6 +6,8 @@ import { StepTypeBadge } from "./StepTypeBadge";
interface ScheduleStepsEditorProps {
steps: AutomationStep[];
onChange: (steps: AutomationStep[]) => void;
/** Called when editing state changes. Useful for parent form validation. */
onEditingChange?: (isEditing: boolean) => void;
}
function generateStepId(): string {
@@ -193,9 +195,14 @@ function StepEditor({ step, onSave, onCancel }: StepEditorProps) {
);
}
export function ScheduleStepsEditor({ steps, onChange }: ScheduleStepsEditorProps) {
export function ScheduleStepsEditor({ steps, onChange, onEditingChange }: ScheduleStepsEditorProps) {
const [editingStepId, setEditingStepId] = useState<string | null>(null);
// Notify parent when editing state changes
useEffect(() => {
onEditingChange?.(editingStepId !== null);
}, [editingStepId, onEditingChange]);
const handleAddStep = useCallback((type: AutomationStepType) => {
const newStep = createEmptyStep(type);
onChange([...steps, newStep]);