diff --git a/apps/web/src/components/pullRequest/PullRequestSummaryTab.tsx b/apps/web/src/components/pullRequest/PullRequestSummaryTab.tsx index a57f2a4d160..5547cc19157 100644 --- a/apps/web/src/components/pullRequest/PullRequestSummaryTab.tsx +++ b/apps/web/src/components/pullRequest/PullRequestSummaryTab.tsx @@ -12,11 +12,12 @@ import { HammerIcon, MessageSquareIcon, PencilIcon, + ReplyIcon, SendIcon, TagIcon, UsersIcon, } from "lucide-react"; -import { useRef, useState, type ReactNode } from "react"; +import { useRef, useState, type ReactNode, type Ref } from "react"; import { useAtomCommand } from "~/state/use-atom-command"; import { pullRequestEnvironment } from "~/state/pullRequests"; @@ -40,6 +41,7 @@ import { PullRequestActivityUnavailableState } from "./PullRequestActivityUnavai import { orderPullRequestComments, pullRequestFindingKey, + quoteReplyDraft, type PullRequestFinding, } from "./pullRequestDetail.logic"; import { @@ -96,10 +98,13 @@ interface CommentEditing { function CommentBody({ comment, editing, + quoteButton, className, }: { comment: PullRequestComment; editing: CommentEditing; + /** Built by the owner of the composer, so this stays a view over whatever actions it is handed. */ + quoteButton?: ReactNode; className?: string | undefined; }) { if (editing.editingId === comment.id) { @@ -118,6 +123,7 @@ function CommentBody({ return (
+ {quoteButton} {editing.canEdit(comment) ? (
) : null} @@ -280,43 +293,22 @@ function Section({ } function CommentComposer({ - environmentId, - detail, - onCommented, + body, + posting, + textareaRef, + onBodyChange, + onSubmit, }: { - environmentId: EnvironmentId; - detail: PullRequestDetailView; - onCommented: () => void; + body: string; + posting: boolean; + textareaRef: Ref; + onBodyChange: (body: string) => void; + onSubmit: () => void; }) { - const [body, setBody] = useState(""); - const [posting, setPosting] = useState(false); - const postComment = useAtomCommand(pullRequestEnvironment.comment, { reportFailure: false }); - - const submit = async () => { - const trimmed = body.trim(); - if (trimmed.length === 0 || posting) return; - setPosting(true); - const result = await postComment({ - environmentId, - input: { - projectId: detail.projectId, - repository: detail.repository, - number: detail.number, - body: trimmed, - }, - }); - setPosting(false); - if (result._tag === "Failure") { - toastManager.add({ type: "error", title: "Could not post the comment" }); - return; - } - setBody(""); - onCommented(); - }; - return (