"use client";
import { TabsContent } from "@kandev/ui/tabs";
import { FileEditorContent } from "./file-editor-content";
import { FileImageViewer } from "./file-image-viewer";
import { FileBinaryViewer } from "./file-binary-viewer";
import type { OpenFileTab } from "@/lib/types/backend";
import { getFileCategory } from "@/lib/utils/file-types";
import { FileViewerExternalLink } from "./file-viewer-header";
function resolveTabCategory(tab: OpenFileTab): "image" | "binary" | "text" {
if (!tab.isBinary) return "text";
return getFileCategory(tab.path) === "image" ? "image" : "binary";
}
export function FileTabContent({
tab,
activeSession,
activeSessionId,
taskId,
isSaving,
onFileChange,
onFileSave,
onFileDelete,
}: {
tab: OpenFileTab;
activeSession: { worktree_path?: string | null; repository_id?: string | null } | null;
activeSessionId: string | null;
taskId?: string | null;
isSaving: boolean;
onFileChange: (path: string, content: string) => void;
onFileSave: (path: string) => void;
onFileDelete: (path: string) => void;
}) {
const category = resolveTabCategory(tab);
const externalLink = (
);
return (
{category === "image" && (
)}
{category === "binary" && (
)}
{category === "text" && (
onFileChange(tab.path, newContent)}
onSave={() => onFileSave(tab.path)}
onDelete={() => onFileDelete(tab.path)}
/>
)}
);
}