-
-
-
-
+
+
+
+
+
+
+
+
+
);
diff --git a/apps/code/src/renderer/features/code-review/components/InteractiveFileDiff.tsx b/apps/code/src/renderer/features/code-review/components/InteractiveFileDiff.tsx
index cdd58b877..3f8195b1e 100644
--- a/apps/code/src/renderer/features/code-review/components/InteractiveFileDiff.tsx
+++ b/apps/code/src/renderer/features/code-review/components/InteractiveFileDiff.tsx
@@ -37,7 +37,7 @@ function PatchDiffView({
repoPath,
options,
renderCustomHeader,
- onComment,
+ taskId,
}: PatchDiffProps) {
const trpc = useTRPC();
const queryClient = useQueryClient();
@@ -78,22 +78,6 @@ function PatchDiffView({
[hunkAnnotations, commentAnnotation],
);
- const handleCommentSubmit = useCallback(
- (text: string) => {
- const meta = commentAnnotation?.metadata;
- if (!currentFilePath || !meta || meta.kind !== "comment") return;
- reset();
- onComment?.(
- currentFilePath,
- meta.startLine,
- meta.endLine,
- meta.side,
- text,
- );
- },
- [currentFilePath, commentAnnotation, reset, onComment],
- );
-
const handleRevert = useCallback(
async (hunkIndex: number) => {
const filePath = filePathRef.current;
@@ -150,8 +134,16 @@ function PatchDiffView({
const renderAnnotation = useCallback(
(annotation: DiffLineAnnotation
) => {
if (annotation.metadata.kind === "comment") {
+ const { startLine, endLine, side } = annotation.metadata;
return (
-
+
);
}
@@ -184,7 +176,7 @@ function PatchDiffView({
);
},
- [handleRevert, handleCommentSubmit, reset, revertingHunks],
+ [handleRevert, reset, revertingHunks, taskId, currentFilePath],
);
const mergedOptions = useMemo(
@@ -214,7 +206,7 @@ function FilesDiffView({
newFile,
options,
renderCustomHeader,
- onComment,
+ taskId,
}: FilesDiffProps) {
const {
selectedRange,
@@ -231,24 +223,22 @@ function FilesDiffView({
[commentAnnotation],
);
- const handleCommentSubmit = useCallback(
- (text: string) => {
- const meta = commentAnnotation?.metadata;
- if (!filePath || !meta || meta.kind !== "comment") return;
- reset();
- onComment?.(filePath, meta.startLine, meta.endLine, meta.side, text);
- },
- [filePath, commentAnnotation, reset, onComment],
- );
-
const renderAnnotation = useCallback(
(annotation: DiffLineAnnotation
) => {
if (annotation.metadata.kind !== "comment") return null;
+ const { startLine, endLine, side } = annotation.metadata;
return (
-
+
);
},
- [handleCommentSubmit, reset],
+ [reset, taskId, filePath],
);
const mergedOptions = useMemo(
diff --git a/apps/code/src/renderer/features/code-review/components/ReviewPage.tsx b/apps/code/src/renderer/features/code-review/components/ReviewPage.tsx
index 1195c035b..8cb5318fb 100644
--- a/apps/code/src/renderer/features/code-review/components/ReviewPage.tsx
+++ b/apps/code/src/renderer/features/code-review/components/ReviewPage.tsx
@@ -8,9 +8,8 @@ import { useTRPC } from "@renderer/trpc/client";
import type { ChangedFile, Task } from "@shared/types";
import { useQuery } from "@tanstack/react-query";
import { useMemo } from "react";
-import { useReviewComment } from "../hooks/useReviewComment";
import { useReviewDiffs } from "../hooks/useReviewDiffs";
-import type { DiffOptions, OnCommentCallback } from "../types";
+import type { DiffOptions } from "../types";
import { InteractiveFileDiff } from "./InteractiveFileDiff";
import {
DeferredDiffPlaceholder,
@@ -32,8 +31,6 @@ export function ReviewPage({ task }: ReviewPageProps) {
const isReviewOpen = useReviewNavigationStore(
(s) => (s.reviewModes[taskId] ?? "closed") !== "closed",
);
- const onComment = useReviewComment(taskId);
-
const {
changedFiles,
changesLoading,
@@ -79,7 +76,6 @@ export function ReviewPage({ task }: ReviewPageProps) {
revealFile,
getDeferredReason,
openFile,
- onComment,
};
return (
@@ -118,7 +114,7 @@ export function ReviewPage({ task }: ReviewPageProps) {
options={diffOptions}
collapsed={isCollapsed}
onToggle={() => toggleFile(key)}
- onComment={onComment}
+ taskId={taskId}
/>
);
@@ -148,7 +144,6 @@ interface FileDiffListProps {
revealFile: (key: string) => void;
getDeferredReason: (key: string) => DeferredReason | null;
openFile: (taskId: string, path: string, preview: boolean) => void;
- onComment: OnCommentCallback;
}
function FileDiffList({
@@ -162,7 +157,6 @@ function FileDiffList({
revealFile,
getDeferredReason,
openFile,
- onComment,
}: FileDiffListProps) {
return files.map((fileDiff) => {
const filePath = fileDiff.name ?? fileDiff.prevName ?? "";
@@ -193,7 +187,7 @@ function FileDiffList({
fileDiff={fileDiff}
repoPath={repoPath}
options={{ ...diffOptions, collapsed: isCollapsed }}
- onComment={onComment}
+ taskId={taskId}
renderCustomHeader={(fd) => (