"use client";
import {
CheckCircle,
ChevronDown,
Sparkles,
Circle,
Check,
} from "lucide-react";
import { useState } from "react";
import { cn } from "@/lib/utils";
import { Button } from "../ui/button";
import { Badge } from "../ui/badge";
import { HumanResponse } from "@langchain/langgraph/prebuilt";
import { TaskPlan } from "@openswe/shared/open-swe/types";
import { getActivePlanItems } from "@openswe/shared/open-swe/tasks";
import { InlineMarkdownText } from "../thread/markdown-text";
type PlanItem = {
index: number;
plan: string;
completed: boolean;
};
type AcceptedPlanStepProps = {
taskPlan?: TaskPlan;
planTitle?: string;
planItems?: PlanItem[];
interruptType?: HumanResponse["type"];
collapse?: boolean;
};
export function AcceptedPlanStep({
taskPlan,
planTitle,
planItems = [],
interruptType,
collapse: collapseProp = true,
}: AcceptedPlanStepProps) {
const [collapsed, setCollapsed] = useState(collapseProp);
const activeTaskPlan = taskPlan ? getActivePlanItems(taskPlan) : planItems;
const getStatusText = () => {
if (interruptType === "edit") {
return "Plan revised and approved";
}
return "Plan approved and ready";
};
const getStatusBadge = () => {
return (
{totalCount} step{totalCount === 1 ? "" : "s"}
)}{planTitle}