import type React from "react"; import type { ReactNode } from "react"; import { useState } from "react"; import { ChevronsDownUp, ChevronsUpDown, Loader, CircleX, Rabbit, } from "lucide-react"; import { CodeHighlight } from "./CodeHighlight"; import { CustomTagState } from "./stateTypes"; interface DyadEditProps { children?: ReactNode; node?: any; path?: string; description?: string; } export const DyadEdit: React.FC = ({ children, node, path: pathProp, description: descriptionProp, }) => { const [isContentVisible, setIsContentVisible] = useState(false); // Use props directly if provided, otherwise extract from node const path = pathProp || node?.properties?.path || ""; const description = descriptionProp || node?.properties?.description || ""; const state = node?.properties?.state as CustomTagState; const inProgress = state === "pending"; const aborted = state === "aborted"; // Extract filename from path const fileName = path ? path.split("/").pop() : ""; return (
setIsContentVisible(!isContentVisible)} >
Turbo Edit
{fileName && ( {fileName} )} {inProgress && (
Editing...
)} {aborted && (
Did not finish
)}
{isContentVisible ? ( ) : ( )}
{path && (
{path}
)} {description && (
Summary: {description}
)} {isContentVisible && (
{children}
)}
); };