"use client"; import { useState, useRef, useEffect } from "react"; import { Button } from "@kandev/ui/button"; import { Textarea } from "@kandev/ui/textarea"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@kandev/ui/tooltip"; import { IconPlayerPlay, IconSend, IconX } from "@tabler/icons-react"; interface CommentFormProps { initialContent?: string; onSubmit: (content: string) => void; onCancel: () => void; onSubmitAndRun?: (content: string) => void; isEditing?: boolean; autoFocus?: boolean; } function ActionButtons({ disabled, modKey, isEditing, showRunButton, onCancel, onSubmit, onSubmitAndRun, }: { disabled: boolean; modKey: string; isEditing: boolean; showRunButton: boolean; onCancel: () => void; onSubmit: () => void; onSubmitAndRun?: () => void; }) { return (

Save comment for review ({modKey}+Enter)

{showRunButton && onSubmitAndRun && (

Save and send to agent ({modKey}+Shift+Enter)

)}
); } export function CommentForm({ initialContent = "", onSubmit, onCancel, onSubmitAndRun, isEditing = false, autoFocus = true, }: CommentFormProps) { const [content, setContent] = useState(initialContent); const textareaRef = useRef(null); useEffect(() => { if (autoFocus && textareaRef.current) textareaRef.current.focus(); }, [autoFocus]); const handleSubmit = () => { const trimmed = content.trim(); if (trimmed) { onSubmit(trimmed); setContent(""); } }; const handleSubmitAndRun = () => { const trimmed = content.trim(); if (trimmed && onSubmitAndRun) { onSubmitAndRun(trimmed); setContent(""); } }; const isMac = typeof navigator !== "undefined" && navigator.platform?.includes("Mac"); const modKey = isMac ? "⌘" : "Ctrl"; const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) { e.preventDefault(); if (e.shiftKey && onSubmitAndRun) handleSubmitAndRun(); else handleSubmit(); } else if (e.key === "Escape") { e.preventDefault(); onCancel(); } }; const disabled = !content.trim(); const showRunButton = !!onSubmitAndRun && !isEditing; return (