diff --git a/apps/web/src/components/app/diff-annotation-style.ts b/apps/web/src/components/app/diff-annotation-style.ts new file mode 100644 index 00000000..4ecccf0e --- /dev/null +++ b/apps/web/src/components/app/diff-annotation-style.ts @@ -0,0 +1,3 @@ +export const stickyAnnotationStyle = { + maxWidth: "calc(var(--diff-scroll-w, 100%) - 1.5rem)", +}; diff --git a/apps/web/src/components/app/diff-annotations.tsx b/apps/web/src/components/app/diff-annotations.tsx deleted file mode 100644 index 0f223689..00000000 --- a/apps/web/src/components/app/diff-annotations.tsx +++ /dev/null @@ -1,551 +0,0 @@ -import { useCallback, useEffect, useRef, useState } from "react"; -import { useNavigate } from "react-router-dom"; -import { - CheckCircle2, - ChevronDown, - ChevronRight, - Circle, - Loader2, - MessageSquare, - MessageSquarePlus, - MoreHorizontal, - Pencil, - Trash2, - XCircle, -} from "lucide-react"; -import { AnimatePresence, motion } from "framer-motion"; -import { toast } from "sonner"; - -import { type ReviewFeedbackItem } from "@/hooks/use-agent-reviews"; -import { - useAddReviewThreadMessage, - useSetReviewFeedbackResolution, -} from "@/hooks/use-agent-reviews"; -import type { PersistedDraftComment } from "@/lib/store"; -import { agentRoute } from "@/lib/agent-routes"; -import { api } from "@/lib/api"; -import { cn } from "@/lib/utils"; -import { Markdown } from "@/components/ui/markdown"; -import { - FeedbackReplyForm, - FeedbackResolutionFooter, - FeedbackThreadMessage, -} from "@/components/app/feedback-card-parts"; -import { - Tooltip, - TooltipContent, - TooltipProvider, - TooltipTrigger, -} from "@/components/ui/tooltip"; -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuTrigger, -} from "@/components/ui/dropdown-menu"; - -const stickyAnnotationStyle = { - maxWidth: "calc(var(--diff-scroll-w, 100%) - 1.5rem)", -}; - -export function InlineCommentForm({ - agentId, - filePath, - startLine, - endLine, - onCancel, - onSubmitted, - reviewMode, - onStartReview, - onAddDraft, -}: { - agentId: string; - filePath: string; - startLine: number; - endLine: number; - onCancel: () => void; - onSubmitted: () => void; - reviewMode?: boolean; - onStartReview?: () => void; - onAddDraft?: ( - filePath: string, - startLine: number, - endLine: number, - comment: string - ) => void; -}): JSX.Element { - const [comment, setComment] = useState(""); - const [submitting, setSubmitting] = useState(false); - const navigate = useNavigate(); - const textareaRef = useRef(null); - - const lineLabel = - startLine === endLine - ? `Line ${startLine}` - : `Lines ${startLine}–${endLine}`; - - const handleChat = useCallback(async () => { - if (!comment.trim() || submitting) return; - setSubmitting(true); - try { - await api(`/api/v1/agents/${agentId}/diff/comment`, { - method: "POST", - body: JSON.stringify({ filePath, startLine, endLine, comment }), - }); - onSubmitted(); - navigate(agentRoute(agentId), { replace: true }); - } catch { - setSubmitting(false); - } - }, [ - agentId, - comment, - endLine, - filePath, - navigate, - onSubmitted, - startLine, - submitting, - ]); - - const handleAddDraft = useCallback(() => { - if (!comment.trim() || !onAddDraft) return; - onAddDraft(filePath, startLine, endLine, comment.trim()); - onSubmitted(); - }, [comment, filePath, startLine, endLine, onAddDraft, onSubmitted]); - - const handleStartReview = useCallback(() => { - if (!comment.trim() || !onStartReview || !onAddDraft) return; - onStartReview(); - onAddDraft(filePath, startLine, endLine, comment.trim()); - onSubmitted(); - }, [ - comment, - filePath, - startLine, - endLine, - onStartReview, - onAddDraft, - onSubmitted, - ]); - - const handlePrimaryAction = reviewMode ? handleAddDraft : handleStartReview; - const primaryLabel = reviewMode ? "Add comment" : "Start a review"; - - const handleKeyDown = useCallback( - (e: React.KeyboardEvent) => { - if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) { - e.preventDefault(); - handlePrimaryAction(); - } - if (e.key === "Escape") { - e.preventDefault(); - onCancel(); - } - }, - [handlePrimaryAction, onCancel] - ); - - return ( -
-
- - Add a comment - {lineLabel} -
-
-