'use client'; import { memo, useMemo, useState } from 'react'; import { DiffModeEnum, DiffView } from '@git-diff-view/react'; import { IconArrowBackUp, IconCopy, IconLayoutColumns, IconLayoutRows } from '@tabler/icons-react'; import { useTheme } from 'next-themes'; import { Badge } from '@kandev/ui/badge'; import { Button } from '@kandev/ui/button'; import { Tooltip, TooltipContent, TooltipTrigger } from '@kandev/ui/tooltip'; import { cn } from '@/lib/utils'; import { getLocalStorage, setLocalStorage } from '@/lib/local-storage'; import { buildDiffData, CHANGED_FILES, DIFF_SAMPLES } from '@/components/task/task-data'; type TaskChangesPanelProps = { selectedDiffPath: string | null; onClearSelected: () => void; }; const DEFAULT_DIFF_MODE: 'unified' | 'split' = 'unified'; const TaskChangesPanel = memo(function TaskChangesPanel({ selectedDiffPath, onClearSelected, }: TaskChangesPanelProps) { const [diffViewMode, setDiffViewMode] = useState<'unified' | 'split'>(() => getLocalStorage('task-diff-view-mode', DEFAULT_DIFF_MODE) ); const { resolvedTheme } = useTheme(); const diffTargets = useMemo( () => (selectedDiffPath ? [selectedDiffPath] : CHANGED_FILES.map((file) => file.path)), [selectedDiffPath] ); const diffModeEnum = diffViewMode === 'split' ? DiffModeEnum.Split : DiffModeEnum.Unified; const diffTheme = resolvedTheme === 'dark' ? 'dark' : 'light'; const selectedDiffContent = selectedDiffPath ? DIFF_SAMPLES[selectedDiffPath]?.newContent ?? '' : ''; const isSingleDiffSelected = Boolean(selectedDiffPath && DIFF_SAMPLES[selectedDiffPath]); return (