"use client"; import { memo, useMemo } from "react"; import { TabsContent } from "@kandev/ui/tabs"; import { SessionPanel, SessionPanelContent } from "@kandev/ui/pannel-session"; import { FileBrowser } from "@/components/task/file-browser"; import { SessionTabs, type SessionTab } from "@/components/session-tabs"; import type { OpenFileTab } from "@/lib/types/backend"; import { useFilesPanelData, useFilesPanelTab, useCommitDiffs, useGitStagingActions, useDiscardDialog, } from "./task-files-panel-hooks"; import { DiffTabContent, DiscardDialog } from "./task-files-panel-parts"; function FilesTabContent({ sessionId, onOpenFile, handleCreateFile, hookDeleteFile, hookRenameFile, activeFilePath, }: { sessionId: string | null; onOpenFile: (file: OpenFileTab) => void; handleCreateFile: (path: string) => Promise; hookDeleteFile: (path: string) => Promise; hookRenameFile: (oldPath: string, newPath: string) => Promise; activeFilePath?: string | null; }) { if (!sessionId) { return (
No task selected
); } return ( ); } type TaskFilesPanelProps = { onSelectDiff: (path: string, content?: string) => void; onOpenFile: (file: OpenFileTab) => void; activeFilePath?: string | null; }; const TaskFilesPanel = memo(function TaskFilesPanel({ onSelectDiff, onOpenFile, activeFilePath, }: TaskFilesPanelProps) { const { activeSessionId, commits, changedFiles, reviewedCount, totalFileCount, hookDeleteFile, hookRenameFile, handleCreateFile, handleOpenFileInDocumentPanel, handleOpenInEditor, } = useFilesPanelData(onOpenFile); const reviewProgressPercent = totalFileCount > 0 ? (reviewedCount / totalFileCount) * 100 : 0; const { topTab, handleTabChange } = useFilesPanelTab( activeSessionId, changedFiles.length, commits.length, ); const { expandedCommit, commitDiffs, loadingCommitSha, toggleCommit } = useCommitDiffs(activeSessionId); const { pendingStageFiles, handleStage, handleUnstage } = useGitStagingActions( activeSessionId, changedFiles, ); const { showDiscardDialog, setShowDiscardDialog, fileToDiscard, handleDiscardClick, handleDiscardConfirm, } = useDiscardDialog(activeSessionId); const tabs: SessionTab[] = useMemo( () => [ { id: "diff", label: `Diff files${changedFiles.length > 0 ? ` (${changedFiles.length})` : ""}`, }, { id: "files", label: "All files" }, ], [changedFiles.length], ); return ( handleTabChange(value as "diff" | "files")} className="flex-1 min-h-0" > ); }); export { TaskFilesPanel };