Add update method to ReviewCommentRepository, updateReviewComment tRPC procedure, and inline edit UI in CommentThread. Edit button appears on user-authored comments (not agent comments) when unresolved. Uses the existing CommentForm with a new initialValue prop.
54 lines
1.6 KiB
TypeScript
54 lines
1.6 KiB
TypeScript
import type { FileDiff, DiffLine, ReviewComment } from "./types";
|
|
import { FileCard } from "./FileCard";
|
|
|
|
interface DiffViewerProps {
|
|
files: FileDiff[];
|
|
comments: ReviewComment[];
|
|
onAddComment: (
|
|
filePath: string,
|
|
lineNumber: number,
|
|
lineType: DiffLine["type"],
|
|
body: string,
|
|
) => void;
|
|
onResolveComment: (commentId: string) => void;
|
|
onUnresolveComment: (commentId: string) => void;
|
|
onReplyComment?: (parentCommentId: string, body: string) => void;
|
|
onEditComment?: (commentId: string, body: string) => void;
|
|
viewedFiles?: Set<string>;
|
|
onToggleViewed?: (filePath: string) => void;
|
|
onRegisterRef?: (filePath: string, el: HTMLDivElement | null) => void;
|
|
}
|
|
|
|
export function DiffViewer({
|
|
files,
|
|
comments,
|
|
onAddComment,
|
|
onResolveComment,
|
|
onUnresolveComment,
|
|
onReplyComment,
|
|
onEditComment,
|
|
viewedFiles,
|
|
onToggleViewed,
|
|
onRegisterRef,
|
|
}: DiffViewerProps) {
|
|
return (
|
|
<div className="space-y-4">
|
|
{files.map((file) => (
|
|
<div key={file.newPath} ref={(el) => onRegisterRef?.(file.newPath, el)}>
|
|
<FileCard
|
|
file={file}
|
|
comments={comments.filter((c) => c.filePath === file.newPath)}
|
|
onAddComment={onAddComment}
|
|
onResolveComment={onResolveComment}
|
|
onUnresolveComment={onUnresolveComment}
|
|
onReplyComment={onReplyComment}
|
|
onEditComment={onEditComment}
|
|
isViewed={viewedFiles?.has(file.newPath) ?? false}
|
|
onToggleViewed={() => onToggleViewed?.(file.newPath)}
|
|
/>
|
|
</div>
|
|
))}
|
|
</div>
|
|
);
|
|
}
|