import { useState } from "react"; import type { IssueComment } from "@paperclip/shared"; import { Button } from "@/components/ui/button"; import { Textarea } from "@/components/ui/textarea"; import { formatDate } from "../lib/utils"; interface CommentThreadProps { comments: IssueComment[]; onAdd: (body: string) => Promise; } export function CommentThread({ comments, onAdd }: CommentThreadProps) { const [body, setBody] = useState(""); const [submitting, setSubmitting] = useState(false); async function handleSubmit(e: React.FormEvent) { e.preventDefault(); const trimmed = body.trim(); if (!trimmed) return; setSubmitting(true); try { await onAdd(trimmed); setBody(""); } finally { setSubmitting(false); } } return (

Comments ({comments.length})

{comments.length === 0 && (

No comments yet.

)}
{comments.map((comment) => (
{comment.authorAgentId ? "Agent" : "Human"} {formatDate(comment.createdAt)}

{comment.body}

))}