diff --git a/apps/code/src/renderer/features/code-review/components/CloudReviewPage.tsx b/apps/code/src/renderer/features/code-review/components/CloudReviewPage.tsx index 4bbbcc6af..35236aa9d 100644 --- a/apps/code/src/renderer/features/code-review/components/CloudReviewPage.tsx +++ b/apps/code/src/renderer/features/code-review/components/CloudReviewPage.tsx @@ -5,8 +5,7 @@ import { Flex, Spinner, Text } from "@radix-ui/themes"; import { useReviewNavigationStore } from "@renderer/features/code-review/stores/reviewNavigationStore"; import type { ChangedFile, Task } from "@shared/types"; import { useMemo } from "react"; -import { useReviewComment } from "../hooks/useReviewComment"; -import type { DiffOptions, OnCommentCallback } from "../types"; +import type { DiffOptions } from "../types"; import { InteractiveFileDiff } from "./InteractiveFileDiff"; import { DeferredDiffPlaceholder, @@ -26,7 +25,6 @@ export function CloudReviewPage({ task }: CloudReviewPageProps) { ); const { effectiveBranch, prUrl, isRunActive, remoteFiles, isLoading } = useCloudChangedFiles(taskId, task, isReviewOpen); - const onComment = useReviewComment(taskId); const allPaths = useMemo(() => remoteFiles.map((f) => f.path), [remoteFiles]); @@ -102,11 +100,11 @@ export function CloudReviewPage({ task }: CloudReviewPageProps) {
toggleFile(file.path)} - onComment={onComment} />
); @@ -117,18 +115,18 @@ export function CloudReviewPage({ task }: CloudReviewPageProps) { function CloudFileDiff({ file, + taskId, prUrl, options, collapsed, onToggle, - onComment, }: { file: ChangedFile; + taskId: string; prUrl: string | null; options: DiffOptions; collapsed: boolean; onToggle: () => void; - onComment: OnCommentCallback; }) { const fileDiff = useMemo((): FileDiffMetadata | undefined => { if (!file.patch) return undefined; @@ -158,7 +156,7 @@ function CloudFileDiff({ ( void; - onCancel: () => void; + taskId: string; + filePath: string; + startLine: number; + endLine: number; + side: AnnotationSide; + onDismiss: () => void; } export function CommentAnnotation({ - onSubmit, - onCancel, + taskId, + filePath, + startLine, + endLine, + side, + onDismiss, }: CommentAnnotationProps) { const textareaRef = useRef(null); @@ -23,9 +36,13 @@ export function CommentAnnotation({ const handleSubmit = useCallback(() => { const text = textareaRef.current?.value?.trim(); if (text) { - onSubmit(text); + onDismiss(); + sendPromptToAgent( + taskId, + buildInlineCommentPrompt(filePath, startLine, endLine, side, text), + ); } - }, [onSubmit]); + }, [taskId, filePath, startLine, endLine, side, onDismiss]); const handleKeyDown = useCallback( (e: React.KeyboardEvent) => { @@ -35,39 +52,32 @@ export function CommentAnnotation({ } if (e.key === "Escape") { e.preventDefault(); - onCancel(); + onDismiss(); } }, - [handleSubmit, onCancel], + [handleSubmit, onDismiss], ); return (