"use client"; import { useState, useCallback, memo } from "react"; import { IconGitCommit, IconSparkles } from "@tabler/icons-react"; import { Button } from "@kandev/ui/button"; import { getWebSocketClient } from "@/lib/ws/connection"; import type { Message } from "@/lib/types/http"; import type { GitOperationErrorMetadata } from "@/components/task/chat/types"; export const GitOperationErrorMessage = memo(function GitOperationErrorMessage({ comment, }: { comment: Message; }) { const [fixSent, setFixSent] = useState(false); const metadata = comment.metadata as GitOperationErrorMetadata | undefined; const handleFix = useCallback(async () => { const client = getWebSocketClient(); if (!client || !metadata) return; setFixSent(true); const prompt = [ `The git ${metadata.operation} command failed with the following error:`, "", "```", metadata.error_output, "```", "", "Please fix the issues reported above.", ].join("\n"); try { await client.request("message.add", { task_id: metadata.task_id, session_id: metadata.session_id, content: prompt, }); } catch { setFixSent(false); } }, [metadata]); const operation = metadata?.operation || "operation"; const title = comment.content || `Git ${operation} failed`; return (
{metadata.error_output}
)}