From 7359ec822203401f91a831aae455c7bb414ed878 Mon Sep 17 00:00:00 2001 From: chihlasm Date: Mon, 16 Mar 2026 01:13:41 -0400 Subject: [PATCH] feat: create FallbackSteps UI component (Task 17) Collapsible component supporting edit and execute modes. Edit mode provides title/description inputs with add/remove controls. Execute mode shows "This worked" / "Didn't help" action buttons with emerald/ rose styling. Amber accent styling throughout. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../components/procedural/FallbackSteps.tsx | 153 ++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 frontend/src/components/procedural/FallbackSteps.tsx diff --git a/frontend/src/components/procedural/FallbackSteps.tsx b/frontend/src/components/procedural/FallbackSteps.tsx new file mode 100644 index 00000000..0f8ff8fa --- /dev/null +++ b/frontend/src/components/procedural/FallbackSteps.tsx @@ -0,0 +1,153 @@ +import { useState } from 'react' +import { AlertCircle, ChevronDown, ChevronRight, Plus, Trash2, Check, X } from 'lucide-react' +import type { ProceduralStep } from '@/types' +import { cn } from '@/lib/utils' + +interface FallbackStepsProps { + fallbackSteps: ProceduralStep[] + mode: 'edit' | 'execute' + // Edit mode + onAdd?: () => void + onRemove?: (index: number) => void + onUpdate?: (index: number, updates: Partial) => void + // Execute mode + onComplete?: (stepId: string, notes: string | null, outcome: 'resolved' | 'not_resolved' | 'skipped') => void + completedIds?: Set +} + +export function FallbackSteps({ + fallbackSteps, + mode, + onAdd, + onRemove, + onUpdate, + onComplete, + completedIds, +}: FallbackStepsProps) { + const [expanded, setExpanded] = useState(false) + + // In execute mode, hide if no fallback steps + if (mode === 'execute' && fallbackSteps.length === 0) { + return null + } + + const toggleLabel = + mode === 'execute' + ? "Didn't work?" + : `Fallback branches (${fallbackSteps.length})` + + return ( +
+ {/* Toggle button */} + + + {expanded && ( +
+
+ {fallbackSteps.map((fbStep, index) => { + const isCompleted = completedIds?.has(fbStep.id) + + return ( +
+ {mode === 'edit' ? ( +
+
+ onUpdate?.(index, { title: e.target.value })} + placeholder="Fallback step title" + className="flex-1 rounded border border-border bg-card px-2.5 py-1.5 text-sm text-foreground placeholder:text-muted-foreground focus:border-primary focus:outline-hidden focus:ring-1 focus:ring-primary/20" + /> + +
+