import "./index.css"; import { v4 as uuidv4 } from "uuid"; import { Button } from "@/components/ui/button"; import ReactMarkdown from "react-markdown"; import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; import { coldarkDark } from "react-syntax-highlighter/dist/cjs/styles/prism"; import { UIMessage, useStreamContext } from "@langchain/langgraph-sdk/react-ui"; import { Message } from "@langchain/langgraph-sdk"; import { DO_NOT_RENDER_ID_PREFIX } from "@/lib/ensure-tool-responses"; import { useState } from "react"; interface ProposedChangeProps { toolCallId: string; change: string; planItem: string; } export default function ProposedChange(props: ProposedChangeProps) { const [isAccepted, setIsAccepted] = useState(false); const thread = useStreamContext< { messages: Message[]; ui: UIMessage[] }, { MetaType: { ui: UIMessage | undefined } } >(); const handleReject = () => { alert("Rejected. (just kidding, you can't reject me silly!)"); }; const handleAccept = () => { const content = "User accepted the proposed change. Please continue."; thread.submit({ messages: [ { type: "tool", tool_call_id: props.toolCallId, id: `${DO_NOT_RENDER_ID_PREFIX}${uuidv4()}`, name: "buy-stock", content, }, { type: "human", content: `Accepted change.`, }, ], }); setIsAccepted(true); }; if (isAccepted) { return (

Accepted Change

{props.planItem}

) : ( {children} ); }, }} />
); } return (

Proposed Change

{props.planItem}

) : ( {children} ); }, }} />
); }